Skip to content

Commit

Permalink
feat: template uri secret
Browse files Browse the repository at this point in the history
  • Loading branch information
jagregory committed Sep 17, 2024
1 parent 88eaf10 commit 18428a3
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 21 deletions.
16 changes: 16 additions & 0 deletions charts/openfga/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,19 @@ Return true if a secret object should be created
{{- true -}}
{{- end -}}
{{- end -}}

{{/*
Generate an environment variable for the datastore URI
*/}}
{{- define "openfga.datastoreURIEnvVar" -}}
{{- if .Values.datastore.uri -}}
- name: OPENFGA_DATASTORE_URI
value: "{{ .Values.datastore.uri }}"
{{- else if .Values.datastore.uriSecret -}}
- name: OPENFGA_DATASTORE_URI
valueFrom:
secretKeyRef:
name: "{{ tpl .Values.datastore.uriSecret . }}"
key: "{{ tpl (.Values.datastore.uriSecretKey | default "uri") . }}"
{{- end -}}
{{- end -}}
11 changes: 1 addition & 10 deletions charts/openfga/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,7 @@ spec:
value: "{{ .Values.datastore.engine }}"
{{- end }}

{{- if .Values.datastore.uri }}
- name: OPENFGA_DATASTORE_URI
value: "{{ .Values.datastore.uri }}"
{{- else if .Values.datastore.uriSecret }}
- name: OPENFGA_DATASTORE_URI
valueFrom:
secretKeyRef:
name: "{{ .Values.datastore.uriSecret }}"
key: "uri"
{{- end }}
{{- include "openfga.datastoreURIEnvVar" . | nindent 12 }}

{{- if .Values.datastore.maxCacheSize }}
- name: OPENFGA_DATASTORE_MAX_CACHE_SIZE
Expand Down
11 changes: 1 addition & 10 deletions charts/openfga/templates/job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,7 @@ spec:
value: "{{ .Values.datastore.engine }}"
{{- end }}

{{- if .Values.datastore.uri }}
- name: OPENFGA_DATASTORE_URI
value: "{{ .Values.datastore.uri }}"
{{- else if .Values.datastore.uriSecret }}
- name: OPENFGA_DATASTORE_URI
valueFrom:
secretKeyRef:
name: "{{ .Values.datastore.uriSecret }}"
key: "uri"
{{- end }}
{{- include "openfga.datastoreURIEnvVar" . | nindent 12 }}

{{- if .Values.migrate.timeout }}
- name: OPENFGA_TIMEOUT
Expand Down
10 changes: 9 additions & 1 deletion charts/openfga/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,15 @@
"string",
"null"
],
"description": "the secret name where to get the datastore URI, it expects a key named uri to exist in the secret"
"description": "the secret name where to get the datastore URI, it expects the key in `uriSecretKey` to exist in the secret"
},
"uriSecretKey": {
"type": [
"string",
"null"
],
"default": "uri",
"description": "the key in the secret where to get the datastore URI, defaults to uri"
},
"maxCacheSize": {
"type": [
Expand Down
1 change: 1 addition & 0 deletions charts/openfga/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ datastore:
engine: memory
uri:
uriSecret:
uriSecretKey:
maxCacheSize:
maxOpenConns:
maxIdleConns:
Expand Down

0 comments on commit 18428a3

Please sign in to comment.