Skip to content

fixing bug in the s3 existing secret logic #198

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions charts/openproject/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,10 @@ securityContext:
- secretRef:
name: {{ include "common.names.fullname" . }}-s3
{{- end }}
{{- if .Values.s3.auth.existingSecret }}
- secretRef:
name: {{ .Values.s3.auth.existingSecret }}
{{- end }}
{{- if eq .Values.openproject.cache.store "memcache" }}
- secretRef:
name: {{ include "common.names.fullname" . }}-memcached
Expand Down
13 changes: 5 additions & 8 deletions charts/openproject/templates/secret_s3.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,11 @@ data: # reset data to make sure only keys defined below remain
stringData:
OPENPROJECT_ATTACHMENTS__STORAGE: fog
OPENPROJECT_FOG_CREDENTIALS_PROVIDER: AWS
{{/* Fall back to '_' as secret name if the name is not given. This way `lookup` will return null (since secrets with this name will and cannot exist) which it doesn't with an empty string. */}}
{{ $secret := (lookup "v1" "Secret" .Release.Namespace (default "_" .Values.s3.auth.existingSecret)) | default (dict "data" dict) -}}
OPENPROJECT_FOG_CREDENTIALS_AWS__ACCESS__KEY__ID: {{
default .Values.s3.auth.accessKeyId (get $secret.data .Values.s3.auth.secretKeys.accessKeyId | b64dec) | quote
}}
OPENPROJECT_FOG_CREDENTIALS_AWS__SECRET__ACCESS__KEY: {{
default .Values.s3.auth.secretAccessKey (get $secret.data .Values.s3.auth.secretKeys.secretAccessKey | b64dec) | quote
}}
{{- if not .Values.s3.auth.existingSecret }}
OPENPROJECT_FOG_CREDENTIALS_AWS__ACCESS__KEY__ID: {{ .Values.s3.auth.accessKeyId }}
OPENPROJECT_FOG_CREDENTIALS_AWS__SECRET__ACCESS__KEY: {{ .Values.s3.auth.secretAccessKey }}
{{- end }}

{{ if .Values.s3.endpoint -}}
OPENPROJECT_FOG_CREDENTIALS_ENDPOINT: {{ .Values.s3.endpoint }}
{{- end }}
Expand Down
11 changes: 6 additions & 5 deletions charts/openproject/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -468,12 +468,13 @@ s3:
## To avoid having sensitive credentials in your values.yaml, the preferred way is to
## use an existing secret containing the S3 compatible access credentials.
## Specify the name of this existing secret here.
existingSecret:

## In case your secret does not use the default keys in the secret, you can adjust them here.
secretKeys:
accessKeyId: "accessKeyId"
secretAccessKey: "secretAccessKey"
# if using an existing secret, use the following keys for your access key and secret.
# OPENPROJECT_FOG_CREDENTIALS_AWS__ACCESS__KEY__ID
# OPENPROJECT_FOG_CREDENTIALS_AWS__SECRET__ACCESS__KEY

# note there are double underscores on these keys
existingSecret:

region:
bucketName:
Expand Down