github.com/oam-dev/kubevela@v1.9.11/vela-templates/definitions/internal/workflowstep/export2secret.cue (about) 1 import ( 2 "vela/op" 3 "encoding/base64" 4 "encoding/json" 5 ) 6 7 "export2secret": { 8 type: "workflow-step" 9 annotations: { 10 "category": "Resource Management" 11 } 12 description: "Export data to Kubernetes Secret in your workflow." 13 } 14 template: { 15 secret: op.#Steps & { 16 data: *parameter.data | {} 17 if parameter.kind == "docker-registry" && parameter.dockerRegistry != _|_ { 18 registryData: { 19 auths: { 20 "\(parameter.dockerRegistry.server)": { 21 username: parameter.dockerRegistry.username 22 password: parameter.dockerRegistry.password 23 auth: base64.Encode(null, "\(parameter.dockerRegistry.username):\(parameter.dockerRegistry.password)") 24 } 25 } 26 } 27 data: { 28 ".dockerconfigjson": json.Marshal(registryData) 29 } 30 } 31 apply: op.#Apply & { 32 value: { 33 apiVersion: "v1" 34 kind: "Secret" 35 if parameter.type == _|_ && parameter.kind == "docker-registry" { 36 type: "kubernetes.io/dockerconfigjson" 37 } 38 if parameter.type != _|_ { 39 type: parameter.type 40 } 41 metadata: { 42 name: parameter.secretName 43 if parameter.namespace != _|_ { 44 namespace: parameter.namespace 45 } 46 if parameter.namespace == _|_ { 47 namespace: context.namespace 48 } 49 } 50 stringData: data 51 } 52 cluster: parameter.cluster 53 } 54 } 55 parameter: { 56 // +usage=Specify the name of the secret 57 secretName: string 58 // +usage=Specify the namespace of the secret 59 namespace?: string 60 // +usage=Specify the type of the secret 61 type?: string 62 // +usage=Specify the data of secret 63 data: {} 64 // +usage=Specify the cluster of the secret 65 cluster: *"" | string 66 // +usage=Specify the kind of the secret 67 kind: *"generic" | "docker-registry" 68 // +usage=Specify the docker data 69 dockerRegistry?: { 70 // +usage=Specify the username of the docker registry 71 username: string 72 // +usage=Specify the password of the docker registry 73 password: string 74 // +usage=Specify the server of the docker registry 75 server: *"https://index.docker.io/v1/" | string 76 } 77 } 78 }