Skip to content

Commit

Permalink
feat(api): allow Inputs config on PromotionStep
Browse files Browse the repository at this point in the history
This includes validation rules to ensure a `PromotionTask` step can
not have `inputs` defined, but `Promotion` and `PromotionTemplate`
steps can (unless they reference a `task` themselves).

Signed-off-by: Hidde Beydals <[email protected]>
  • Loading branch information
hiddeco committed Dec 11, 2024
1 parent 02c2316 commit dd30bb1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions api/v1alpha1/promotion_task_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ type PromotionTaskSpec struct {
// +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)"
// +kubebuilder:validation:items:XValidation:message="PromotionTask step must not have inputs set",rule="self.inputs.size() == 0"
Steps []PromotionStep `json:"steps" protobuf:"bytes,2,rep,name=steps"`
}

Expand Down
9 changes: 9 additions & 0 deletions api/v1alpha1/promotion_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,8 @@ func (r *PromotionStepRetry) GetErrorThreshold(fallback uint32) uint32 {
}

// PromotionStep describes a directive to be executed as part of a Promotion.
//
// +kubebuilder:validation:XValidation:message="inputs must not be set when task is set",rule="!(has(self.task) && self.inputs.size() > 0)"
type PromotionStep struct {
// Uses identifies a runner that can execute this step.
//
Expand All @@ -208,6 +210,13 @@ type PromotionStep struct {
As string `json:"as,omitempty" protobuf:"bytes,2,opt,name=as"`
// Retry is the retry policy for this step.
Retry *PromotionStepRetry `json:"retry,omitempty" protobuf:"bytes,4,opt,name=retry"`
// Inputs is a map of inputs that can used to parameterize the execution
// of the PromotionStep and can be referenced by expressions in the Config.
//
// When a PromotionStep is inflated from a PromotionTask, the inputs
// specified in the PromotionTask are set based on the inputs specified
// in the Config of the PromotionStep that references the PromotionTask.
Inputs map[string]string `json:"inputs,omitempty" protobuf:"bytes,6,rep,name=inputs"`
// Config is opaque configuration for the PromotionStep that is understood
// only by each PromotionStep's implementation. It is legal to utilize
// expressions in defining values at any level of this block.
Expand Down

0 comments on commit dd30bb1

Please sign in to comment.