Skip to content

Commit

Permalink
fix: correctly check which keys to use
Browse files Browse the repository at this point in the history
  • Loading branch information
danielr1996 committed Jul 10, 2024
1 parent 8a0cd77 commit c77dd4e
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 23 deletions.
2 changes: 1 addition & 1 deletion charts/vaultwarden/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ maintainers:
- name: guerzon
email: [email protected]
url: https://github.com/guerzon
version: 0.24.1
version: 0.24.3
kubeVersion: ">=1.12.0-0"
28 changes: 15 additions & 13 deletions charts/vaultwarden/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -321,19 +321,21 @@ helm -n $NAMESPACE uninstall $RELEASE_NAME

### Database settings

| Name | Description | Value |
| ---------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- | --------- |
| `database.type` | Database type, either mysql or postgresql | `default` |
| `database.host` | Database hostname or IP address | `""` |
| `database.port` | Database port | `""` |
| `database.username` | Database username | `""` |
| `database.password` | Database password | `""` |
| `database.dbName` | Database name | `""` |
| `database.uriOverride` | Manually specify the DB connection string | `""` |
| `database.existingSecret` | Name of an existing secret containing the database URI | `""` |
| `database.existingSecretKey` | Key in the existing secret | `""` |
| `database.connectionRetries` | Number of times to retry the database connection during startup, with 1 second delay between each retry, set to 0 to retry indefinitely. | `15` |
| `database.maxConnections` | Define the size of the connection pool used for connecting to the database. | `10` |
| Name | Description | Value |
| ------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------- | ---------- |
| `database.type` | Database type, either mysql or postgresql | `default` |
| `database.host` | Database hostname or IP address | `""` |
| `database.port` | Database port | `""` |
| `database.username` | Database username | `""` |
| `database.password` | Database password | `""` |
| `database.dbName` | Database name | `""` |
| `database.uriOverride` | Manually specify the DB connection string | `""` |
| `database.existingSecret` | Name of an existing secret containing either a single key with the database uri, or a separate key for username and password | `""` |
| `database.existingSecretKey` | Key in the existing secret | `""` |
| `database.existingSecretUserKey` | Key in the existing secret | `username` |
| `database.existingSecretPasswordKey` | Key in the existing secret | `password` |
| `database.connectionRetries` | Number of times to retry the database connection during startup, with 1 second delay between each retry, set to 0 to retry indefinitely. | `15` |
| `database.maxConnections` | Define the size of the connection pool used for connecting to the database. | `10` |

### Push notifications

Expand Down
18 changes: 13 additions & 5 deletions charts/vaultwarden/templates/_podSpec.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -68,23 +68,31 @@ containers:
- name: DISABLE_ADMIN_TOKEN
value: "true"
{{- end }}
{{- if and ( eq .Values.database.type "postgresql") (not .Values.database.existingSecretKey)}}
{{- if and ( eq .Values.database.type "postgresql") .Values.database.existingSecret (not .Values.database.existingSecretKey)}}
- name: DATABASE_URL
value: "postgresql://{{ .Values.database.host }}"
- name: PGPORT
value: {{ .Values.database.port | quote }}
- name: PGDATABASE
value: {{ .Values.database.dbName | quote }}
- name: PGUSER
{{- if .Values.database.existingSecretUserKey}}
valueFrom:
secretKeyRef:
name: {{ .Values.database.existingSecret }}
key: {{ .Values.database.existingSecretUserKey }}
name: {{ .Values.database.existingSecret | quote }}
key: {{ .Values.database.existingSecretUserKey | quote }}
{{- else }}
value: {{ .Values.database.username | quote }}
{{- end }}
- name: PGPASSWORD
{{- if .Values.database.existingSecretPasswordKey}}
valueFrom:
secretKeyRef:
name: {{ .Values.database.existingSecret }}
key: {{ .Values.database.existingSecretPasswordKey }}
name: {{ .Values.database.existingSecret | quote }}
key: {{ .Values.database.existingSecretPasswordKey | quote }}
{{- else }}
value: {{ .Values.database.password }}
{{- end }}
{{- else if ne "default" .Values.database.type }}
- name: DATABASE_URL
{{- if .Values.database.existingSecret }}
Expand Down
10 changes: 6 additions & 4 deletions charts/vaultwarden/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -277,16 +277,18 @@ database:
## @param database.uriOverride Manually specify the DB connection string
##
uriOverride: ""
## @param database.existingSecret Name of an existing secret containing the database URI
## @param database.existingSecret Name of an existing secret containing either a single key with the database uri, or a separate key for username and password
##
existingSecret: ""
## @param database.existingSecretKey Key in the existing secret
##
existingSecretKey: null
existingSecretKey: ""
## @param database.existingSecretUserKey Key in the existing secret
##
existingSecretUserKey: username
## @param database.existingSecretPasswordKey Key in the existing secret
##
existingSecretPasswordKey: password
# existingSecretKey: uri

## @param database.connectionRetries Number of times to retry the database connection during startup, with 1 second delay between each retry, set to 0 to retry indefinitely.
##
connectionRetries: 15
Expand Down

0 comments on commit c77dd4e

Please sign in to comment.