Skip to content

Commit

Permalink
jiralogin: report correct server to update
Browse files Browse the repository at this point in the history
The server to connect to was correctly read out for the connection
itself, but later on when asking for confirmation it reported the wrong
server. This because the server in the cfg file was set to the (old)
production server and didn't query the setting in the yaml file.

To fix this we've wrapped the retrieval of the server details in a
single function, which now selects the correct server.

The test server has been kept for now, but should be removed since we
won't have a test server in the future.

Fixes #44.

Signed-off-by: Joakim Bech <[email protected]>
  • Loading branch information
jbech-linaro committed Jul 9, 2021
1 parent d4a89bb commit 459f9e6
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
11 changes: 10 additions & 1 deletion cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

TEST_SERVER = { 'url' : 'https://dev-projects.linaro.org' }
PRODUCTION_SERVER = { 'url' : 'https://projects.linaro.org' }
server = PRODUCTION_SERVER

args = None

Expand Down Expand Up @@ -90,6 +89,16 @@ def get_config_file():
return config_path + "/" + config_filename


def get_server(use_test_server=False):
# Get Jira Server details. Check first if using the test server
# then try user config file, then default from cfg.py
server = TEST_SERVER
if use_test_server is False:
server = yml_config.get('server', PRODUCTION_SERVER)

return server


def initiate_config():
""" Reads the config file (yaml format) and returns the sets the global
instance.
Expand Down
3 changes: 2 additions & 1 deletion jipdate.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,8 @@ def get_jira_issues(jira, username):
def should_update():
""" A yes or no dialogue. """
while True:
print("Server to update: %s\n" % cfg.server.get('url'));
server = cfg.get_server()
print("Server to update: %s\n" % server.get('url'));
answer = input("Are you sure you want to update Jira with the " +
"information above? [y/n] ").lower().strip()
if answer in set(['y', 'n']):
Expand Down
8 changes: 1 addition & 7 deletions jiralogin.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,7 @@ def get_jira_instance(use_test_server):
"""
username = get_username()

# Get Jira Server details. Check first if using the test server
# then try user config file, then default from cfg.py
if use_test_server:
server = cfg.TEST_SERVER
else:
server = cfg.yml_config.get('server', cfg.server)

server = cfg.get_server(use_test_server)
url = server.get('url')
token = server.get('token')

Expand Down

0 comments on commit 459f9e6

Please sign in to comment.