Add some postwalk experiments
This commit is contained in:
parent
558653d698
commit
2244778187
2 changed files with 17 additions and 2 deletions
|
@ -4,7 +4,8 @@
|
||||||
[clojure.spec.alpha :as s]
|
[clojure.spec.alpha :as s]
|
||||||
#?(:clj [orchestra.core :refer [defn-spec]]
|
#?(:clj [orchestra.core :refer [defn-spec]]
|
||||||
:cljs [orchestra.core :refer-macros [defn-spec]])
|
:cljs [orchestra.core :refer-macros [defn-spec]])
|
||||||
[dda.k8s-keycloak.yaml :as yaml]))
|
[dda.k8s-keycloak.yaml :as yaml]
|
||||||
|
[clojure.walk]))
|
||||||
|
|
||||||
(defn bash-env-string?
|
(defn bash-env-string?
|
||||||
[input]
|
[input]
|
||||||
|
@ -26,6 +27,19 @@
|
||||||
|
|
||||||
(def auth? (s/keys :req-un [::user-name ::user-password]))
|
(def auth? (s/keys :req-un [::user-name ::user-password]))
|
||||||
|
|
||||||
|
(defn cast-lazy-seq-to-vec
|
||||||
|
[lazy-seq]
|
||||||
|
(clojure.walk/postwalk #(if (instance? clojure.lang.LazySeq %)
|
||||||
|
(do (println %) (into [] %))
|
||||||
|
%) lazy-seq))
|
||||||
|
|
||||||
|
(defn replace-all-matching-values-by-new-value
|
||||||
|
[value-to-match value-to-replace coll]
|
||||||
|
(clojure.walk/postwalk #(if (and (= (type value-to-match) (type %))
|
||||||
|
(= value-to-match %))
|
||||||
|
value-to-replace
|
||||||
|
%) coll))
|
||||||
|
|
||||||
(declare assoc-in-nested)
|
(declare assoc-in-nested)
|
||||||
(declare assoc-in-nested-seq)
|
(declare assoc-in-nested-seq)
|
||||||
(declare assoc-in-nested-map)
|
(declare assoc-in-nested-map)
|
||||||
|
|
|
@ -95,7 +95,8 @@
|
||||||
:http {:paths [{:backend {:serviceName "another_keycloak"
|
:http {:paths [{:backend {:serviceName "another_keycloak"
|
||||||
:servicePort 8081}}]}}
|
:servicePort 8081}}]}}
|
||||||
]))]
|
]))]
|
||||||
(is (= desired-result (cut/assoc-in-nested ingress-yaml [:spec :rules :host] fqdn))))
|
(is (= desired-result
|
||||||
|
(cut/assoc-in-nested (cut/cast-lazy-seq-to-vec ingress-yaml) [:spec :rules :host] fqdn))))
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue