{{- $release := .Release }}
{{- range $client := .Values.keycloak.clients }}
{{- if not $client.public }}
{{- $secret := (lookup "v1" "Secret" $release.Namespace $client.secretName) }}
---
apiVersion: v1
kind: Secret
metadata:
  name: {{ $client.secretName }}
  annotations:
    "helm.sh/resource-policy": keep
type: Opaque
  {{- if $secret }}
data:
  clientSecret: {{ $secret.data.clientSecret }}
  {{- else }}
stringData:
  {{- $clientSecret := uuidv4 | quote }}
  clientSecret: {{ $clientSecret }}
{{- end -}}
{{- end -}}
{{- end -}}
