Allow for no role_versions to be present (#56519)

* Allow for no role_versions to be present

  fixes #46650

  better info on fetch, ensure list return

* use correct to_
This commit is contained in:
Brian Coca 2019-07-17 12:35:24 -04:00 committed by GitHub
parent 4ef2545eb5
commit c2253c8133
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 5 deletions

View file

@ -0,0 +1,2 @@
bugfixes:
- new code assumed role_versions always were present event though rest of code does not.

View file

@ -200,6 +200,7 @@ class GalaxyAPI(object):
The url comes from the 'related' field of the role. The url comes from the 'related' field of the role.
""" """
results = []
try: try:
url = '%s/roles/%s/%s/?page_size=50' % (self.baseurl, role_id, related) url = '%s/roles/%s/%s/?page_size=50' % (self.baseurl, role_id, related)
data = self.__call_galaxy(url) data = self.__call_galaxy(url)
@ -210,9 +211,9 @@ class GalaxyAPI(object):
data = self.__call_galaxy(url) data = self.__call_galaxy(url)
results += data['results'] results += data['results']
done = (data.get('next_link', None) is None) done = (data.get('next_link', None) is None)
return results except Exception as e:
except Exception: display.vvvv("Unable to retrive role (id=%s) data (%s), but this is not fatal so we continue: %s" % (role_id, related, to_text(e)))
return None return results
@g_connect @g_connect
def get_list(self, what): def get_list(self, what):

View file

@ -230,13 +230,13 @@ class GalaxyRole(object):
'Please contact the role author to resolve versioning conflicts, or specify an explicit role version to ' 'Please contact the role author to resolve versioning conflicts, or specify an explicit role version to '
'install.' % ', '.join([v.vstring for v in loose_versions]) 'install.' % ', '.join([v.vstring for v in loose_versions])
) )
self.version = str(loose_versions[-1]) self.version = to_text(loose_versions[-1])
elif role_data.get('github_branch', None): elif role_data.get('github_branch', None):
self.version = role_data['github_branch'] self.version = role_data['github_branch']
else: else:
self.version = 'master' self.version = 'master'
elif self.version != 'master': elif self.version != 'master':
if role_versions and str(self.version) not in [a.get('name', None) for a in role_versions]: if role_versions and to_text(self.version) not in [a.get('name', None) for a in role_versions]:
raise AnsibleError("- the specified version (%s) of %s was not found in the list of available versions (%s)." % (self.version, raise AnsibleError("- the specified version (%s) of %s was not found in the list of available versions (%s)." % (self.version,
self.name, self.name,
role_versions)) role_versions))