# Code generated by KubeVela templates. DO NOT EDIT. Please edit the original cue file.
# Definition source cue file: vela-templates/definitions/internal/lifecycle.cue
apiVersion: core.oam.dev/v1beta1
kind: TraitDefinition
metadata:
  annotations:
    definition.oam.dev/description: Add lifecycle hooks for the first container of K8s pod for your workload which follows the pod spec in path 'spec.template'.
  name: lifecycle
  namespace: {{.Values.systemDefinitionNamespace}}
spec:
  appliesToWorkloads:
    - '*'
  podDisruptive: true
  schematic:
    cue:
      template: |
        patch: spec: template: spec: containers: [{
        	lifecycle: {
        		if parameter.postStart != _|_ {
        			postStart: parameter.postStart
        		}
        		if parameter.preStop != _|_ {
        			preStop: parameter.preStop
        		}
        	}
        }, ...]
        parameter: {
        	postStart?: #LifeCycleHandler
        	preStop?:   #LifeCycleHandler
        }
        #Port: int & >=1 & <=65535
        #LifeCycleHandler: {
        	exec?: command: [...string]
        	httpGet?: {
        		path?:  string
        		port:   #Port
        		host?:  string
        		scheme: *"HTTP" | "HTTPS"
        		httpHeaders?: [...{
        			name:  string
        			value: string
        		}]
        	}
        	tcpSocket?: {
        		port:  #Port
        		host?: string
        	}
        }

