diff --git a/src/main/cljc/dda/c4k_common/postgres.cljc b/src/main/cljc/dda/c4k_common/postgres.cljc index 97d0956..314e745 100644 --- a/src/main/cljc/dda/c4k_common/postgres.cljc +++ b/src/main/cljc/dda/c4k_common/postgres.cljc @@ -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?)] diff --git a/src/main/cljs/dda/c4k_common/yaml.cljs b/src/main/cljs/dda/c4k_common/yaml.cljs index ef31be5..f64612f 100644 --- a/src/main/cljs/dda/c4k_common/yaml.cljs +++ b/src/main/cljs/dda/c4k_common/yaml.cljs @@ -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) diff --git a/src/test/cljs/dda/c4k_common/yaml_test.cljs b/src/test/cljs/dda/c4k_common/yaml_test.cljs index 4f43ce5..9b2775b 100644 --- a/src/test/cljs/dda/c4k_common/yaml_test.cljs +++ b/src/test/cljs/dda/c4k_common/yaml_test.cljs @@ -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