Skip to content

Commit

Permalink
relax state action validation (#183)
Browse files Browse the repository at this point in the history
The purpose of this change is to align the workflow validationb between
the Java and the GO SDK. Spec allows the action to be a empty list while
in the GO SDK, if defined, must have at least one item.

Signed-off-by: Spolti <filippespolti@gmail.com>
  • Loading branch information
spolti authored Aug 24, 2023
1 parent 926a85d commit 796270c
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 8 deletions.
3 changes: 1 addition & 2 deletions hack/deepcopy-gen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ if [ "${GENS}" = "all" ] || grep -qw "deepcopy" <<<"${GENS}"; then
# for debug purposes, increase the log level by updating the -v flag to higher numbers, e.g. -v 4
"${GOPATH}/bin/deepcopy-gen" -v 1 \
--input-dirs ./model -O zz_generated.deepcopy \
--go-header-file "${SCRIPT_ROOT}/hack/boilerplate.txt" \
--output-base ./
--go-header-file "${SCRIPT_ROOT}/hack/boilerplate.txt"
"$@"
fi
4 changes: 2 additions & 2 deletions model/foreach_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ type ForEachState struct {
// +optional
BatchSize *intstr.IntOrString `json:"batchSize,omitempty"`
// Actions to be executed for each of the elements of inputCollection.
// +kubebuilder:validation:MinItems=1
Actions []Action `json:"actions,omitempty" validate:"required,min=1,dive"`
// +kubebuilder:validation:MinItems=0
Actions []Action `json:"actions,omitempty" validate:"required,min=0,dive"`
// State specific timeout.
// +optional
Timeouts *ForEachStateTimeout `json:"timeouts,omitempty"`
Expand Down
2 changes: 1 addition & 1 deletion model/foreach_state_validator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ workflow.states[0].forEachState.mode is required`,
model.States[0].ForEachState.Actions = []Action{}
return *model
},
Err: `workflow.states[0].forEachState.actions must have the minimum 1`,
Err: ``,
},
}

Expand Down
4 changes: 2 additions & 2 deletions model/operation_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ type OperationState struct {
// +kubebuilder:default=sequential
ActionMode ActionMode `json:"actionMode,omitempty" validate:"required,oneofkind"`
// Actions to be performed
// +kubebuilder:validation:MinItems=1
Actions []Action `json:"actions" validate:"min=1,dive"`
// +kubebuilder:validation:MinItems=0
Actions []Action `json:"actions" validate:"min=0,dive"`
// State specific timeouts
// +optional
Timeouts *OperationStateTimeout `json:"timeouts,omitempty"`
Expand Down
2 changes: 1 addition & 1 deletion model/operation_state_validator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func TestOperationStateStructLevelValidation(t *testing.T) {
model.States[0].OperationState.Actions = []Action{}
return *model
},
Err: `workflow.states[0].actions must have the minimum 1`,
Err: ``,
},
{
Desp: "oneofkind",
Expand Down

0 comments on commit 796270c

Please sign in to comment.