diff --git a/api/v1alpha1/generated.proto b/api/v1alpha1/generated.proto index ca4b49ac4..1ee3b25d2 100644 --- a/api/v1alpha1/generated.proto +++ b/api/v1alpha1/generated.proto @@ -858,14 +858,19 @@ message PromotionSpec { // applies. The Stage referenced by this field MUST be in the same // namespace as the Promotion. // + // +kubebuilder:validation:Required // +kubebuilder:validation:MinLength=1 + // +kubebuilder:validation:MaxLength=253 // +kubebuilder:validation:Pattern=^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$ optional string stage = 1; // Freight specifies the piece of Freight to be promoted into the Stage // referenced by the Stage field. // + // +kubebuilder:validation:Required // +kubebuilder:validation:MinLength=1 + // +kubebuilder:validation:MaxLength=253 + // +kubebuilder:validation:Pattern=^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$ optional string freight = 2; // Vars is a list of variables that can be referenced by expressions in @@ -875,6 +880,10 @@ message PromotionSpec { // Steps specifies the directives to be executed as part of this Promotion. // The order in which the directives are executed is the order in which they // are listed in this field. + // + // +kubebuilder:validation:Required + // +kubebuilder:validation:MinItems=1 + // +kubebuilder:validation:items:XValidation:message="Promotion step must have uses set and must not reference a task",rule="has(self.uses) && !has(self.task)" repeated PromotionStep steps = 3; } @@ -935,8 +944,6 @@ message PromotionStep { // Task is a reference to a PromotionTask that should be deflated into a // Promotion when it is built from a PromotionTemplate. - // - // +kubebuilder:validation:Optional optional PromotionTaskReference task = 5; // As is the alias this step can be referred to as. @@ -1060,6 +1067,7 @@ message PromotionTaskSpec { // // +kubebuilder:validation:Required // +kubebuilder:validation:MinItems=1 + // +kubebuilder:validation:items:XValidation:message="PromotionTask step must have uses set and must not reference another task",rule="has(self.uses) && !has(self.task)" repeated PromotionStep steps = 2; } @@ -1082,6 +1090,7 @@ message PromotionTemplateSpec { // are listed in this field. // // +kubebuilder:validation:MinItems=1 + // +kubebuilder:validation:items:XValidation:message="PromotionTemplate step must have exactly one of uses or task set",rule="(has(self.uses) ? !has(self.task) : has(self.task))" repeated PromotionStep steps = 1; } diff --git a/charts/kargo/resources/crds/kargo.akuity.io_clusterpromotiontasks.yaml b/charts/kargo/resources/crds/kargo.akuity.io_clusterpromotiontasks.yaml index 8d8998414..63ce17930 100644 --- a/charts/kargo/resources/crds/kargo.akuity.io_clusterpromotiontasks.yaml +++ b/charts/kargo/resources/crds/kargo.akuity.io_clusterpromotiontasks.yaml @@ -167,6 +167,10 @@ spec: minLength: 1 type: string type: object + x-kubernetes-validations: + - message: PromotionTask step must have uses set and must not reference + another task + rule: has(self.uses) && !has(self.task) minItems: 1 type: array required: diff --git a/charts/kargo/resources/crds/kargo.akuity.io_promotions.yaml b/charts/kargo/resources/crds/kargo.akuity.io_promotions.yaml index 07fa07d25..8ae7e59a3 100644 --- a/charts/kargo/resources/crds/kargo.akuity.io_promotions.yaml +++ b/charts/kargo/resources/crds/kargo.akuity.io_promotions.yaml @@ -66,13 +66,16 @@ spec: description: |- Freight specifies the piece of Freight to be promoted into the Stage referenced by the Stage field. + maxLength: 253 minLength: 1 + pattern: ^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$ type: string stage: description: |- Stage specifies the name of the Stage to which this Promotion applies. The Stage referenced by this field MUST be in the same namespace as the Promotion. + maxLength: 253 minLength: 1 pattern: ^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$ type: string @@ -167,6 +170,11 @@ spec: minLength: 1 type: string type: object + x-kubernetes-validations: + - message: Promotion step must have uses set and must not reference + a task + rule: has(self.uses) && !has(self.task) + minItems: 1 type: array vars: description: |- @@ -196,6 +204,7 @@ spec: required: - freight - stage + - steps type: object status: description: |- diff --git a/charts/kargo/resources/crds/kargo.akuity.io_promotiontasks.yaml b/charts/kargo/resources/crds/kargo.akuity.io_promotiontasks.yaml index 2ff858e52..f6129bc8a 100644 --- a/charts/kargo/resources/crds/kargo.akuity.io_promotiontasks.yaml +++ b/charts/kargo/resources/crds/kargo.akuity.io_promotiontasks.yaml @@ -167,6 +167,10 @@ spec: minLength: 1 type: string type: object + x-kubernetes-validations: + - message: PromotionTask step must have uses set and must not reference + another task + rule: has(self.uses) && !has(self.task) minItems: 1 type: array required: diff --git a/charts/kargo/resources/crds/kargo.akuity.io_stages.yaml b/charts/kargo/resources/crds/kargo.akuity.io_stages.yaml index 2e3c0bb9d..364dbd963 100644 --- a/charts/kargo/resources/crds/kargo.akuity.io_stages.yaml +++ b/charts/kargo/resources/crds/kargo.akuity.io_stages.yaml @@ -160,6 +160,10 @@ spec: minLength: 1 type: string type: object + x-kubernetes-validations: + - message: PromotionTemplate step must have exactly one + of uses or task set + rule: '(has(self.uses) ? !has(self.task) : has(self.task))' minItems: 1 type: array vars: diff --git a/ui/src/gen/schema/clusterpromotiontasks.kargo.akuity.io_v1alpha1.json b/ui/src/gen/schema/clusterpromotiontasks.kargo.akuity.io_v1alpha1.json index a2b1a771e..752027ae4 100644 --- a/ui/src/gen/schema/clusterpromotiontasks.kargo.akuity.io_v1alpha1.json +++ b/ui/src/gen/schema/clusterpromotiontasks.kargo.akuity.io_v1alpha1.json @@ -97,7 +97,13 @@ "type": "string" } }, - "type": "object" + "type": "object", + "x-kubernetes-validations": [ + { + "message": "PromotionTask step must have uses set and must not reference another task", + "rule": "has(self.uses) && !has(self.task)" + } + ] }, "minItems": 1, "type": "array" diff --git a/ui/src/gen/schema/promotions.kargo.akuity.io_v1alpha1.json b/ui/src/gen/schema/promotions.kargo.akuity.io_v1alpha1.json index 2c4c5fc58..b8d28f9d0 100644 --- a/ui/src/gen/schema/promotions.kargo.akuity.io_v1alpha1.json +++ b/ui/src/gen/schema/promotions.kargo.akuity.io_v1alpha1.json @@ -18,11 +18,14 @@ "properties": { "freight": { "description": "Freight specifies the piece of Freight to be promoted into the Stage\nreferenced by the Stage field.", + "maxLength": 253, "minLength": 1, + "pattern": "^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$", "type": "string" }, "stage": { "description": "Stage specifies the name of the Stage to which this Promotion\napplies. The Stage referenced by this field MUST be in the same\nnamespace as the Promotion.", + "maxLength": 253, "minLength": 1, "pattern": "^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$", "type": "string" @@ -87,8 +90,15 @@ "type": "string" } }, - "type": "object" + "type": "object", + "x-kubernetes-validations": [ + { + "message": "Promotion step must have uses set and must not reference a task", + "rule": "has(self.uses) && !has(self.task)" + } + ] }, + "minItems": 1, "type": "array" }, "vars": { @@ -118,7 +128,8 @@ }, "required": [ "freight", - "stage" + "stage", + "steps" ], "type": "object" }, diff --git a/ui/src/gen/schema/promotiontasks.kargo.akuity.io_v1alpha1.json b/ui/src/gen/schema/promotiontasks.kargo.akuity.io_v1alpha1.json index 9b788665c..5d5c4cfa6 100644 --- a/ui/src/gen/schema/promotiontasks.kargo.akuity.io_v1alpha1.json +++ b/ui/src/gen/schema/promotiontasks.kargo.akuity.io_v1alpha1.json @@ -97,7 +97,13 @@ "type": "string" } }, - "type": "object" + "type": "object", + "x-kubernetes-validations": [ + { + "message": "PromotionTask step must have uses set and must not reference another task", + "rule": "has(self.uses) && !has(self.task)" + } + ] }, "minItems": 1, "type": "array" diff --git a/ui/src/gen/schema/stages.kargo.akuity.io_v1alpha1.json b/ui/src/gen/schema/stages.kargo.akuity.io_v1alpha1.json index 01d1317be..d4eeb03ab 100644 --- a/ui/src/gen/schema/stages.kargo.akuity.io_v1alpha1.json +++ b/ui/src/gen/schema/stages.kargo.akuity.io_v1alpha1.json @@ -82,7 +82,13 @@ "type": "string" } }, - "type": "object" + "type": "object", + "x-kubernetes-validations": [ + { + "message": "PromotionTemplate step must have exactly one of uses or task set", + "rule": "(has(self.uses) ? !has(self.task) : has(self.task))" + } + ] }, "minItems": 1, "type": "array" diff --git a/ui/src/gen/v1alpha1/generated_pb.ts b/ui/src/gen/v1alpha1/generated_pb.ts index 8de75b3b1..a8006f6c8 100644 --- a/ui/src/gen/v1alpha1/generated_pb.ts +++ b/ui/src/gen/v1alpha1/generated_pb.ts @@ -2721,7 +2721,9 @@ export class PromotionSpec extends Message { * applies. The Stage referenced by this field MUST be in the same * namespace as the Promotion. * + * +kubebuilder:validation:Required * +kubebuilder:validation:MinLength=1 + * +kubebuilder:validation:MaxLength=253 * +kubebuilder:validation:Pattern=^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$ * * @generated from field: optional string stage = 1; @@ -2732,7 +2734,10 @@ export class PromotionSpec extends Message { * Freight specifies the piece of Freight to be promoted into the Stage * referenced by the Stage field. * + * +kubebuilder:validation:Required * +kubebuilder:validation:MinLength=1 + * +kubebuilder:validation:MaxLength=253 + * +kubebuilder:validation:Pattern=^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$ * * @generated from field: optional string freight = 2; */ @@ -2751,6 +2756,10 @@ export class PromotionSpec extends Message { * The order in which the directives are executed is the order in which they * are listed in this field. * + * +kubebuilder:validation:Required + * +kubebuilder:validation:MinItems=1 + * +kubebuilder:validation:items:XValidation:message="Promotion step must have uses set and must not reference a task",rule="has(self.uses) && !has(self.task)" + * * @generated from field: repeated github.com.akuity.kargo.api.v1alpha1.PromotionStep steps = 3; */ steps: PromotionStep[] = []; @@ -2933,8 +2942,6 @@ export class PromotionStep extends Message { * Task is a reference to a PromotionTask that should be deflated into a * Promotion when it is built from a PromotionTemplate. * - * +kubebuilder:validation:Optional - * * @generated from field: optional github.com.akuity.kargo.api.v1alpha1.PromotionTaskReference task = 5; */ task?: PromotionTaskReference; @@ -3307,6 +3314,7 @@ export class PromotionTaskSpec extends Message { * * +kubebuilder:validation:Required * +kubebuilder:validation:MinItems=1 + * +kubebuilder:validation:items:XValidation:message="PromotionTask step must have uses set and must not reference another task",rule="has(self.uses) && !has(self.task)" * * @generated from field: repeated github.com.akuity.kargo.api.v1alpha1.PromotionStep steps = 2; */ @@ -3403,6 +3411,7 @@ export class PromotionTemplateSpec extends Message { * are listed in this field. * * +kubebuilder:validation:MinItems=1 + * +kubebuilder:validation:items:XValidation:message="PromotionTemplate step must have exactly one of uses or task set",rule="(has(self.uses) ? !has(self.task) : has(self.task))" * * @generated from field: repeated github.com.akuity.kargo.api.v1alpha1.PromotionStep steps = 1; */