From 930e520c42099f5890ec439bf26cf01f6f2844f7 Mon Sep 17 00:00:00 2001 From: bom Date: Fri, 9 Jul 2021 16:53:38 +0200 Subject: [PATCH] yaml multimethod, added postgres --- package.json | 2 +- project-cljs.clj | 2 +- project.clj | 2 +- src/main/cljc/dda/c4k_common/postgres.cljc | 14 +++++++++++++- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index f8c2c2b..904966a 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "c4k-common-cljs", "description": "Contains predicates and tools for c4k", "author": "meissa GmbH", - "version": "0.1.0-SNAPSHOT", + "version": "0.2.0-SNAPSHOT", "homepage": "https://gitlab.com/domaindrivenarchitecture/c4k-common#readme", "repository": "https://www.npmjs.com/package/c4k-common", "license": "APACHE2", diff --git a/project-cljs.clj b/project-cljs.clj index 07fc2f4..c85ac7b 100644 --- a/project-cljs.clj +++ b/project-cljs.clj @@ -1,4 +1,4 @@ -(defproject org.domaindrivenarchitecture/c4k-common-cljs "0.1.0-SNAPSHOT" +(defproject org.domaindrivenarchitecture/c4k-common-cljs "0.2.0-SNAPSHOT" :description "Contains predicates and tools for c4k" :url "https://domaindrivenarchitecture.org" :license {:name "Apache License, Version 2.0" diff --git a/project.clj b/project.clj index ef8fee5..293fffc 100644 --- a/project.clj +++ b/project.clj @@ -1,4 +1,4 @@ -(defproject org.domaindrivenarchitecture/c4k-common-clj "0.1.0-SNAPSHOT" +(defproject org.domaindrivenarchitecture/c4k-common-clj "0.2.0-SNAPSHOT" :description "Contains predicates and tools for c4k" :url "https://domaindrivenarchitecture.org" :license {:name "Apache License, Version 2.0" diff --git a/src/main/cljc/dda/c4k_common/postgres.cljc b/src/main/cljc/dda/c4k_common/postgres.cljc index d284030..8ef0a06 100644 --- a/src/main/cljc/dda/c4k_common/postgres.cljc +++ b/src/main/cljc/dda/c4k_common/postgres.cljc @@ -1,6 +1,7 @@ (ns dda.c4k-common.postgres (:require [clojure.spec.alpha :as s] + #?(:cljs [shadow.resource :as rc]) [dda.c4k-common.yaml :as yaml] [dda.c4k-common.base64 :as b64] [dda.c4k-common.common :as cm])) @@ -9,8 +10,19 @@ (s/def ::postgres-db-password cm/bash-env-string?) (s/def ::postgres-data-volume-path string?) +#?(:cljs + (defmethod yaml/load-resource :postgres [resource-name] + (case resource-name + "postgres/config.yaml" (rc/inline "postgres/config.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 generate-config [] - (yaml/from-string (yaml/load-resource "postgres/config.yaml"))) + (yaml/from-string (yaml/load-resource "postgres/config.yaml"))) (defn generate-deployment [] (yaml/from-string (yaml/load-resource "postgres/deployment.yaml")))