{{/*
This template defines the main container for application specific
environment variables.

The application deployment object will consume this object as
a main container for providing environmental specifics configurations.

Ref: https://kubernetes.io/docs/tasks/inject-data-application/distribute-credentials-secure/#define-container-environment-variables-using-secret-data
*/}}
{{- if .Values.include }}
{{- if or .Values.envs .Values.additionalEnvs }}
{{/* Note: .Values.additionalEnvs overwrite values in .Values.envs */}}
{{- $envs := mergeOverwrite .Values.envs .Values.additionalEnvs -}}
apiVersion: v1
kind: Secret
type: Opaque
metadata:
  name: {{ include "lib.appName" . }}-envs
  namespace: {{ include "lib.namespace" . }}
  labels:
    app.kubernetes.io/component: {{ include "lib.componentName" . }}
    {{- include "lib.labels" . | nindent 4 }}
  annotations:
    {{- include "lib.annotations" . | indent 4 }}
data:
  {{- include "app.renderEnvVars" (dict "envs" $envs "context" $) }}
{{- end }}
{{- end }}
