Added github token support for github autentification

Change-Id: I5869e01a9e8816d7aee1d783c8e091632cda707a
This commit is contained in:
Sergey Nikitin 2020-11-17 16:47:22 +04:00
parent 8e85f8706d
commit b69d2b008b
4 changed files with 19 additions and 5 deletions

View File

@ -17,6 +17,7 @@ usage: stackalytics-processor [-h] [--config-dir DIR] [--config-file PATH]
[--sources-root SOURCES_ROOT] [--sources-root SOURCES_ROOT]
[--ssh-key-filename SSH_KEY_FILENAME] [--ssh-key-filename SSH_KEY_FILENAME]
[--ssh-username SSH_USERNAME] [--ssh-username SSH_USERNAME]
[--github-token GITHUB_TOKEN]
[--github-login GITHUB_LOGIN] [--github-login GITHUB_LOGIN]
[--github-password GITHUB_PASSWORD] [--github-password GITHUB_PASSWORD]
[--syslog-log-facility SYSLOG_LOG_FACILITY] [--syslog-log-facility SYSLOG_LOG_FACILITY]
@ -91,10 +92,14 @@ optional arguments:
SSH key for gerrit review system access SSH key for gerrit review system access
--ssh-username SSH_USERNAME --ssh-username SSH_USERNAME
SSH username for gerrit review system access SSH username for gerrit review system access
--github-token GITHUB_TOKEN
Token for github access. (string value)
--github-login GITHUB_LOGIN --github-login GITHUB_LOGIN
Login for github access (string value) Login for github access. If GITHUB_TOKEN is specified,
GITHUB_LOGIN will be ignored (string value)
--github-password GITHUB_PASSWORD --github-password GITHUB_PASSWORD
Password for github access Password for github access. If GITHUB_TOKEN is specified,
GITHUB_PASSWORD will be ignored (string value)
--syslog-log-facility SYSLOG_LOG_FACILITY --syslog-log-facility SYSLOG_LOG_FACILITY
Syslog facility to receive log lines. This option is Syslog facility to receive log lines. This option is
ignored if log_config_append is set. ignored if log_config_append is set.

View File

@ -190,6 +190,9 @@
# How many times to retry after Gerrit errors (integer value) # How many times to retry after Gerrit errors (integer value)
#gerrit_retry = 10 #gerrit_retry = 10
# Token for github access. If specified, github_login and github_password will be ignored (string value)
#github_token = token
# Login for github access (string value) # Login for github access (string value)
#github_login = login #github_login = login

View File

@ -46,6 +46,8 @@ PROCESSOR_OPTS = [
help='SSH key for gerrit review system access'), help='SSH key for gerrit review system access'),
cfg.StrOpt('ssh-username', default='user', cfg.StrOpt('ssh-username', default='user',
help='SSH username for gerrit review system access'), help='SSH username for gerrit review system access'),
cfg.StrOpt('github-token', default=None,
help='Token for github access'),
cfg.StrOpt('github-login', default=None, cfg.StrOpt('github-login', default=None,
help='Login for github access'), help='Login for github access'),
cfg.StrOpt('github-password', default=None, cfg.StrOpt('github-password', default=None,

View File

@ -108,9 +108,13 @@ def _retrieve_project_list_from_gerrit(project_source):
def _retrieve_project_list_from_github(project_source): def _retrieve_project_list_from_github(project_source):
LOG.info('Retrieving project list from GitHub') LOG.info('Retrieving project list from GitHub')
github = MainClass.Github(timeout=60, if CONF.github_token:
login_or_token=CONF.github_login, github = MainClass.Github(timeout=60,
password=CONF.github_password) login_or_token=CONF.github_token)
else:
github = MainClass.Github(timeout=60,
login_or_token=CONF.github_login,
password=CONF.github_password)
organization = project_source['organization'] organization = project_source['organization']
LOG.debug('Get list of projects for organization %s', organization) LOG.debug('Get list of projects for organization %s', organization)