prep for release

This commit is contained in:
see 2022-05-13 15:58:07 +02:00
parent 2fab2a1335
commit c9f4bff103
4 changed files with 46 additions and 42 deletions

View file

@ -1,33 +1,33 @@
{ {
"name": "c4k-shynet", "name": "c4k-shynet",
"description": "Generate c4k yaml for a shynet deployment.", "description": "Generate c4k yaml for a shynet deployment.",
"author": "meissa GmbH", "author": "meissa GmbH",
"version": "1.0.6-SNAPSHOT", "version": "1.0.6",
"homepage": "https://gitlab.com/domaindrivenarchitecture/c4k-shynet#readme", "homepage": "https://gitlab.com/domaindrivenarchitecture/c4k-shynet#readme",
"repository": "https://www.npmjs.com/package/c4k-shynet", "repository": "https://www.npmjs.com/package/c4k-shynet",
"license": "APACHE2", "license": "APACHE2",
"main": "c4k-shynet.js", "main": "c4k-shynet.js",
"bin": { "bin": {
"c4k-shynet": "./c4k-shynet.js" "c4k-shynet": "./c4k-shynet.js"
}, },
"keywords": [ "keywords": [
"cljs", "cljs",
"shynet", "shynet",
"k8s", "k8s",
"c4k", "c4k",
"deployment", "deployment",
"yaml", "yaml",
"convention4kubernetes" "convention4kubernetes"
], ],
"bugs": { "bugs": {
"url": "https://gitlab.com/domaindrivenarchitecture/c4k-shynet/issues" "url": "https://gitlab.com/domaindrivenarchitecture/c4k-shynet/issues"
}, },
"dependencies": { "dependencies": {
"js-base64": "^3.6.1", "js-base64": "^3.6.1",
"js-yaml": "^4.0.0" "js-yaml": "^4.0.0"
}, },
"devDependencies": { "devDependencies": {
"shadow-cljs": "^2.11.18", "shadow-cljs": "^2.11.18",
"source-map-support": "^0.5.19" "source-map-support": "^0.5.19"
} }
} }

View file

@ -5,7 +5,7 @@
:url "https://www.apache.org/licenses/LICENSE-2.0.html"} :url "https://www.apache.org/licenses/LICENSE-2.0.html"}
:dependencies [[org.clojure/clojure "1.10.3"] :dependencies [[org.clojure/clojure "1.10.3"]
[org.clojure/tools.reader "1.3.6"] [org.clojure/tools.reader "1.3.6"]
[org.domaindrivenarchitecture/c4k-common-clj "2.0.1"] [org.domaindrivenarchitecture/c4k-common-clj "2.0.3"]
[hickory "0.7.1"]] [hickory "0.7.1"]]
:target-path "target/%s/" :target-path "target/%s/"
:source-paths ["src/main/cljc" :source-paths ["src/main/cljc"

View file

@ -4,7 +4,7 @@
"src/test/cljc" "src/test/cljc"
"src/test/cljs" "src/test/cljs"
"src/test/resources"] "src/test/resources"]
:dependencies [[org.domaindrivenarchitecture/c4k-common-cljs "2.0.1"] :dependencies [[org.domaindrivenarchitecture/c4k-common-cljs "2.0.3"]
[hickory "0.7.1"]] [hickory "0.7.1"]]
:builds {:frontend {:target :browser :builds {:frontend {:target :browser
:modules {:main {:init-fn dda.c4k-shynet.browser/init}} :modules {:main {:init-fn dda.c4k-shynet.browser/init}}

View file

@ -21,11 +21,15 @@
"shynet/service-webserver.yaml" (rc/inline "shynet/service-webserver.yaml") "shynet/service-webserver.yaml" (rc/inline "shynet/service-webserver.yaml")
"shynet/statefulset.yaml" (rc/inline "shynet/statefulset.yaml") "shynet/statefulset.yaml" (rc/inline "shynet/statefulset.yaml")
(throw (js/Error. "Undefined Resource!"))))) (throw (js/Error. "Undefined Resource!")))))
#?(:cljs
(defmethod yaml/load-as-edn :shynet [resource-name]
(yaml/from-string (yaml/load-resource resource-name))))
(defn generate-secret [config] (defn generate-secret [config]
(let [{:keys [fqdn django-secret-key postgres-db-user postgres-db-password]} config] (let [{:keys [fqdn django-secret-key postgres-db-user postgres-db-password]} config]
(-> (->
(yaml/from-string (yaml/load-resource "shynet/secret.yaml")) (yaml/load-as-edn "shynet/secret.yaml")
; TODO: See comment in secret.yaml ; TODO: See comment in secret.yaml
;(assoc-in [:stringData :ALLOWED_HOSTS] fqdn) ;(assoc-in [:stringData :ALLOWED_HOSTS] fqdn)
(assoc-in [:stringData :DJANGO_SECRET_KEY] django-secret-key) (assoc-in [:stringData :DJANGO_SECRET_KEY] django-secret-key)
@ -36,20 +40,20 @@
(let [{:keys [fqdn issuer]} config (let [{:keys [fqdn issuer]} config
letsencrypt-issuer (name issuer)] letsencrypt-issuer (name issuer)]
(-> (->
(yaml/from-string (yaml/load-resource "shynet/certificate.yaml")) (yaml/load-as-edn "shynet/certificate.yaml")
(assoc-in [:spec :commonName] fqdn) (assoc-in [:spec :commonName] fqdn)
(assoc-in [:spec :dnsNames] [fqdn]) (assoc-in [:spec :dnsNames] [fqdn])
(assoc-in [:spec :issuerRef :name] letsencrypt-issuer)))) (assoc-in [:spec :issuerRef :name] letsencrypt-issuer))))
(defn generate-webserver-deployment [] (defn generate-webserver-deployment []
(let [shynet-application "shynet-webserver"] (let [shynet-application "shynet-webserver"]
(-> (yaml/from-string (yaml/load-resource "shynet/deployments.yaml")) (-> (yaml/load-as-edn "shynet/deployments.yaml")
(cm/replace-all-matching-values-by-new-value "shynet-application" shynet-application) (cm/replace-all-matching-values-by-new-value "shynet-application" shynet-application)
(update-in [:spec :template :spec :containers 0] dissoc :command)))) (update-in [:spec :template :spec :containers 0] dissoc :command))))
(defn generate-celeryworker-deployment [] (defn generate-celeryworker-deployment []
(let [shynet-application "shynet-celeryworker"] (let [shynet-application "shynet-celeryworker"]
(-> (yaml/from-string (yaml/load-resource "shynet/deployments.yaml")) (-> (yaml/load-as-edn "shynet/deployments.yaml")
(cm/replace-all-matching-values-by-new-value "shynet-application" shynet-application)))) (cm/replace-all-matching-values-by-new-value "shynet-application" shynet-application))))
(defn generate-ingress [config] (defn generate-ingress [config]
@ -57,15 +61,15 @@
:or {issuer :staging}} config :or {issuer :staging}} config
letsencrypt-issuer (name issuer)] letsencrypt-issuer (name issuer)]
(-> (->
(yaml/from-string (yaml/load-resource "shynet/ingress.yaml")) (yaml/load-as-edn "shynet/ingress.yaml")
(assoc-in [:metadata :annotations :cert-manager.io/cluster-issuer] letsencrypt-issuer) (assoc-in [:metadata :annotations :cert-manager.io/cluster-issuer] letsencrypt-issuer)
(cm/replace-all-matching-values-by-new-value "fqdn" fqdn)))) (cm/replace-all-matching-values-by-new-value "fqdn" fqdn))))
(defn generate-statefulset [] (defn generate-statefulset []
(yaml/from-string (yaml/load-resource "shynet/statefulset.yaml"))) (yaml/load-as-edn "shynet/statefulset.yaml"))
(defn generate-service-redis [] (defn generate-service-redis []
(yaml/from-string (yaml/load-resource "shynet/service-redis.yaml"))) (yaml/load-as-edn "shynet/service-redis.yaml"))
(defn generate-service-webserver [] (defn generate-service-webserver []
(yaml/from-string (yaml/load-resource "shynet/service-webserver.yaml"))) (yaml/load-as-edn "shynet/service-webserver.yaml"))