Skip to content

Commit

Permalink
invenio: refactor sentry block
Browse files Browse the repository at this point in the history
* Deprecates non-camelcase sentry variables.

* Addresses secret handling as described in inveniosoftware#117.
  • Loading branch information
egabancho committed Dec 16, 2024
1 parent f490f4f commit bf38b3f
Show file tree
Hide file tree
Showing 8 changed files with 69 additions and 27 deletions.
17 changes: 17 additions & 0 deletions charts/invenio/templates/NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,20 @@ DEPRECATION WARNING:
removed in a future release.

{{- end }}

{{- if .Values.invenio.sentry.existing_secret}}

DEPRECATION WARNING:
`invenio.sentry.existing_secret` has been renamed to `invenio.sentry.existingSecret`
and its type has changed from boolean to string.
This key will be removed in a future release.

{{- end }}

{{- if .Values.invenio.sentry.secret_name}}

DEPRECATION WARNING:
`invenio.sentry.secret_name` has been removed in favor of
`invenio.sentry.existingSecret` will be removed in a future release.

{{- end }}
26 changes: 26 additions & 0 deletions charts/invenio/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -273,3 +273,29 @@ app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- $databaseName := include "invenio.postgresql.databaseName" . -}}
{{- printf "postgresql+psycopg2://%s:%s@%s:%v/%s" $username $password $hostname $port $databaseName -}}
{{- end -}}
{{/*
Get the sentry secret name
*/}}
{{- define "invenio.sentrySecretName" -}}
{{- if .Values.invenio.sentry.existingSecret -}}
{{- print (tpl .Values.invenio.sentry.existingSecret .) -}}
{{- else if .Values.invenio.sentry.secret_name -}}
{{- print (tpl .Values.invenio.sentry.secret_name .) -}}
{{- else -}}
{{- "sentry-secrets" -}}
{{- end -}}
{{- end -}}
{{/*
Add sentry environmental variables
*/}}
{{- define "invenio.config.sentry" -}}
{{- if .Values.invenio.sentry.enabled -}}
- name: INVENIO_SENTRY_DSN
valueFrom:
secretKeyRef:
name: {{ include "invenio.sentrySecretName" . }}
key: {{ .Values.invenio.sentry.secretKeys.dsnKey }}
{{- end }}
{{- end -}}
1 change: 1 addition & 0 deletions charts/invenio/templates/install-init-job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ spec:
secretKeyRef:
name: invenio-secrets
key: INVENIO_CSRF_SECRET_SALT
{{- include "invenio.config.sentry" . | nindent 8 }}
{{- if .Values.web.resources }}
resources: {{- toYaml .Values.web.resources | nindent 10 }}
{{- end }}
Expand Down
9 changes: 5 additions & 4 deletions charts/invenio/templates/sentry-secret.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
{{- if and (.Values.invenio.sentry.enabled) (not .Values.invenio.sentry.existing_secret) }}
{{- if and (.Values.invenio.sentry.enabled) (and (not .Values.invenio.sentry.existingSecret) (not .Values.invenio.sentry.existing_secret))}}
{{- $dsn := .Values.invenio.sentry.dsn | required ".Values.invenio.sentry.dns is required if not secret is provided." -}}
---
apiVersion: v1
kind: Secret
type: Opaque
metadata:
name: {{ .Values.invenio.sentry.secret_name }}
name: sentry-secrets
labels:
{{- include "invenio.labels" . | nindent 4 }}
app: {{ .Values.invenio.sentry.secret_name }}
app: sentry-secrets
annotations:
helm.sh/resource-policy: keep
data:
SENTRY_DSN: {{ .Values.invenio.sentry.dsn | b64enc }}
{{ .Values.invenio.sentry.secretKeys.dsnKey }}: {{ $dsn | b64enc }}
{{- end -}}
8 changes: 1 addition & 7 deletions charts/invenio/templates/web-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,7 @@ spec:
secretKeyRef:
name: invenio-secrets
key: INVENIO_CSRF_SECRET_SALT
{{- if .Values.invenio.sentry.enabled }}
- name: INVENIO_SENTRY_DSN
valueFrom:
secretKeyRef:
name: {{ .Values.invenio.sentry.secret_name }}
key: SENTRY_DSN
{{- end }}
{{- include "invenio.config.sentry" . | nindent 8 }}
{{- if .Values.invenio.datacite.enabled }}
- name: INVENIO_DATACITE_USERNAME
valueFrom:
Expand Down
8 changes: 1 addition & 7 deletions charts/invenio/templates/worker-beat-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,7 @@ spec:
secretKeyRef:
name: invenio-secrets
key: INVENIO_CSRF_SECRET_SALT
{{- if .Values.invenio.sentry.enabled }}
- name: INVENIO_SENTRY_DSN
valueFrom:
secretKeyRef:
name: {{ .Values.invenio.sentry.secret_name }}
key: SENTRY_DSN
{{- end }}
{{- include "invenio.config.sentry" . | nindent 8 }}
{{- if .Values.invenio.datacite.enabled }}
- name: INVENIO_DATACITE_USERNAME
valueFrom:
Expand Down
8 changes: 1 addition & 7 deletions charts/invenio/templates/worker-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,7 @@ spec:
secretKeyRef:
name: invenio-secrets
key: INVENIO_CSRF_SECRET_SALT
{{- if .Values.invenio.sentry.enabled }}
- name: INVENIO_SENTRY_DSN
valueFrom:
secretKeyRef:
name: {{ .Values.invenio.sentry.secret_name }}
key: SENTRY_DSN
{{- end }}
{{- include "invenio.config.sentry" . | nindent 10 }}
{{- if .Values.invenio.datacite.enabled }}
- name: INVENIO_DATACITE_USERNAME
valueFrom:
Expand Down
19 changes: 17 additions & 2 deletions charts/invenio/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,25 @@ invenio:
default_users: [] # Requires invenio.init=true
demo_data: false # Setting invenio.demo_data=true requires also setting default_users!
sentry:
## @param invenio.sentry.enabled Enable Sentry.io integration
##
enabled: false
existing_secret: false
secret_name: "sentry-secrets"
## @param invenio.sentry.dns Sentry DSN, required if not secret is provided
##
dsn: ""
## @param invenio.sentry.secret_name DEPRECATED: invenio.sentry.existingSecret instead
##
secret_name: "sentry-secrets"
## @param invenio.sentry.existing_secret DEPRECATED: invenio.sentry.existingSecret instead
##
existing_secret: false
## @param invenio.sentry.existingSecret Existing secret name for sentry's dsn
##
existingSecret: ""
## @param invenio.sentry.secretKeys.dsnKey Name of key in existing secret to use for dns. Only used when `invenio.sentry.existingSecret` is set.
##
secretKeys:
dsnKey: "SENTRY_DSN"
datacite:
enabled: false
existing_secret: false
Expand Down

0 comments on commit bf38b3f

Please sign in to comment.