Skip to content

Commit 796270c

Browse files
authored
relax state action validation (#183)
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>
1 parent 926a85d commit 796270c

File tree

5 files changed

+7
-8
lines changed

5 files changed

+7
-8
lines changed

hack/deepcopy-gen.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ if [ "${GENS}" = "all" ] || grep -qw "deepcopy" <<<"${GENS}"; then
4343
# for debug purposes, increase the log level by updating the -v flag to higher numbers, e.g. -v 4
4444
"${GOPATH}/bin/deepcopy-gen" -v 1 \
4545
--input-dirs ./model -O zz_generated.deepcopy \
46-
--go-header-file "${SCRIPT_ROOT}/hack/boilerplate.txt" \
47-
--output-base ./
46+
--go-header-file "${SCRIPT_ROOT}/hack/boilerplate.txt"
4847
"$@"
4948
fi

model/foreach_state.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ type ForEachState struct {
6060
// +optional
6161
BatchSize *intstr.IntOrString `json:"batchSize,omitempty"`
6262
// Actions to be executed for each of the elements of inputCollection.
63-
// +kubebuilder:validation:MinItems=1
64-
Actions []Action `json:"actions,omitempty" validate:"required,min=1,dive"`
63+
// +kubebuilder:validation:MinItems=0
64+
Actions []Action `json:"actions,omitempty" validate:"required,min=0,dive"`
6565
// State specific timeout.
6666
// +optional
6767
Timeouts *ForEachStateTimeout `json:"timeouts,omitempty"`

model/foreach_state_validator_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ workflow.states[0].forEachState.mode is required`,
108108
model.States[0].ForEachState.Actions = []Action{}
109109
return *model
110110
},
111-
Err: `workflow.states[0].forEachState.actions must have the minimum 1`,
111+
Err: ``,
112112
},
113113
}
114114

model/operation_state.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ type OperationState struct {
2727
// +kubebuilder:default=sequential
2828
ActionMode ActionMode `json:"actionMode,omitempty" validate:"required,oneofkind"`
2929
// Actions to be performed
30-
// +kubebuilder:validation:MinItems=1
31-
Actions []Action `json:"actions" validate:"min=1,dive"`
30+
// +kubebuilder:validation:MinItems=0
31+
Actions []Action `json:"actions" validate:"min=0,dive"`
3232
// State specific timeouts
3333
// +optional
3434
Timeouts *OperationStateTimeout `json:"timeouts,omitempty"`

model/operation_state_validator_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ func TestOperationStateStructLevelValidation(t *testing.T) {
6363
model.States[0].OperationState.Actions = []Action{}
6464
return *model
6565
},
66-
Err: `workflow.states[0].actions must have the minimum 1`,
66+
Err: ``,
6767
},
6868
{
6969
Desp: "oneofkind",

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy