From 474b86681b8576c2f198ed0f7f5c9c193267a964 Mon Sep 17 00:00:00 2001 From: bom Date: Thu, 27 May 2021 12:39:26 +0200 Subject: [PATCH] wip changes to core --- src/main/cljc/dda/k8s_keycloak/core.cljc | 11 +--- src/test/cljc/dda/k8s_keycloak/core_test.cljc | 50 +++++++------------ 2 files changed, 19 insertions(+), 42 deletions(-) diff --git a/src/main/cljc/dda/k8s_keycloak/core.cljc b/src/main/cljc/dda/k8s_keycloak/core.cljc index 6a44b38..6239e9d 100644 --- a/src/main/cljc/dda/k8s_keycloak/core.cljc +++ b/src/main/cljc/dda/k8s_keycloak/core.cljc @@ -62,15 +62,8 @@ (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} - {: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}}}])))) + (assoc-in [:spec :template :spec :containers 0 :env 0 :value] user-name) + (assoc-in [:spec :template :spec :containers 0 :env 1 :value] user-password)))) (defn generate-certificate [config] (let [{:keys [fqdn issuer] diff --git a/src/test/cljc/dda/k8s_keycloak/core_test.cljc b/src/test/cljc/dda/k8s_keycloak/core_test.cljc index 0e26041..caf629b 100644 --- a/src/test/cljc/dda/k8s_keycloak/core_test.cljc +++ b/src/test/cljc/dda/k8s_keycloak/core_test.cljc @@ -65,37 +65,21 @@ (deftest should-generate-deployment (is (= {:apiVersion "apps/v1" - :kind "Deployment" - :metadata {:name "keycloak", :namespace "default", :labels {:app "keycloak"}} - :spec - {:replicas 1 - :selector {:matchLabels {:app "keycloak"}} - :template - {:metadata {:labels {:app "keycloak"}} - :spec - {:containers - [{:name "keycloak" - :image "quay.io/keycloak/keycloak:13.0.0" - :env - [{:name "KEYCLOAK_USER", :value "testuser"} - {:name "KEYCLOAK_PASSWORD", :value "test1234"} - {:name "PROXY_ADDRESS_FORWARDING", :value "true"}] - :ports [{:name "http", :containerPort 8080}] - :readinessProbe {:httpGet {:path "/auth/realms/master", :port 8080}}}]}}}} + :kind "Deployment" + :metadata {:name "keycloak", :namespace "default", :labels {:app "keycloak"}} + :spec + {:replicas 1 + :selector {:matchLabels {:app "keycloak"}} + :template + {:metadata {:labels {:app "keycloak"}} + :spec + {:containers + [{:name "keycloak" + :image "quay.io/keycloak/keycloak:13.0.0" + :env + [{:name "KEYCLOAK_USER", :value "testuser"} + {:name "KEYCLOAK_PASSWORD", :value "test1234"} + {:name "PROXY_ADDRESS_FORWARDING", :value "true"}] + :ports [{:name "http", :containerPort 8080}] + :readinessProbe {:httpGet {:path "/auth/realms/master", :port 8080}}}]}}}} (cut/generate-deployment {:user-name "testuser" :user-password "test1234"})))) - -(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 ingress-yaml [:spec :rules :host] fqdn)))) - ) - -