Split generation of config- and auth-objects #2

Merged
gec merged 5 commits from split-config-auth into main 2024-07-19 09:18:27 +00:00
5 changed files with 30 additions and 23 deletions
Showing only changes of commit 40030c3ce2 - Show all commits

View file

@ -3,9 +3,9 @@
:url "https://domaindrivenarchitecture.org"
:license {:name "Apache License, Version 2.0"
:url "https://www.apache.org/licenses/LICENSE-2.0.html"}
:dependencies [[org.clojure/clojure "1.11.1"]
:dependencies [[org.clojure/clojure "1.11.3"]
[org.clojure/tools.reader "1.4.2"]
[org.domaindrivenarchitecture/c4k-common-clj "6.4.0"]
[org.domaindrivenarchitecture/c4k-common-clj "6.4.2-SNAPSHOT"] ; TODO: Release c4k-common version with refactorings and update here
[hickory "0.7.1" :exclusions [viebel/codox-klipse-theme]]]
:target-path "target/%s/"
:source-paths ["src/main/cljc"

View file

@ -4,7 +4,7 @@
"src/test/cljc"
"src/test/cljs"
"src/test/resources"]
:dependencies [[org.domaindrivenarchitecture/c4k-common-cljs "6.4.0"]
:dependencies [[org.domaindrivenarchitecture/c4k-common-cljs "6.4.0"] ; TODO: Release c4k-common version with refactorings and update here
[hickory "0.7.1"]]
:builds {:frontend {:target :browser
:modules {:main {:init-fn dda.c4k-shynet.browser/init}}

View file

@ -1,14 +1,14 @@
(ns dda.c4k-shynet.core
(:require
[clojure.string :as cs]
[clojure.spec.alpha :as s]
#?(:clj [orchestra.core :refer [defn-spec]]
:cljs [orchestra.core :refer-macros [defn-spec]])
[dda.c4k-common.common :as cm]
[dda.c4k-common.yaml :as yaml]
[dda.c4k-common.postgres :as postgres]
[dda.c4k-common.monitoring :as mon]
[dda.c4k-shynet.shynet :as shynet]))
(:require
[clojure.string :as cs]
[clojure.spec.alpha :as s]
#?(:clj [orchestra.core :refer [defn-spec]]
:cljs [orchestra.core :refer-macros [defn-spec]])
[dda.c4k-common.common :as cm]
[dda.c4k-common.yaml :as yaml]
[dda.c4k-common.postgres :as postgres]
[dda.c4k-common.monitoring :as mon]
[dda.c4k-shynet.shynet :as shynet]))
(def config-defaults {:issuer :staging})
@ -21,8 +21,8 @@
::mon-cfg]))
(def auth? (s/keys :req-un [::shynet/django-secret-key
::postgres/postgres-db-user ::postgres/postgres-db-password
::mon-auth]))
::postgres/postgres-db-user ::postgres/postgres-db-password]
:opt-un [::mon-auth]))
(defn config-objects [config]
(let [storage-class (if (contains? config :postgres-data-volume-path) :manual :local-path)]
@ -44,10 +44,15 @@
(shynet/generate-service-webserver)
(shynet/generate-statefulset)]
(shynet/generate-ingress-and-cert config)
(when (:contains? config :mon-cfg)
(mon/generate (:mon-cfg config) (:mon-auth config))))))))
(when (contains? config :mon-cfg)
(mon/generate-config)))))))
(defn auth-objects [config]
(defn auth-objects [config auth]
(map yaml/to-string
[(postgres/generate-secret config)
(shynet/generate-secret config)]))
(filter
#(not (nil? %))
(cm/concat-vec
[(postgres/generate-secret config auth)
(shynet/generate-secret config auth)]
(when (contains? config :mon-cfg)
(mon/generate-auth (:mon-cfg config) (:mon-auth auth)))))))

View file

@ -15,8 +15,9 @@
(defmethod yaml/load-resource :shynet [resource-name]
(get (inline-resources "shynet") resource-name)))
(defn generate-secret [config]
(let [{:keys [fqdn django-secret-key postgres-db-user postgres-db-password]} config]
(defn generate-secret [config auth]
(let [{:keys [fqdn]} config
{:keys [django-secret-key postgres-db-user postgres-db-password]} auth]
(->
(yaml/load-as-edn "shynet/secret.yaml")
; TODO: See comment in secret.yaml

View file

@ -100,5 +100,6 @@
:EMAIL_HOST_PASSWORD ""
:EMAIL_HOST ""
:SERVER_EMAIL "Shynet <noreply@shynet.example.com>"}}
(cut/generate-secret {:fqdn "test.com" :django-secret-key "django-pw"
(cut/generate-secret {:fqdn "test.com"}
{:django-secret-key "django-pw"
:postgres-db-user "postgres-user" :postgres-db-password "postgres-pw"}))))