# Code generated by KubeVela templates. DO NOT EDIT. Please edit the original cue file.
# Definition source cue file: vela-templates/definitions/internal/resource.cue
apiVersion: core.oam.dev/v1beta1
kind: TraitDefinition
metadata:
  annotations:
    definition.oam.dev/description: Add resource requests and limits on K8s pod for your workload which follows the pod spec in path 'spec.template.'
  name: resource
  namespace: {{.Values.systemDefinitionNamespace}}
spec:
  appliesToWorkloads:
    - '*'
  podDisruptive: true
  schematic:
    cue:
      template: |
        patch: spec: template: spec: containers: [{
        	metadata: annotations: "customized-resource": "cpu:\(parameter.cpu) memory:\(parameter.memory)"
        	resources: {
        		requests: parameter
        		limits:   parameter
        	}
        }, ...]
        parameter: {
        	// +usage=Specify the amount of cpu to limit
        	cpu: *1 | number
        	// +usage=Specify the amount of memory to limit
        	memory: *"2048Mi" | =~"^([1-9][0-9]{0,63})(E|P|T|G|M|K|Ei|Pi|Ti|Gi|Mi|Ki)$"
        }

