github.com/oam-dev/kubevela@v1.9.11/charts/vela-core/templates/defwithtemplate/webhook.yaml (about) 1 # Code generated by KubeVela templates. DO NOT EDIT. Please edit the original cue file. 2 # Definition source cue file: vela-templates/definitions/internal/webhook.cue 3 apiVersion: core.oam.dev/v1beta1 4 kind: WorkflowStepDefinition 5 metadata: 6 annotations: 7 custom.definition.oam.dev/category: External Intergration 8 definition.oam.dev/description: Send a POST request to the specified Webhook URL. If no request body is specified, the current Application body will be sent by default. 9 name: webhook 10 namespace: {{ include "systemDefinitionNamespace" . }} 11 spec: 12 schematic: 13 cue: 14 template: | 15 import ( 16 "vela/op" 17 "encoding/json" 18 "encoding/base64" 19 ) 20 21 data: op.#Steps & { 22 if parameter.data == _|_ { 23 read: op.#Read & { 24 value: { 25 apiVersion: "core.oam.dev/v1beta1" 26 kind: "Application" 27 metadata: { 28 name: context.name 29 namespace: context.namespace 30 } 31 } 32 } @step(1) 33 value: json.Marshal(read.value) @step(2) 34 } 35 if parameter.data != _|_ { 36 value: json.Marshal(parameter.data) @step(3) 37 } 38 } 39 webhook: op.#Steps & { 40 if parameter.url.value != _|_ { 41 http: op.#HTTPPost & { 42 url: parameter.url.value 43 request: { 44 body: data.value 45 header: "Content-Type": "application/json" 46 } 47 } @step(4) 48 } 49 if parameter.url.secretRef != _|_ && parameter.url.value == _|_ { 50 read: op.#Read & { 51 value: { 52 apiVersion: "v1" 53 kind: "Secret" 54 metadata: { 55 name: parameter.url.secretRef.name 56 namespace: context.namespace 57 } 58 } 59 } @step(5) 60 61 stringValue: op.#ConvertString & {bt: base64.Decode(null, read.value.data[parameter.url.secretRef.key])} @step(6) 62 http: op.#HTTPPost & { 63 url: stringValue.str 64 request: { 65 body: data.value 66 header: "Content-Type": "application/json" 67 } 68 } @step(7) 69 } 70 } 71 72 parameter: { 73 // +usage=Specify the webhook url 74 url: close({ 75 value: string 76 }) | close({ 77 secretRef: { 78 // +usage=name is the name of the secret 79 name: string 80 // +usage=key is the key in the secret 81 key: string 82 } 83 }) 84 // +usage=Specify the data you want to send 85 data?: {...} 86 } 87