From 0319ff3981baf8bb59efe2b66d8f69ea0a73bf56 Mon Sep 17 00:00:00 2001 From: Salomon Popp Date: Tue, 17 Dec 2024 15:19:17 +0100 Subject: [PATCH] Fix allow optional resources requests and limits --- docs/docs/schema/defaults.json | 16 ++++++++++------ docs/docs/schema/pipeline.json | 16 ++++++++++------ kpops/components/common/kubernetes_model.py | 10 ++++++++-- 3 files changed, 28 insertions(+), 14 deletions(-) diff --git a/docs/docs/schema/defaults.json b/docs/docs/schema/defaults.json index 498acb5cd..c8c7ca909 100644 --- a/docs/docs/schema/defaults.json +++ b/docs/docs/schema/defaults.json @@ -2383,26 +2383,30 @@ "description": "Model representing the resource specifications for a Kubernetes container.", "properties": { "limits": { - "allOf": [ + "anyOf": [ { "$ref": "#/$defs/ResourceDefinition" + }, + { + "type": "null" } ], + "default": null, "description": "The maximum resource limits for the container." }, "requests": { - "allOf": [ + "anyOf": [ { "$ref": "#/$defs/ResourceDefinition" + }, + { + "type": "null" } ], + "default": null, "description": "The minimum resource requirements for the container." } }, - "required": [ - "requests", - "limits" - ], "title": "Resources", "type": "object" }, diff --git a/docs/docs/schema/pipeline.json b/docs/docs/schema/pipeline.json index 85ca15c14..226f3c99b 100644 --- a/docs/docs/schema/pipeline.json +++ b/docs/docs/schema/pipeline.json @@ -2043,26 +2043,30 @@ "description": "Model representing the resource specifications for a Kubernetes container.", "properties": { "limits": { - "allOf": [ + "anyOf": [ { "$ref": "#/$defs/ResourceDefinition" + }, + { + "type": "null" } ], + "default": null, "description": "The maximum resource limits for the container." }, "requests": { - "allOf": [ + "anyOf": [ { "$ref": "#/$defs/ResourceDefinition" + }, + { + "type": "null" } ], + "default": null, "description": "The minimum resource requirements for the container." } }, - "required": [ - "requests", - "limits" - ], "title": "Resources", "type": "object" }, diff --git a/kpops/components/common/kubernetes_model.py b/kpops/components/common/kubernetes_model.py index 80af34f79..81d01e1a7 100644 --- a/kpops/components/common/kubernetes_model.py +++ b/kpops/components/common/kubernetes_model.py @@ -384,5 +384,11 @@ class Resources(DescConfigModel): :param limits: The maximum resource limits for the container. """ - requests: ResourceDefinition = Field(description=describe_attr("requests", __doc__)) - limits: ResourceDefinition = Field(description=describe_attr("limits", __doc__)) + requests: ResourceDefinition | None = Field( + default=None, + description=describe_attr("requests", __doc__), + ) + limits: ResourceDefinition | None = Field( + default=None, + description=describe_attr("limits", __doc__), + )