mob finish
This commit is contained in:
parent
86a191f45a
commit
47b7a412c9
1 changed files with 18 additions and 6 deletions
|
@ -13,11 +13,19 @@
|
||||||
[input]
|
[input]
|
||||||
(contains? #{:2gb :4gb :8gb :16gb} input))
|
(contains? #{:2gb :4gb :8gb :16gb} input))
|
||||||
|
|
||||||
|
(defn postgres-image?
|
||||||
|
[input]
|
||||||
|
(contains? #{"postgres:13" "postgres:14"} input))
|
||||||
|
|
||||||
(s/def ::postgres-db-user cp/bash-env-string?)
|
(s/def ::postgres-db-user cp/bash-env-string?)
|
||||||
(s/def ::postgres-db-password cp/bash-env-string?)
|
(s/def ::postgres-db-password cp/bash-env-string?)
|
||||||
(s/def ::postgres-data-volume-path string?)
|
(s/def ::postgres-data-volume-path string?)
|
||||||
(s/def ::postgres-size postgres-size?)
|
(s/def ::postgres-size postgres-size?)
|
||||||
(s/def ::db-name cp/bash-env-string?)
|
(s/def ::db-name cp/bash-env-string?)
|
||||||
|
(defn pg-config? [input]
|
||||||
|
(s/keys :un-opt [::postgres-size ::db-name ::postgres-data-volume-path]))
|
||||||
|
(defn pg-auth? [input]
|
||||||
|
(s/keys :un-opt [::postgres-db-user ::postgres-db-password]))
|
||||||
|
|
||||||
(def postgres-function (s/keys :opt-un [::deserializer ::optional]))
|
(def postgres-function (s/keys :opt-un [::deserializer ::optional]))
|
||||||
|
|
||||||
|
@ -35,7 +43,8 @@
|
||||||
"postgres/service.yaml" (rc/inline "postgres/service.yaml")
|
"postgres/service.yaml" (rc/inline "postgres/service.yaml")
|
||||||
(throw (js/Error. "Undefined Resource!")))))
|
(throw (js/Error. "Undefined Resource!")))))
|
||||||
|
|
||||||
(defn generate-config [& args]
|
(defn-spec generate-config cp/map-or-seq?
|
||||||
|
[& args pg-config?]
|
||||||
(let [{:keys [postgres-size db-name]
|
(let [{:keys [postgres-size db-name]
|
||||||
:or {postgres-size :2gb
|
:or {postgres-size :2gb
|
||||||
db-name "postgres"}} args]
|
db-name "postgres"}} args]
|
||||||
|
@ -43,7 +52,8 @@
|
||||||
(yaml/from-string (yaml/load-resource (str "postgres/config-" (name postgres-size) ".yaml")))
|
(yaml/from-string (yaml/load-resource (str "postgres/config-" (name postgres-size) ".yaml")))
|
||||||
(assoc-in [:data :postgres-db] db-name))))
|
(assoc-in [:data :postgres-db] db-name))))
|
||||||
|
|
||||||
(defn generate-deployment [& args]
|
(defn-spec generate-deployment cp/map-or-seq?
|
||||||
|
[& args postgres-image?]
|
||||||
(let [{:keys [postgres-image]
|
(let [{:keys [postgres-image]
|
||||||
:or {postgres-image "postgres:13"}} args]
|
:or {postgres-image "postgres:13"}} args]
|
||||||
(->
|
(->
|
||||||
|
@ -51,22 +61,24 @@
|
||||||
(assoc-in [:spec :template :spec :containers 0 :image] postgres-image))))
|
(assoc-in [:spec :template :spec :containers 0 :image] postgres-image))))
|
||||||
|
|
||||||
(defn-spec generate-persistent-volume cp/map-or-seq?
|
(defn-spec generate-persistent-volume cp/map-or-seq?
|
||||||
[config (s/keys :req-un [::postgres-data-volume-path])]
|
[config pg-config?]
|
||||||
(let [{:keys [postgres-data-volume-path]} config]
|
(let [{:keys [postgres-data-volume-path]} config]
|
||||||
(->
|
(->
|
||||||
(yaml/from-string (yaml/load-resource "postgres/persistent-volume.yaml"))
|
(yaml/from-string (yaml/load-resource "postgres/persistent-volume.yaml"))
|
||||||
(assoc-in [:spec :hostPath :path] postgres-data-volume-path))))
|
(assoc-in [:spec :hostPath :path] postgres-data-volume-path))))
|
||||||
|
|
||||||
(defn-spec generate-pvc cp/map-or-seq? []
|
(defn-spec generate-pvc cp/map-or-seq?
|
||||||
|
[]
|
||||||
(yaml/from-string (yaml/load-resource "postgres/pvc.yaml")))
|
(yaml/from-string (yaml/load-resource "postgres/pvc.yaml")))
|
||||||
|
|
||||||
(defn-spec generate-secret cp/map-or-seq?
|
(defn-spec generate-secret cp/map-or-seq?
|
||||||
[my-auth (s/keys :req-un [::postgres-db-user ::postgres-db-password])]
|
[my-auth pg-auth?]
|
||||||
(let [{:keys [postgres-db-user postgres-db-password]} my-auth]
|
(let [{:keys [postgres-db-user postgres-db-password]} my-auth]
|
||||||
(->
|
(->
|
||||||
(yaml/from-string (yaml/load-resource "postgres/secret.yaml"))
|
(yaml/from-string (yaml/load-resource "postgres/secret.yaml"))
|
||||||
(cm/replace-key-value :postgres-user (b64/encode postgres-db-user))
|
(cm/replace-key-value :postgres-user (b64/encode postgres-db-user))
|
||||||
(cm/replace-key-value :postgres-password (b64/encode postgres-db-password)))))
|
(cm/replace-key-value :postgres-password (b64/encode postgres-db-password)))))
|
||||||
|
|
||||||
(defn-spec generate-service cp/map-or-seq? []
|
(defn-spec generate-service cp/map-or-seq?
|
||||||
|
[]
|
||||||
(yaml/from-string (yaml/load-resource "postgres/service.yaml")))
|
(yaml/from-string (yaml/load-resource "postgres/service.yaml")))
|
||||||
|
|
Loading…
Reference in a new issue