breaking: widen spec for ingress usage

This commit is contained in:
jerger 2022-12-26 18:05:52 +01:00
parent 167c58be08
commit 2c8ce98d66
3 changed files with 20 additions and 6 deletions

View file

@ -7,7 +7,6 @@
:cljs [orchestra.core :refer-macros [defn-spec]])
[dda.c4k-common.predicate :as cp]))
;; deprecated functions were moved to dda.c4k-common.predicate
(defn ^{:deprecated "0.1"} bash-env-string?
[input]
@ -26,7 +25,7 @@
(defn-spec replace-named-value cp/map-or-seq?
[coll cp/map-or-seq?
name string?
value string?]
value cp/str-or-number?]
(clojure.walk/postwalk #(if (and (map? %)
(= name (:name %)))
{:name name :value value}
@ -36,7 +35,7 @@
(defn-spec replace-key-value cp/map-or-seq?
[coll cp/map-or-seq?
key keyword?
value string?]
value cp/str-or-number?]
(clojure.walk/postwalk #(if (and (map? %)
(contains? % key))
(assoc % key value)
@ -46,7 +45,7 @@
(defn-spec replace-all-matching-values-by-new-value cp/map-or-seq?
[coll cp/map-or-seq?
value-to-match string?
value-to-replace string?]
value-to-replace cp/str-or-number?]
(clojure.walk/postwalk #(if (and (= (type value-to-match) (type %))
(= value-to-match %))
value-to-replace
@ -58,7 +57,10 @@
(into []
(apply concat vs)))
(defn generate-common [my-config my-auth config-defaults k8s-objects]
(defn generate-common
[my-config
my-auth
config-defaults k8s-objects]
(let [resulting-config (merge config-defaults my-config)]
(cs/join
"\n---\n"

View file

@ -28,7 +28,8 @@
(defn map-or-seq?
[input]
(or (map? input) (seq? input)))
(or (map? input)
(seq? input)))
(defn pvc-storage-class-name?
[input]
@ -65,3 +66,9 @@
(and (int? input)
(> input n)))
(defn str-or-number?
[input]
(or
(string? input)
(number? input)))

View file

@ -72,3 +72,8 @@
(is (cut/int-gt-n? 5 6))
(is ((partial cut/int-gt-n? 5) 10))
(is (not ((partial cut/int-gt-n? 5) 4))))
(deftest test-str-or-number?
(is (cut/str-or-number? "string"))
(is (cut/str-or-number? 42))
(is (not (cut/str-or-number? []))))