Remove unneeded fields from spec
This commit is contained in:
parent
6e644dfe44
commit
2f769e0e2e
1 changed files with 6 additions and 3 deletions
|
@ -28,12 +28,15 @@ def generate_django_model(schema, group, version, kind):
|
|||
"""
|
||||
Generates a virtual Django model from a Kubernetes CRD's OpenAPI v3 schema.
|
||||
"""
|
||||
spec = schema["properties"].get("spec") or {}
|
||||
# defaults = {"apiVersion": f"{group}/{version}", "kind": kind}
|
||||
|
||||
# We always need these three fields to know our own name and our full namespace
|
||||
model_fields = {"__module__": "crd_models"}
|
||||
for field_name in ("name", "organization", "context"):
|
||||
model_fields[field_name] = duplicate_field(field_name, ServiceInstance)
|
||||
|
||||
# All other fields are generated from the schema, except for the
|
||||
# resourceRef object
|
||||
spec = schema["properties"].get("spec") or {}
|
||||
spec["properties"].pop("resourceRef", None)
|
||||
model_fields.update(build_object_fields(spec, "spec"))
|
||||
|
||||
meta_class = type("Meta", (), {"app_label": "crd_models"})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue