split auth and config
This commit is contained in:
parent
d5d4dd5b43
commit
d3dd3ca5ef
4 changed files with 55 additions and 39 deletions
|
@ -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.11.3" :scope "provided"]
|
:dependencies [[org.clojure/clojure "1.11.3" :scope "provided"]
|
||||||
[org.clojure/tools.reader "1.4.2"]
|
[org.clojure/tools.reader "1.4.2"]
|
||||||
[org.domaindrivenarchitecture/c4k-common-clj "6.4.1"]
|
[org.domaindrivenarchitecture/c4k-common-clj "6.4.2-SNAPSHOT"] ; TODO: Release version with refactorings and update here
|
||||||
[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"
|
||||||
|
|
|
@ -7,10 +7,11 @@
|
||||||
(set! *warn-on-reflection* true)
|
(set! *warn-on-reflection* true)
|
||||||
|
|
||||||
(defn -main [& cmd-args]
|
(defn -main [& cmd-args]
|
||||||
(uberjar/main-common
|
(uberjar/main-cm
|
||||||
"c4k-forgejo"
|
"c4k-forgejo"
|
||||||
core/config?
|
core/config?
|
||||||
core/auth?
|
core/auth?
|
||||||
core/config-defaults
|
core/config-defaults
|
||||||
core/k8s-objects
|
core/config-objects
|
||||||
|
core/auth-objects
|
||||||
cmd-args))
|
cmd-args))
|
||||||
|
|
|
@ -39,7 +39,7 @@
|
||||||
:postgres-image "postgres:14"
|
:postgres-image "postgres:14"
|
||||||
:postgres-size :2gb})
|
:postgres-size :2gb})
|
||||||
|
|
||||||
(defn k8s-objects [config auth] ; ToDo: ADR for generate functions - vector or no vector?
|
(defn config-objects [config] ; ToDo: ADR for generate functions - vector or no vector?
|
||||||
(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)
|
||||||
resolved-config (merge {:namespace "forgejo"} postgres-config config)]
|
resolved-config (merge {:namespace "forgejo"} postgres-config config)]
|
||||||
(map yaml/to-string
|
(map yaml/to-string
|
||||||
|
@ -47,7 +47,6 @@
|
||||||
(cm/concat-vec
|
(cm/concat-vec
|
||||||
(ns/generate resolved-config)
|
(ns/generate resolved-config)
|
||||||
[(postgres/generate-config resolved-config)
|
[(postgres/generate-config resolved-config)
|
||||||
(postgres/generate-secret {:namespace "forgejo"} auth)
|
|
||||||
(when (contains? resolved-config :postgres-data-volume-path)
|
(when (contains? resolved-config :postgres-data-volume-path)
|
||||||
(postgres/generate-persistent-volume (select-keys resolved-config [:postgres-data-volume-path :pv-storage-size-gb])))
|
(postgres/generate-persistent-volume (select-keys resolved-config [:postgres-data-volume-path :pv-storage-size-gb])))
|
||||||
(postgres/generate-pvc (merge resolved-config {:pvc-storage-class-name storage-class}))
|
(postgres/generate-pvc (merge resolved-config {:pvc-storage-class-name storage-class}))
|
||||||
|
@ -57,13 +56,25 @@
|
||||||
(forgejo/generate-service)
|
(forgejo/generate-service)
|
||||||
(forgejo/generate-service-ssh)
|
(forgejo/generate-service-ssh)
|
||||||
(forgejo/generate-data-volume resolved-config)
|
(forgejo/generate-data-volume resolved-config)
|
||||||
(forgejo/generate-appini-env resolved-config)
|
(forgejo/generate-appini-env resolved-config)]
|
||||||
(forgejo/generate-secrets auth)] ; this does not have a vector as output
|
|
||||||
(forgejo/generate-ratelimit-ingress-and-cert resolved-config) ; this function has a vector as output
|
(forgejo/generate-ratelimit-ingress-and-cert resolved-config) ; this function has a vector as output
|
||||||
(when (contains? resolved-config :restic-repository)
|
(when (contains? resolved-config :restic-repository)
|
||||||
[(backup/generate-config resolved-config)
|
[(backup/generate-config resolved-config)
|
||||||
(backup/generate-secret auth)
|
|
||||||
(backup/generate-cron)
|
(backup/generate-cron)
|
||||||
(backup/generate-backup-restore-deployment resolved-config)])
|
(backup/generate-backup-restore-deployment resolved-config)])
|
||||||
(when (:contains? resolved-config :mon-cfg)
|
(when (:contains? resolved-config :mon-cfg)
|
||||||
(mon/generate (:mon-cfg resolved-config) (:mon-auth auth))))))))
|
(mon/generate-config)))))))
|
||||||
|
|
||||||
|
(defn auth-objects [config auth] ; ToDo: ADR for generate functions - vector or no vector?
|
||||||
|
(let [storage-class (if (contains? config :postgres-data-volume-path) :manual :local-path)
|
||||||
|
resolved-config (merge {:namespace "forgejo"} postgres-config config)]
|
||||||
|
(map yaml/to-string
|
||||||
|
(filter #(not (nil? %))
|
||||||
|
(cm/concat-vec
|
||||||
|
(ns/generate resolved-config)
|
||||||
|
[(postgres/generate-secret {:namespace "forgejo"} auth)
|
||||||
|
(forgejo/generate-secrets auth)]
|
||||||
|
(when (contains? resolved-config :restic-repository)
|
||||||
|
[(backup/generate-secret auth)])
|
||||||
|
(when (:contains? resolved-config :mon-cfg)
|
||||||
|
(mon/generate-auth (:mon-cfg resolved-config) (:mon-auth auth))))))))
|
||||||
|
|
|
@ -79,8 +79,7 @@
|
||||||
(when (not (st/blank? app-name))
|
(when (not (st/blank? app-name))
|
||||||
{:default-app-name app-name})
|
{:default-app-name app-name})
|
||||||
(when (not (st/blank? domain-whitelist))
|
(when (not (st/blank? domain-whitelist))
|
||||||
{:service-domain-whitelist domain-whitelist})
|
{:service-domain-whitelist domain-whitelist}))))
|
||||||
)))
|
|
||||||
|
|
||||||
(defn validate-all! []
|
(defn validate-all! []
|
||||||
(br/validate! "fqdn" ::forgejo/fqdn)
|
(br/validate! "fqdn" ::forgejo/fqdn)
|
||||||
|
@ -103,16 +102,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 "deploy-federated")
|
(add-validate-listener "deploy-federated")
|
||||||
(add-validate-listener "mailer-from")
|
(add-validate-listener "mailer-from")
|
||||||
|
|
Loading…
Reference in a new issue