added load-as-edn as function

This commit is contained in:
bom 2022-05-13 14:19:16 +02:00
parent 48e76ad686
commit 56e30b0b5f
2 changed files with 37 additions and 1 deletions

View file

@ -37,3 +37,8 @@
(defmethod load-resource :clj [resource-name] (defmethod load-resource :clj [resource-name]
(slurp (io/resource resource-name))) (slurp (io/resource resource-name)))
(defmulti load-as-edn dispatch-by-resource-name)
(defmethod load-as-edn :clj [resource-name]
(from-string (load-resource resource-name)))

View file

@ -51,3 +51,34 @@
{:serviceName "another_keycloak" {:serviceName "another_keycloak"
:servicePort 8081}}]}}]}} :servicePort 8081}}]}}]}}
(cut/from-string (cut/load-resource "test/ingress_test.yaml"))))) (cut/from-string (cut/load-resource "test/ingress_test.yaml")))))
(deftest should-directly-convert-config-yml-to-map
(is (= {:apiVersion "networking.k8s.io/v1beta1"
:kind "Ingress"
:metadata
{:name "ingress-cloud"
:annotations
{:cert-manager.io/cluster-issuer
"letsencrypt-staging-issuer"
:nginx.ingress.kubernetes.io/proxy-body-size "256m"
:nginx.ingress.kubernetes.io/ssl-redirect "true"
:nginx.ingress.kubernetes.io/rewrite-target "/"
:nginx.ingress.kubernetes.io/proxy-connect-timeout "300"
:nginx.ingress.kubernetes.io/proxy-send-timeout "300"
:nginx.ingress.kubernetes.io/proxy-read-timeout "300"}
:namespace "default"}
:spec
{:tls [{:hosts ["fqdn"], :secretName "keycloak-secret"}]
:rules
[{:host "fqdn"
:http
{:paths
[{:backend
{:serviceName "keycloak", :servicePort 8080}}]}}
{:host "fqdn"
:http
{:paths
[{:backend
{:serviceName "another_keycloak"
:servicePort 8081}}]}}]}}
(cut/load-as-edn "test/ingress_test.yaml"))))