Skip to content

Commit

Permalink
fix(centralidp): fix seeding of extra service accounts (#209)
Browse files Browse the repository at this point in the history
  • Loading branch information
evegufy authored Oct 21, 2024
1 parent 89ac91c commit 225a37f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
2 changes: 2 additions & 0 deletions charts/centralidp/templates/job-seeding.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,8 @@ spec:
key: {{ .clientId }}
- name: "KEYCLOAKSEEDING__REALMS__0__USERS__{{ $index }}__USERNAME"
value: {{ printf "service-account-%s" .clientId | quote }}
- name: "KEYCLOAKSEEDING__REALMS__0__USERS__{{ $index }}__ATTRIBUTES__0__NAME"
value: "bpn"
- name: "KEYCLOAKSEEDING__REALMS__0__USERS__{{ $index }}__ATTRIBUTES__0__VALUES__0"
value: {{ .bpn | quote }}
{{- $index = add1 $index }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* SPDX-License-Identifier: Apache-2.0
*/}}

{{- if and (.Values.realmSeeding.enabled) (.Values.realmSeeding.extraServiceAccounts.clientSecrets) (not .Values.realmSeeding.extraServiceAccounts.existingSecret) -}}
{{- if and (.Values.realmSeeding.enabled) (.Values.realmSeeding.extraServiceAccounts.clientSecretsAndBpn) (not .Values.realmSeeding.extraServiceAccounts.existingSecret) -}}
{{- $secretName := include "centralidp.secret.extraServiceAccounts" . -}}
apiVersion: v1
kind: Secret
Expand All @@ -31,13 +31,13 @@ data:
# if secret exists, use value provided from values file (to cover update scenario) or existing value from secret or generate a random one (if keys are added later on)
# use data map instead of stringData to prevent base64 encoding of already base64-encoded existing value from secret
# use index function for secret keys with hyphen otherwise '$secret.data.secretKey' works too
{{- range .Values.realmSeeding.extraServiceAccounts.clientSecrets }}
{{- range .Values.realmSeeding.extraServiceAccounts.clientSecretsAndBpn }}
{{ .clientId }}: {{ coalesce ( .clientSecret | b64enc ) ( index $secret.data .clientId ) | default ( randAlphaNum 32 ) | quote }}
{{- end }}
{{ else -}}
stringData:
# if secret doesn't exist, use provided value from values file or generate a random one
{{- range .Values.realmSeeding.extraServiceAccounts.clientSecrets }}
{{- range .Values.realmSeeding.extraServiceAccounts.clientSecretsAndBpn }}
{{ .clientId }}: {{ .clientSecret | default ( randAlphaNum 32 ) | quote }}
{{- end }}
{{ end }}
Expand Down
8 changes: 4 additions & 4 deletions charts/centralidp/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -221,12 +221,12 @@ realmSeeding:
# meant to enable possible test data, default value for client secrets is autogenerated.
extraServiceAccounts:
clientSecretsAndBpn: []
# - clientId: "sa-test-01"
# - clientId: sa-test-01
# clientSecret: ""
# bpn: "TBD1"
# - clientId: "sa-test-02"
# bpn: TBD1
# - clientId: sa-test-02
# clientSecret: ""
# bpn: "TBD2"
# bpn: TBD2
# -- Option to provide an existingSecret for additional service accounts with clientId as key and clientSecret as value.
existingSecret: ""
image:
Expand Down

0 comments on commit 225a37f

Please sign in to comment.