{{- if and .Values.config.tlsserver.serverkey .Values.config.tlsserver.servercrt .Values.config.tlsserver.cacrt }}
apiVersion: v1
kind: Secret
metadata:
  name: {{ include "falcosidekick.fullname" . }}-certs
  namespace: {{ .Release.Namespace }}
  labels:
    {{- include "falcosidekick.labels" . | nindent 4 }}
    app.kubernetes.io/component: core
type: Opaque
data:
  {{ $key := .Values.config.tlsserver.serverkey }}
  server.key: {{ $key | b64enc | quote }}
  {{ $crt := .Values.config.tlsserver.servercrt }}
  server.crt: {{ $crt | b64enc | quote }}
  falcosidekick.pem: {{ print $key $crt | b64enc | quote }}
  ca.crt: {{ .Values.config.tlsserver.cacrt | b64enc | quote }}
  ca.pem: {{ .Values.config.tlsserver.cacrt | b64enc | quote }}
{{- end }}