breaking: widen spec for ingress usage

pull/1/head
jerger 1 year ago
parent 167c58be08
commit 2c8ce98d66

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

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

@ -72,3 +72,8 @@
(is (cut/int-gt-n? 5 6)) (is (cut/int-gt-n? 5 6))
(is ((partial cut/int-gt-n? 5) 10)) (is ((partial cut/int-gt-n? 5) 10))
(is (not ((partial cut/int-gt-n? 5) 4)))) (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? []))))

Loading…
Cancel
Save