Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: template datastore uri secret #158

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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