now galaxy correctly detects empty requirements file

also allow for 'scm' and 'src' not to be populated in requirements entries
This commit is contained in:
Brian Coca 2015-10-20 14:38:07 -04:00
parent b46ce47a84
commit 1ecad5aed2
2 changed files with 20 additions and 10 deletions

View file

@ -310,7 +310,15 @@ class GalaxyCLI(CLI):
try: try:
f = open(role_file, 'r') f = open(role_file, 'r')
if role_file.endswith('.yaml') or role_file.endswith('.yml'): 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) role = RoleRequirement.role_yaml_parse(role)
self.display.debug('found role %s in yaml file' % str(role)) self.display.debug('found role %s in yaml file' % str(role))
if 'name' not in role and 'scm' not in role: if 'name' not in role and 'scm' not in role:

View file

@ -140,17 +140,19 @@ class RoleRequirement(RoleDefinition):
role = RoleRequirement.role_spec_parse(role['role']) role = RoleRequirement.role_spec_parse(role['role'])
else: else:
role = role.copy() 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"]: if 'src'in role:
(scm, src) = role["src"].split('+') # New style: { src: 'galaxy.role,version,name', other_vars: "here" }
role["scm"] = scm 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"] = src role["src"] = "git+" + role["src"]
if 'name' not in role: if '+' in role["src"]:
role["name"] = RoleRequirement.repo_url_to_role_name(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: if 'version' not in role:
role['version'] = '' role['version'] = ''