{{ $secret := (lookup "oauth.openshift.io/v1" "OAuthClient" .Release.Namespace "admin-console-client") }}
{{ $oauthclientSecret := randAlphaNum 16 }}

---
apiVersion: oauth.openshift.io/v1
grantMethod: auto
kind: OAuthClient
metadata:
  name: admin-console-client
redirectURIs:
  - {{ template "control-plane-console.url" . }}/auth/callback
  - http://localhost:8080/auth/callback
secret: {{ if .Values.oauthclientSecret }}{{ .Values.oauthclientSecret }}{{ else }}{{ if $secret }}{{ $secret.secret }}{{ else }}{{ $oauthclientSecret }}{{ end }}{{ end }}

---

kind: Secret
apiVersion: v1
metadata:
  name: {{ .Values.oauthclientName }}
data:
  clientId: YWRtaW4tY29uc29sZS1jbGllbnQ=
  secret: {{ if .Values.oauthclientSecret }}{{ b64enc .Values.oauthclientSecret }}{{ else }}{{ if $secret }}{{ b64enc $secret.secret }}{{ else }}{{ b64enc $oauthclientSecret }}{{ end }}{{ end }}
type: Opaque