galaxy: Handle token as dict while loading using yaml (#70911)

Malformed galaxy_token file creates stacktrace.

Fixes: #70887

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
This commit is contained in:
Abhijeet Kasurde 2020-12-22 01:23:00 +05:30 committed by GitHub
parent 932ba36160
commit aa56a2ff6a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 1 deletions

View file

@ -0,0 +1,2 @@
minor_changes:
- galaxy - handle token as dict while loading from yaml file (https://github.com/ansible/ansible/issues/70887).

View file

@ -120,7 +120,7 @@ class GalaxyToken(object):
def _read(self):
action = 'Opened'
if not os.path.isfile(self.b_file):
# token file not found, create and chomd u+rw
# token file not found, create and chmod u+rw
open(self.b_file, 'w').close()
os.chmod(self.b_file, S_IRUSR | S_IWUSR) # owner has +rw
action = 'Created'
@ -130,6 +130,10 @@ class GalaxyToken(object):
display.vvv('%s %s' % (action, to_text(self.b_file)))
if config and not isinstance(config, dict):
display.vvv('Galaxy token file %s malformed, unable to read it' % to_text(self.b_file))
return {}
return config or {}
def set(self, token):