yaml multimethod, added postgres

This commit is contained in:
bom 2021-07-09 16:53:38 +02:00
parent 67631747ae
commit 930e520c42
4 changed files with 16 additions and 4 deletions

View file

@ -2,7 +2,7 @@
"name": "c4k-common-cljs", "name": "c4k-common-cljs",
"description": "Contains predicates and tools for c4k", "description": "Contains predicates and tools for c4k",
"author": "meissa GmbH", "author": "meissa GmbH",
"version": "0.1.0-SNAPSHOT", "version": "0.2.0-SNAPSHOT",
"homepage": "https://gitlab.com/domaindrivenarchitecture/c4k-common#readme", "homepage": "https://gitlab.com/domaindrivenarchitecture/c4k-common#readme",
"repository": "https://www.npmjs.com/package/c4k-common", "repository": "https://www.npmjs.com/package/c4k-common",
"license": "APACHE2", "license": "APACHE2",

View file

@ -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" :description "Contains predicates and tools for c4k"
:url "https://domaindrivenarchitecture.org" :url "https://domaindrivenarchitecture.org"
:license {:name "Apache License, Version 2.0" :license {:name "Apache License, Version 2.0"

View file

@ -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" :description "Contains predicates and tools for c4k"
:url "https://domaindrivenarchitecture.org" :url "https://domaindrivenarchitecture.org"
:license {:name "Apache License, Version 2.0" :license {:name "Apache License, Version 2.0"

View file

@ -1,6 +1,7 @@
(ns dda.c4k-common.postgres (ns dda.c4k-common.postgres
(:require (:require
[clojure.spec.alpha :as s] [clojure.spec.alpha :as s]
#?(:cljs [shadow.resource :as rc])
[dda.c4k-common.yaml :as yaml] [dda.c4k-common.yaml :as yaml]
[dda.c4k-common.base64 :as b64] [dda.c4k-common.base64 :as b64]
[dda.c4k-common.common :as cm])) [dda.c4k-common.common :as cm]))
@ -9,6 +10,17 @@
(s/def ::postgres-db-password cm/bash-env-string?) (s/def ::postgres-db-password cm/bash-env-string?)
(s/def ::postgres-data-volume-path 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 [] (defn generate-config []
(yaml/from-string (yaml/load-resource "postgres/config.yaml"))) (yaml/from-string (yaml/load-resource "postgres/config.yaml")))