diff --git a/charts/spire/charts/spire-server/README.md b/charts/spire/charts/spire-server/README.md index 4294866..cb59246 100644 --- a/charts/spire/charts/spire-server/README.md +++ b/charts/spire/charts/spire-server/README.md @@ -131,7 +131,8 @@ In order to run Tornjak with simple HTTP Connection only, make sure you don't cr | `dataStore.sql.port` | If 0 (default), it will auto set to 5432 for postgres and 3306 for mysql. Only used by those databases. | `0` | | `dataStore.sql.username` | Only used when type != "sqlite3" | `spire` | | `dataStore.sql.password` | Only used when type != "sqlite3" | `""` | -| `dataStore.sql.options` | Only used when type != "sqlite3" | `[]` | +| `dataStore.sql.file` | Data source file. Only used when type == "sqlite3" | `/run/spire/data/datastore.sqlite3` | +| `dataStore.sql.options` | takes an array of objects of form {: } to use when building the database connection string | `[]` | | `dataStore.sql.rootCAPath` | Path to Root CA bundle (MySQL only) | `""` | | `dataStore.sql.clientCertPath` | Path to client certificate (MySQL only) | `""` | | `dataStore.sql.clientKeyPath` | Path to private key for client certificate (MySQL only) | `""` | diff --git a/charts/spire/charts/spire-server/templates/_helpers.tpl b/charts/spire/charts/spire-server/templates/_helpers.tpl index 58a392e..49c8e6e 100644 --- a/charts/spire/charts/spire-server/templates/_helpers.tpl +++ b/charts/spire/charts/spire-server/templates/_helpers.tpl @@ -161,6 +161,20 @@ Create the name of the service account to use {{- end }} {{- end }} +{{- define "spire-server.config-sqlite-query" }} +{{- $lst := list }} +{{- range . }} +{{- range $key, $value := . }} +{{- $eValue := toString $value }} +{{- $entry := printf "%s=%s" (urlquery $key) (urlquery $eValue) }} +{{- $lst = append $lst $entry }} +{{- end }} +{{- end }} +{{- if gt (len $lst) 0 }} +{{- printf "?%s" (join "&" (uniq $lst)) }} +{{- end }} +{{- end }} + {{- define "spire-server.config-mysql-query" }} {{- $lst := list }} {{- range . }} @@ -194,7 +208,8 @@ Create the name of the service account to use {{- $ropw := "" }} {{- if eq .Values.dataStore.sql.databaseType "sqlite3" }} {{- $_ := set $config "database_type" "sqlite3" }} - {{- $_ := set $config "connection_string" "/run/spire/data/datastore.sqlite3" }} + {{- $query := include "spire-server.config-sqlite-query" .Values.dataStore.sql.options }} + {{- $_ := set $config "connection_string" (printf "%s%s" .Values.dataStore.sql.file $query) }} {{- else if or (eq .Values.dataStore.sql.databaseType "mysql") (eq .Values.dataStore.sql.databaseType "aws_mysql") }} {{- if eq .Values.dataStore.sql.databaseType "mysql" }} {{- $_ := set $config "database_type" "mysql" }} diff --git a/charts/spire/charts/spire-server/values.yaml b/charts/spire/charts/spire-server/values.yaml index c113754..69bb392 100644 --- a/charts/spire/charts/spire-server/values.yaml +++ b/charts/spire/charts/spire-server/values.yaml @@ -167,7 +167,9 @@ dataStore: username: spire ## @param dataStore.sql.password Only used when type != "sqlite3" password: "" - ## @param dataStore.sql.options [array] Only used when type != "sqlite3" + ## @param dataStore.sql.file Data source file. Only used when type == "sqlite3" + file: "/run/spire/data/datastore.sqlite3" + ## @param dataStore.sql.options [array] takes an array of objects of form {: } to use when building the database connection string options: [] ## @param dataStore.sql.rootCAPath Path to Root CA bundle (MySQL only)