Skip to content

Commit

Permalink
feat: allow pulling ebean username from secrets alongside password (#291
Browse files Browse the repository at this point in the history
)
  • Loading branch information
maxpospischil authored Jun 8, 2023
1 parent 07e205e commit 6c72601
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 3 deletions.
4 changes: 4 additions & 0 deletions charts/datahub/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ helm install datahub datahub/datahub --values <<path-to-values-file>>
| global.sql.datasource.port | string | `"3306"` | SQL database port |
| global.sql.datasource.url | string | `"jdbc:mysql://prerequisites-mysql:3306/datahub?verifyServerCertificate=false\u0026useSSL=true"` | URL to access SQL database |
| global.sql.datasource.username | string | `"root"` | SQL user name |
| global.sql.datasource.username.secretRef | string | `"mysql-secrets"` | Secret that contains the MySQL username |
| global.sql.datasource.username.secretKey | string | `"mysql-username"` | Secret key that contains the MySQL username |
| global.sql.datasource.password.secretRef | string | `"mysql-secrets"` | Secret that contains the MySQL password |
| global.sql.datasource.password.secretKey | string | `"mysql-password"` | Secret key that contains the MySQL password |
| global.sql.datasource.password.value | string | `"mysql-password"` | Alternative to using the secret above, uses raw string value instead |
Expand All @@ -119,6 +121,8 @@ helm install datahub datahub/datahub --values <<path-to-values-file>>
| Key | Type | Default | Description |
|-----|------|---------|-------------|
| datahub-gms.sql.datasource.username | string | `root` | SQL username for GMS (overrides global value) |
| datahub-gms.sql.datasource.username.secretRef | string | `"mysql-secrets"` | Secret that contains the GMS SQL username (overrides global value) |
| datahub-gms.sql.datasource.username.secretKey | string | `"mysql-username"` | Secret key that contains the GMS SQL username (overrides global value) |
| datahub-gms.sql.datasource.password.secretRef | string | `"mysql-secrets"` | Secret that contains the GMS SQL password (overrides global value) |
| datahub-gms.sql.datasource.password.secretKey | string | `"mysql-password"` | Secret key that contains the GMS SQL password (overrides global value) |
| datahub-gms.sql.datasource.password.value | string | `"mysql-password"` | Alternative to using the secret above, uses raw string value for GMS SQL login (overrides global value) |
Expand Down
10 changes: 9 additions & 1 deletion charts/datahub/subcharts/datahub-gms/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,15 @@ spec:
- name: DATAHUB_ANALYTICS_ENABLED
value: "{{ .Values.global.datahub_analytics_enabled }}"
- name: EBEAN_DATASOURCE_USERNAME
value: {{ (.Values.sql).datasource.username | default .Values.global.sql.datasource.username | quote }}
{{- $usernameValue := (.Values.sql).datasource.username | default .Values.global.sql.datasource.username }}
{{- if and (kindIs "string" $usernameValue) $usernameValue }}
value: {{ $usernameValue | quote }}
{{- else }}
valueFrom:
secretKeyRef:
name: "{{ (.Values.sql).datasource.username.secretRef | default .Values.global.sql.datasource.username.secretRef }}"
key: "{{ (.Values.sql).datasource.username.secretKey | default .Values.global.sql.datasource.username.secretKey }}"
{{- end }}
- name: EBEAN_DATASOURCE_PASSWORD
{{- $passwordValue := (.Values.sql).datasource.password.value | default .Values.global.sql.datasource.password.value }}
{{- if $passwordValue }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,15 @@ spec:
- name: ENTITY_REGISTRY_CONFIG_PATH
value: /datahub/datahub-mce-consumer/resources/entity-registry.yml
- name: EBEAN_DATASOURCE_USERNAME
value: {{ (.Values.sql).datasource.username | default .Values.global.sql.datasource.username | quote }}
{{- $usernameValue := (.Values.sql).datasource.username | default .Values.global.sql.datasource.username }}
{{- if and (kindIs "string" $usernameValue) $usernameValue }}
value: {{ $usernameValue | quote }}
{{- else }}
valueFrom:
secretKeyRef:
name: "{{ (.Values.sql).datasource.username.secretRef | default .Values.global.sql.datasource.username.secretRef }}"
key: "{{ (.Values.sql).datasource.username.secretKey | default .Values.global.sql.datasource.username.secretKey }}"
{{- end }}
- name: EBEAN_DATASOURCE_PASSWORD
{{- $passwordValue := (.Values.sql).datasource.password.value | default .Values.global.sql.datasource.password.value }}
{{- if $passwordValue }}
Expand Down
10 changes: 9 additions & 1 deletion charts/datahub/templates/datahub-upgrade/_upgrade.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,15 @@ Return the env variables for upgrade jobs
- name: DATAHUB_MAE_CONSUMER_PORT
value: "{{ .Values.global.datahub.mae_consumer.port }}"
- name: EBEAN_DATASOURCE_USERNAME
value: {{ (.Values.sql).datasource.username | default .Values.global.sql.datasource.username | quote }}
{{- $usernameValue := (.Values.sql).datasource.username | default .Values.global.sql.datasource.username }}
{{- if and (kindIs "string" $usernameValue) $usernameValue }}
value: {{ $usernameValue | quote }}
{{- else }}
valueFrom:
secretKeyRef:
name: "{{ (.Values.sql).datasource.username.secretRef | default .Values.global.sql.datasource.username.secretRef }}"
key: "{{ (.Values.sql).datasource.username.secretKey | default .Values.global.sql.datasource.username.secretKey }}"
{{- end }}
- name: EBEAN_DATASOURCE_PASSWORD
{{- $passwordValue := (.Values.sql).datasource.password.value | default .Values.global.sql.datasource.password.value }}
{{- if $passwordValue }}
Expand Down

0 comments on commit 6c72601

Please sign in to comment.