Skip to content

Commit

Permalink
Merge pull request #4 from small-hack/make-origin-optional
Browse files Browse the repository at this point in the history
Make API Key origin optional when using existing Secret
  • Loading branch information
jessebot authored Nov 11, 2024
2 parents 31745c1 + 7e4a28b commit 1632af6
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 8 deletions.
2 changes: 1 addition & 1 deletion charts/libretranslate/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ sources:
- https://github.com/LibreTranslate/LibreTranslate/
- https://github.com/LibreTranslate/helm-chart/
icon: https://libretranslate.com/static/favicon.ico
version: 0.3.1
version: 0.4.0
9 changes: 9 additions & 0 deletions charts/libretranslate/templates/secret-api-key.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{{- if and .Values.appSettings.requireApiKeySecret (not .Values.appSettings.existingSecret) }}
apiVersion: v1
kind: Secret
metadata:
name: {{ include "libretranslate.fullname" . }}-api-key
type: Opaque
data:
requireApiKeySecret: {{ .Values.appSettings.requireApiKeySecret | quote }}
{{- end }}
File renamed without changes.
16 changes: 10 additions & 6 deletions charts/libretranslate/templates/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,12 @@ spec:
{{- toYaml .Values.podAnnotations | nindent 8 }}
{{- end }}
checksum/config: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }}
checksum/secret: {{ include (print $.Template.BasePath "/secret.yaml") . | sha256sum }}
{{- if and .Values.appSettings.requireApiKeySecret (not .Values.appSettings.existingSecret) }}
checksum/secret-api-key: {{ include (print $.Template.BasePath "/secret-api-key.yaml") . | sha256sum }}
{{- end }}
{{- if and .Values.adminUser.auth (not .Values.adminUser.existingSecret) }}
checksum/secret-auth: {{ include (print $.Template.BasePath "/secret-auth.yaml") . | sha256sum }}
{{- end }}
labels:
{{- include "libretranslate.selectorLabels" . | nindent 8 }}
spec:
Expand Down Expand Up @@ -110,7 +115,7 @@ spec:
name: libretranslate-appsettings
key: apiKeys
{{- end }}
{{- if or .Values.appSettings.requireApiKeyOrigin .Values.appSettings.existingSecret }}
{{- if or .Values.appSettings.requireApiKeyOrigin (and .Values.appSettings.existingSecret .Values.appSettings.secretKeys.apiKeyorigin) }}
- name: LT_REQUIRE_API_KEY_ORIGIN
valueFrom:
{{- if not .Values.appSettings.existingSecret }}
Expand All @@ -123,15 +128,14 @@ spec:
key: {{ .Values.appSettings.secretKeys.apiKeyorigin }}
{{- end }}
{{- end }}
{{- if and .Values.appSettings.requireApiKeySecret .Values.appSettings.existingSecret }}
{{- if or .Values.appSettings.requireApiKeySecret (and .Values.appSettings.existingSecret .Values.appSettings.secretKeys.apiKeysecret) }}
- name: LT_REQUIRE_API_KEY_SECRET
valueFrom:
secretKeyRef:
{{- if not .Values.appSettings.existingSecret }}
configMapKeyRef:
name: libretranslate-appsettings
name: {{ include "libretranslate.fullname" . }}-api-key
key: requireApiKeySecret
{{- else }}
secretKeyRef:
name: {{ .Values.appSettings.existingSecret }}
key: {{ .Values.appSettings.secretKeys.apiKeysecret }}
{{- end }}
Expand Down
2 changes: 1 addition & 1 deletion charts/libretranslate/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ appSettings:
existingSecret: "" # use an existing secret for api key origin and secret
# keys in existing secret
secretKeys:
apiKeyorigin: "origin"
apiKeyorigin: ""
apiKeysecret: "secret"


Expand Down

0 comments on commit 1632af6

Please sign in to comment.