use c4k-common

This commit is contained in:
jem 2021-06-18 17:36:57 +02:00
parent f542121386
commit 4f9e7e889d
8 changed files with 7 additions and 78 deletions

View file

@ -15,7 +15,7 @@
"keycloak",
"k8s",
"c4k",
"deplyoment",
"deployment",
"yaml",
"convention4kubernetes"
],

View file

@ -5,10 +5,7 @@
:url "https://www.apache.org/licenses/LICENSE-2.0.html"}
:dependencies [[org.clojure/clojure "1.10.3"]
[org.clojure/tools.reader "1.3.4"]
[aero "1.1.6"]
[orchestra "2021.01.01-1"]
[expound "0.8.9"]
[clj-commons/clj-yaml "0.7.106"]]
[org.domaindrivenarchitecture/c4k-common-clj "0.1.0-SNAPSHOT"]]
:target-path "target/%s/"
:source-paths ["src/main/cljc"
"src/main/clj"]

View file

@ -3,9 +3,7 @@
"src/main/resources"
"src/test/cljc"
"src/test/resources"]
:dependencies [[aero "1.1.6"]
[orchestra "2021.01.01-1"]
[expound "0.8.9"]]
:dependencies [[org.domaindrivenarchitecture/c4k-common-cljs "0.1.0-SNAPSHOT"]]
:dev-http {8080 "public"}
:builds {:frontend {:target :browser
:modules {:main {:init-fn dda.c4k-keycloak.browser/init}}

View file

@ -1,14 +0,0 @@
(ns dda.c4k-keycloak.base64
(:import (java.util Base64)))
(defn encode
[string]
(.encodeToString
(Base64/getEncoder)
(.getBytes string "UTF-8")))
(defn decode
[string]
(String.
(.decode (Base64/getDecoder) string)
"UTF-8"))

View file

@ -1,41 +0,0 @@
(ns dda.c4k-keycloak.common
(:require
[clojure.walk]))
(defn bash-env-string?
[input]
(and (string? input)
(not (re-matches #".*['\"\$]+.*" input))))
(defn fqdn-string?
[input]
(and (string? input)
(some? (re-matches #"(?=^.{4,253}$)(^((?!-)[a-zA-Z0-9-]{0,62}[a-zA-Z0-9]\.)+[a-zA-Z]{2,63}$)" input))))
(defn letsencrypt-issuer?
[input]
(contains? #{:prod :staging} input))
(defn replace-named-value
[coll name value]
(clojure.walk/postwalk #(if (and (map? %)
(= name (:name %)))
{:name name :value value}
%)
coll))
(defn replace-key-value
[coll key value]
(clojure.walk/postwalk #(if (and (map? %)
(contains? % key))
(assoc % key value)
%)
coll))
(defn replace-all-matching-values-by-new-value
[coll value-to-match value-to-replace]
(clojure.walk/postwalk #(if (and (= (type value-to-match) (type %))
(= value-to-match %))
value-to-replace
%)
coll))

View file

@ -2,8 +2,8 @@
(:require
[clojure.spec.alpha :as s]
[dda.c4k-keycloak.yaml :as yaml]
[dda.c4k-keycloak.base64 :as b64]
[dda.c4k-keycloak.common :as cm]))
[dda.c4k-common.base64 :as b64]
[dda.c4k-common.common :as cm]))
(s/def ::keycloak-admin-user cm/bash-env-string?)
(s/def ::keycloak-admin-password cm/bash-env-string?)

View file

@ -2,8 +2,8 @@
(:require
[clojure.spec.alpha :as s]
[dda.c4k-keycloak.yaml :as yaml]
[dda.c4k-keycloak.base64 :as b64]
[dda.c4k-keycloak.common :as cm]))
[dda.c4k-common.base64 :as b64]
[dda.c4k-common.common :as cm]))
(s/def ::postgres-db-user cm/bash-env-string?)
(s/def ::postgres-db-password cm/bash-env-string?)

View file

@ -1,11 +0,0 @@
(ns dda.c4k-keycloak.base64
(:require
["js-base64" :as b64]))
(defn encode
[string]
(.encode b64/Base64 string))
(defn decode
[string]
(.decode b64/Base64 string))