Skip to content

Commit c49d980

Browse files
egabancholindhe
andauthored
invenio: refactor datacite block
* Deprecates non-camelcase datacite variables. * Addresses secret handling as described in #117. --------- Co-authored-by: Andreas Lindhé <[email protected]>
1 parent 9eab8d9 commit c49d980

File tree

7 files changed

+75
-40
lines changed

7 files changed

+75
-40
lines changed

charts/invenio/templates/NOTES.txt

+17
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,20 @@ DEPRECATION WARNING:
4444
`invenio.existingSecret` and it will be removed in a future release.
4545

4646
{{- end }}
47+
48+
{{- if .Values.invenio.datacite.existing_secret }}
49+
50+
DEPRECATION WARNING:
51+
`invenio.datacite.existing_secret` has been renamed to `invenio.datacite.existingSecret`
52+
and its type has changed from boolean to string.
53+
This key will be removed in a future release.
54+
55+
{{- end }}
56+
57+
{{- if .Values.invenio.datacite.secret_name }}
58+
59+
DEPRECATION WARNING:
60+
`invenio.datacite.secret_name` has been renamed in favor of
61+
`invenio.datacite.existingSecret` will be removed in a future release.
62+
63+
{{- end }}

charts/invenio/templates/_helpers.tpl

+32-1
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ INVENIO_SEARCH_HOSTS: {{ printf "[{'host': '%s'}]" (include "invenio.opensearch.
334334
INVENIO_SITE_HOSTNAME: '{{ include "invenio.hostname" $ }}'
335335
INVENIO_SITE_UI_URL: 'https://{{ include "invenio.hostname" $ }}'
336336
INVENIO_SITE_API_URL: 'https://{{ include "invenio.hostname" $ }}/api'
337-
INVENIO_DATACITE_ENABLED: "False"
337+
INVENIO_DATACITE_ENABLED: {{ ternary "True" "False" .Values.invenio.datacite.enabled | quote }}
338338
INVENIO_LOGGING_CONSOLE_LEVEL: "WARNING"
339339
{{- end -}}
340340

@@ -361,3 +361,34 @@ Get the invenio general secret name
361361
{{- include "invenio.fullname" . -}}
362362
{{- end -}}
363363
{{- end -}}
364+
365+
{{/*
366+
Get the sentry secret name
367+
*/}}
368+
{{- define "invenio.dataciteSecretName" -}}
369+
{{- if .Values.invenio.datacite.existingSecret -}}
370+
{{- print (tpl .Values.invenio.datacite.existingSecret .) -}}
371+
{{- else if .Values.invenio.datacite.secret_name -}}
372+
{{- print .Values.invenio.datacite.secret_name -}}
373+
{{- else -}}
374+
{{- printf "%s-%s" (include "invenio.fullname" .) "datacite" -}}
375+
{{- end -}}
376+
{{- end -}}
377+
378+
{{/*
379+
Add datacite environmental variables
380+
*/}}
381+
{{- define "invenio.config.datacite" -}}
382+
{{- if .Values.invenio.datacite.enabled }}
383+
- name: INVENIO_DATACITE_USERNAME
384+
valueFrom:
385+
secretKeyRef:
386+
name: {{ include "invenio.dataciteSecretName" . }}
387+
key: {{ .Values.invenio.datacite.secretKeys.usernameKey }}
388+
- name: INVENIO_DATACITE_PASSWORD
389+
valueFrom:
390+
secretKeyRef:
391+
name: {{ include "invenio.dataciteSecretName" . }}
392+
key: {{ .Values.invenio.datacite.secretKeys.passwordKey }}
393+
{{- end }}
394+
{{- end -}}

charts/invenio/templates/datacite-secret.yaml

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
1-
{{- if and (.Values.invenio.datacite.enabled) (not .Values.invenio.datacite.existing_secret)}}
1+
{{- if and (.Values.invenio.datacite.enabled) (not (or .Values.invenio.datacite.existingSecret .Values.invenio.datacite.existing_secret))}}
22
---
33
apiVersion: v1
44
kind: Secret
55
type: Opaque
66
metadata:
7-
name: datacite-secrets
7+
name: {{ include "invenio.dataciteSecretName" . }}
88
labels:
99
{{- include "invenio.labels" . | nindent 4 }}
10-
app: datacite-secrets
1110
annotations:
1211
helm.sh/resource-policy: keep
1312
data:

charts/invenio/templates/web-deployment.yaml

+1-12
Original file line numberDiff line numberDiff line change
@@ -60,18 +60,7 @@ spec:
6060
{{- toYaml . | nindent 8 }}
6161
{{- end }}
6262
{{- include "invenio.config.sentry" . | nindent 8 }}
63-
{{- if .Values.invenio.datacite.enabled }}
64-
- name: INVENIO_DATACITE_USERNAME
65-
valueFrom:
66-
secretKeyRef:
67-
name: {{ .Values.invenio.datacite.secret_name }}
68-
key: DATACITE_USERNAME
69-
- name: INVENIO_DATACITE_PASSWORD
70-
valueFrom:
71-
secretKeyRef:
72-
name: {{ .Values.invenio.datacite.secret_name }}
73-
key: DATACITE_PASSWORD
74-
{{- end }}
63+
{{- include "invenio.config.datacite" . | nindent 8 }}
7564
{{- if .Values.invenio.remote_apps.enabled }}
7665
{{- range .Values.invenio.remote_apps.credentials }}
7766
- name: {{ default (printf "INVENIO_%s_APP_CREDENTIALS" .name) }}

charts/invenio/templates/worker-beat-deployment.yaml

+1-12
Original file line numberDiff line numberDiff line change
@@ -72,18 +72,7 @@ spec:
7272
{{- toYaml . | nindent 8 }}
7373
{{- end }}
7474
{{- include "invenio.config.sentry" . | nindent 8 }}
75-
{{- if .Values.invenio.datacite.enabled }}
76-
- name: INVENIO_DATACITE_USERNAME
77-
valueFrom:
78-
secretKeyRef:
79-
name: {{ .Values.invenio.datacite.secret_name }}
80-
key: DATACITE_USERNAME
81-
- name: INVENIO_DATACITE_PASSWORD
82-
valueFrom:
83-
secretKeyRef:
84-
name: {{ .Values.invenio.datacite.secret_name }}
85-
key: DATACITE_PASSWORD
86-
{{- end }}
75+
{{- include "invenio.config.datacite" . | nindent 8 }}
8776
{{- range .Values.invenio.extra_env_from_secret }}
8877
- name: {{ .name }}
8978
valueFrom:

charts/invenio/templates/worker-deployment.yaml

+1-12
Original file line numberDiff line numberDiff line change
@@ -63,18 +63,7 @@ spec:
6363
{{- toYaml . | nindent 10 }}
6464
{{- end }}
6565
{{- include "invenio.config.sentry" . | nindent 10 }}
66-
{{- if .Values.invenio.datacite.enabled }}
67-
- name: INVENIO_DATACITE_USERNAME
68-
valueFrom:
69-
secretKeyRef:
70-
name: {{ .Values.invenio.datacite.secret_name }}
71-
key: DATACITE_USERNAME
72-
- name: INVENIO_DATACITE_PASSWORD
73-
valueFrom:
74-
secretKeyRef:
75-
name: {{ .Values.invenio.datacite.secret_name }}
76-
key: DATACITE_PASSWORD
77-
{{- end }}
66+
{{- include "invenio.config.datacite" . | nindent 10 }}
7867
{{- if .Values.invenio.remote_apps.enabled }}
7968
{{- range .Values.invenio.remote_apps.credentials }}
8069
- name: {{ default (printf "INVENIO_%s_APP_CREDENTIALS" .name) }}

charts/invenio/values.yaml

+21
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,29 @@ invenio:
6060
secretKeys:
6161
dsnKey: "SENTRY_DSN"
6262
datacite:
63+
## @param invenio.datacite.enabled Enable DataCite provider
64+
##
6365
enabled: false
66+
## @param invenio.datacite.username Datacite username
67+
##
68+
username: ""
69+
## @param invenio.datacite.password Datacite password
70+
##
71+
password: ""
72+
## @param invenio.datacite.existingSecret Existing secret name for datacite username and password
73+
##
74+
existingSecret: ""
75+
## @param invenio.datacite.secretKeys.usernameKey Name of key in existing secret to use for username. Only used when `invenio.datacite.existingSecret` is set.
76+
## @param invenio.datacite.secretKeys.passwordKey Name of key in existing secret to use for password. Only used when `invenio.datacite.existingSecret` is set.
77+
##
78+
secretKeys:
79+
usernameKey: "DATACITE_USERNAME"
80+
passwordKey: "DATACITE_PASSWORD"
81+
## @param invenio.datacite.existing_secret DEPRECATED: use invenio.datacite.existingSecret instead
82+
##
6483
existing_secret: false
84+
## @param invenio.datacite.secret_name DEPRECATED: use invenio.datacite.existingSecret instead
85+
##
6586
secret_name: "datacite-secrets"
6687
podSecurityContext:
6788
enabled: true

0 commit comments

Comments
 (0)