[WIP] Update postgres and tests
This commit is contained in:
parent
65dd1d1ca2
commit
1cadd0e993
3 changed files with 24 additions and 24 deletions
|
@ -33,18 +33,16 @@
|
||||||
(def postgres-function (s/keys :opt-un [::deserializer ::optional]))
|
(def postgres-function (s/keys :opt-un [::deserializer ::optional]))
|
||||||
|
|
||||||
#?(:cljs
|
#?(:cljs
|
||||||
(defmethod yaml/load-resource :postgres [resource-name]
|
(defmethod yaml/allowed-resources :postgres []
|
||||||
(case resource-name
|
["postgres/config-2gb.yaml"
|
||||||
"postgres/config-2gb.yaml" (rc/inline "postgres/config-2gb.yaml")
|
"postgres/config-4gb.yaml"
|
||||||
"postgres/config-4gb.yaml" (rc/inline "postgres/config-4gb.yaml")
|
"postgres/config-8gb.yaml"
|
||||||
"postgres/config-8gb.yaml" (rc/inline "postgres/config-8gb.yaml")
|
"postgres/config-16gb.yaml"
|
||||||
"postgres/config-16gb.yaml" (rc/inline "postgres/config-16gb.yaml")
|
"postgres/deployment.yaml"
|
||||||
"postgres/deployment.yaml" (rc/inline "postgres/deployment.yaml")
|
"postgres/persistent-volume.yaml"
|
||||||
"postgres/persistent-volume.yaml" (rc/inline "postgres/persistent-volume.yaml")
|
"postgres/pvc.yaml"
|
||||||
"postgres/pvc.yaml" (rc/inline "postgres/pvc.yaml")
|
"postgres/secret.yaml"
|
||||||
"postgres/secret.yaml" (rc/inline "postgres/secret.yaml")
|
"postgres/service.yaml"]))
|
||||||
"postgres/service.yaml" (rc/inline "postgres/service.yaml")
|
|
||||||
(throw (js/Error. "Undefined Resource!")))))
|
|
||||||
|
|
||||||
(defn-spec generate-config cp/map-or-seq?
|
(defn-spec generate-config cp/map-or-seq?
|
||||||
[& config (s/? pg-config?)]
|
[& config (s/? pg-config?)]
|
||||||
|
|
|
@ -6,6 +6,9 @@
|
||||||
[shadow.resource :as rc]
|
[shadow.resource :as rc]
|
||||||
[dda.c4k-common.predicate :as cp]))
|
[dda.c4k-common.predicate :as cp]))
|
||||||
|
|
||||||
|
(defn string-or-keyword? [input]
|
||||||
|
(or (string? input) (keyword? input)))
|
||||||
|
|
||||||
(defn-spec from-string cp/map-or-seq?
|
(defn-spec from-string cp/map-or-seq?
|
||||||
[input string?]
|
[input string?]
|
||||||
(js->clj (yaml/load input)
|
(js->clj (yaml/load input)
|
||||||
|
@ -16,22 +19,23 @@
|
||||||
(yaml/dump (clj->js edn)))
|
(yaml/dump (clj->js edn)))
|
||||||
|
|
||||||
(defn-spec dispatch-by-resource-name keyword?
|
(defn-spec dispatch-by-resource-name keyword?
|
||||||
[resource string?]
|
[resource string-or-keyword?]
|
||||||
:cljs)
|
(keyword (first (st/split resource #"/"))))
|
||||||
|
|
||||||
(defmulti load-resource dispatch-by-resource-name)
|
(defmulti load-resource dispatch-by-resource-name)
|
||||||
|
|
||||||
(defmethod load-resource :cljs [allowed-resources resource-name]
|
(defmethod load-resource :default [allowed-resources resource-name]
|
||||||
(if (some #(= % resource-name) allowed-resources)
|
(if (some #(= % resource-name) allowed-resources)
|
||||||
(rc/inline resource-name)
|
(rc/inline resource-name)
|
||||||
(throw (js/Error. "Undefined Resource!"))))
|
(throw (js/Error. "Undefined Resource!"))))
|
||||||
|
|
||||||
(defmulti load-as-edn dispatch-by-resource-name)
|
(defmulti load-as-edn dispatch-by-resource-name)
|
||||||
|
|
||||||
(defmethod load-as-edn :cljs [allowed-resource resource-name]
|
(defmethod load-as-edn :default [resource-name]
|
||||||
(from-string (load-resource (allowed-resource) resource-name)))
|
(let [allowed-resources (allowed-resources)]
|
||||||
|
(from-string (load-resource allowed-resources resource-name))))
|
||||||
|
|
||||||
(defmulti allowed-resources dispatch-by-resource-name)
|
(defmulti allowed-resources dispatch-by-resource-name)
|
||||||
|
|
||||||
(defmethod allowed-resources :cljs []
|
(defmethod allowed-resources :default []
|
||||||
[])
|
[])
|
|
@ -9,10 +9,8 @@
|
||||||
(st/instrument `cut/to-string)
|
(st/instrument `cut/to-string)
|
||||||
(st/instrument `cut/dispatch-by-resource-name)
|
(st/instrument `cut/dispatch-by-resource-name)
|
||||||
|
|
||||||
(defmethod cut/load-resource :test [resource-name]
|
#?(:cljs (defmethod cut/allowed-resources :cljs []
|
||||||
(case resource-name
|
["test/ingress_test.yaml"]))
|
||||||
"test/ingress_test.yaml" (rc/inline "test/ingress_test.yaml")
|
|
||||||
(throw (js/Error. "Undefined Resource!"))))
|
|
||||||
|
|
||||||
(deftest should-dispatch-by-resource-name
|
(deftest should-dispatch-by-resource-name
|
||||||
(is (= :postgres
|
(is (= :postgres
|
||||||
|
@ -56,4 +54,4 @@
|
||||||
[{:backend
|
[{:backend
|
||||||
{:serviceName "another_keycloak"
|
{:serviceName "another_keycloak"
|
||||||
:servicePort 8081}}]}}]}}
|
:servicePort 8081}}]}}]}}
|
||||||
(cut/from-string (cut/load-resource "test/ingress_test.yaml")))))
|
(cut/load-as-edn "test/ingress_test.yaml"))))
|
||||||
|
|
Loading…
Reference in a new issue