Refactor main to use main-cm #1
5 changed files with 31 additions and 31 deletions
13
project.clj
13
project.clj
|
@ -4,13 +4,14 @@
|
|||
:license {:name "Apache License, Version 2.0"
|
||||
:url "https://www.apache.org/licenses/LICENSE-2.0.html"}
|
||||
:dependencies [[org.clojure/clojure "1.11.1"]
|
||||
[org.clojure/tools.reader "1.3.6"]
|
||||
[org.domaindrivenarchitecture/c4k-common-clj "2.0.3"]
|
||||
[org.clojure/tools.reader "1.4.2"]
|
||||
[org.domaindrivenarchitecture/c4k-common-clj "6.4.0"]
|
||||
[hickory "0.7.1" :exclusions [viebel/codox-klipse-theme]]]
|
||||
:target-path "target/%s/"
|
||||
:source-paths ["src/main/cljc"
|
||||
"src/main/clj"]
|
||||
:resource-paths ["src/main/resources"]
|
||||
:resource-paths ["src/main/resources"
|
||||
"project.clj"]
|
||||
:repositories [["snapshots" :clojars]
|
||||
["releases" :clojars]]
|
||||
:deploy-repositories [["snapshots" {:sign-releases false :url "https://clojars.org/repo"}]
|
||||
|
@ -22,10 +23,10 @@
|
|||
:uberjar {:aot :all
|
||||
:main dda.c4k-shynet.uberjar
|
||||
:uberjar-name "c4k-shynet-standalone.jar"
|
||||
:dependencies [[org.clojure/tools.cli "1.0.214"]
|
||||
[ch.qos.logback/logback-classic "1.4.5"
|
||||
:dependencies [[org.clojure/tools.cli "1.1.230"]
|
||||
[ch.qos.logback/logback-classic "1.5.6"
|
||||
:exclusions [com.sun.mail/javax.mail]]
|
||||
[org.slf4j/jcl-over-slf4j "2.0.6"]]}}
|
||||
[org.slf4j/jcl-over-slf4j "2.0.13"]]}}
|
||||
:release-tasks [["test"]
|
||||
["vcs" "assert-committed"]
|
||||
["change" "version" "leiningen.release/bump-version" "release"]
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
"src/test/cljc"
|
||||
"src/test/cljs"
|
||||
"src/test/resources"]
|
||||
:dependencies [[org.domaindrivenarchitecture/c4k-common-cljs "2.0.3"]
|
||||
:dependencies [[org.domaindrivenarchitecture/c4k-common-cljs "6.4.0"]
|
||||
[hickory "0.7.1"]]
|
||||
:builds {:frontend {:target :browser
|
||||
:modules {:main {:init-fn dda.c4k-shynet.browser/init}}
|
||||
|
|
|
@ -5,4 +5,4 @@
|
|||
[dda.c4k-common.uberjar :as uberjar]))
|
||||
|
||||
(defn -main [& cmd-args]
|
||||
(uberjar/main-common "c4k-shynet" core/config? core/auth? core/config-defaults core/k8s-objects cmd-args))
|
||||
(uberjar/main-cm "c4k-shynet" core/config? core/auth? core/config-defaults core/config-objects core/auth-objects cmd-args))
|
||||
|
|
|
@ -16,19 +16,17 @@
|
|||
(def auth? (s/keys :req-un [::shynet/django-secret-key
|
||||
::postgres/postgres-db-user ::postgres/postgres-db-password]))
|
||||
|
||||
(defn k8s-objects [config]
|
||||
(defn config-objects [config]
|
||||
(let [storage-class (if (contains? config :postgres-data-volume-path) :manual :local-path)]
|
||||
(map yaml/to-string
|
||||
[(postgres/generate-config {:postgres-size :2gb :db-name "shynet"})
|
||||
(postgres/generate-secret config)
|
||||
(when (contains? config :postgres-data-volume-path)
|
||||
(postgres/generate-persistent-volume (select-keys config [:postgres-data-volume-path :pv-storage-size-gb])))
|
||||
(postgres/generate-pvc {:pv-storage-size-gb 20
|
||||
:pvc-storage-class-name storage-class})
|
||||
(postgres/generate-deployment {:postgres-image "postgres:14"
|
||||
:postgres-size :2gb})
|
||||
(postgres/generate-service)
|
||||
(shynet/generate-secret config)
|
||||
(postgres/generate-service config)
|
||||
(shynet/generate-webserver-deployment)
|
||||
(shynet/generate-celeryworker-deployment)
|
||||
(shynet/generate-ingress config)
|
||||
|
@ -37,11 +35,7 @@
|
|||
(shynet/generate-service-webserver)
|
||||
(shynet/generate-statefulset)])))
|
||||
|
||||
; TODO: Remove once cljs release of common worked
|
||||
(defn-spec generate any?
|
||||
[my-config config?
|
||||
my-auth auth?]
|
||||
(let [resulting-config (merge config-defaults my-config my-auth)]
|
||||
(cs/join
|
||||
"\n---\n"
|
||||
(k8s-objects resulting-config))))
|
||||
(defn auth-objects [config]
|
||||
(map yaml/to-string
|
||||
[(postgres/generate-secret config)
|
||||
(shynet/generate-secret config)]))
|
|
@ -72,7 +72,7 @@
|
|||
(br/validate! "issuer" ::shynet/issuer :optional true :deserializer keyword)
|
||||
(br/validate! "postgres-data-volume-path" ::pgc/postgres-data-volume-path :optional true)
|
||||
(br/validate! "auth" core/auth? :deserializer edn/read-string)
|
||||
(br/set-validated!))
|
||||
(br/set-form-validated!))
|
||||
|
||||
(defn add-validate-listener [name]
|
||||
(-> (br/get-element-by-id name)
|
||||
|
@ -81,16 +81,21 @@
|
|||
|
||||
(defn init []
|
||||
(br/append-hickory (generate-content-div))
|
||||
(-> js/document
|
||||
(.getElementById "generate-button")
|
||||
(.addEventListener "click"
|
||||
#(do (validate-all!)
|
||||
(-> (cm/generate-common
|
||||
(config-from-document)
|
||||
(br/get-content-from-element "auth" :deserializer edn/read-string)
|
||||
core/config-defaults
|
||||
core/k8s-objects)
|
||||
(br/set-output!)))))
|
||||
(let [config-only false
|
||||
auth-only false]
|
||||
(-> js/document
|
||||
(.getElementById "generate-button")
|
||||
(.addEventListener "click"
|
||||
#(do (validate-all!)
|
||||
(-> (cm/generate-cm
|
||||
(config-from-document)
|
||||
(br/get-content-from-element "auth" :deserializer edn/read-string)
|
||||
core/config-defaults
|
||||
core/config-objects
|
||||
core/auth-objects
|
||||
config-only
|
||||
auth-only)
|
||||
(br/set-output!))))))
|
||||
(add-validate-listener "fqdn")
|
||||
(add-validate-listener "postgres-data-volume-path")
|
||||
(add-validate-listener "issuer")
|
||||
|
|
Loading…
Reference in a new issue