Tidied up a little, added tests

Moved repo_url_to_role_name to common method in ansible.utils
Added unit test for repo_url_to_role_name
Added integration tests for galaxy
This commit is contained in:
Will Thames
2014-08-14 20:20:10 +10:00
committed by Michael DeHaan
parent b550cb9bc3
commit c2fe33f9f4
7 changed files with 38 additions and 7 deletions

View File

@@ -181,7 +181,7 @@ class Play(object):
if '+' in orig_path and '://' in orig_path:
# dependency name pointing to SCM URL
# assume role name is last part of the URL
orig_path = orig_path.split('/')[-1]
orig_path = utils.repo_url_to_role_name(orig_path)
role_vars = {}
if type(orig_path) == dict:
@@ -417,7 +417,7 @@ class Play(object):
else:
role_name = role
if '+' in role_name and '://' in role_name:
role_name = role_name.split('/')[-1]
role_name = utils.repo_url_to_role_name(role_name)
role_names.append(role_name)
if os.path.isfile(task):

View File

@@ -352,6 +352,12 @@ def path_dwim_relative(original, dirname, source, playbook_base, check=True):
raise errors.AnsibleError("input file not found at %s or %s" % (source2, obvious_local_path))
return source2 # which does not exist
def repo_url_to_role_name(repo_url):
trailing_path = repo_url.split('/')[-1]
if trailing_path.endswith('.git'):
trailing_path = trailing_path[:-4]
return trailing_path
def json_loads(data):
''' parse a JSON string and return a data structure '''