{{- if .Values.notary.enabled }}
apiVersion: v1
kind: Secret
metadata:
  name: {{ include "harbor.notary-server" . }}
  labels: {{- include "common.labels.standard" . | nindent 4 }}
    {{- if .Values.commonLabels }}
    {{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
    {{- end }}
    app.kubernetes.io/component: notary
  {{- if .Values.commonAnnotations }}
  annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
  {{- end }}
type: Opaque
data:
  {{- if not .Values.notary.secretName }}
  {{ $ca := genCA "harbor-notary-ca" 365 }}
  {{ $cert := genSignedCert (include "harbor.notary-signer" .) nil nil 365 $ca }}
  notary-signer-ca.crt: {{ $ca.Cert | b64enc | quote }}
  notary-signer.crt: {{ $cert.Cert | b64enc | quote }}
  notary-signer.key: {{ $cert.Key | b64enc | quote }}
  {{- end }}
  server-config.postgres.json: {{ tpl (.Files.Get "conf/notary-server.json") . | b64enc }}
  signer-config.postgres.json: {{ tpl (.Files.Get "conf/notary-signer.json") . | b64enc }}
{{- end }}
