# Code generated by KubeVela templates. DO NOT EDIT. Please edit the original cue file.
# Definition source cue file: vela-templates/definitions/internal/service-binding.cue
apiVersion: core.oam.dev/v1beta1
kind: TraitDefinition
metadata:
  annotations:
    definition.oam.dev/description: Binding secrets of cloud resources to component env. This definition is DEPRECATED, please use 'storage' instead.
  labels:
    custom.definition.oam.dev/ui-hidden: "true"
  name: service-binding
  namespace: {{ include "systemDefinitionNamespace" . }}
spec:
  appliesToWorkloads:
    - '*'
  schematic:
    cue:
      template: |
        patch: spec: template: spec: {
        	// +patchKey=name
        	containers: [{
        		name: context.name
        		// +patchKey=name
        		env: [
        			for envName, v in parameter.envMappings {
        				name: envName
        				valueFrom: secretKeyRef: {
        					name: v.secret
        					if v["key"] != _|_ {
        						key: v.key
        					}
        					if v["key"] == _|_ {
        						key: envName
        					}
        				}
        			},
        		]
        	}]
        }
        parameter: {
        	// +usage=The mapping of environment variables to secret
        	envMappings: [string]: #KeySecret
        }
        #KeySecret: {
        	key?:   string
        	secret: string
        }

