# Code generated by KubeVela templates. DO NOT EDIT. Please edit the original cue file.
# Definition source cue file: vela-templates/definitions/internal/node-affinity.cue
apiVersion: core.oam.dev/v1beta1
kind: TraitDefinition
metadata:
  annotations:
    definition.oam.dev/description: affinity specify node affinity and toleration on K8s pod for your workload which follows the pod spec in path 'spec.template'.
  labels:
    custom.definition.oam.dev/ui-hidden: "true"
  name: node-affinity
  namespace: {{ include "systemDefinitionNamespace" . }}
spec:
  appliesToWorkloads:
    - '*'
  podDisruptive: true
  schematic:
    cue:
      template: |
        patch: spec: template: spec: {
        	if parameter.affinity != _|_ {
        		affinity: nodeAffinity: requiredDuringSchedulingIgnoredDuringExecution: nodeSelectorTerms: [{
        			matchExpressions: [
        				for k, v in parameter.affinity {
        					key:      k
        					operator: "In"
        					values:   v
        				},
        			]}]
        	}
        	if parameter.tolerations != _|_ {
        		tolerations: [
        			for k, v in parameter.tolerations {
        				effect:   "NoSchedule"
        				key:      k
        				operator: "Equal"
        				value:    v
        			}]
        	}
        }
        parameter: {
        	affinity?: [string]: [...string]
        	tolerations?: [string]: string
        }

