From c23993426a963ec8871a63a8617b9ec8a709965b Mon Sep 17 00:00:00 2001 From: jem Date: Wed, 8 Sep 2021 13:03:43 +0200 Subject: [PATCH 1/9] add refactoring overview --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index a0a2952..07cb83e 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,14 @@ Our convention 4 kubernetes c4k-* tools combine the advantages of both approache ## Usage +## Refactoring & Module Overview + +| Module | Version | common postgres | frontend script | provider adapter | +| c4k-mastodon-bot | 0.1 | - | | | +| c4k-keycloak | 0.2 | | | | +| c4k-jira | 1.0 | x | x | | +| c4k-nextcloud | 0.1 | | | | + ## License Copyright © 2021 meissa GmbH From 30e61392f7dba18e52e05cc57dc30f6155184913 Mon Sep 17 00:00:00 2001 From: jem Date: Wed, 8 Sep 2021 13:05:16 +0200 Subject: [PATCH 2/9] add refactoring overview --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 07cb83e..4b016e5 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,7 @@ Our convention 4 kubernetes c4k-* tools combine the advantages of both approache ## Refactoring & Module Overview | Module | Version | common postgres | frontend script | provider adapter | +|------------------|---------|-----------------|-----------------|------------------| | c4k-mastodon-bot | 0.1 | - | | | | c4k-keycloak | 0.2 | | | | | c4k-jira | 1.0 | x | x | | From 1b4502b316ec824a43bb511f04dc04ae46893013 Mon Sep 17 00:00:00 2001 From: jem Date: Wed, 8 Sep 2021 13:06:38 +0200 Subject: [PATCH 3/9] add refactoring overview --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4b016e5..d6d2934 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ Our convention 4 kubernetes c4k-* tools combine the advantages of both approache ## Refactoring & Module Overview | Module | Version | common postgres | frontend script | provider adapter | -|------------------|---------|-----------------|-----------------|------------------| +|------------------|---------|:---------------:|:---------------:|:----------------:| | c4k-mastodon-bot | 0.1 | - | | | | c4k-keycloak | 0.2 | | | | | c4k-jira | 1.0 | x | x | | From a0ce8044992f7d7db482318f864fa73cb01e2df4 Mon Sep 17 00:00:00 2001 From: jem Date: Mon, 13 Sep 2021 09:05:08 +0200 Subject: [PATCH 4/9] introduce size dependand postgres-sizings --- project-cljs.clj | 2 +- project.clj | 2 +- src/main/cljc/dda/c4k_common/postgres.cljc | 16 +++++++++++++--- .../postgres/{config.yaml => config-16gb.yaml} | 2 +- src/main/resources/postgres/config-2gb.yaml | 11 +++++++++++ src/main/resources/postgres/config-4gb.yaml | 11 +++++++++++ src/main/resources/postgres/config-8gb.yaml | 11 +++++++++++ src/test/cljc/dda/c4k_common/postgres_test.cljc | 9 +++++++++ 8 files changed, 58 insertions(+), 6 deletions(-) rename src/main/resources/postgres/{config.yaml => config-16gb.yaml} (89%) create mode 100644 src/main/resources/postgres/config-2gb.yaml create mode 100644 src/main/resources/postgres/config-4gb.yaml create mode 100644 src/main/resources/postgres/config-8gb.yaml diff --git a/project-cljs.clj b/project-cljs.clj index 0a17342..b840852 100644 --- a/project-cljs.clj +++ b/project-cljs.clj @@ -1,4 +1,4 @@ -(defproject org.domaindrivenarchitecture/c4k-common-cljs "0.2.11-SNAPSHOT" +(defproject org.domaindrivenarchitecture/c4k-common-cljs "0.3.0-SNAPSHOT" :description "Contains predicates and tools for c4k" :url "https://domaindrivenarchitecture.org" :license {:name "Apache License, Version 2.0" diff --git a/project.clj b/project.clj index 88139a4..b15cd8d 100644 --- a/project.clj +++ b/project.clj @@ -1,4 +1,4 @@ -(defproject org.domaindrivenarchitecture/c4k-common-clj "0.2.11-SNAPSHOT" +(defproject org.domaindrivenarchitecture/c4k-common-clj "0.3.0-SNAPSHOT" :description "Contains predicates and tools for c4k" :url "https://domaindrivenarchitecture.org" :license {:name "Apache License, Version 2.0" diff --git a/src/main/cljc/dda/c4k_common/postgres.cljc b/src/main/cljc/dda/c4k_common/postgres.cljc index 8ef0a06..e2189cf 100644 --- a/src/main/cljc/dda/c4k_common/postgres.cljc +++ b/src/main/cljc/dda/c4k_common/postgres.cljc @@ -6,14 +6,22 @@ [dda.c4k-common.base64 :as b64] [dda.c4k-common.common :as cm])) +(defn postgres-size? + [input] + (contains? #{:2gb :4gb :8gb :16gb} input)) + (s/def ::postgres-db-user cm/bash-env-string?) (s/def ::postgres-db-password cm/bash-env-string?) (s/def ::postgres-data-volume-path string?) +(s/def ::postgres-size postgres-size?) #?(:cljs (defmethod yaml/load-resource :postgres [resource-name] (case resource-name - "postgres/config.yaml" (rc/inline "postgres/config.yaml") + "postgres/config-2gb.yaml" (rc/inline "postgres/config-2gb.yaml") + "postgres/config-4gb.yaml" (rc/inline "postgres/config-4gb.yaml") + "postgres/config-8gb.yaml" (rc/inline "postgres/config-8gb.yaml") + "postgres/config-16gb.yaml" (rc/inline "postgres/config-16gb.yaml") "postgres/deployment.yaml" (rc/inline "postgres/deployment.yaml") "postgres/persistent-volume.yaml" (rc/inline "postgres/persistent-volume.yaml") "postgres/pvc.yaml" (rc/inline "postgres/pvc.yaml") @@ -21,8 +29,10 @@ "postgres/service.yaml" (rc/inline "postgres/service.yaml") (throw (js/Error. "Undefined Resource!"))))) -(defn generate-config [] - (yaml/from-string (yaml/load-resource "postgres/config.yaml"))) +(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"))))) (defn generate-deployment [] (yaml/from-string (yaml/load-resource "postgres/deployment.yaml"))) diff --git a/src/main/resources/postgres/config.yaml b/src/main/resources/postgres/config-16gb.yaml similarity index 89% rename from src/main/resources/postgres/config.yaml rename to src/main/resources/postgres/config-16gb.yaml index e2c62d5..fc32eee 100644 --- a/src/main/resources/postgres/config.yaml +++ b/src/main/resources/postgres/config-16gb.yaml @@ -5,7 +5,7 @@ metadata: labels: app: postgres data: - postgres-db: jira postgresql.conf: | max_connections = 1000 + work_mem = 4MB shared_buffers = 512MB diff --git a/src/main/resources/postgres/config-2gb.yaml b/src/main/resources/postgres/config-2gb.yaml new file mode 100644 index 0000000..3bcba85 --- /dev/null +++ b/src/main/resources/postgres/config-2gb.yaml @@ -0,0 +1,11 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: postgres-config + labels: + app: postgres +data: + postgresql.conf: | + max_connections = 100 + work_mem = 4MB + shared_buffers = 128MB diff --git a/src/main/resources/postgres/config-4gb.yaml b/src/main/resources/postgres/config-4gb.yaml new file mode 100644 index 0000000..ec36a3f --- /dev/null +++ b/src/main/resources/postgres/config-4gb.yaml @@ -0,0 +1,11 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: postgres-config + labels: + app: postgres +data: + postgresql.conf: | + max_connections = 500 + work_mem = 2MB + shared_buffers = 256MB diff --git a/src/main/resources/postgres/config-8gb.yaml b/src/main/resources/postgres/config-8gb.yaml new file mode 100644 index 0000000..4bd9837 --- /dev/null +++ b/src/main/resources/postgres/config-8gb.yaml @@ -0,0 +1,11 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: postgres-config + labels: + app: postgres +data: + postgresql.conf: | + max_connections = 700 + work_mem = 3MB + shared_buffers = 512MB diff --git a/src/test/cljc/dda/c4k_common/postgres_test.cljc b/src/test/cljc/dda/c4k_common/postgres_test.cljc index de5f0f1..6f79342 100644 --- a/src/test/cljc/dda/c4k_common/postgres_test.cljc +++ b/src/test/cljc/dda/c4k_common/postgres_test.cljc @@ -4,6 +4,15 @@ :cljs [cljs.test :refer-macros [deftest is are testing run-tests]]) [dda.c4k-common.postgres :as cut])) +(deftest should-generate-config + (is (= {:postgresql.conf + "max_connections = 100\nwork_mem = 4MB\nshared_buffers = 128MB\n"} + (:data (cut/generate-config)))) + (is (= {:postgresql.conf + "max_connections = 700\nwork_mem = 3MB\nshared_buffers = 512MB\n"} + (:data (cut/generate-config :postgres-size :8gb)))) + ) + (deftest should-generate-persistent-volume (is (= {:kind "PersistentVolume" :apiVersion "v1" From a1969ff6199a0cc881414a30f250fc4d0cdd53fc Mon Sep 17 00:00:00 2001 From: jem Date: Mon, 13 Sep 2021 09:08:40 +0200 Subject: [PATCH 5/9] prepare release --- doc/Releasing.md | 2 +- project-cljs.clj | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/Releasing.md b/doc/Releasing.md index df84f9e..8aeea73 100644 --- a/doc/Releasing.md +++ b/doc/Releasing.md @@ -1,7 +1,7 @@ # stable release (should be done from master) ``` -#adjust [version] +#adjust [version] and remove the -SNAPSHOT vi project-cljs.clj lein release diff --git a/project-cljs.clj b/project-cljs.clj index b840852..7027967 100644 --- a/project-cljs.clj +++ b/project-cljs.clj @@ -1,4 +1,4 @@ -(defproject org.domaindrivenarchitecture/c4k-common-cljs "0.3.0-SNAPSHOT" +(defproject org.domaindrivenarchitecture/c4k-common-cljs "0.3.0" :description "Contains predicates and tools for c4k" :url "https://domaindrivenarchitecture.org" :license {:name "Apache License, Version 2.0" From c9ec3879005f25062abb02e926b90eb02c93acde Mon Sep 17 00:00:00 2001 From: jem Date: Mon, 13 Sep 2021 09:10:36 +0200 Subject: [PATCH 6/9] better release task support --- project.clj | 1 - 1 file changed, 1 deletion(-) diff --git a/project.clj b/project.clj index b15cd8d..62f3737 100644 --- a/project.clj +++ b/project.clj @@ -20,7 +20,6 @@ :dependencies [[dda/data-test "0.1.1"]]} :dev {:plugins [[lein-shell "0.5.0"]]}} :release-tasks [["test"] - ["vcs" "assert-committed"] ["change" "version" "leiningen.release/bump-version" "release"] ["vcs" "commit"] ["vcs" "tag"] From fd1c14ba35bf6c60ce3e739c2614788837326b50 Mon Sep 17 00:00:00 2001 From: jem Date: Mon, 13 Sep 2021 09:11:01 +0200 Subject: [PATCH 7/9] Version 0.3.0 --- project.clj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project.clj b/project.clj index 62f3737..5f22c29 100644 --- a/project.clj +++ b/project.clj @@ -1,4 +1,4 @@ -(defproject org.domaindrivenarchitecture/c4k-common-clj "0.3.0-SNAPSHOT" +(defproject org.domaindrivenarchitecture/c4k-common-clj "0.3.0" :description "Contains predicates and tools for c4k" :url "https://domaindrivenarchitecture.org" :license {:name "Apache License, Version 2.0" From ce836de0b8d8afd98fdd031896b638193774c3cf Mon Sep 17 00:00:00 2001 From: jem Date: Mon, 13 Sep 2021 09:12:17 +0200 Subject: [PATCH 8/9] version bump --- project-cljs.clj | 2 +- project.clj | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/project-cljs.clj b/project-cljs.clj index 7027967..7456352 100644 --- a/project-cljs.clj +++ b/project-cljs.clj @@ -1,4 +1,4 @@ -(defproject org.domaindrivenarchitecture/c4k-common-cljs "0.3.0" +(defproject org.domaindrivenarchitecture/c4k-common-cljs "0.3.1-SNAPSHOT" :description "Contains predicates and tools for c4k" :url "https://domaindrivenarchitecture.org" :license {:name "Apache License, Version 2.0" diff --git a/project.clj b/project.clj index 5f22c29..a041e99 100644 --- a/project.clj +++ b/project.clj @@ -1,4 +1,4 @@ -(defproject org.domaindrivenarchitecture/c4k-common-clj "0.3.0" +(defproject org.domaindrivenarchitecture/c4k-common-clj "0.3.1-SNAPSHOT" :description "Contains predicates and tools for c4k" :url "https://domaindrivenarchitecture.org" :license {:name "Apache License, Version 2.0" From 8b5c33183cbe8e324b69ee5150f5cc40add9a2b4 Mon Sep 17 00:00:00 2001 From: jem Date: Mon, 13 Sep 2021 09:24:47 +0200 Subject: [PATCH 9/9] resolve deprecation --- src/main/cljc/dda/c4k_common/postgres.cljc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/cljc/dda/c4k_common/postgres.cljc b/src/main/cljc/dda/c4k_common/postgres.cljc index e2189cf..b7a7738 100644 --- a/src/main/cljc/dda/c4k_common/postgres.cljc +++ b/src/main/cljc/dda/c4k_common/postgres.cljc @@ -4,7 +4,7 @@ #?(:cljs [shadow.resource :as rc]) [dda.c4k-common.yaml :as yaml] [dda.c4k-common.base64 :as b64] - [dda.c4k-common.common :as cm])) + [dda.c4k-common.prefixes :as cm])) (defn postgres-size? [input]