Skip to content
This repository has been archived by the owner on Mar 23, 2019. It is now read-only.

Handle role with empty metadata file (fix AttributeError) #882

Merged
merged 1 commit into from
Mar 6, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions container/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,12 +310,9 @@ def get_dependencies_for_role(role_path):
meta_main_path = os.path.join(role_path, 'meta', 'main.yml')
if os.path.exists(meta_main_path):
meta_main = yaml.safe_load(open(meta_main_path))
if not meta_main:
yield None
for dependency in meta_main.get('dependencies', []):
yield dependency.get('role', None)
else:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this else statement is still needed to account for no meta_main_path?

Copy link
Contributor Author

@pilou- pilou- Feb 11, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so: the caller ignores None value (and None was yielded when os.path.exists(meta_main_path) was False).

yield None
if meta_main:
for dependency in meta_main.get('dependencies', []):
yield dependency.get('role', None)

hash_obj = hashlib.sha256()
# Account for variables passed to the role by including the invocation string
Expand Down