diff --git a/src/main/cljc/dda/k8s_keycloak/core.cljc b/src/main/cljc/dda/k8s_keycloak/core.cljc index 776449c..6051fb4 100644 --- a/src/main/cljc/dda/k8s_keycloak/core.cljc +++ b/src/main/cljc/dda/k8s_keycloak/core.cljc @@ -32,11 +32,11 @@ (defn cast-lazy-seq-to-vec [lazy-seq] (clojure.walk/postwalk #(if (instance? clojure.lang.LazySeq %) - (do (println %) (into [] %)) + (do (into [] %)) %) lazy-seq)) (defn replace-all-matching-values-by-new-value - [value-to-match value-to-replace coll] + [coll value-to-match value-to-replace] (clojure.walk/postwalk #(if (and (= (type value-to-match) (type %)) (= value-to-match %)) value-to-replace @@ -78,6 +78,7 @@ (let [{:keys [user-name user-password]} my-auth] (-> (yaml/from-string (yaml/load-resource "deployment.yaml")) + (cast-lazy-seq-to-vec) (assoc-in [:spec :template :spec :containers 0 :env 0 :value] user-name) (assoc-in [:spec :template :spec :containers 0 :env 1 :value] user-password)))) @@ -98,10 +99,7 @@ (-> (yaml/from-string (yaml/load-resource "ingress.yaml")) (assoc-in [:metadata :annotations :cert-manager.io/cluster-issuer] letsencrypt-issuer) - (assoc-in [:spec :tls] [{:hosts [fqdn], :secretName "keycloak-secret"}]) - (assoc-in [:spec :rules] [{:host fqdn - :http {:paths [{:backend {:serviceName "keycloak" - :servicePort 8080}}]}}])))) + (replace-all-matching-values-by-new-value "fqdn" fqdn)))) diff --git a/src/test/cljc/dda/k8s_keycloak/core_test.cljc b/src/test/cljc/dda/k8s_keycloak/core_test.cljc index 81f5939..caf629b 100644 --- a/src/test/cljc/dda/k8s_keycloak/core_test.cljc +++ b/src/test/cljc/dda/k8s_keycloak/core_test.cljc @@ -83,23 +83,3 @@ :ports [{:name "http", :containerPort 8080}] :readinessProbe {:httpGet {:path "/auth/realms/master", :port 8080}}}]}}}} (cut/generate-deployment {:user-name "testuser" :user-password "test1234"})))) -<<<<<<< HEAD -======= - -(deftest test-vector-replace-fqdn-function - (let [ingress-yaml (yaml/from-string (yaml/load-resource "ingress.yaml")) - fqdn "some_host" - desired-result (-> ingress-yaml - (assoc-in [:spec :rules] [{:host fqdn - :http {:paths [{:backend {:serviceName "keycloak" - :servicePort 8080}}]}} - {:host fqdn - :http {:paths [{:backend {:serviceName "another_keycloak" - :servicePort 8081}}]}} - ]))] - (is (= desired-result - (cut/assoc-in-nested (cut/cast-lazy-seq-to-vec ingress-yaml) [:spec :rules :host] fqdn)))) - ) - - ->>>>>>> 0379ad882851993440561c5c09c9f813e4357ab1