Split for generation of config and auth objects #4

Merged
gec merged 9 commits from split-config-auth into main 2024-07-19 09:06:52 +00:00
5 changed files with 58 additions and 21 deletions
Showing only changes of commit 1bcbca58c8 - Show all commits

View file

@ -101,11 +101,12 @@
(println
(expound/expound-str auth-spec? auth-edn {:print-specs? false})))))))))))
; REVIEW gec: should this also be changed to main-cm? This would mean a breaking change.
(defn -main [& cmd-args]
(main-common "c4k-common"
(main-cm
"c4k-common"
core/config?
core/auth?
core/config-defaults
core/k8s-objects
core/config-objects
core/auth-objects
cmd-args))

View file

@ -7,15 +7,22 @@
(def config-defaults {})
(def config? (s/keys :req-un []
(def config? (s/keys :req-un [::monitoring/mon-cfg]
:opt-un []))
(def auth? (s/keys :req-un []
(def auth? (s/keys :req-un [::monitoring/mon-auth]
:opt-un []))
(defn k8s-objects [config auth]
(defn config-objects [config]
(let []
(map yaml/to-string
(filter #(not (nil? %))
(cm/concat-vec
(monitoring/generate config auth))))))
(monitoring/generate-config))))))
(defn auth-objects [config auth]
(let []
(map yaml/to-string
(filter #(not (nil? %))
(cm/concat-vec
(monitoring/generate-auth (:mon-cfg config) (:mon-auth auth)))))))

View file

@ -0,0 +1,22 @@
(ns dda.c4k-common.core-test
(:require
#?(:cljs [shadow.resource :as rc])
#?(:clj [clojure.test :refer [deftest is are testing run-tests]]
:cljs [cljs.test :refer-macros [deftest is are testing run-tests]])
[clojure.spec.alpha :as s]
[dda.c4k-common.yaml :as yaml]
[dda.c4k-common.core :as cut]))
#?(:cljs
(defmethod yaml/load-resource :common-test [resource-name]
(case resource-name
"common-test/valid-auth.yaml" (rc/inline "common-test/valid-auth.yaml")
"common-test/valid-config.yaml" (rc/inline "common-test/valid-config.yaml")
(throw (js/Error. "Undefined Resource!")))))
(def conf (yaml/load-as-edn "common-test/valid-config.yaml"))
(def auth (yaml/load-as-edn "common-test/valid-auth.yaml"))
(deftest validate-valid-resources
(is (s/valid? cut/config? conf))
(is (s/valid? cut/auth? auth)))

View file

@ -0,0 +1,3 @@
mon-auth:
grafana-cloud-user: "user"
grafana-cloud-password: "password"

View file

@ -0,0 +1,4 @@
mon-cfg:
grafana-cloud-url: "url-for-your-prom-remote-write-endpoint"
cluster-name: "forgejo"
cluster-stage: "test"