Skip to content

Commit

Permalink
fix(apply): raises error when a metadata has no name (#266)
Browse files Browse the repository at this point in the history
When a resource manifest has no name in metadata, it throws a KeyError.
This commit fixes the error reporting to state the issue more
explicitly.

Wrike Ticket: https://www.wrike.com/open.htm?id=1238536095
  • Loading branch information
pallabpain authored Feb 1, 2024
1 parent f056d3a commit be26ff8
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion riocli/apply/parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,9 @@ def _get_attr(obj, accept_keys):
@staticmethod
def _get_object_key(obj: dict) -> str:
kind = obj.get('kind').lower()
name_or_guid = obj['metadata']['name']
name_or_guid = obj.get('metadata', {}).get('name')

if not name_or_guid:
raise ValueError('[kind:{}] name is required.'.format(kind))

return '{}:{}'.format(kind, name_or_guid)

0 comments on commit be26ff8

Please sign in to comment.