shadow-cljs/resource need literal string

merge-requests/2/head
erik 2 years ago
parent 1cadd0e993
commit 6358701732

@ -33,16 +33,18 @@
(def postgres-function (s/keys :opt-un [::deserializer ::optional]))
#?(:cljs
(defmethod yaml/allowed-resources :postgres []
["postgres/config-2gb.yaml"
"postgres/config-4gb.yaml"
"postgres/config-8gb.yaml"
"postgres/config-16gb.yaml"
"postgres/deployment.yaml"
"postgres/persistent-volume.yaml"
"postgres/pvc.yaml"
"postgres/secret.yaml"
"postgres/service.yaml"]))
(defmethod yaml/load-resource :postgres [resource-name]
(case resource-name
"postgres/config-2gb.yaml" (rc/inline "postgres/config-2gb.yaml")
"postgres/config-4gb.yaml" (rc/inline "postgres/config-4gb.yaml")
"postgres/config-8gb.yaml" (rc/inline "postgres/config-8gb.yaml")
"postgres/config-16gb.yaml" (rc/inline "postgres/config-16gb.yaml")
"postgres/deployment.yaml" (rc/inline "postgres/deployment.yaml")
"postgres/persistent-volume.yaml" (rc/inline "postgres/persistent-volume.yaml")
"postgres/pvc.yaml" (rc/inline "postgres/pvc.yaml")
"postgres/secret.yaml" (rc/inline "postgres/secret.yaml")
"postgres/service.yaml" (rc/inline "postgres/service.yaml")
(throw (js/Error. "Undefined Resource!")))))
(defn-spec generate-config cp/map-or-seq?
[& config (s/? pg-config?)]

@ -24,16 +24,10 @@
(defmulti load-resource dispatch-by-resource-name)
(defmethod load-resource :default [allowed-resources resource-name]
(if (some #(= % resource-name) allowed-resources)
(rc/inline resource-name)
(throw (js/Error. "Undefined Resource!"))))
(defmulti load-as-edn dispatch-by-resource-name)
(defmethod load-as-edn :default [resource-name]
(let [allowed-resources (allowed-resources)]
(from-string (load-resource allowed-resources resource-name))))
(from-string (load-resource resource-name)))
(defmulti allowed-resources dispatch-by-resource-name)

@ -9,8 +9,10 @@
(st/instrument `cut/to-string)
(st/instrument `cut/dispatch-by-resource-name)
#?(:cljs (defmethod cut/allowed-resources :cljs []
["test/ingress_test.yaml"]))
(defmethod cut/load-resource :test [resource-name]
(case resource-name
"test/ingress_test.yaml" (rc/inline "test/ingress_test.yaml")
(throw (js/Error. "Undefined Resource!"))))
(deftest should-dispatch-by-resource-name
(is (= :postgres

Loading…
Cancel
Save