# Code generated by KubeVela templates. DO NOT EDIT. Please edit the original cue file.
# Definition source cue file: vela-templates/definitions/internal/rollout.cue
apiVersion: core.oam.dev/v1beta1
kind: TraitDefinition
metadata:
  annotations:
    definition.oam.dev/description: Rollout the component.
  labels:
    custom.definition.oam.dev/ui-hidden: "true"
  name: rollout
  namespace: {{.Values.systemDefinitionNamespace}}
spec:
  manageWorkload: true
  schematic:
    cue:
      template: |
        outputs: rollout: {
        	apiVersion: "standard.oam.dev/v1alpha1"
        	kind:       "Rollout"
        	metadata: {
        		name:      context.name
        		namespace: context.namespace
        	}
        	spec: {
        		targetRevisionName: parameter.targetRevision
        		componentName:      context.name
        		rolloutPlan: {
        			rolloutStrategy: "IncreaseFirst"
        			if parameter.rolloutBatches != _|_ {
        				rolloutBatches: parameter.rolloutBatches
        			}
        			targetSize: parameter.targetSize
        			if parameter["batchPartition"] != _|_ {
        				batchPartition: parameter.batchPartition
        			}
        		}
        	}
        }
        parameter: {
        	targetRevision: *context.revision | string
        	targetSize:     int
        	rolloutBatches?: [...rolloutBatch]
        	batchPartition?: int
        }
        rolloutBatch: replicas: int
  status:
    customStatus: 'message: context.outputs.rollout.status.rollingState'
    healthPolicy: 'isHealth: context.outputs.rollout.status.batchRollingState == "batchReady"'

