now galaxy correctly detects empty requirements file

also allow for 'scm' and 'src' not to be populated in requirements entries
pull/12847/head
Brian Coca 9 years ago
parent b46ce47a84
commit 1ecad5aed2

@ -310,7 +310,15 @@ class GalaxyCLI(CLI):
try:
f = open(role_file, 'r')
if role_file.endswith('.yaml') or role_file.endswith('.yml'):
for role in yaml.safe_load(f.read()):
try:
required_roles = yaml.safe_load(f.read())
except Exception as e:
raise AnsibleError("Unable to load data from the requirements file: %s" % role_file)
if required_roles is None:
raise AnsibleError("No roles found in file: %s" % role_file)
for role in required_roles:
role = RoleRequirement.role_yaml_parse(role)
self.display.debug('found role %s in yaml file' % str(role))
if 'name' not in role and 'scm' not in role:

@ -140,17 +140,19 @@ class RoleRequirement(RoleDefinition):
role = RoleRequirement.role_spec_parse(role['role'])
else:
role = role.copy()
# New style: { src: 'galaxy.role,version,name', other_vars: "here" }
if 'github.com' in role["src"] and 'http' in role["src"] and '+' not in role["src"] and not role["src"].endswith('.tar.gz'):
role["src"] = "git+" + role["src"]
if '+' in role["src"]:
(scm, src) = role["src"].split('+')
role["scm"] = scm
role["src"] = src
if 'src'in role:
# New style: { src: 'galaxy.role,version,name', other_vars: "here" }
if 'github.com' in role["src"] and 'http' in role["src"] and '+' not in role["src"] and not role["src"].endswith('.tar.gz'):
role["src"] = "git+" + role["src"]
if 'name' not in role:
role["name"] = RoleRequirement.repo_url_to_role_name(role["src"])
if '+' in role["src"]:
(scm, src) = role["src"].split('+')
role["scm"] = scm
role["src"] = src
if 'name' not in role:
role["name"] = RoleRequirement.repo_url_to_role_name(role["src"])
if 'version' not in role:
role['version'] = ''

Loading…
Cancel
Save