Use common monitoring
This commit is contained in:
parent
1f459b1cde
commit
4640a2e762
1 changed files with 26 additions and 6 deletions
|
@ -1,6 +1,7 @@
|
||||||
(ns dda.c4k-keycloak.browser
|
(ns dda.c4k-keycloak.browser
|
||||||
(:require
|
(:require
|
||||||
[clojure.tools.reader.edn :as edn]
|
[clojure.tools.reader.edn :as edn]
|
||||||
|
[dda.c4k-common.monitoring :as mon]
|
||||||
[dda.c4k-common.common :as cm]
|
[dda.c4k-common.common :as cm]
|
||||||
[dda.c4k-common.browser :as br]
|
[dda.c4k-common.browser :as br]
|
||||||
[dda.c4k-keycloak.core :as core]
|
[dda.c4k-keycloak.core :as core]
|
||||||
|
@ -15,11 +16,17 @@
|
||||||
"domain"
|
"domain"
|
||||||
(cm/concat-vec
|
(cm/concat-vec
|
||||||
(br/generate-input-field "fqdn" "Your fqdn:" "keycloak.prod.meissa.de")
|
(br/generate-input-field "fqdn" "Your fqdn:" "keycloak.prod.meissa.de")
|
||||||
(br/generate-input-field "issuer" "(Optional) Your issuer prod/staging:" "")))
|
(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
|
(br/generate-group
|
||||||
"credentials"
|
"credentials"
|
||||||
(br/generate-text-area "auth" "Your auth.edn:" ":keycloak-admin-user \"keycloak\"
|
(br/generate-text-area "auth" "Your auth.edn:"
|
||||||
:keycloak-admin-password \"adminpassword\""
|
"{:keycloak-admin-user \"keycloak\"
|
||||||
|
:keycloak-admin-password \"adminpassword\"}
|
||||||
|
:mon-auth {:grafana-cloud-user \"your-user-id\"
|
||||||
|
:grafana-cloud-password \"your-cloud-password\"}"
|
||||||
"5"))
|
"5"))
|
||||||
[(br/generate-br)]
|
[(br/generate-br)]
|
||||||
(br/generate-button "generate-button" "Generate c4k yaml")))]
|
(br/generate-button "generate-button" "Generate c4k yaml")))]
|
||||||
|
@ -33,15 +40,25 @@
|
||||||
(generate-content)})
|
(generate-content)})
|
||||||
|
|
||||||
(defn config-from-document []
|
(defn config-from-document []
|
||||||
(let [issuer (br/get-content-from-element "issuer" :optional true)]
|
(let [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 :deserializer keyword)
|
||||||
|
mon-cloud-url (br/get-content-from-element "mon-cloud-url" :optional true)]
|
||||||
(merge
|
(merge
|
||||||
{:fqdn (br/get-content-from-element "fqdn")}
|
{:fqdn (br/get-content-from-element "fqdn")}
|
||||||
(when (some? issuer)
|
(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! []
|
(defn validate-all! []
|
||||||
(br/validate! "fqdn" ::kc/fqdn)
|
(br/validate! "fqdn" ::kc/fqdn)
|
||||||
(br/validate! "issuer" ::kc/issuer :optional true)
|
(br/validate! "issuer" ::kc/issuer :optional true)
|
||||||
|
(br/validate! "mon-cluster-name" ::mon/cluster-name :optional true)
|
||||||
|
(br/validate! "mon-cluster-stage" ::mon/cluster-stage :optional true :deserializer keyword)
|
||||||
|
(br/validate! "mon-cloud-url" ::mon/grafana-cloud-url :optional true)
|
||||||
(br/validate! "auth" core/auth? :deserializer edn/read-string)
|
(br/validate! "auth" core/auth? :deserializer edn/read-string)
|
||||||
(br/set-validated!))
|
(br/set-validated!))
|
||||||
|
|
||||||
|
@ -56,11 +73,14 @@
|
||||||
(.addEventListener "click"
|
(.addEventListener "click"
|
||||||
#(do (validate-all!)
|
#(do (validate-all!)
|
||||||
(-> (cm/generate-common
|
(-> (cm/generate-common
|
||||||
(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/k8s-objects)
|
core/k8s-objects)
|
||||||
(br/set-output!)))))
|
(br/set-output!)))))
|
||||||
(add-validate-listener "fqdn")
|
(add-validate-listener "fqdn")
|
||||||
(add-validate-listener "issuer")
|
(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"))
|
(add-validate-listener "auth"))
|
Loading…
Reference in a new issue