apiVersion: v1
kind: Secret
metadata:
  name: {{ include "common.names.fullname" . }}-registration-token
  namespace: {{ include "names.namespace" . | quote }}
  labels: {{- include "common.labels.standard" . | nindent 4 }}
    {{- if .Values.commonLabels }}
    {{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
    {{- end }}
  {{- if .Values.commonAnnotations }}
  annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
  {{- end }}
type: Opaque
stringData:
  token: "{{ required "Use --set release.registrationToken=<value> to define the Digital.ai Release registration token" .Values.release.registrationToken }}"
---
apiVersion: v1
kind: Secret
metadata:
  name: {{ include "common.names.fullname" . }}-registry-mapping
  namespace: {{ include "names.namespace" . | quote }}
type: Opaque
data:
    registry-mapping.json: e30=
---
{{- if .Values.runner.truststore}}
apiVersion: v1
kind: Secret
metadata:
  name: {{ include "common.names.fullname" . }}-truststore
  namespace: {{ include "names.namespace" . | quote }}
  labels: {{- include "common.labels.standard" . | nindent 4 }}
    {{- if .Values.commonLabels }}
    {{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
    {{- end }}
  {{- if .Values.commonAnnotations }}
  annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
  {{- end }}
data:
  password: {{ .Values.runner.truststorePassword | b64enc | quote }}
  # support multiline base64 string
  truststore.p12: {{ .Values.runner.truststore | b64dec | b64enc | quote }}
{{- end }}
---
{{- if .Values.runner.restClientCA}}
apiVersion: v1
kind: Secret
metadata:
  name: {{ include "common.names.fullname" . }}-rest-client-ca
  namespace: {{ include "names.namespace" . | quote }}
  labels: {{- include "common.labels.standard" . | nindent 4 }}
    {{- if .Values.commonLabels }}
    {{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
    {{- end }}
  {{- if .Values.commonAnnotations }}
  annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
  {{- end }}
data:
  ca.pem: {{ .Values.runner.restClientCA | b64dec | b64enc | quote }}
{{- end }}
