From aa9bfc482d3e0d623fbc92043cbf3d0b025e8dc8 Mon Sep 17 00:00:00 2001 From: patdyn Date: Wed, 28 Aug 2024 14:24:23 +0200 Subject: [PATCH] Update and test deployment generation --- src/main/cljc/dda/c4k_keycloak/keycloak.cljc | 7 +-- .../cljc/dda/c4k_keycloak/keycloak_test.cljc | 60 +------------------ 2 files changed, 5 insertions(+), 62 deletions(-) diff --git a/src/main/cljc/dda/c4k_keycloak/keycloak.cljc b/src/main/cljc/dda/c4k_keycloak/keycloak.cljc index f710501..8a33df4 100644 --- a/src/main/cljc/dda/c4k_keycloak/keycloak.cljc +++ b/src/main/cljc/dda/c4k_keycloak/keycloak.cljc @@ -55,12 +55,11 @@ (-> (yaml/load-as-edn "keycloak/service.yaml") (cm/replace-all-matching "NAMESPACE" namespace)))) -; TODO: Fix test + (defn-spec generate-deployment cp/map-or-seq? [config config?] (let [{:keys [fqdn namespace]} config] - (-> + (-> (yaml/load-as-edn "keycloak/deployment.yaml") - (cm/replace-all-matching "NAMESPACE" namespace) - (cm/replace-all-matching "FQDN" fqdn)))) + (cm/replace-all-matching "NAMESPACE" namespace)))) diff --git a/src/test/cljc/dda/c4k_keycloak/keycloak_test.cljc b/src/test/cljc/dda/c4k_keycloak/keycloak_test.cljc index 8c9d17e..630a38f 100644 --- a/src/test/cljc/dda/c4k_keycloak/keycloak_test.cljc +++ b/src/test/cljc/dda/c4k_keycloak/keycloak_test.cljc @@ -18,61 +18,5 @@ (cut/generate-secret {:namespace "keycloak" :fqdn "test.de"} {:keycloak-admin-user "user" :keycloak-admin-password "password"})))) (deftest should-generate-deployment - (is (= {:apiVersion "apps/v1", - :kind "Deployment", - :metadata - {:name "keycloak", :namespace "keycloak", :labels {:app "keycloak"}}, - :spec - {:replicas 1, - :selector {:matchLabels {:app "keycloak"}}, - :template - {:metadata {:labels {:app "keycloak"}}, - :spec - {:containers - [{:name "keycloak", - :image "quay.io/keycloak/keycloak:20.0.3", - :imagePullPolicy "IfNotPresent", - :args ["start"], - :volumeMounts - [{:name "keycloak-cert", - :mountPath "/etc/certs", - :readOnly true}], - :env - [{:name "KC_HTTPS_CERTIFICATE_FILE", - :value "/etc/certs/tls.crt"} - {:name "KC_HTTPS_CERTIFICATE_KEY_FILE", - :value "/etc/certs/tls.key"} - {:name "KC_HOSTNAME", :value "test.de"} - {:name "KC_PROXY", :value "edge"} - {:name "DB_VENDOR", :value "POSTGRES"} - {:name "DB_ADDR", :value "postgresql-service"} - {:name "DB_SCHEMA", :value "public"} - {:name "DB_DATABASE", - :valueFrom - {:configMapKeyRef - {:name "postgres-config", :key "postgres-db"}}} - {:name "DB_USER", - :valueFrom - {:secretKeyRef - {:name "postgres-secret", :key "postgres-user"}}} - {:name "DB_PASSWORD", - :valueFrom - {:secretKeyRef - {:name "postgres-secret", :key "postgres-password"}}} - {:name "KEYCLOAK_ADMIN", - :valueFrom - {:secretKeyRef - {:name "keycloak-secret", :key "keycloak-user"}}} - {:name "KEYCLOAK_ADMIN_PASSWORD", - :valueFrom - {:secretKeyRef - {:name "keycloak-secret", :key "keycloak-password"}}}], - :ports [{:name "http", :containerPort 8080}]}], - :volumes - [{:name "keycloak-cert", - :secret - {:secretName "keycloak", - :items - [{:key "tls.crt", :path "tls.crt"} - {:key "tls.key", :path "tls.key"}]}}]}}}} - (cut/generate-deployment {:fqdn "test.de" :namespace "keycloak"})))) + (is (= {:name "keycloak", :namespace "keycloak", :labels {:app "keycloak"}} + (:metadata (cut/generate-deployment {:fqdn "example.com" :namespace "keycloak"})))))