mirror of
https://github.com/kubevela/kubevela.git
synced 2026-08-19 04:26:39 +00:00
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:
@@ -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",
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user