# Code generated by KubeVela templates. DO NOT EDIT. Please edit the original cue file.
# Definition source cue file: vela-templates/definitions/internal/apply-deployment.cue
apiVersion: core.oam.dev/v1beta1
kind: WorkflowStepDefinition
metadata:
  annotations:
    custom.definition.oam.dev/category: Resource Management
    definition.oam.dev/alias: ""
    definition.oam.dev/description: Apply deployment with specified image and cmd.
  name: apply-deployment
  namespace: {{ include "systemDefinitionNamespace" . }}
spec:
  schematic:
    cue:
      template: |
        import (
        	"strconv"
        	"strings"
        	"vela/kube"
        	"vela/builtin"
        )

        output: kube.#Apply & {
        	$params: {
        		cluster: parameter.cluster
        		value: {
        			apiVersion: "apps/v1"
        			kind:       "Deployment"
        			metadata: {
        				name:      context.stepName
        				namespace: context.namespace
        			}
        			spec: {
        				selector: matchLabels: "workflow.oam.dev/step-name": "\(context.name)-\(context.stepName)"
        				replicas: parameter.replicas
        				template: {
        					metadata: labels: "workflow.oam.dev/step-name": "\(context.name)-\(context.stepName)"
        					spec: containers: [{
        						name:  context.stepName
        						image: parameter.image
        						if parameter["cmd"] != _|_ {
        							command: parameter.cmd
        						}
        					}]
        				}
        			}
        		}
        	}
        }
        wait: builtin.#ConditionalWait & {
        	$params: continue: output.$returns.value.status.readyReplicas == parameter.replicas
        }
        parameter: {
        	image:    string
        	replicas: *1 | int
        	cluster:  *"" | string
        	cmd?: [...string]
        }

