diff --git a/charts/vela-core/crds/core.oam.dev_applicationrevisions.yaml b/charts/vela-core/crds/core.oam.dev_applicationrevisions.yaml index 0ba506890..c4addb00e 100644 --- a/charts/vela-core/crds/core.oam.dev_applicationrevisions.yaml +++ b/charts/vela-core/crds/core.oam.dev_applicationrevisions.yaml @@ -2209,10 +2209,11 @@ spec: execution properties: steps: - description: WorkflowMode describes the mode of workflow + description: Steps is the mode of workflow steps execution type: string subSteps: - description: WorkflowMode describes the mode of workflow + description: SubSteps is the mode of workflow sub + steps execution type: string type: object ref: @@ -4008,6 +4009,17 @@ spec: namespace: type: string type: object + mode: + description: WorkflowExecuteMode defines the mode of workflow + execution + properties: + steps: + description: Steps is the mode of workflow steps execution + type: string + subSteps: + description: SubSteps is the mode of workflow sub steps execution + type: string + type: object steps: items: description: WorkflowStep defines how to execute a workflow diff --git a/charts/vela-core/crds/core.oam.dev_applications.yaml b/charts/vela-core/crds/core.oam.dev_applications.yaml index 71f08e8f9..e40fc76df 100644 --- a/charts/vela-core/crds/core.oam.dev_applications.yaml +++ b/charts/vela-core/crds/core.oam.dev_applications.yaml @@ -1020,10 +1020,10 @@ spec: execution properties: steps: - description: WorkflowMode describes the mode of workflow + description: Steps is the mode of workflow steps execution type: string subSteps: - description: WorkflowMode describes the mode of workflow + description: SubSteps is the mode of workflow sub steps execution type: string type: object ref: diff --git a/charts/vela-core/crds/core.oam.dev_workflows.yaml b/charts/vela-core/crds/core.oam.dev_workflows.yaml index 1abf7c7a2..f949da0c4 100644 --- a/charts/vela-core/crds/core.oam.dev_workflows.yaml +++ b/charts/vela-core/crds/core.oam.dev_workflows.yaml @@ -1,10 +1,10 @@ - --- apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.6.2 + controller-gen.kubebuilder.io/version: v0.9.0 + creationTimestamp: null name: workflows.core.oam.dev spec: group: core.oam.dev @@ -34,6 +34,16 @@ spec: type: string metadata: type: object + mode: + description: WorkflowExecuteMode defines the mode of workflow execution + properties: + steps: + description: Steps is the mode of workflow steps execution + type: string + subSteps: + description: SubSteps is the mode of workflow sub steps execution + type: string + type: object steps: items: description: WorkflowStep defines how to execute a workflow step. @@ -161,153 +171,3 @@ spec: type: object served: true storage: true - - name: v1beta1 - schema: - openAPIV3Schema: - description: Workflow defines workflow steps and other attributes - properties: - mode: - description: WorkflowExecuteMode defines the mode of workflow execution - properties: - steps: - description: WorkflowMode describes the mode of workflow - type: string - subSteps: - description: WorkflowMode describes the mode of workflow - type: string - type: object - ref: - type: string - steps: - items: - description: WorkflowStep defines how to execute a workflow step. - properties: - dependsOn: - description: DependsOn is the dependency of the step - items: - type: string - type: array - if: - description: If is the if condition of the step - type: string - inputs: - description: Inputs is the inputs of the step - items: - properties: - from: - type: string - parameterKey: - type: string - required: - - from - - parameterKey - type: object - type: array - meta: - description: Meta is the meta data of the workflow step. - properties: - alias: - type: string - type: object - name: - description: Name is the unique name of the workflow step. - type: string - outputs: - description: Outputs is the outputs of the step - items: - properties: - name: - type: string - valueFrom: - type: string - required: - - name - - valueFrom - type: object - type: array - properties: - description: Properties is the properties of the step - type: object - x-kubernetes-preserve-unknown-fields: true - subSteps: - items: - description: WorkflowStepBase defines the workflow step base - properties: - dependsOn: - description: DependsOn is the dependency of the step - items: - type: string - type: array - if: - description: If is the if condition of the step - type: string - inputs: - description: Inputs is the inputs of the step - items: - properties: - from: - type: string - parameterKey: - type: string - required: - - from - - parameterKey - type: object - type: array - meta: - description: Meta is the meta data of the workflow step. - properties: - alias: - type: string - type: object - name: - description: Name is the unique name of the workflow step. - type: string - outputs: - description: Outputs is the outputs of the step - items: - properties: - name: - type: string - valueFrom: - type: string - required: - - name - - valueFrom - type: object - type: array - properties: - description: Properties is the properties of the step - type: object - x-kubernetes-preserve-unknown-fields: true - timeout: - description: Timeout is the timeout of the step - type: string - type: - description: Type is the type of the workflow step. - type: string - required: - - name - - type - type: object - type: array - timeout: - description: Timeout is the timeout of the step - type: string - type: - description: Type is the type of the workflow step. - type: string - required: - - name - - type - type: object - type: array - type: object - served: true - storage: false -status: - acceptedNames: - kind: "" - plural: "" - conditions: [] - storedVersions: [] diff --git a/charts/vela-minimal/crds/core.oam.dev_applicationrevisions.yaml b/charts/vela-minimal/crds/core.oam.dev_applicationrevisions.yaml index 0ba506890..c4addb00e 100644 --- a/charts/vela-minimal/crds/core.oam.dev_applicationrevisions.yaml +++ b/charts/vela-minimal/crds/core.oam.dev_applicationrevisions.yaml @@ -2209,10 +2209,11 @@ spec: execution properties: steps: - description: WorkflowMode describes the mode of workflow + description: Steps is the mode of workflow steps execution type: string subSteps: - description: WorkflowMode describes the mode of workflow + description: SubSteps is the mode of workflow sub + steps execution type: string type: object ref: @@ -4008,6 +4009,17 @@ spec: namespace: type: string type: object + mode: + description: WorkflowExecuteMode defines the mode of workflow + execution + properties: + steps: + description: Steps is the mode of workflow steps execution + type: string + subSteps: + description: SubSteps is the mode of workflow sub steps execution + type: string + type: object steps: items: description: WorkflowStep defines how to execute a workflow diff --git a/charts/vela-minimal/crds/core.oam.dev_applications.yaml b/charts/vela-minimal/crds/core.oam.dev_applications.yaml index 71f08e8f9..e40fc76df 100644 --- a/charts/vela-minimal/crds/core.oam.dev_applications.yaml +++ b/charts/vela-minimal/crds/core.oam.dev_applications.yaml @@ -1020,10 +1020,10 @@ spec: execution properties: steps: - description: WorkflowMode describes the mode of workflow + description: Steps is the mode of workflow steps execution type: string subSteps: - description: WorkflowMode describes the mode of workflow + description: SubSteps is the mode of workflow sub steps execution type: string type: object ref: diff --git a/go.mod b/go.mod index 4ba287f13..c5b106af2 100644 --- a/go.mod +++ b/go.mod @@ -57,7 +57,7 @@ require ( github.com/koding/websocketproxy v0.0.0-20181220232114-7ed82d81a28c github.com/kubevela/pkg v0.0.0-20221024115939-a103acee6db2 github.com/kubevela/prism v1.5.1-0.20220915071949-6bf3ad33f84f - github.com/kubevela/workflow v0.0.0-20221025085648-3317390aa1e4 + github.com/kubevela/workflow v0.0.0-20221026075108-0ede3974b003 github.com/kyokomi/emoji v2.2.4+incompatible github.com/mitchellh/hashstructure/v2 v2.0.1 github.com/oam-dev/cluster-gateway v1.4.0 diff --git a/go.sum b/go.sum index 3ae788dc2..5c8dae1a9 100644 --- a/go.sum +++ b/go.sum @@ -1334,8 +1334,8 @@ github.com/kubevela/pkg v0.0.0-20221024115939-a103acee6db2 h1:C3cAfrxst1+dIWgLLh github.com/kubevela/pkg v0.0.0-20221024115939-a103acee6db2/go.mod h1:TgIGEB/r0NOy63Jzem7WsL3AIr34l+ClH9dmPqcZ4d4= github.com/kubevela/prism v1.5.1-0.20220915071949-6bf3ad33f84f h1:1lUtU1alPThdcsn4MI6XjPb7eJLuZPpmlEdgjtnUMKw= github.com/kubevela/prism v1.5.1-0.20220915071949-6bf3ad33f84f/go.mod h1:m724/7ANnB/iukyHW20+DicpeJMEC/JA0ZhgsHY10MA= -github.com/kubevela/workflow v0.0.0-20221025085648-3317390aa1e4 h1:cf3VG1ChgzZZxNczKtNeDKxg6X2J2lff1rCdVHajrQw= -github.com/kubevela/workflow v0.0.0-20221025085648-3317390aa1e4/go.mod h1:z3fMAQTsKTZz4Oq6xusd01pfCjezbOJV1ImFQ084MZc= +github.com/kubevela/workflow v0.0.0-20221026075108-0ede3974b003 h1:+5xexEl6AkaTtNZFS+hQ8UVg3oaGG0PG/EexW2WgH9s= +github.com/kubevela/workflow v0.0.0-20221026075108-0ede3974b003/go.mod h1:z3fMAQTsKTZz4Oq6xusd01pfCjezbOJV1ImFQ084MZc= github.com/kulti/thelper v0.4.0/go.mod h1:vMu2Cizjy/grP+jmsvOFDx1kYP6+PD1lqg4Yu5exl2U= github.com/kunwardeep/paralleltest v1.0.3/go.mod h1:vLydzomDFpk7yu5UX02RmP0H8QfRPOV/oFhWN85Mjb4= github.com/kylelemons/godebug v0.0.0-20160406211939-eadb3ce320cb/go.mod h1:B69LEHPfb2qLo0BaaOLcbitczOKLWTsrBG9LczfCD4k= diff --git a/legacy/charts/vela-core-legacy/crds/core.oam.dev_applicationrevisions.yaml b/legacy/charts/vela-core-legacy/crds/core.oam.dev_applicationrevisions.yaml index b9b1bb2fa..0aa54fe1b 100644 --- a/legacy/charts/vela-core-legacy/crds/core.oam.dev_applicationrevisions.yaml +++ b/legacy/charts/vela-core-legacy/crds/core.oam.dev_applicationrevisions.yaml @@ -2209,10 +2209,11 @@ spec: execution properties: steps: - description: WorkflowMode describes the mode of workflow + description: Steps is the mode of workflow steps execution type: string subSteps: - description: WorkflowMode describes the mode of workflow + description: SubSteps is the mode of workflow sub + steps execution type: string type: object ref: @@ -4008,6 +4009,17 @@ spec: namespace: type: string type: object + mode: + description: WorkflowExecuteMode defines the mode of workflow + execution + properties: + steps: + description: Steps is the mode of workflow steps execution + type: string + subSteps: + description: SubSteps is the mode of workflow sub steps execution + type: string + type: object steps: items: description: WorkflowStep defines how to execute a workflow diff --git a/legacy/charts/vela-core-legacy/crds/core.oam.dev_applications.yaml b/legacy/charts/vela-core-legacy/crds/core.oam.dev_applications.yaml index c9ca82463..a00c5247c 100644 --- a/legacy/charts/vela-core-legacy/crds/core.oam.dev_applications.yaml +++ b/legacy/charts/vela-core-legacy/crds/core.oam.dev_applications.yaml @@ -1021,10 +1021,10 @@ spec: execution properties: steps: - description: WorkflowMode describes the mode of workflow + description: Steps is the mode of workflow steps execution type: string subSteps: - description: WorkflowMode describes the mode of workflow + description: SubSteps is the mode of workflow sub steps execution type: string type: object ref: diff --git a/legacy/charts/vela-core-legacy/crds/core.oam.dev_workflows.yaml b/legacy/charts/vela-core-legacy/crds/core.oam.dev_workflows.yaml index eafdf0092..1f3499462 100644 --- a/legacy/charts/vela-core-legacy/crds/core.oam.dev_workflows.yaml +++ b/legacy/charts/vela-core-legacy/crds/core.oam.dev_workflows.yaml @@ -1,10 +1,9 @@ - --- apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.6.2 + controller-gen.kubebuilder.io/version: v0.9.0 name: workflows.core.oam.dev spec: group: core.oam.dev @@ -34,6 +33,16 @@ spec: type: string metadata: type: object + mode: + description: WorkflowExecuteMode defines the mode of workflow execution + properties: + steps: + description: Steps is the mode of workflow steps execution + type: string + subSteps: + description: SubSteps is the mode of workflow sub steps execution + type: string + type: object steps: items: description: WorkflowStep defines how to execute a workflow step. @@ -161,297 +170,3 @@ spec: type: object served: true storage: true - - name: v1alpha1 - schema: - openAPIV3Schema: - description: Workflow is the Schema for the workflow API - properties: - apiVersion: - description: 'APIVersion defines the versioned schema of this representation - of an object. Servers should convert recognized schemas to the latest - internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' - type: string - kind: - description: 'Kind is a string value representing the REST resource this - object represents. Servers may infer this from the endpoint the client - submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' - type: string - metadata: - type: object - steps: - items: - description: WorkflowStep defines how to execute a workflow step. - properties: - dependsOn: - description: DependsOn is the dependency of the step - items: - type: string - type: array - if: - description: If is the if condition of the step - type: string - inputs: - description: Inputs is the inputs of the step - items: - properties: - from: - type: string - parameterKey: - type: string - required: - - from - - parameterKey - type: object - type: array - meta: - description: Meta is the meta data of the workflow step. - properties: - alias: - type: string - type: object - name: - description: Name is the unique name of the workflow step. - type: string - outputs: - description: Outputs is the outputs of the step - items: - properties: - name: - type: string - valueFrom: - type: string - required: - - name - - valueFrom - type: object - type: array - properties: - description: Properties is the properties of the step - type: object - - subSteps: - items: - description: WorkflowStepBase defines the workflow step base - properties: - dependsOn: - description: DependsOn is the dependency of the step - items: - type: string - type: array - if: - description: If is the if condition of the step - type: string - inputs: - description: Inputs is the inputs of the step - items: - properties: - from: - type: string - parameterKey: - type: string - required: - - from - - parameterKey - type: object - type: array - meta: - description: Meta is the meta data of the workflow step. - properties: - alias: - type: string - type: object - name: - description: Name is the unique name of the workflow step. - type: string - outputs: - description: Outputs is the outputs of the step - items: - properties: - name: - type: string - valueFrom: - type: string - required: - - name - - valueFrom - type: object - type: array - properties: - description: Properties is the properties of the step - type: object - - timeout: - description: Timeout is the timeout of the step - type: string - type: - description: Type is the type of the workflow step. - type: string - required: - - name - - type - type: object - type: array - timeout: - description: Timeout is the timeout of the step - type: string - type: - description: Type is the type of the workflow step. - type: string - required: - - name - - type - type: object - type: array - type: object - served: true - storage: false - - name: v1beta1 - schema: - openAPIV3Schema: - description: Workflow defines workflow steps and other attributes - properties: - mode: - description: WorkflowExecuteMode defines the mode of workflow execution - properties: - steps: - description: WorkflowMode describes the mode of workflow - type: string - subSteps: - description: WorkflowMode describes the mode of workflow - type: string - type: object - ref: - type: string - steps: - items: - description: WorkflowStep defines how to execute a workflow step. - properties: - dependsOn: - description: DependsOn is the dependency of the step - items: - type: string - type: array - if: - description: If is the if condition of the step - type: string - inputs: - description: Inputs is the inputs of the step - items: - properties: - from: - type: string - parameterKey: - type: string - required: - - from - - parameterKey - type: object - type: array - meta: - description: Meta is the meta data of the workflow step. - properties: - alias: - type: string - type: object - name: - description: Name is the unique name of the workflow step. - type: string - outputs: - description: Outputs is the outputs of the step - items: - properties: - name: - type: string - valueFrom: - type: string - required: - - name - - valueFrom - type: object - type: array - properties: - description: Properties is the properties of the step - type: object - - subSteps: - items: - description: WorkflowStepBase defines the workflow step base - properties: - dependsOn: - description: DependsOn is the dependency of the step - items: - type: string - type: array - if: - description: If is the if condition of the step - type: string - inputs: - description: Inputs is the inputs of the step - items: - properties: - from: - type: string - parameterKey: - type: string - required: - - from - - parameterKey - type: object - type: array - meta: - description: Meta is the meta data of the workflow step. - properties: - alias: - type: string - type: object - name: - description: Name is the unique name of the workflow step. - type: string - outputs: - description: Outputs is the outputs of the step - items: - properties: - name: - type: string - valueFrom: - type: string - required: - - name - - valueFrom - type: object - type: array - properties: - description: Properties is the properties of the step - type: object - - timeout: - description: Timeout is the timeout of the step - type: string - type: - description: Type is the type of the workflow step. - type: string - required: - - name - - type - type: object - type: array - timeout: - description: Timeout is the timeout of the step - type: string - type: - description: Type is the type of the workflow step. - type: string - required: - - name - - type - type: object - type: array - type: object - served: true - storage: false -status: - acceptedNames: - kind: "" - plural: "" - conditions: [] - storedVersions: [] diff --git a/pkg/appfile/parser.go b/pkg/appfile/parser.go index 21024ef16..8b12cc881 100644 --- a/pkg/appfile/parser.go +++ b/pkg/appfile/parser.go @@ -452,15 +452,24 @@ func (p *Parser) loadWorkflowToAppfile(ctx context.Context, af *Appfile) error { Steps: workflowv1alpha1.WorkflowModeDAG, SubSteps: workflowv1alpha1.WorkflowModeDAG, } - if wfSpec := af.app.Spec.Workflow; wfSpec != nil && len(wfSpec.Steps) > 0 { + if wfSpec := af.app.Spec.Workflow; wfSpec != nil { + app := af.app + mode := wfSpec.Mode + if wfSpec.Ref != "" && mode == nil { + wf := &workflowv1alpha1.Workflow{} + if err := af.WorkflowClient(p.client).Get(ctx, ktypes.NamespacedName{Namespace: af.app.Namespace, Name: app.Spec.Workflow.Ref}, wf); err != nil { + return err + } + mode = wf.Mode + } af.WorkflowSteps = wfSpec.Steps af.WorkflowMode.Steps = workflowv1alpha1.WorkflowModeStep - if wfSpec.Mode != nil { - if wfSpec.Mode.Steps != "" { - af.WorkflowMode.Steps = wfSpec.Mode.Steps + if mode != nil { + if mode.Steps != "" { + af.WorkflowMode.Steps = mode.Steps } - if wfSpec.Mode.SubSteps != "" { - af.WorkflowMode.SubSteps = wfSpec.Mode.SubSteps + if mode.SubSteps != "" { + af.WorkflowMode.SubSteps = mode.SubSteps } } } diff --git a/pkg/stdlib/pkgs/oam.cue b/pkg/stdlib/pkgs/oam.cue index 4b7f7e1bf..a0c422329 100644 --- a/pkg/stdlib/pkgs/oam.cue +++ b/pkg/stdlib/pkgs/oam.cue @@ -1,11 +1,18 @@ #ApplyComponent: { - #provider: "oam" - #do: "component-apply" - cluster: *"" | string - env: *"" | string - namespace: *"" | string + #provider: "oam" + #do: "component-apply" + + // +usage=The cluster to use + cluster: *"" | string + // +usage=The env to use + env: *"" | string + // +usage=The namespace to apply + namespace: *"" | string + // +usage=Whether to wait healthy of the applied component waitHealthy: *true | bool + // +usage=The value of the component resource value: {...} + // +usage=The patcher that will be applied to the resource, you can define the strategy of list merge through comments. Reference doc here: https://kubevela.io/docs/platform-engineers/traits/patch-trait#patch-in-workflow-step patch?: {...} ... } @@ -26,6 +33,11 @@ #LoadComponets: { #provider: "oam" #do: "load" + + // +usage=If specify `app`, use specified application to load its component resources otherwise use current application + app?: string + // +usage=The value of the components will be filled in this field after the action is executed, you can use value[componentName] to refer a specified component + value?: {...} ... } diff --git a/test/e2e-multicluster-test/multicluster_standalone_test.go b/test/e2e-multicluster-test/multicluster_standalone_test.go index f6f589e58..c64cc458a 100644 --- a/test/e2e-multicluster-test/multicluster_standalone_test.go +++ b/test/e2e-multicluster-test/multicluster_standalone_test.go @@ -97,8 +97,10 @@ var _ = Describe("Test multicluster standalone scenario", func() { Eventually(func(g Gomega) { app := &v1beta1.Application{} - Expect(k8sClient.Get(context.Background(), types.NamespacedName{Namespace: namespace, Name: "podinfo"}, app)).Should(Succeed()) - Expect(k8sClient.Delete(context.Background(), app)).Should(Succeed()) + g.Expect(k8sClient.Get(context.Background(), types.NamespacedName{Namespace: namespace, Name: "podinfo"}, app)).Should(Succeed()) + g.Expect(app.Status.Workflow).ShouldNot(BeNil()) + g.Expect(app.Status.Workflow.Mode).Should(Equal("DAG-DAG")) + g.Expect(k8sClient.Delete(context.Background(), app)).Should(Succeed()) }, 15*time.Second).Should(Succeed()) Eventually(func(g Gomega) { diff --git a/test/e2e-multicluster-test/testdata/app/standalone/workflow.yaml b/test/e2e-multicluster-test/testdata/app/standalone/workflow.yaml index 869e50a3b..7a5d0baa7 100644 --- a/test/e2e-multicluster-test/testdata/app/standalone/workflow.yaml +++ b/test/e2e-multicluster-test/testdata/app/standalone/workflow.yaml @@ -2,6 +2,8 @@ apiVersion: core.oam.dev/v1alpha1 kind: Workflow metadata: name: deploy-podinfo +mode: + steps: DAG steps: - type: deploy name: deploy-worker