add missing db-name

This commit is contained in:
jem 2021-09-14 19:38:57 +02:00
parent 60baab6a8c
commit d66189bd9f
6 changed files with 18 additions and 5 deletions

View file

@ -31,9 +31,12 @@
(throw (js/Error. "Undefined Resource!"))))) (throw (js/Error. "Undefined Resource!")))))
(defn generate-config [& args] (defn generate-config [& args]
(let [{:keys [postgres-size] (let [{:keys [postgres-size db-name]
:or {postgres-size :2gb}} args] :or {postgres-size :2gb
(yaml/from-string (yaml/load-resource (str "postgres/config-" (name postgres-size) ".yaml"))))) db-name "postgres"}} args]
(->
(yaml/from-string (yaml/load-resource (str "postgres/config-" (name postgres-size) ".yaml")))
(assoc-in [:data :postgres-db] db-name))))
(defn generate-deployment [] (defn generate-deployment []
(yaml/from-string (yaml/load-resource "postgres/deployment.yaml"))) (yaml/from-string (yaml/load-resource "postgres/deployment.yaml")))

View file

@ -5,6 +5,7 @@ metadata:
labels: labels:
app: postgres app: postgres
data: data:
postgres-db: postgres
postgresql.conf: | postgresql.conf: |
max_connections = 1000 max_connections = 1000
work_mem = 4MB work_mem = 4MB

View file

@ -5,6 +5,7 @@ metadata:
labels: labels:
app: postgres app: postgres
data: data:
postgres-db: postgres
postgresql.conf: | postgresql.conf: |
max_connections = 100 max_connections = 100
work_mem = 4MB work_mem = 4MB

View file

@ -5,6 +5,7 @@ metadata:
labels: labels:
app: postgres app: postgres
data: data:
postgres-db: postgres
postgresql.conf: | postgresql.conf: |
max_connections = 500 max_connections = 500
work_mem = 2MB work_mem = 2MB

View file

@ -5,6 +5,7 @@ metadata:
labels: labels:
app: postgres app: postgres
data: data:
postgres-db: postgres
postgresql.conf: | postgresql.conf: |
max_connections = 700 max_connections = 700
work_mem = 3MB work_mem = 3MB

View file

@ -5,12 +5,18 @@
[dda.c4k-common.postgres :as cut])) [dda.c4k-common.postgres :as cut]))
(deftest should-generate-config (deftest should-generate-config
(is (= {:postgresql.conf (is (= {:postgres-db "postgres"
:postgresql.conf
"max_connections = 100\nwork_mem = 4MB\nshared_buffers = 512MB\n"} "max_connections = 100\nwork_mem = 4MB\nshared_buffers = 512MB\n"}
(:data (cut/generate-config)))) (:data (cut/generate-config))))
(is (= {:postgresql.conf (is (= {:postgres-db "postgres"
:postgresql.conf
"max_connections = 700\nwork_mem = 3MB\nshared_buffers = 2048MB\n"} "max_connections = 700\nwork_mem = 3MB\nshared_buffers = 2048MB\n"}
(:data (cut/generate-config :postgres-size :8gb)))) (:data (cut/generate-config :postgres-size :8gb))))
(is (= {:postgres-db "test"
:postgresql.conf
"max_connections = 100\nwork_mem = 4MB\nshared_buffers = 512MB\n"}
(:data (cut/generate-config :db-name "test"))))
) )
(deftest should-generate-persistent-volume (deftest should-generate-persistent-volume