Feat: add if in workflow (#3941)

* Feat: add if in workflow struct

Signed-off-by: FogDong <dongtianxin.tx@alibaba-inc.com>

* Feat: implement the if in workflow

Signed-off-by: FogDong <dongtianxin.tx@alibaba-inc.com>

* Feat: support dependency and skip for suspend step

Signed-off-by: FogDong <dongtianxin.tx@alibaba-inc.com>

* Fix: fix the rebase from sub steps

Signed-off-by: FogDong <dongtianxin.tx@alibaba-inc.com>

* Fix: fix the lint

Signed-off-by: FogDong <dongtianxin.tx@alibaba-inc.com>

* Feat: support if in sub steps

Signed-off-by: FogDong <dongtianxin.tx@alibaba-inc.com>

* Feat: add tests in application controller

Signed-off-by: FogDong <dongtianxin.tx@alibaba-inc.com>

* Fix: fix the lint

Signed-off-by: FogDong <dongtianxin.tx@alibaba-inc.com>

* Test: add more tests in discover and custom

Signed-off-by: FogDong <dongtianxin.tx@alibaba-inc.com>

* Lint: fix lint

Signed-off-by: FogDong <dongtianxin.tx@alibaba-inc.com>

* Tests: add more tests in application controller

Signed-off-by: FogDong <dongtianxin.tx@alibaba-inc.com>

* Fix: change failed after retries into reason

Signed-off-by: FogDong <dongtianxin.tx@alibaba-inc.com>

* Fix: fix the terminate cli

Signed-off-by: FogDong <dongtianxin.tx@alibaba-inc.com>

* fix lint

Signed-off-by: FogDong <dongtianxin.tx@alibaba-inc.com>

* remove the terminate workflow to pkg and add feature gates

Signed-off-by: FogDong <dongtianxin.tx@alibaba-inc.com>

* resolve comments

Signed-off-by: FogDong <dongtianxin.tx@alibaba-inc.com>

* nit fix

Signed-off-by: FogDong <dongtianxin.tx@alibaba-inc.com>

* make finish condition more clear

Signed-off-by: FogDong <dongtianxin.tx@alibaba-inc.com>
This commit is contained in:
Tianxin Dong
2022-05-27 22:01:14 +08:00
committed by GitHub
parent fd024bc3e2
commit fcfb1012d6
31 changed files with 1442 additions and 273 deletions
-17
View File
@@ -28,18 +28,8 @@ import (
wfContext "github.com/oam-dev/kubevela/pkg/workflow/context"
)
const (
// ReadyComponent is the key for depends on in workflow context
ReadyComponent = "readyComponent__"
)
// Input set data to parameter.
func Input(ctx wfContext.Context, paramValue *value.Value, step v1beta1.WorkflowStep) error {
for _, depend := range step.DependsOn {
if _, err := ctx.GetVar(ReadyComponent, depend); err != nil {
return errors.WithMessagef(err, "the depends on component [%s] is not ready", depend)
}
}
for _, input := range step.Inputs {
inputValue, err := ctx.GetVar(strings.Split(input.From, ".")...)
if err != nil {
@@ -66,13 +56,6 @@ func Output(ctx wfContext.Context, taskValue *value.Value, step v1beta1.Workflow
if err := json.Unmarshal(js, &o); err != nil {
return err
}
ready, err := value.NewValue(`true`, nil, "")
if err != nil {
return err
}
if err := ctx.SetVar(ready, ReadyComponent, o.Name); err != nil {
return err
}
}
for _, output := range step.Outputs {
-10
View File
@@ -43,10 +43,6 @@ func TestInput(t *testing.T) {
r.NoError(err)
err = wfCtx.SetVar(score, "foo")
r.NoError(err)
ready, err := value.NewValue(`true`, nil, "")
r.NoError(err)
err = wfCtx.SetVar(ready, ReadyComponent, "mystep")
r.NoError(err)
err = Input(wfCtx, paramValue, v1beta1.WorkflowStep{
DependsOn: []string{"mystep"},
Inputs: common.StepInputs{{
@@ -85,12 +81,6 @@ output: score: 99
s, err := result.String()
r.NoError(err)
r.Equal(s, `99
`)
ready, err := wfCtx.GetVar(ReadyComponent, "mystep")
r.NoError(err)
s, err = ready.String()
r.NoError(err)
r.Equal(s, `true
`)
}