diff --git a/go.mod b/go.mod index c33343d..c48dd09 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/kubevela/workflow go 1.19 require ( - cuelang.org/go v0.4.4-0.20220915174651-ad253ed099e9 + cuelang.org/go v0.5.0-alpha.1 github.com/agiledragon/gomonkey/v2 v2.4.0 github.com/aliyun/aliyun-log-go-sdk v0.1.38 github.com/crossplane/crossplane-runtime v0.14.1-0.20210722005935-0b469fcc77cd diff --git a/go.sum b/go.sum index b11e4eb..613e757 100644 --- a/go.sum +++ b/go.sum @@ -23,8 +23,8 @@ cloud.google.com/go/storage v1.5.0/go.mod h1:tpKbwo567HUNpVclU5sGELwQWBDZ8gh0Zeo cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohlUTyfDhBk= cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs= contrib.go.opencensus.io/exporter/stackdriver v0.13.4/go.mod h1:aXENhDJ1Y4lIg4EUaVTwzvYETVNZk10Pu26tevFKLUc= -cuelang.org/go v0.4.4-0.20220915174651-ad253ed099e9 h1:4mfDNgtdb398g0bekqiW8J8tw+JN3/U/3wh+Jw/I4Yk= -cuelang.org/go v0.4.4-0.20220915174651-ad253ed099e9/go.mod h1:nxWFAPWKYvZJ+eYayxArWqKKjdBTeU1N52vJpML/c6w= +cuelang.org/go v0.5.0-alpha.1 h1:uftOYkiScCHPCQMF2dIwoyCIJsTAEONkFSA2GCm5xIc= +cuelang.org/go v0.5.0-alpha.1/go.mod h1:nxWFAPWKYvZJ+eYayxArWqKKjdBTeU1N52vJpML/c6w= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= github.com/AlecAivazis/survey/v2 v2.1.1 h1:LEMbHE0pLj75faaVEKClEX1TM4AJmmnOh9eimREzLWI= github.com/AlecAivazis/survey/v2 v2.1.1/go.mod h1:9FJRdMdDm8rnT+zHVbvQT2RTSTLq0Ttd6q3Vl2fahjk= diff --git a/pkg/executor/workflow.go b/pkg/executor/workflow.go index dfb2962..8579f4c 100644 --- a/pkg/executor/workflow.go +++ b/pkg/executor/workflow.go @@ -546,8 +546,6 @@ func (e *engine) checkWorkflowStatusMessage(wfStatus *v1alpha1.WorkflowRunStatus switch { case !e.waiting && e.failedAfterRetries && feature.DefaultMutableFeatureGate.Enabled(features.EnableSuspendOnFailure): e.status.Message = types.MessageSuspendFailedAfterRetries - case wfStatus.Terminated && !feature.DefaultMutableFeatureGate.Enabled(features.EnableSuspendOnFailure): - e.status.Message = types.MessageTerminated default: e.status.Message = "" } diff --git a/pkg/executor/workflow_test.go b/pkg/executor/workflow_test.go index 0fd1640..e80221b 100644 --- a/pkg/executor/workflow_test.go +++ b/pkg/executor/workflow_test.go @@ -285,7 +285,6 @@ var _ = Describe("Test Workflow", func() { cleanStepTimeStamp(&workflowStatus) Expect(cmp.Diff(workflowStatus, v1alpha1.WorkflowRunStatus{ Mode: defaultMode, - Message: types.MessageTerminated, Terminated: true, Steps: []v1alpha1.WorkflowStepStatus{ { @@ -371,7 +370,6 @@ var _ = Describe("Test Workflow", func() { cleanStepTimeStamp(&workflowStatus) Expect(cmp.Diff(workflowStatus, v1alpha1.WorkflowRunStatus{ Mode: defaultMode, - Message: types.MessageTerminated, Terminated: true, Steps: []v1alpha1.WorkflowStepStatus{ { @@ -464,7 +462,6 @@ var _ = Describe("Test Workflow", func() { cleanStepTimeStamp(&workflowStatus) Expect(cmp.Diff(workflowStatus, v1alpha1.WorkflowRunStatus{ Mode: defaultMode, - Message: types.MessageTerminated, Terminated: true, Steps: []v1alpha1.WorkflowStepStatus{{ StepStatus: v1alpha1.StepStatus{ @@ -556,7 +553,6 @@ var _ = Describe("Test Workflow", func() { cleanStepTimeStamp(&workflowStatus) Expect(cmp.Diff(workflowStatus, v1alpha1.WorkflowRunStatus{ Mode: defaultMode, - Message: types.MessageTerminated, Terminated: true, Steps: []v1alpha1.WorkflowStepStatus{{ StepStatus: v1alpha1.StepStatus{ @@ -641,7 +637,6 @@ var _ = Describe("Test Workflow", func() { Expect(cmp.Diff(instance.Status, v1alpha1.WorkflowRunStatus{ Mode: defaultMode, Terminated: true, - Message: string(types.MessageTerminated), Steps: []v1alpha1.WorkflowStepStatus{{ StepStatus: v1alpha1.StepStatus{ Name: "s1", @@ -729,7 +724,6 @@ var _ = Describe("Test Workflow", func() { Expect(cmp.Diff(instance.Status, v1alpha1.WorkflowRunStatus{ Mode: defaultMode, Terminated: true, - Message: types.MessageTerminated, Steps: []v1alpha1.WorkflowStepStatus{{ StepStatus: v1alpha1.StepStatus{ Name: "s1", @@ -1057,7 +1051,6 @@ var _ = Describe("Test Workflow", func() { cleanStepTimeStamp(&workflowStatus) Expect(cmp.Diff(workflowStatus, v1alpha1.WorkflowRunStatus{ Mode: defaultMode, - Message: types.MessageTerminated, Suspend: false, Terminated: true, Steps: []v1alpha1.WorkflowStepStatus{{ @@ -1154,7 +1147,6 @@ var _ = Describe("Test Workflow", func() { cleanStepTimeStamp(&workflowStatus) Expect(cmp.Diff(workflowStatus, v1alpha1.WorkflowRunStatus{ Mode: dagMode, - Message: types.MessageTerminated, Terminated: true, Steps: []v1alpha1.WorkflowStepStatus{{ StepStatus: v1alpha1.StepStatus{ @@ -1425,7 +1417,6 @@ var _ = Describe("Test Workflow", func() { Expect(cmp.Diff(instance.Status, v1alpha1.WorkflowRunStatus{ Mode: defaultMode, Terminated: true, - Message: types.MessageTerminated, Steps: []v1alpha1.WorkflowStepStatus{{ StepStatus: v1alpha1.StepStatus{ Name: "s1", @@ -1924,7 +1915,6 @@ var _ = Describe("Test Workflow", func() { Expect(cmp.Diff(instance.Status, v1alpha1.WorkflowRunStatus{ Mode: defaultMode, Terminated: true, - Message: types.MessageTerminated, Steps: []v1alpha1.WorkflowStepStatus{{ StepStatus: v1alpha1.StepStatus{ Name: "s1", @@ -1983,7 +1973,6 @@ var _ = Describe("Test Workflow", func() { Expect(cmp.Diff(instance.Status, v1alpha1.WorkflowRunStatus{ Mode: defaultMode, Terminated: true, - Message: types.MessageTerminated, Steps: []v1alpha1.WorkflowStepStatus{{ StepStatus: v1alpha1.StepStatus{ Name: "s1", diff --git a/pkg/stdlib/actions/v1/op.cue b/pkg/stdlib/actions/v1/op.cue index 4d708df..f3b741e 100644 --- a/pkg/stdlib/actions/v1/op.cue +++ b/pkg/stdlib/actions/v1/op.cue @@ -5,23 +5,32 @@ import ( ) #ConditionalWait: { - #do: "wait" + #do: "wait" + + // +usage=If continue is false, the step will wait for continue to be true. continue: bool + // +usage=Optional message that will be shown in workflow step status, note that the message might be override by other actions. message?: string } #Break: { - #do: "break" + #do: "break" + + // +usage=Optional message that will be shown in workflow step status, note that the message might be override by other actions. message?: string } #Fail: { - #do: "fail" + #do: "fail" + + // +usage=Optional message that will be shown in workflow step status, note that the message might be override by other actions. message?: string } #Message: { - #do: "message" + #do: "message" + + // +usage=Optional message that will be shown in workflow step status, note that the message might be override by other actions. message?: string } diff --git a/pkg/stdlib/actions/v1/pkgs/email.cue b/pkg/stdlib/actions/v1/pkgs/email.cue index a573fb2..41c8add 100644 --- a/pkg/stdlib/actions/v1/pkgs/email.cue +++ b/pkg/stdlib/actions/v1/pkgs/email.cue @@ -2,17 +2,27 @@ #do: "send" #provider: "email" + // +usage=The info of the sender from: { - address: string - alias?: string + // +usage=The address of the sender + address: string + // +usage=The alias of the sender + alias?: string + // +usage=The password of the sender password: string - host: string - port: int + // +usage=The host of the sender server + host: string + // +usage=The port of the sender server + port: int } + // +usgae=The email address list of the recievers to: [...string] + // +usage=The content of the email content: { + // +usage=The subject of the email subject: string - body: string + // +usage=The body of the email + body: string } stepID: context.stepSessionID ... diff --git a/pkg/stdlib/actions/v1/pkgs/http.cue b/pkg/stdlib/actions/v1/pkgs/http.cue index 2458f68..c88c208 100644 --- a/pkg/stdlib/actions/v1/pkgs/http.cue +++ b/pkg/stdlib/actions/v1/pkgs/http.cue @@ -2,24 +2,38 @@ #do: "do" #provider: "http" + // +usage=The method of HTTP request method: *"GET" | "POST" | "PUT" | "DELETE" - url: string + // +usage=The url to request + url: string + // +usage=The request config request?: { + // +usage=The timeout of this request timeout?: string - body?: string - header?: [string]: string + // +usage=The request body + body?: string + // +usage=The header of the request + header?: [string]: string + // +usage=The trailer of the request trailer?: [string]: string + // +usage=The rate limiter of the request ratelimiter?: { limit: int period: string } ... } + // +usgae=The tls config of the request tls_config?: secret: string + // +usage=The response of the request will be filled in this field after the action is executed response: { + // +usage=The body of the response body: string + // +usage=The header of the response header?: [string]: [...string] + // +usage=The trailer of the response trailer?: [string]: [...string] + // +usage=The status code of the response statusCode: int ... } diff --git a/pkg/stdlib/actions/v1/pkgs/kube.cue b/pkg/stdlib/actions/v1/pkgs/kube.cue index 401bc74..27cc3b1 100644 --- a/pkg/stdlib/actions/v1/pkgs/kube.cue +++ b/pkg/stdlib/actions/v1/pkgs/kube.cue @@ -1,7 +1,10 @@ #Apply: { #do: "apply" #provider: "kube" - cluster: *"" | string + + // +usage=The cluster to use + cluster: *"" | string + // +usage=The resource to apply value: {...} ... } @@ -9,7 +12,10 @@ #ApplyInParallel: { #do: "apply-in-parallel" #provider: "kube" - cluster: *"" | string + + // +usage=The cluster to use + cluster: *"" | string + // +usage=The resources to apply in parallel value: [...{...}] ... } @@ -17,7 +23,10 @@ #Read: { #do: "read" #provider: "kube" - cluster: *"" | string + + // +usage=The cluster to use + cluster: *"" | string + // +usage=The resource to read, this field will be filled with the resource read from the cluster after the action is executed value?: {...} ... } @@ -25,15 +34,24 @@ #List: { #do: "list" #provider: "kube" - cluster: *"" | string + + // +usage=The cluster to use + cluster: *"" | string + // +usage=The resource to list resource: { + // +usage=The api version of the resource apiVersion: string - kind: string + // +usage=The kind of the resource + kind: string } + // +usage=The filter to list the resources filter?: { + // +usage=The namespace to list the resources namespace?: *"" | string + // +usage=The label selector to filter the resources matchingLabels?: {...} } + // +usage=The listed resources will be filled in this field after the action is executed list?: {...} ... } @@ -41,17 +59,28 @@ #Delete: { #do: "delete" #provider: "kube" - cluster: *"" | string + + // +usage=The cluster to use + cluster: *"" | string + // +usage=The resource to delete value: { + // +usage=The api version of the resource apiVersion: string - kind: string + // +usage=The kind of the resource + kind: string + // +usage=The metadata of the resource metadata: { - name?: string + // +usage=The name of the resource + name?: string + // +usage=The namespace of the resource namespace: *"default" | string } } + // +usage=The filter to delete the resources filter?: { + // +usage=The namespace to list the resources namespace?: string + // +usage=The label selector to filter the resources matchingLabels?: {...} } ... diff --git a/pkg/stdlib/actions/v1/pkgs/ws.cue b/pkg/stdlib/actions/v1/pkgs/ws.cue index 422af6b..2c002d9 100644 --- a/pkg/stdlib/actions/v1/pkgs/ws.cue +++ b/pkg/stdlib/actions/v1/pkgs/ws.cue @@ -12,8 +12,12 @@ } #DoVar: { - #do: "var" + #do: "var" + + // +usage=The method to call on the variable method: *"Get" | "Put" - path: string + // +usage=The path to the variable + path: string + // +usage=The value of the variable value?: _ } diff --git a/pkg/types/types.go b/pkg/types/types.go index dd3b29f..1a9c66b 100644 --- a/pkg/types/types.go +++ b/pkg/types/types.go @@ -267,8 +267,6 @@ const ( ) const ( - // MessageTerminated is the message of failed workflow - MessageTerminated = "The workflow terminates because of the failed steps" // MessageSuspendFailedAfterRetries is the message of failed after retries MessageSuspendFailedAfterRetries = "The workflow suspends automatically because the failed times of steps have reached the limit" )