diff --git a/src/main/cljc/dda/c4k_forgejo/core.cljc b/src/main/cljc/dda/c4k_forgejo/core.cljc index 005f510..7378c0a 100644 --- a/src/main/cljc/dda/c4k_forgejo/core.cljc +++ b/src/main/cljc/dda/c4k_forgejo/core.cljc @@ -3,12 +3,16 @@ [clojure.spec.alpha :as s] [dda.c4k-common.yaml :as yaml] [dda.c4k-common.common :as cm] + [dda.c4k-common.monitoring :as mon] [dda.c4k-forgejo.forgejo :as forgejo] [dda.c4k-forgejo.backup :as backup] [dda.c4k-common.postgres :as postgres])) (def config-defaults {:issuer "staging"}) +(s/def ::mon-cfg mon/config?) +(s/def ::mon-auth mon/auth?) + (def config? (s/keys :req-un [::forgejo/fqdn ::forgejo/mailer-from ::forgejo/mailer-host-port @@ -16,16 +20,18 @@ :opt-un [::forgejo/issuer ::forgejo/default-app-name ::forgejo/service-domain-whitelist - ::backup/restic-repository])) + ::backup/restic-repository + ::mon-cfg])) (def auth? (s/keys :req-un [::postgres/postgres-db-user ::postgres/postgres-db-password ::forgejo/mailer-user ::forgejo/mailer-pw ::backup/aws-access-key-id ::backup/aws-secret-access-key] - :opt-un [::backup/restic-password])) ; TODO gec: Is restic password opt or req? + :opt-un [::backup/restic-password ; TODO gec: Is restic password opt or req? + ::mon-cfg])) (def vol? (s/keys :req-un [::forgejo/volume-total-storage-size])) -(defn k8s-objects [config] +(defn k8s-objects [config auth] (let [storage-class (if (contains? config :postgres-data-volume-path) :manual :local-path)] (map yaml/to-string (filter #(not (nil? %)) @@ -50,4 +56,6 @@ [(backup/generate-config config) (backup/generate-secret config) (backup/generate-cron) - (backup/generate-backup-restore-deployment config)])))))) + (backup/generate-backup-restore-deployment config)]) + (when (:contains? config :mon-cfg) + (mon/generate (:mon-cfg config) (:mon-auth auth)))))))) diff --git a/valid-auth.edn b/valid-auth.edn index 33e9ade..d444915 100644 --- a/valid-auth.edn +++ b/valid-auth.edn @@ -4,4 +4,6 @@ :mailer-pw "" :aws-access-key-id "AWS_KEY_ID" :aws-secret-access-key "AWS_KEY_SECRET" - :restic-password ""} + :restic-password "" + :mon-auth {:grafana-cloud-user "user" + :grafana-cloud-password "password"}} diff --git a/valid-auth.yaml b/valid-auth.yaml new file mode 100644 index 0000000..cf1efb9 --- /dev/null +++ b/valid-auth.yaml @@ -0,0 +1,10 @@ +postgres-db-user: "forgejo" +postgres-db-password: "forgejo-db-password" +mailer-user: "" +mailer-pw: "" +aws-access-key-id: "AWS_KEY_ID" +aws-secret-access-key: "AWS_KEY_SECRET" +restic-password: "" +mon-auth: + grafana-cloud-user: "user" + grafana-cloud-password: "password" diff --git a/valid-config.edn b/valid-config.edn index 9a04f74..c8d4253 100644 --- a/valid-config.edn +++ b/valid-config.edn @@ -6,4 +6,7 @@ :service-whitelist-domains "test.de" :service-noreply-address "noreply@test.de" :volume-total-storage-size 6 - :restic-repository "repo-path"} + :restic-repository "repo-path" + :mon-cfg {:grafana-cloud-url "url-for-your-prom-remote-write-endpoint" + :k3s-cluster-name "jitsi" + :k3s-cluster-stage "test"}} diff --git a/valid-config.yaml b/valid-config.yaml new file mode 100644 index 0000000..10b63e6 --- /dev/null +++ b/valid-config.yaml @@ -0,0 +1,13 @@ +default-app-name: "Meissas awesome forgejo" +fqdn: "test.de" +issuer: "staging" +mailer-from: "test@test.de" +mailer-host-port: "test.de:123" +service-whitelist-domains: "test.de" +service-noreply-address: "noreply@test.de" +volume-total-storage-size: 6 +restic-repository: "repo-path" +mon-cfg: + grafana-cloud-url: "url-for-your-prom-remote-write-endpoint" + k3s-cluster-name: "jitsi" + k3s-cluster-stage: "test" \ No newline at end of file