Commit eb7ea504 by syed-awais-ali

add modified dockerfiles to the list of plays

parent 6a3342cc
...@@ -182,7 +182,7 @@ def change_set_to_roles(files, git_dir, roles_dirs, playbooks_dirs, graph): ...@@ -182,7 +182,7 @@ def change_set_to_roles(files, git_dir, roles_dirs, playbooks_dirs, graph):
return items return items
def get_plays(files, git_dir, playbooks_dirs): def get_plays(files, git_dir, playbooks_dirs):
""" """
Determines which files in the change set are aws playbooks Determines which files in the change set are aws playbooks
files: A list of files modified by a commit range. files: A list of files modified by a commit range.
...@@ -210,7 +210,7 @@ def get_plays(files, git_dir, playbooks_dirs): ...@@ -210,7 +210,7 @@ def get_plays(files, git_dir, playbooks_dirs):
plays.add(_get_playbook_name_from_file(file_path)) plays.add(_get_playbook_name_from_file(file_path))
return plays return plays
def _get_playbook_name_from_file(path): def _get_playbook_name_from_file(path):
""" """
Gets name of playbook from the filepath, which is the last part of the filepath. Gets name of playbook from the filepath, which is the last part of the filepath.
...@@ -220,7 +220,7 @@ def _get_playbook_name_from_file(path): ...@@ -220,7 +220,7 @@ def _get_playbook_name_from_file(path):
""" """
# get last part of filepath # get last part of filepath
return path.stem return path.stem
def _get_role_name_from_file(path): def _get_role_name_from_file(path):
""" """
...@@ -330,6 +330,29 @@ def _get_role_name(role): ...@@ -330,6 +330,29 @@ def _get_role_name(role):
LOGGER.warning("role %s could not be resolved to a role name." % role) LOGGER.warning("role %s could not be resolved to a role name." % role)
return None return None
def _get_modified_dockerfiles(files, git_dir):
"""
Return Playbooks whose dockerfile has been changed/modified
:param files:
:param git_dir:
:return:
"""
items = set()
for play in plays:
dockerfile = pathlib2.Path(DOCKER_PATH_ROOT, play, "Dockerfile")
for f in files:
file_path = pathlib2.Path(git_dir, f)
if file_path in dockerfile:
items.add(_get_playbook_name_from_file(file_path))
return items
def arg_parse(): def arg_parse():
parser = argparse.ArgumentParser(description = 'Given a commit range, analyze Ansible dependencies between roles and playbooks ' parser = argparse.ArgumentParser(description = 'Given a commit range, analyze Ansible dependencies between roles and playbooks '
...@@ -387,5 +410,8 @@ if __name__ == '__main__': ...@@ -387,5 +410,8 @@ if __name__ == '__main__':
# filter out docker plays without a Dockerfile # filter out docker plays without a Dockerfile
docker_plays = filter_docker_plays(docker_plays, TRAVIS_BUILD_DIR) docker_plays = filter_docker_plays(docker_plays, TRAVIS_BUILD_DIR)
# Add playbooks to the list whose docker file has been modified
modified_docer_files = _get_modified_dockerfiles(docker_plays, TRAVIS_BUILD_DIR)
# prints Docker plays # prints Docker plays
print " ".join(str(play) for play in docker_plays) print " ".join(str(play) for play in docker_plays)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment