Skip to content

Commit 7148c71

Browse files
committed
invenio: refactor datacite block
* Deprecates non-camelcase datacite variables. * Addresses secret handling as described in #117.
1 parent b45778d commit 7148c71

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: "{{ .Values.invenio.datacite.enabled }} "
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.datacire.secretKeys.usernameKey }}
388+
- name: INVENIO_DATACITE_PASSWORD
389+
valueFrom:
390+
secretKeyRef:
391+
name: {{ include "invenio.dataciteSecretName" . }}
392+
key: {{ .Values.invenio.datacire.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 (.Values.invenio.datacite.existingSecret or .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
@@ -46,18 +46,7 @@ spec:
4646
{{- toYaml . | nindent 8 }}
4747
{{- end }}
4848
{{- include "invenio.config.sentry" . | nindent 8 }}
49-
{{- if .Values.invenio.datacite.enabled }}
50-
- name: INVENIO_DATACITE_USERNAME
51-
valueFrom:
52-
secretKeyRef:
53-
name: {{ .Values.invenio.datacite.secret_name }}
54-
key: DATACITE_USERNAME
55-
- name: INVENIO_DATACITE_PASSWORD
56-
valueFrom:
57-
secretKeyRef:
58-
name: {{ .Values.invenio.datacite.secret_name }}
59-
key: DATACITE_PASSWORD
60-
{{- end }}
49+
{{- include "invenio.config.datacite" . | nindent 8 }}
6150
{{- if .Values.invenio.remote_apps.enabled }}
6251
{{- range .Values.invenio.remote_apps.credentials }}
6352
- 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
@@ -58,18 +58,7 @@ spec:
5858
{{- toYaml . | nindent 8 }}
5959
{{- end }}
6060
{{- include "invenio.config.sentry" . | nindent 8 }}
61-
{{- if .Values.invenio.datacite.enabled }}
62-
- name: INVENIO_DATACITE_USERNAME
63-
valueFrom:
64-
secretKeyRef:
65-
name: {{ .Values.invenio.datacite.secret_name }}
66-
key: DATACITE_USERNAME
67-
- name: INVENIO_DATACITE_PASSWORD
68-
valueFrom:
69-
secretKeyRef:
70-
name: {{ .Values.invenio.datacite.secret_name }}
71-
key: DATACITE_PASSWORD
72-
{{- end }}
61+
{{- include "invenio.config.datacite" . | nindent 8 }}
7362
{{- range .Values.invenio.extra_env_from_secret }}
7463
- name: {{ .name }}
7564
valueFrom:

charts/invenio/templates/worker-deployment.yaml

+1-12
Original file line numberDiff line numberDiff line change
@@ -49,18 +49,7 @@ spec:
4949
{{- toYaml . | nindent 10 }}
5050
{{- end }}
5151
{{- include "invenio.config.sentry" . | nindent 10 }}
52-
{{- if .Values.invenio.datacite.enabled }}
53-
- name: INVENIO_DATACITE_USERNAME
54-
valueFrom:
55-
secretKeyRef:
56-
name: {{ .Values.invenio.datacite.secret_name }}
57-
key: DATACITE_USERNAME
58-
- name: INVENIO_DATACITE_PASSWORD
59-
valueFrom:
60-
secretKeyRef:
61-
name: {{ .Values.invenio.datacite.secret_name }}
62-
key: DATACITE_PASSWORD
63-
{{- end }}
52+
{{- include "invenio.config.datacite" . | nindent 10 }}
6453
{{- if .Values.invenio.remote_apps.enabled }}
6554
{{- range .Values.invenio.remote_apps.credentials }}
6655
- 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)