Skip to content

Commit

Permalink
simplifies some logic in models/base
Browse files Browse the repository at this point in the history
  • Loading branch information
Skybound1 committed Dec 5, 2023
1 parent 518bce4 commit 75b9217
Showing 1 changed file with 7 additions and 19 deletions.
26 changes: 7 additions & 19 deletions icekube/models/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ def inject_missing_required_fields(cls, values):
break
else:
# Nothing found, setting them to blank

def get_value(field):
if isinstance(values, dict) and field in values:
return values[field]
Expand All @@ -88,24 +87,13 @@ def get_value(field):

return values

if isinstance(values, dict):
if "apiVersion" not in values:
values["apiVersion"] = api_resource.group

if "kind" not in values:
values["kind"] = api_resource.kind

if "plural" not in values:
values["plural"] = api_resource.name
else:
if not values.apiVersion:
values.apiVersion = api_resource.group

if not values.kind:
values.kind = api_resource.kind

if not values.plural:
values.plural = api_resource.name
for attr, val in [
("apiVersion", api_resource.group),
("kind", api_resource.kind),
("plural", api_resource.name),
]:
if load(values, attr) is None:
values = save(values, attr, val)

return values

Expand Down

0 comments on commit 75b9217

Please sign in to comment.