diff --git a/src/main/cljc/dda/c4k_common/postgres.cljc b/src/main/cljc/dda/c4k_common/postgres.cljc index c7e2667..0dcfb7f 100644 --- a/src/main/cljc/dda/c4k_common/postgres.cljc +++ b/src/main/cljc/dda/c4k_common/postgres.cljc @@ -31,9 +31,12 @@ (throw (js/Error. "Undefined Resource!"))))) (defn generate-config [& args] - (let [{:keys [postgres-size] - :or {postgres-size :2gb}} args] - (yaml/from-string (yaml/load-resource (str "postgres/config-" (name postgres-size) ".yaml"))))) + (let [{:keys [postgres-size db-name] + :or {postgres-size :2gb + 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 [] (yaml/from-string (yaml/load-resource "postgres/deployment.yaml"))) diff --git a/src/main/resources/postgres/config-16gb.yaml b/src/main/resources/postgres/config-16gb.yaml index 30605aa..f7551a6 100644 --- a/src/main/resources/postgres/config-16gb.yaml +++ b/src/main/resources/postgres/config-16gb.yaml @@ -5,6 +5,7 @@ metadata: labels: app: postgres data: + postgres-db: postgres postgresql.conf: | max_connections = 1000 work_mem = 4MB diff --git a/src/main/resources/postgres/config-2gb.yaml b/src/main/resources/postgres/config-2gb.yaml index 751af1e..0a3a695 100644 --- a/src/main/resources/postgres/config-2gb.yaml +++ b/src/main/resources/postgres/config-2gb.yaml @@ -5,6 +5,7 @@ metadata: labels: app: postgres data: + postgres-db: postgres postgresql.conf: | max_connections = 100 work_mem = 4MB diff --git a/src/main/resources/postgres/config-4gb.yaml b/src/main/resources/postgres/config-4gb.yaml index 27211c0..5acba2a 100644 --- a/src/main/resources/postgres/config-4gb.yaml +++ b/src/main/resources/postgres/config-4gb.yaml @@ -5,6 +5,7 @@ metadata: labels: app: postgres data: + postgres-db: postgres postgresql.conf: | max_connections = 500 work_mem = 2MB diff --git a/src/main/resources/postgres/config-8gb.yaml b/src/main/resources/postgres/config-8gb.yaml index 43314ad..07e3c06 100644 --- a/src/main/resources/postgres/config-8gb.yaml +++ b/src/main/resources/postgres/config-8gb.yaml @@ -5,6 +5,7 @@ metadata: labels: app: postgres data: + postgres-db: postgres postgresql.conf: | max_connections = 700 work_mem = 3MB diff --git a/src/test/cljc/dda/c4k_common/postgres_test.cljc b/src/test/cljc/dda/c4k_common/postgres_test.cljc index 38a5bb8..9bf29ec 100644 --- a/src/test/cljc/dda/c4k_common/postgres_test.cljc +++ b/src/test/cljc/dda/c4k_common/postgres_test.cljc @@ -5,12 +5,18 @@ [dda.c4k-common.postgres :as cut])) (deftest should-generate-config - (is (= {:postgresql.conf + (is (= {:postgres-db "postgres" + :postgresql.conf "max_connections = 100\nwork_mem = 4MB\nshared_buffers = 512MB\n"} (:data (cut/generate-config)))) - (is (= {:postgresql.conf + (is (= {:postgres-db "postgres" + :postgresql.conf "max_connections = 700\nwork_mem = 3MB\nshared_buffers = 2048MB\n"} (: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