Skip to content

Commit

Permalink
fix(api): loosen Stage validation (#2644)
Browse files Browse the repository at this point in the history
Signed-off-by: Hidde Beydals <[email protected]>
  • Loading branch information
hiddeco authored Oct 3, 2024
1 parent 609a937 commit cdec347
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 18 deletions.
3 changes: 1 addition & 2 deletions api/v1alpha1/generated.proto

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions api/v1alpha1/stage_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,7 @@ func (s *Stage) GetStatus() *StageStatus {
// StageSpec describes the sources of Freight used by a Stage and how to
// incorporate Freight into the Stage.
//
// +kubebuilder:validation:XValidation:rule="(has(self.promotionTemplate) || has(self.promotionMechanisms))",message="one of promotionTemplate or promotionMechanisms must be specified"
// +kubebuilder:validation:XValidation:rule="(has(self.promotionTemplate) && !has(self.promotionMechanisms)) || (!has(self.promotionTemplate) && has(self.promotionMechanisms))",message="only one of promotionTemplate or promotionMechanisms can be specified"
// +kubebuilder:validation:XValidation:rule="(!has(self.promotionTemplate) && !has(self.promotionMechanisms) ) || ( has(self.promotionTemplate) && !has(self.promotionMechanisms) ) || (!has(self.promotionTemplate) && has(self.promotionMechanisms))",message="at most one of promotionTemplate or promotionMechanisms can be specified"
type StageSpec struct {
// Shard is the name of the shard that this Stage belongs to. This is an
// optional field. If not specified, the Stage will belong to the default
Expand Down
11 changes: 5 additions & 6 deletions charts/kargo/resources/crds/kargo.akuity.io_stages.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1051,12 +1051,11 @@ spec:
- requestedFreight
type: object
x-kubernetes-validations:
- message: one of promotionTemplate or promotionMechanisms must be specified
rule: (has(self.promotionTemplate) || has(self.promotionMechanisms))
- message: only one of promotionTemplate or promotionMechanisms can be
specified
rule: (has(self.promotionTemplate) && !has(self.promotionMechanisms))
|| (!has(self.promotionTemplate) && has(self.promotionMechanisms))
- message: at most one of promotionTemplate or promotionMechanisms can
be specified
rule: (!has(self.promotionTemplate) && !has(self.promotionMechanisms)
) || ( has(self.promotionTemplate) && !has(self.promotionMechanisms)
) || (!has(self.promotionTemplate) && has(self.promotionMechanisms))
status:
description: Status describes the Stage's current and recent Freight,
health, and more.
Expand Down
8 changes: 2 additions & 6 deletions ui/src/gen/schema/stages.kargo.akuity.io_v1alpha1.json
Original file line number Diff line number Diff line change
Expand Up @@ -836,12 +836,8 @@
"type": "object",
"x-kubernetes-validations": [
{
"message": "one of promotionTemplate or promotionMechanisms must be specified",
"rule": "(has(self.promotionTemplate) || has(self.promotionMechanisms))"
},
{
"message": "only one of promotionTemplate or promotionMechanisms can be specified",
"rule": "(has(self.promotionTemplate) && !has(self.promotionMechanisms)) || (!has(self.promotionTemplate) && has(self.promotionMechanisms))"
"message": "at most one of promotionTemplate or promotionMechanisms can be specified",
"rule": "(!has(self.promotionTemplate) && !has(self.promotionMechanisms) ) || ( has(self.promotionTemplate) && !has(self.promotionMechanisms) ) || (!has(self.promotionTemplate) && has(self.promotionMechanisms))"
}
]
},
Expand Down
3 changes: 1 addition & 2 deletions ui/src/gen/v1alpha1/generated_pb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4458,8 +4458,7 @@ export class StageList extends Message<StageList> {
* StageSpec describes the sources of Freight used by a Stage and how to
* incorporate Freight into the Stage.
*
* +kubebuilder:validation:XValidation:rule="(has(self.promotionTemplate) || has(self.promotionMechanisms))",message="one of promotionTemplate or promotionMechanisms must be specified"
* +kubebuilder:validation:XValidation:rule="(has(self.promotionTemplate) && !has(self.promotionMechanisms)) || (!has(self.promotionTemplate) && has(self.promotionMechanisms))",message="only one of promotionTemplate or promotionMechanisms can be specified"
* +kubebuilder:validation:XValidation:rule="(!has(self.promotionTemplate) && !has(self.promotionMechanisms) ) || ( has(self.promotionTemplate) && !has(self.promotionMechanisms) ) || (!has(self.promotionTemplate) && has(self.promotionMechanisms))",message="at most one of promotionTemplate or promotionMechanisms can be specified"
*
* @generated from message github.com.akuity.kargo.api.v1alpha1.StageSpec
*/
Expand Down

0 comments on commit cdec347

Please sign in to comment.