mirror of
https://github.com/kubevela/kubevela.git
synced 2026-05-21 08:43:35 +00:00
* Feat: add if in workflow struct Signed-off-by: FogDong <dongtianxin.tx@alibaba-inc.com> (cherry picked from commite800ed3e98) * Feat: implement the if in workflow Signed-off-by: FogDong <dongtianxin.tx@alibaba-inc.com> (cherry picked from commite171fa9212) * Feat: support dependency and skip for suspend step Signed-off-by: FogDong <dongtianxin.tx@alibaba-inc.com> (cherry picked from commit6c045dc593) * Fix: fix the rebase from sub steps Signed-off-by: FogDong <dongtianxin.tx@alibaba-inc.com> (cherry picked from commitf6746e7d26) * Fix: fix the lint Signed-off-by: FogDong <dongtianxin.tx@alibaba-inc.com> (cherry picked from commit9cb9887327) * Feat: support if in sub steps Signed-off-by: FogDong <dongtianxin.tx@alibaba-inc.com> (cherry picked from commitc41ccfabb9) * Feat: add tests in application controller Signed-off-by: FogDong <dongtianxin.tx@alibaba-inc.com> (cherry picked from commitb308d89912) * Fix: fix the lint Signed-off-by: FogDong <dongtianxin.tx@alibaba-inc.com> (cherry picked from commit2c784b185a) * Test: add more tests in discover and custom Signed-off-by: FogDong <dongtianxin.tx@alibaba-inc.com> (cherry picked from commit39f49fd901) * Lint: fix lint Signed-off-by: FogDong <dongtianxin.tx@alibaba-inc.com> (cherry picked from commitf5149c859a) * Tests: add more tests in application controller Signed-off-by: FogDong <dongtianxin.tx@alibaba-inc.com> (cherry picked from commit255f4014c2) * Fix: change failed after retries into reason Signed-off-by: FogDong <dongtianxin.tx@alibaba-inc.com> (cherry picked from commitdfbba699c5) * Fix: fix the terminate cli Signed-off-by: FogDong <dongtianxin.tx@alibaba-inc.com> (cherry picked from commit14192e1fb3) * fix lint Signed-off-by: FogDong <dongtianxin.tx@alibaba-inc.com> (cherry picked from commitd1dd602cc8) * remove the terminate workflow to pkg and add feature gates Signed-off-by: FogDong <dongtianxin.tx@alibaba-inc.com> (cherry picked from commitbf5c8d138a) * resolve comments Signed-off-by: FogDong <dongtianxin.tx@alibaba-inc.com> (cherry picked from commit8a1b499f24) * nit fix Signed-off-by: FogDong <dongtianxin.tx@alibaba-inc.com> (cherry picked from commit784e5f5db3) * make finish condition more clear Signed-off-by: FogDong <dongtianxin.tx@alibaba-inc.com> (cherry picked from commitb4c1ca36b0) Co-authored-by: FogDong <dongtianxin.tx@alibaba-inc.com>
74 lines
2.0 KiB
Go
74 lines
2.0 KiB
Go
/*
|
|
Copyright 2021 The KubeVela Authors.
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
you may not use this file except in compliance with the License.
|
|
You may obtain a copy of the License at
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
See the License for the specific language governing permissions and
|
|
limitations under the License.
|
|
*/
|
|
|
|
package hooks
|
|
|
|
import (
|
|
"encoding/json"
|
|
"strings"
|
|
|
|
"github.com/pkg/errors"
|
|
|
|
"github.com/oam-dev/kubevela/apis/core.oam.dev/common"
|
|
"github.com/oam-dev/kubevela/apis/core.oam.dev/v1beta1"
|
|
"github.com/oam-dev/kubevela/pkg/cue/model/value"
|
|
wfContext "github.com/oam-dev/kubevela/pkg/workflow/context"
|
|
)
|
|
|
|
// Input set data to parameter.
|
|
func Input(ctx wfContext.Context, paramValue *value.Value, step v1beta1.WorkflowStep) error {
|
|
for _, input := range step.Inputs {
|
|
inputValue, err := ctx.GetVar(strings.Split(input.From, ".")...)
|
|
if err != nil {
|
|
return errors.WithMessagef(err, "get input from [%s]", input.From)
|
|
}
|
|
if err := paramValue.FillValueByScript(inputValue, input.ParameterKey); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Output get data from task value.
|
|
func Output(ctx wfContext.Context, taskValue *value.Value, step v1beta1.WorkflowStep, phase common.WorkflowStepPhase) error {
|
|
if phase == common.WorkflowStepPhaseSucceeded {
|
|
if step.Properties != nil {
|
|
o := struct {
|
|
Name string `json:"name"`
|
|
}{}
|
|
js, err := common.RawExtensionPointer{RawExtension: step.Properties}.MarshalJSON()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
if err := json.Unmarshal(js, &o); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
|
|
for _, output := range step.Outputs {
|
|
v, err := taskValue.LookupByScript(output.ValueFrom)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
if err := ctx.SetVar(v, output.Name); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|