From f2871aa383e23cb5c1668d5025f99547e0fecfbe Mon Sep 17 00:00:00 2001 From: jem Date: Fri, 21 May 2021 17:59:44 +0200 Subject: [PATCH] keycloak deployment now may work --- src/main/clj/dda/k8s_keycloak/uberjar.clj | 2 +- src/main/cljc/dda/k8s_keycloak/core.cljc | 15 +++++++-------- src/test/cljc/dda/k8s_keycloak/core_test.cljc | 2 +- valid-config.edn | 3 +-- 4 files changed, 10 insertions(+), 12 deletions(-) diff --git a/src/main/clj/dda/k8s_keycloak/uberjar.clj b/src/main/clj/dda/k8s_keycloak/uberjar.clj index 8fcb6ec..5e33ad0 100644 --- a/src/main/clj/dda/k8s_keycloak/uberjar.clj +++ b/src/main/clj/dda/k8s_keycloak/uberjar.clj @@ -46,7 +46,7 @@ config-valid? (s/valid? core/config? config-edn) auth-valid? (s/valid? core/auth? auth-edn)] (if (and config-valid? auth-valid?) - (println (core/generate config-str auth-str)) + (println (core/generate config-edn auth-edn)) (do (when (not config-valid?) (println diff --git a/src/main/cljc/dda/k8s_keycloak/core.cljc b/src/main/cljc/dda/k8s_keycloak/core.cljc index e743412..1eb6cef 100644 --- a/src/main/cljc/dda/k8s_keycloak/core.cljc +++ b/src/main/cljc/dda/k8s_keycloak/core.cljc @@ -32,17 +32,16 @@ (assoc-in [:data :config.edn] (str my-config)) (assoc-in [ :data :credentials.edn] (str my-auth)))) -(defn generate-deployment [config] - (let [user (:user config) - password (:password config)] +(defn generate-deployment [my-auth] + (let [{:keys [user-name user-password]} my-auth] (-> (yaml/from-string (yaml/load-resource "deployment.yaml")) (assoc-in [:spec :template :spec :containers] [{:name "keycloak" :image "quay.io/keycloak/keycloak:13.0.0" :env - [{:name "KEYCLOAK_USER", :value user} - {:name "KEYCLOAK_PASSWORD", :value password} + [{:name "KEYCLOAK_USER", :value user-name} + {:name "KEYCLOAK_PASSWORD", :value user-password} {:name "PROXY_ADDRESS_FORWARDING", :value "true"}] :ports [{:name "http", :containerPort 8080}] :readinessProbe {:httpGet {:path "/auth/realms/master", :port 8080}}}])))) @@ -78,10 +77,10 @@ (cs/join "\n" [(yaml/to-string (generate-config my-config my-auth)) "---" - (yaml/to-string (generate-certificate)) + (yaml/to-string (generate-certificate my-config)) "---" - (yaml/to-string (generate-ingress)) + (yaml/to-string (generate-ingress my-config)) "---" (yaml/to-string (generate-service)) "---" - (yaml/to-string (generate-deployment))])) + (yaml/to-string (generate-deployment my-auth))])) diff --git a/src/test/cljc/dda/k8s_keycloak/core_test.cljc b/src/test/cljc/dda/k8s_keycloak/core_test.cljc index e5a62c8..bb73f45 100644 --- a/src/test/cljc/dda/k8s_keycloak/core_test.cljc +++ b/src/test/cljc/dda/k8s_keycloak/core_test.cljc @@ -81,4 +81,4 @@ {:name "PROXY_ADDRESS_FORWARDING", :value "true"}] :ports [{:name "http", :containerPort 8080}] :readinessProbe {:httpGet {:path "/auth/realms/master", :port 8080}}}]}}}} - (cut/generate-deployment {:user "testuser" :password "test1234"})))) \ No newline at end of file + (cut/generate-deployment {:user-name "testuser" :user-password "test1234"})))) \ No newline at end of file diff --git a/valid-config.edn b/valid-config.edn index 40de098..e8961b5 100644 --- a/valid-config.edn +++ b/valid-config.edn @@ -1,2 +1 @@ -{:fqdn "test.de" - :issuer :prod} \ No newline at end of file +{:fqdn "keycloak.test.meissa-gmbh.de"} \ No newline at end of file