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:
parent
932ba36160
commit
aa56a2ff6a
2 changed files with 7 additions and 1 deletions
2
changelogs/fragments/70887_galaxy_token.yml
Normal file
2
changelogs/fragments/70887_galaxy_token.yml
Normal file
|
@ -0,0 +1,2 @@
|
|||
minor_changes:
|
||||
- galaxy - handle token as dict while loading from yaml file (https://github.com/ansible/ansible/issues/70887).
|
|
@ -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):
|
||||
|
|
Loading…
Reference in a new issue