diff --git a/pkg/workflow/step/dependency_test.go b/pkg/workflow/step/dependency_test.go index 39688ed84..214dc76c8 100644 --- a/pkg/workflow/step/dependency_test.go +++ b/pkg/workflow/step/dependency_test.go @@ -42,7 +42,7 @@ func TestLoadExternalPoliciesForWorkflow(t *testing.T) { policies, err := LoadExternalPoliciesForWorkflow(context.Background(), cli, "demo", []v1beta1.WorkflowStep{{ Name: "deploy", Type: DeployWorkflowStep, - Properties: &runtime.RawExtension{Raw: []byte(`{"policies":["ex","internal"]}`)}, + Properties: &runtime.RawExtension{Raw: []byte(`{"auto":false,"policies":["ex","internal"]}`)}, }}, []v1beta1.AppPolicy{{ Name: "internal", Type: "internal", diff --git a/pkg/workflow/step/generator.go b/pkg/workflow/step/generator.go index a07d7dcf4..c32dcf899 100644 --- a/pkg/workflow/step/generator.go +++ b/pkg/workflow/step/generator.go @@ -28,6 +28,7 @@ import ( "github.com/oam-dev/kubevela/apis/core.oam.dev/v1alpha1" "github.com/oam-dev/kubevela/apis/core.oam.dev/v1beta1" "github.com/oam-dev/kubevela/pkg/oam/util" + "github.com/oam-dev/kubevela/pkg/utils" ) // WorkflowStepGenerator generator generates workflow steps @@ -165,11 +166,9 @@ func (g *DeployPreApproveWorkflowStepGenerator) Generate(app *v1beta1.Applicatio lastSuspend := false for _, step := range existingSteps { if step.Type == "deploy" && !lastSuspend { - cfg := map[string]interface{}{} - _ = json.Unmarshal(step.Properties.Raw, &cfg) - _auto, found := cfg["auto"] - auto, isBool := _auto.(bool) - if found && isBool && !auto { + props := DeployWorkflowStepSpec{} + _ = utils.StrictUnmarshal(step.Properties.Raw, &props) + if props.Auto != nil && !*props.Auto { steps = append(steps, v1beta1.WorkflowStep{ Name: "manual-approve-" + step.Name, Type: "suspend", diff --git a/pkg/workflow/step/types.go b/pkg/workflow/step/types.go index a9ebb1d74..e59545ebb 100644 --- a/pkg/workflow/step/types.go +++ b/pkg/workflow/step/types.go @@ -23,5 +23,7 @@ const ( // DeployWorkflowStepSpec the spec of `deploy` WorkflowStep type DeployWorkflowStepSpec struct { + // Auto nil/true mean auto deploy, false means additional pre-approve step will be injected before the deploy step + Auto *bool `json:"auto,omitempty"` Policies []string `json:"policies,omitempty"` }