From 1b1d316653c43c886c6df193a9feb7a9fa96e38e Mon Sep 17 00:00:00 2001 From: Michael Jerger Date: Thu, 29 Feb 2024 15:58:57 +0100 Subject: [PATCH] refactore auth -> websiteauths --- src/main/cljc/dda/c4k_website/core.cljc | 14 +++++++------- .../dda/c4k_website/website/website_internal.cljc | 4 ++-- src/main/cljs/dda/c4k_website/browser.cljs | 2 +- src/test/cljc/dda/c4k_website/core_test.cljc | 4 ++-- src/test/resources/website-test/valid-auth.yaml | 2 +- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/main/cljc/dda/c4k_website/core.cljc b/src/main/cljc/dda/c4k_website/core.cljc index 7362f7d..d7bef40 100644 --- a/src/main/cljc/dda/c4k_website/core.cljc +++ b/src/main/cljc/dda/c4k_website/core.cljc @@ -40,14 +40,14 @@ ::build-memory-limit])) (def websiteauth? (s/keys :req-un [::unique-name ::username ::authtoken])) (s/def ::websiteconfigs (s/coll-of websiteconfig?)) -(s/def ::auth (s/coll-of websiteauth?)) +(s/def ::websiteauths (s/coll-of websiteauth?)) (def config? (s/keys :req-un [::websiteconfigs] :opt-un [::issuer ::volume-size ::mon-cfg])) -(def auth? (s/keys :req-un [::auth] +(def auth? (s/keys :req-un [::websiteauths] :opt-un [::mon-auth])) (def config-defaults {:issuer "staging"}) @@ -68,9 +68,9 @@ (defn-spec sort-auth map? [unsorted-auth auth?] - (let [sorted-auth (into [] (sort-by :unique-name (unsorted-auth :auth)))] + (let [sorted-auth (into [] (sort-by :unique-name (unsorted-auth :websiteauths)))] (-> unsorted-auth - (assoc-in [:auth] sorted-auth)))) + (assoc-in [:websiteauths] sorted-auth)))) (defn-spec flatten-and-reduce-config map? [config config?] @@ -84,7 +84,7 @@ (defn-spec flatten-and-reduce-auth map? [auth auth?] - (-> auth :auth first)) + (-> auth :websiteauths first)) (defn-spec generate-ingress seq? [config websiteconfig?] @@ -103,14 +103,14 @@ sorted-auth (sort-auth auth) result []] - (if (and (empty? (config :websiteconfigs)) (empty? (sorted-auth :auth))) + (if (and (empty? (config :websiteconfigs)) (empty? (sorted-auth :websiteauths))) result (recur (-> config (assoc-in [:websiteconfigs] (rest (config :websiteconfigs)))) (-> auth - (assoc-in [:auth] (rest (sorted-auth :auth)))) + (assoc-in [:websiteauths] (rest (sorted-auth :websiteauths)))) (let [final-config (merge website-config-defaults diff --git a/src/main/cljc/dda/c4k_website/website/website_internal.cljc b/src/main/cljc/dda/c4k_website/website/website_internal.cljc index 6cc3ffe..4b5b1c6 100644 --- a/src/main/cljc/dda/c4k_website/website/website_internal.cljc +++ b/src/main/cljc/dda/c4k_website/website/website_internal.cljc @@ -48,11 +48,11 @@ (s/def ::websiteconfigs (s/coll-of websiteconfig?)) -(s/def ::auth (s/coll-of websiteauth?)) +(s/def ::websiteauths (s/coll-of websiteauth?)) (def websiteconfigs? (s/keys :req-un [::websiteconfigs])) -(def auth? (s/keys :req-un [::auth])) +(def auth? (s/keys :req-un [::websiteauths])) (defn-spec replace-dots-by-minus string? [fqdn pred/fqdn-string?] diff --git a/src/main/cljs/dda/c4k_website/browser.cljs b/src/main/cljs/dda/c4k_website/browser.cljs index 73763ce..04a8944 100644 --- a/src/main/cljs/dda/c4k_website/browser.cljs +++ b/src/main/cljs/dda/c4k_website/browser.cljs @@ -49,7 +49,7 @@ "{:mon-auth {:grafana-cloud-user \"your-user-id\" :grafana-cloud-password \"your-cloud-password\"} - :auth + :websiteauths [{:unique-name \"test.io\", :username \"someuser\", :authtoken \"abedjgbasdodj\"} diff --git a/src/test/cljc/dda/c4k_website/core_test.cljc b/src/test/cljc/dda/c4k_website/core_test.cljc index ef74984..f369ec6 100644 --- a/src/test/cljc/dda/c4k_website/core_test.cljc +++ b/src/test/cljc/dda/c4k_website/core_test.cljc @@ -52,7 +52,7 @@ :branchname "main"}]}) (def auth1 - {:auth + {:websiteauths [{:unique-name "example.io" :username "someuser" :authtoken "abedjgbasdodj"} @@ -61,7 +61,7 @@ :authtoken "abedjgbasdodj"}]}) (def auth2 - {:auth + {:websiteauths [{:unique-name "test.io" :username "someuser" :authtoken "abedjgbasdodj"} diff --git a/src/test/resources/website-test/valid-auth.yaml b/src/test/resources/website-test/valid-auth.yaml index 85bf915..ddb2e8b 100644 --- a/src/test/resources/website-test/valid-auth.yaml +++ b/src/test/resources/website-test/valid-auth.yaml @@ -1,4 +1,4 @@ -auth: +websiteauths: - unique-name: "test.io" username: "someuser" authtoken: "abedjgbasdodj"