Skip to content

Commit

Permalink
Handle empty annotations
Browse files Browse the repository at this point in the history
Cope with resources without last_applied annotation, and add
the annotation to such resources too
  • Loading branch information
willthames authored and fabianvf committed Mar 11, 2019
1 parent 6754d37 commit a6aaf5b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion openshift/dynamic/apply.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def apply(resource, definition):
actual = resource.get(name=definition['metadata']['name'], namespace=definition['metadata']['namespace'])
except NotFoundError:
return resource.create(body=dict_merge(definition, desired_annotation), namespace=definition['metadata']['namespace'])
last_applied = actual.metadata.annotations.get(LAST_APPLIED_CONFIG_ANNOTATION)
last_applied = actual.metadata.get('annotations',{}).get(LAST_APPLIED_CONFIG_ANNOTATION)

if last_applied:
last_applied = json.loads(last_applied)
Expand Down

0 comments on commit a6aaf5b

Please sign in to comment.