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: configure datastore username and password separately #163

Closed
wants to merge 6 commits into from
Closed
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
15 changes: 2 additions & 13 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,12 @@ jobs:
- name: Configure Git
run: |
git config user.name github-actions
git config user.email [email protected]

- name: Import GPG key
uses: crazy-max/ghaction-import-gpg@v6
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.GPG_KEY_PASSPHRASE }}

- name: Export GPG key to legacy format
run: gpg --export-secret-keys > ~/.gnupg/pubring.gpg
git config user.email [email protected]

- name: Install Helm
uses: azure/setup-helm@v4
with:
version: v3.5.0
version: v3.16.2

- name: Add Helm Repositories
run: |
Expand All @@ -43,8 +34,6 @@ jobs:

- name: Run chart-releaser
uses: helm/[email protected]
with:
config: .github/cr.yaml
env:
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
CR_SKIP_EXISTING: true
38 changes: 38 additions & 0 deletions charts/openfga/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,41 @@ Return true if a secret object should be created
{{- true -}}
{{- end -}}
{{- end -}}


{{- define "openfga.datastore.envConfig" -}}
{{- if .Values.datastore.engine }}
- name: OPENFGA_DATASTORE_ENGINE
value: "{{ .Values.datastore.engine }}"
{{- end }}
{{- if .Values.datastore.externalSecret.uriSecretKey }}
- name: OPENFGA_DATASTORE_URI
valueFrom:
secretKeyRef:
name: "{{ .Values.datastore.externalSecret.name }}"
key: "{{ .Values.datastore.externalSecret.uriSecretKey }}"
{{- else if .Values.datastore.uri }}
- name: OPENFGA_DATASTORE_URI
value: "{{ .Values.datastore.uri }}"
{{- end }}
{{- if .Values.datastore.externalSecret.usernameSecretKey }}
- name: OPENFGA_DATASTORE_USERNAME
valueFrom:
secretKeyRef:
name: "{{ .Values.datastore.externalSecret.name }}"
key: "{{ .Values.datastore.externalSecret.usernameSecretKey }}"
{{- else if .Values.datastore.username }}
- name: OPENFGA_DATASTORE_USERNAME
value: "{{ .Values.datastore.username }}"
{{- end }}
{{- if .Values.datastore.externalSecret.passwordSecretKey }}
- name: OPENFGA_DATASTORE_PASSWORD
valueFrom:
secretKeyRef:
name: "{{ .Values.datastore.externalSecret.name }}"
key: "{{ .Values.datastore.externalSecret.passwordSecretKey }}"
{{- else if .Values.datastore.password }}
- name: OPENFGA_DATASTORE_PASSWORD
value: "{{ .Values.datastore.password }}"
{{- end }}
{{- end -}}
18 changes: 2 additions & 16 deletions charts/openfga/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ metadata:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- if not .Values.autoscaling.enabled }}
{{- if not .Values.autoscaling.enabled }}
replicas: {{ ternary 1 .Values.replicaCount (eq .Values.datastore.engine "memory")}}
{{- end }}
selector:
Expand Down Expand Up @@ -80,21 +80,7 @@ spec:
{{- end }}

env:
{{- if .Values.datastore.engine }}
- name: OPENFGA_DATASTORE_ENGINE
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.datastore.envConfig" . | nindent 12 }}

{{- if .Values.datastore.maxCacheSize }}
- name: OPENFGA_DATASTORE_MAX_CACHE_SIZE
Expand Down
16 changes: 1 addition & 15 deletions charts/openfga/templates/job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,21 +36,7 @@ spec:
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
args: ["migrate"]
env:
{{- if .Values.datastore.engine }}
- name: OPENFGA_DATASTORE_ENGINE
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.datastore.envConfig" . | nindent 12 }}

{{- if .Values.migrate.timeout }}
- name: OPENFGA_TIMEOUT
Expand Down
31 changes: 30 additions & 1 deletion charts/openfga/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,22 @@
"type": [
"string",
"null"
]
],
"description": "the URI of the datastore including credentials and database (e.g. postgres://user:password@host:port/dbname)"
},
"username": {
"type": [
"string",
"null"
],
"description": "the username to authenticate with the datastore"
},
"password": {
"type": [
"string",
"null"
],
"description": "the password to authenticate with the datastore"
},
"uriSecret": {
"type": [
Expand All @@ -280,6 +295,20 @@
],
"description": "the secret name where to get the datastore URI, it expects a key named uri to exist in the secret"
},
"usernameSecret": {
"type": [
"string",
"null"
],
"description": "the secret name where to get the datastore username, it expects a key named username to exist in the secret"
},
"passwordSecret": {
"type": [
"string",
"null"
],
"description": "the secret name where to get the datastore password, it expects a key named password to exist in the secret"
},
"maxCacheSize": {
"type": [
"integer",
Expand Down
8 changes: 7 additions & 1 deletion charts/openfga/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,13 @@ telemetry:
datastore:
engine: memory
uri:
uriSecret:
username:
password:
externalSecret:
name: ""
uriSecretKey: ""
usernameSecretKey: ""
passwordSecretKey: ""
maxCacheSize:
maxOpenConns:
maxIdleConns:
Expand Down