Fix: auto deploy spec missing (#3386)

* Fix: auto deploy spec missing

Signed-off-by: Somefive <yd219913@alibaba-inc.com>

* Fix: modify test

Signed-off-by: Somefive <yd219913@alibaba-inc.com>
This commit is contained in:
Somefive
2022-03-09 11:28:52 +08:00
committed by GitHub
parent d5ad037173
commit f9635de027
3 changed files with 7 additions and 6 deletions
+1 -1
View File
@@ -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",
+4 -5
View File
@@ -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",
+2
View File
@@ -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"`
}