From 5b4e68ae2a738b83dd3f185606087d036e36be5a Mon Sep 17 00:00:00 2001 From: Clemens Geibel Date: Wed, 20 Apr 2022 16:51:57 +0200 Subject: [PATCH] Changed issuer keywords to strings --- src/main/cljc/dda/c4k_nextcloud/core.cljc | 2 +- src/main/cljc/dda/c4k_nextcloud/nextcloud.cljc | 10 ++++++++-- src/test/cljc/dda/c4k_nextcloud/core_test.cljc | 10 +++++----- src/test/cljc/dda/c4k_nextcloud/nextcloud_test.cljc | 2 +- valid-config.edn | 2 +- valid-config.yaml | 2 +- 6 files changed, 17 insertions(+), 11 deletions(-) diff --git a/src/main/cljc/dda/c4k_nextcloud/core.cljc b/src/main/cljc/dda/c4k_nextcloud/core.cljc index 20b57e2..928c879 100644 --- a/src/main/cljc/dda/c4k_nextcloud/core.cljc +++ b/src/main/cljc/dda/c4k_nextcloud/core.cljc @@ -9,7 +9,7 @@ [dda.c4k-nextcloud.nextcloud :as nextcloud] [dda.c4k-nextcloud.backup :as backup])) -(def config-defaults {:issuer :staging}) +(def config-defaults {:issuer "staging"}) (def auth? (s/keys :req-un [::postgres/postgres-db-user ::postgres/postgres-db-password ::nextcloud/nextcloud-admin-user ::nextcloud/nextcloud-admin-password diff --git a/src/main/cljc/dda/c4k_nextcloud/nextcloud.cljc b/src/main/cljc/dda/c4k_nextcloud/nextcloud.cljc index ac3db50..df5c85f 100644 --- a/src/main/cljc/dda/c4k_nextcloud/nextcloud.cljc +++ b/src/main/cljc/dda/c4k_nextcloud/nextcloud.cljc @@ -10,8 +10,14 @@ [dda.c4k-common.common :as cm] [dda.c4k-common.postgres :as postgres])) +; TODO: Replace method in c4k-common.predicate and update all c4k modules. +(defn letsencrypt-issuer? + [input] + (contains? #{"prod" "staging"} input)) +; TODO: Remove (name ...) function calls, when issuer is no longer a keyword (also in c4k-common) + (s/def ::fqdn cp/fqdn-string?) -(s/def ::issuer cp/letsencrypt-issuer?) +(s/def ::issuer letsencrypt-issuer?) ;cp/letsencrypt-issuer? (s/def ::restic-repository string?) (s/def ::nextcloud-data-volume-path string?) (s/def ::nextcloud-admin-user cp/bash-env-string?) @@ -52,7 +58,7 @@ (defn generate-ingress [config] (let [{:keys [fqdn issuer] - :or {issuer :staging}} config + :or {issuer "staging"}} config letsencrypt-issuer (name issuer)] (-> (yaml/from-string (yaml/load-resource "nextcloud/ingress.yaml")) diff --git a/src/test/cljc/dda/c4k_nextcloud/core_test.cljc b/src/test/cljc/dda/c4k_nextcloud/core_test.cljc index f46cfe6..82cfcf5 100644 --- a/src/test/cljc/dda/c4k_nextcloud/core_test.cljc +++ b/src/test/cljc/dda/c4k_nextcloud/core_test.cljc @@ -13,7 +13,7 @@ :postgres-db-password "nextcloud-db-password" :nextcloud-admin-user "cloudadmin" :nextcloud-admin-password "cloudpassword" - :issuer :prod + :issuer "prod" :nextcloud-data-volume-path "/var/nextcloud" :postgres-data-volume-path "/var/postgres" :aws-access-key-id "aws-id" @@ -26,7 +26,7 @@ :postgres-db-password "nextcloud-db-password" :nextcloud-admin-user "cloudadmin" :nextcloud-admin-password "cloudpassword" - :issuer :prod + :issuer "prod" :aws-access-key-id "aws-id" :aws-secret-access-key "aws-secret" :restic-password "restic-pw" @@ -37,7 +37,7 @@ :postgres-db-password "nextcloud-db-password" :nextcloud-admin-user "cloudadmin" :nextcloud-admin-password "cloudpassword" - :issuer :prod + :issuer "prod" :aws-access-key-id "aws-id" :aws-secret-access-key "aws-secret" :restic-password "restic-pw"})))) @@ -47,7 +47,7 @@ :postgres-db-password "nextcloud-db-password" :nextcloud-admin-user "cloudadmin" :nextcloud-admin-password "cloudpassword" - :issuer :prod + :issuer "prod" :aws-access-key-id "aws-id" :aws-secret-access-key "aws-secret" :restic-password "restic-pw"}) @@ -59,7 +59,7 @@ :postgres-db-password "nextcloud-db-password" :nextcloud-admin-user "cloudadmin" :nextcloud-admin-password "cloudpassword" - :issuer :prod + :issuer "prod" :aws-access-key-id "aws-id" :aws-secret-access-key "aws-secret" :restic-password "restic-pw"}) diff --git a/src/test/cljc/dda/c4k_nextcloud/nextcloud_test.cljc b/src/test/cljc/dda/c4k_nextcloud/nextcloud_test.cljc index 024a0c6..3a2b6b6 100644 --- a/src/test/cljc/dda/c4k_nextcloud/nextcloud_test.cljc +++ b/src/test/cljc/dda/c4k_nextcloud/nextcloud_test.cljc @@ -25,7 +25,7 @@ :dnsNames ["xx"] :issuerRef {:name "prod", :kind "ClusterIssuer"}}} - (cut/generate-certificate {:fqdn "xx" :issuer :prod})))) + (cut/generate-certificate {:fqdn "xx" :issuer "prod"})))) (deftest should-generate-ingress (is (= {:apiVersion "networking.k8s.io/v1" diff --git a/valid-config.edn b/valid-config.edn index 87ebb80..b50ced9 100644 --- a/valid-config.edn +++ b/valid-config.edn @@ -1,5 +1,5 @@ {:fqdn "cloud.test.meissa-gmbh.de" - :issuer :staging + :issuer "staging" :nextcloud-data-volume-path "/var/cloud" :postgres-data-volume-path "/var/postgres" :restic-repository "s3:s3.amazonaws.com/your-bucket/your-folder"} \ No newline at end of file diff --git a/valid-config.yaml b/valid-config.yaml index dff692c..c716cf2 100644 --- a/valid-config.yaml +++ b/valid-config.yaml @@ -1,5 +1,5 @@ fqdn: "cloud.test.meissa-gmbh.de" -issuer: :staging +issuer: "staging" nextcloud-data-volume-path: "/var/cloud" postgres-data-volume-path: "/var/postgres" restic-repository: "s3:s3.amazonaws.com/your-bucket/your-folder" \ No newline at end of file