Refactor main to use main-cm #1

Merged
bom merged 1 commit from refactor-main-cm into main 2024-07-02 13:08:43 +00:00
5 changed files with 31 additions and 31 deletions
Showing only changes of commit e503f8edd4 - Show all commits

View file

@ -4,13 +4,14 @@
:license {:name "Apache License, Version 2.0" :license {:name "Apache License, Version 2.0"
: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.11.1"] :dependencies [[org.clojure/clojure "1.11.1"]
[org.clojure/tools.reader "1.3.6"] [org.clojure/tools.reader "1.4.2"]
[org.domaindrivenarchitecture/c4k-common-clj "2.0.3"] [org.domaindrivenarchitecture/c4k-common-clj "6.4.0"]
[hickory "0.7.1" :exclusions [viebel/codox-klipse-theme]]] [hickory "0.7.1" :exclusions [viebel/codox-klipse-theme]]]
:target-path "target/%s/" :target-path "target/%s/"
:source-paths ["src/main/cljc" :source-paths ["src/main/cljc"
"src/main/clj"] "src/main/clj"]
:resource-paths ["src/main/resources"] :resource-paths ["src/main/resources"
"project.clj"]
:repositories [["snapshots" :clojars] :repositories [["snapshots" :clojars]
["releases" :clojars]] ["releases" :clojars]]
:deploy-repositories [["snapshots" {:sign-releases false :url "https://clojars.org/repo"}] :deploy-repositories [["snapshots" {:sign-releases false :url "https://clojars.org/repo"}]
@ -22,10 +23,10 @@
:uberjar {:aot :all :uberjar {:aot :all
:main dda.c4k-shynet.uberjar :main dda.c4k-shynet.uberjar
:uberjar-name "c4k-shynet-standalone.jar" :uberjar-name "c4k-shynet-standalone.jar"
:dependencies [[org.clojure/tools.cli "1.0.214"] :dependencies [[org.clojure/tools.cli "1.1.230"]
[ch.qos.logback/logback-classic "1.4.5" [ch.qos.logback/logback-classic "1.5.6"
:exclusions [com.sun.mail/javax.mail]] :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"] :release-tasks [["test"]
["vcs" "assert-committed"] ["vcs" "assert-committed"]
["change" "version" "leiningen.release/bump-version" "release"] ["change" "version" "leiningen.release/bump-version" "release"]

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.3"] :dependencies [[org.domaindrivenarchitecture/c4k-common-cljs "6.4.0"]
[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

@ -5,4 +5,4 @@
[dda.c4k-common.uberjar :as uberjar])) [dda.c4k-common.uberjar :as uberjar]))
(defn -main [& cmd-args] (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))

View file

@ -16,19 +16,17 @@
(def auth? (s/keys :req-un [::shynet/django-secret-key (def auth? (s/keys :req-un [::shynet/django-secret-key
::postgres/postgres-db-user ::postgres/postgres-db-password])) ::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)] (let [storage-class (if (contains? config :postgres-data-volume-path) :manual :local-path)]
(map yaml/to-string (map yaml/to-string
[(postgres/generate-config {:postgres-size :2gb :db-name "shynet"}) [(postgres/generate-config {:postgres-size :2gb :db-name "shynet"})
(postgres/generate-secret config)
(when (contains? config :postgres-data-volume-path) (when (contains? config :postgres-data-volume-path)
(postgres/generate-persistent-volume (select-keys config [:postgres-data-volume-path :pv-storage-size-gb]))) (postgres/generate-persistent-volume (select-keys config [:postgres-data-volume-path :pv-storage-size-gb])))
(postgres/generate-pvc {:pv-storage-size-gb 20 (postgres/generate-pvc {:pv-storage-size-gb 20
:pvc-storage-class-name storage-class}) :pvc-storage-class-name storage-class})
(postgres/generate-deployment {:postgres-image "postgres:14" (postgres/generate-deployment {:postgres-image "postgres:14"
:postgres-size :2gb}) :postgres-size :2gb})
(postgres/generate-service) (postgres/generate-service config)
(shynet/generate-secret config)
(shynet/generate-webserver-deployment) (shynet/generate-webserver-deployment)
(shynet/generate-celeryworker-deployment) (shynet/generate-celeryworker-deployment)
(shynet/generate-ingress config) (shynet/generate-ingress config)
@ -37,11 +35,7 @@
(shynet/generate-service-webserver) (shynet/generate-service-webserver)
(shynet/generate-statefulset)]))) (shynet/generate-statefulset)])))
; TODO: Remove once cljs release of common worked (defn auth-objects [config]
(defn-spec generate any? (map yaml/to-string
[my-config config? [(postgres/generate-secret config)
my-auth auth?] (shynet/generate-secret config)]))
(let [resulting-config (merge config-defaults my-config my-auth)]
(cs/join
"\n---\n"
(k8s-objects resulting-config))))

View file

@ -72,7 +72,7 @@
(br/validate! "issuer" ::shynet/issuer :optional true :deserializer keyword) (br/validate! "issuer" ::shynet/issuer :optional true :deserializer keyword)
(br/validate! "postgres-data-volume-path" ::pgc/postgres-data-volume-path :optional true) (br/validate! "postgres-data-volume-path" ::pgc/postgres-data-volume-path :optional true)
(br/validate! "auth" core/auth? :deserializer edn/read-string) (br/validate! "auth" core/auth? :deserializer edn/read-string)
(br/set-validated!)) (br/set-form-validated!))
(defn add-validate-listener [name] (defn add-validate-listener [name]
(-> (br/get-element-by-id name) (-> (br/get-element-by-id name)
@ -81,16 +81,21 @@
(defn init [] (defn init []
(br/append-hickory (generate-content-div)) (br/append-hickory (generate-content-div))
(let [config-only false
auth-only false]
(-> js/document (-> js/document
(.getElementById "generate-button") (.getElementById "generate-button")
(.addEventListener "click" (.addEventListener "click"
#(do (validate-all!) #(do (validate-all!)
(-> (cm/generate-common (-> (cm/generate-cm
(config-from-document) (config-from-document)
(br/get-content-from-element "auth" :deserializer edn/read-string) (br/get-content-from-element "auth" :deserializer edn/read-string)
core/config-defaults core/config-defaults
core/k8s-objects) core/config-objects
(br/set-output!))))) core/auth-objects
config-only
auth-only)
(br/set-output!))))))
(add-validate-listener "fqdn") (add-validate-listener "fqdn")
(add-validate-listener "postgres-data-volume-path") (add-validate-listener "postgres-data-volume-path")
(add-validate-listener "issuer") (add-validate-listener "issuer")