github.com/kubevela/workflow@v0.6.0/charts/vela-workflow/templates/definitions/build-push-image.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/build-push-image.cue 3 apiVersion: core.oam.dev/v1beta1 4 kind: WorkflowStepDefinition 5 metadata: 6 annotations: 7 definition.oam.dev/alias: "" 8 definition.oam.dev/description: Build and push image from git url 9 definition.oam.dev/example-url: https://raw.githubusercontent.com/kubevela/workflow/main/examples/workflow-run/built-push-image.yaml 10 name: build-push-image 11 namespace: {{ include "systemDefinitionNamespace" . }} 12 spec: 13 schematic: 14 cue: 15 template: | 16 import ( 17 "vela/op" 18 "encoding/json" 19 "strings" 20 ) 21 22 url: { 23 if parameter.context.git != _|_ { 24 address: strings.TrimPrefix(parameter.context.git, "git://") 25 value: "git://\(address)#refs/heads/\(parameter.context.branch)" 26 } 27 if parameter.context.git == _|_ { 28 value: parameter.context 29 } 30 } 31 kaniko: op.#Apply & { 32 value: { 33 apiVersion: "v1" 34 kind: "Pod" 35 metadata: { 36 name: "\(context.name)-\(context.stepSessionID)-kaniko" 37 namespace: context.namespace 38 } 39 spec: { 40 containers: [ 41 { 42 args: [ 43 "--dockerfile=\(parameter.dockerfile)", 44 "--context=\(url.value)", 45 "--destination=\(parameter.image)", 46 "--verbosity=\(parameter.verbosity)", 47 if parameter.platform != _|_ { 48 "--customPlatform=\(parameter.platform)" 49 }, 50 if parameter.buildArgs != _|_ for arg in parameter.buildArgs { 51 "--build-arg=\(arg)" 52 }, 53 ] 54 image: parameter.kanikoExecutor 55 name: "kaniko" 56 if parameter.credentials != _|_ && parameter.credentials.image != _|_ { 57 volumeMounts: [ 58 { 59 mountPath: "/kaniko/.docker/" 60 name: parameter.credentials.image.name 61 }, 62 ] 63 } 64 if parameter.credentials != _|_ && parameter.credentials.git != _|_ { 65 env: [ 66 { 67 name: "GIT_TOKEN" 68 valueFrom: secretKeyRef: { 69 key: parameter.credentials.git.key 70 name: parameter.credentials.git.name 71 } 72 }, 73 ] 74 } 75 }, 76 ] 77 if parameter.credentials != _|_ && parameter.credentials.image != _|_ { 78 volumes: [ 79 { 80 name: parameter.credentials.image.name 81 secret: { 82 defaultMode: 420 83 items: [ 84 { 85 key: parameter.credentials.image.key 86 path: "config.json" 87 }, 88 ] 89 secretName: parameter.credentials.image.name 90 } 91 }, 92 ] 93 } 94 restartPolicy: "Never" 95 } 96 } 97 } 98 log: op.#Log & { 99 source: resources: [{ 100 name: "\(context.name)-\(context.stepSessionID)-kaniko" 101 namespace: context.namespace 102 }] 103 } 104 read: op.#Read & { 105 value: { 106 apiVersion: "v1" 107 kind: "Pod" 108 metadata: { 109 name: "\(context.name)-\(context.stepSessionID)-kaniko" 110 namespace: context.namespace 111 } 112 } 113 } 114 wait: op.#ConditionalWait & { 115 continue: read.value.status != _|_ && read.value.status.phase == "Succeeded" 116 } 117 #secret: { 118 name: string 119 key: string 120 } 121 #git: { 122 git: string 123 branch: *"master" | string 124 } 125 parameter: { 126 // +usage=Specify the kaniko executor image, default to oamdev/kaniko-executor:v1.9.1 127 kanikoExecutor: *"oamdev/kaniko-executor:v1.9.1" | string 128 // +usage=Specify the context to build image, you can use context with git and branch or directly specify the context, please refer to https://github.com/GoogleContainerTools/kaniko#kaniko-build-contexts 129 context: #git | string 130 // +usage=Specify the dockerfile 131 dockerfile: *"./Dockerfile" | string 132 // +usage=Specify the image 133 image: string 134 // +usage=Specify the platform to build 135 platform?: string 136 // +usage=Specify the build args 137 buildArgs?: [...string] 138 // +usage=Specify the credentials to access git and image registry 139 credentials?: { 140 // +usage=Specify the credentials to access git 141 git?: { 142 // +usage=Specify the secret name 143 name: string 144 // +usage=Specify the secret key 145 key: string 146 } 147 // +usage=Specify the credentials to access image registry 148 image?: { 149 // +usage=Specify the secret name 150 name: string 151 // +usage=Specify the secret key 152 key: *".dockerconfigjson" | string 153 } 154 } 155 // +usage=Specify the verbosity level 156 verbosity: *"info" | "panic" | "fatal" | "error" | "warn" | "debug" | "trace" 157 } 158