From be684408a087ea77fcf5b2478abcb9605dd04272 Mon Sep 17 00:00:00 2001 From: bom Date: Fri, 3 Feb 2023 12:33:49 +0100 Subject: [PATCH] Add monitoring config/auth to browser --- src/main/cljs/dda/c4k_nextcloud/browser.cljs | 27 +++++++++++++++++--- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/src/main/cljs/dda/c4k_nextcloud/browser.cljs b/src/main/cljs/dda/c4k_nextcloud/browser.cljs index 411bd88..cb151c1 100644 --- a/src/main/cljs/dda/c4k_nextcloud/browser.cljs +++ b/src/main/cljs/dda/c4k_nextcloud/browser.cljs @@ -2,6 +2,7 @@ (:require [clojure.tools.reader.edn :as edn] [dda.c4k-common.common :as cm] + [dda.c4k-common.monitoring :as mon] [dda.c4k-nextcloud.core :as core] [dda.c4k-nextcloud.nextcloud :as nextcloud] [dda.c4k-common.browser :as br] @@ -14,11 +15,14 @@ (cm/concat-vec (br/generate-group "domain" (cm/concat-vec (br/generate-input-field "fqdn" "Your fqdn:" "nextcloud-neu.prod.meissa-gmbh.de") + (br/generate-input-field "issuer" "(Optional) Your issuer prod/staging:" "") (br/generate-input-field "pv-storage-size-gb" "(Optional) Your nextcloud storage size in GB" "8") (br/generate-input-field "pvc-storage-class-name" "(Optional) Your storage class type (manual / local-path):" "local-path") (br/generate-input-field "postgres-data-volume-path" "(Optional) Your postgres-data-volume-path:" "/var/postgres") (br/generate-input-field "restic-repository" "(Optional) Your restic-repository:" "restic-repository") - (br/generate-input-field "issuer" "(Optional) Your issuer prod/staging:" ""))) + (br/generate-input-field "mon-cluster-name" "(Optional) monitoring cluster name:" "keycloak") + (br/generate-input-field "mon-cluster-stage" "(Optional) monitoring cluster stage:" "test") + (br/generate-input-field "mon-cloud-url" "(Optional) grafana cloud url:" "https://prometheus-prod-01-eu-west-0.grafana.net/api/prom/push"))) (br/generate-group "credentials" (br/generate-text-area "auth" "Your auth.edn:" "{:postgres-db-user \"nextcloud\" :postgres-db-password \"nextcloud-db-password\" @@ -26,7 +30,9 @@ :nextcloud-admin-user \"nextcloud-admin-user\" :aws-access-key-id \"aws-id\" :aws-secret-access-key \"aws-secret\" - :restic-password \"restic-password\"}" + :restic-password \"restic-password\"} + :mon-auth {:grafana-cloud-user \"your-user-id\" + :grafana-cloud-password \"your-cloud-password\"}" "5")) [(br/generate-br)] (br/generate-button "generate-button" "Generate c4k yaml")))] @@ -44,7 +50,10 @@ pvc-storage-class-name (br/get-content-from-element "pvc-storage-class-name" :optional true) postgres-data-volume-path (br/get-content-from-element "postgres-data-volume-path" :optional true) restic-repository (br/get-content-from-element "restic-repository" :optional true) - issuer (br/get-content-from-element "issuer" :optional true :deserializer keyword)] + issuer (br/get-content-from-element "issuer" :optional true) + mon-cluster-name (br/get-content-from-element "mon-cluster-name" :optional true) + mon-cluster-stage (br/get-content-from-element "mon-cluster-stage" :optional true) + mon-cloud-url (br/get-content-from-element "mon-cloud-url" :optional true)] (merge {:fqdn (br/get-content-from-element "fqdn")} (when (and (some? pv-storage-size-gb) (some? pvc-storage-class-name)) @@ -54,7 +63,11 @@ (when (some? restic-repository) {:restic-repository restic-repository}) (when (some? issuer) - {:issuer issuer})))) + {:issuer issuer}) + (when (some? mon-cluster-name) + {:mon-cfg {:cluster-name mon-cluster-name + :cluster-stage (keyword mon-cluster-stage) + :grafana-cloud-url mon-cloud-url}})))) (defn validate-all! [] (br/validate! "fqdn" ::nextcloud/fqdn) @@ -63,6 +76,9 @@ (br/validate! "postgres-data-volume-path" ::pgc/postgres-data-volume-path :optional true) (br/validate! "restic-repository" ::nextcloud/restic-repository :optional true) (br/validate! "issuer" ::nextcloud/issuer :optional true) + (br/validate! "mon-cluster-name" ::mon/cluster-name :optional true) + (br/validate! "mon-cluster-stage" ::mon/cluster-stage :optional true) + (br/validate! "mon-cloud-url" ::mon/grafana-cloud-url :optional true) (br/validate! "auth" nextcloud/auth? :deserializer edn/read-string) (br/set-validated!)) @@ -88,4 +104,7 @@ (add-validate-listener "postgres-data-volume-path") (add-validate-listener "restic-repository") (add-validate-listener "issuer") + (add-validate-listener "mon-cluster-name") + (add-validate-listener "mon-cluster-stage") + (add-validate-listener "mon-cloud-url") (add-validate-listener "auth"))