diff --git a/src/main/cljc/dda/c4k_jira/core.cljc b/src/main/cljc/dda/c4k_jira/core.cljc index 78f0cde..5ce7381 100644 --- a/src/main/cljc/dda/c4k_jira/core.cljc +++ b/src/main/cljc/dda/c4k_jira/core.cljc @@ -14,39 +14,31 @@ :opt-un [::jira/issuer ::jira/jira-data-volume-path ::postgres/postgres-data-volume-path])) -(def auth? (s/keys :req-un [::postgres/db-user-name ::postgres/db-user-password])) +(def auth? (s/keys :req-un [::postgres/postgres-db-user ::postgres/postgres-db-password])) + +(defn k8s-objects [config] + (into + [] + (concat [(yaml/to-string (postgres/generate-config)) + (yaml/to-string (postgres/generate-secret config))] + (when (contains? config :postgres-data-volume-path) + [(yaml/to-string (postgres/generate-persistent-volume config))]) + [(yaml/to-string (postgres/generate-pvc)) + (yaml/to-string (postgres/generate-deployment)) + (yaml/to-string (postgres/generate-service))] + (when (contains? config :jira-data-volume-path) + [(yaml/to-string (jira/generate-persistent-volume config))]) + [(yaml/to-string (jira/generate-pvc)) + (yaml/to-string (jira/generate-pod config)) + (yaml/to-string (jira/generate-service)) + (yaml/to-string (jira/generate-certificate config)) + (yaml/to-string (jira/generate-ingress config)) + (yaml/to-string (jira/generate-service))]))) (defn-spec generate any? [my-config config? my-auth auth?] (let [resulting-config (merge config-defaults my-config my-auth)] (cs/join - "\n" - (into - [(yaml/to-string (postgres/generate-config)) - "---" - (yaml/to-string (postgres/generate-secret resulting-config))] - (when-some [{:keys [postgres-data-volume-path]} resulting-config] - ["---" - (yaml/to-string (postgres/generate-persistent-volume resulting-config))]) - ["---" - (yaml/to-string (postgres/generate-pvc)) - "---" - (yaml/to-string (postgres/generate-deployment)) - "---" - (yaml/to-string (postgres/generate-service))] - (when-some [{:keys [jira-data-volume-path]} resulting-config] - ["---" - (yaml/to-string (jira/generate-persistent-volume resulting-config))]) - ["---" - (yaml/to-string (jira/generate-pvc)) - "---" - (yaml/to-string (jira/generate-pod resulting-config)) - "---" - (yaml/to-string (jira/generate-service)) - "---" - (yaml/to-string (jira/generate-certificate resulting-config)) - "---" - (yaml/to-string (jira/generate-ingress resulting-config)) - "---" - (yaml/to-string (jira/generate-service))])))) + "\n---\n" + (k8s-objects resulting-config)))) diff --git a/src/main/resources/postgres/deployment.yaml b/src/main/resources/postgres/deployment.yaml index e7c0d48..5b4bb4d 100644 --- a/src/main/resources/postgres/deployment.yaml +++ b/src/main/resources/postgres/deployment.yaml @@ -46,6 +46,6 @@ spec: - name: postgres-config-volume configMap: name: postgres-config - - name: postgre-d + - name: postgre-data-volume persistentVolumeClaim: claimName: postgres-claim diff --git a/src/test/cljc/dda/c4k_jira/core_test.cljc b/src/test/cljc/dda/c4k_jira/core_test.cljc new file mode 100644 index 0000000..10b9c47 --- /dev/null +++ b/src/test/cljc/dda/c4k_jira/core_test.cljc @@ -0,0 +1,19 @@ +(ns dda.c4k-jira.core-test + (:require + #?(:clj [clojure.test :refer [deftest is are testing run-tests]] + :cljs [cljs.test :refer-macros [deftest is are testing run-tests]]) + [dda.c4k-jira.core :as cut])) + +(deftest should-k8s-objects + (is (= 13 + (count (cut/k8s-objects {:fqdn "jira-neu.prod.meissa-gmbh.de" + :postgres-db-user "jira" + :postgres-db-password "jira-db-password" + :issuer :prod + :jira-data-volume-path "/var/jira" + :postgres-data-volume-path "/var/postgres"})))) + (is (= 11 + (count (cut/k8s-objects {:fqdn "jira-neu.prod.meissa-gmbh.de" + :postgres-db-user "jira" + :postgres-db-password "jira-db-password" + :issuer :prod}))))) diff --git a/valid-auth.edn b/valid-auth.edn index 105dcdd..a07c585 100644 --- a/valid-auth.edn +++ b/valid-auth.edn @@ -1,2 +1,2 @@ -{:db-user-name "jira" - :db-user-password "jira-db-password"} \ No newline at end of file +{:postgres-db-user "jira" + :postgres-db-password "jira-db-password"} \ No newline at end of file diff --git a/valid-config.edn b/valid-config.edn index 3193e42..7a85b54 100644 --- a/valid-config.edn +++ b/valid-config.edn @@ -1 +1,3 @@ -{:fqdn "jira-neu.prod.meissa-gmbh.de"} \ No newline at end of file +{:fqdn "jira-neu.prod.meissa-gmbh.de" + :jira-data-volume-path "/var/jira" + :postgres-data-volume-path "/var/postgres"} \ No newline at end of file