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
4 changed files with 45 additions and 8 deletions
Showing only changes of commit ca8ab8d708 - Show all commits

View file

@ -101,6 +101,7 @@
(println (println
(expound/expound-str auth-spec? auth-edn {:print-specs? false}))))))))))) (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] (defn -main [& cmd-args]
(main-common "c4k-common" (main-common "c4k-common"
core/config? core/config?

View file

@ -21,7 +21,8 @@
(def filter-regex-string int/filter-regex-string) (def filter-regex-string int/filter-regex-string)
(defn-spec generate seq? (defn-spec ^{:deprecated "6.4.1"} generate seq?
"use generate-config and generate-auth instead"
[config ::mon-cfg [config ::mon-cfg
auth ::mon-auth] auth ::mon-auth]
[(yaml/load-as-edn "monitoring/namespace.yaml") [(yaml/load-as-edn "monitoring/namespace.yaml")
@ -29,7 +30,7 @@
(yaml/load-as-edn "monitoring/prometheus-cluster-role-binding.yaml") (yaml/load-as-edn "monitoring/prometheus-cluster-role-binding.yaml")
(yaml/load-as-edn "monitoring/prometheus-service.yaml") (yaml/load-as-edn "monitoring/prometheus-service.yaml")
(yaml/load-as-edn "monitoring/prometheus-service-account.yaml") (yaml/load-as-edn "monitoring/prometheus-service-account.yaml")
(int/generate-config config auth) (int/generate-config-secret config auth)
(yaml/load-as-edn "monitoring/prometheus-deployment.yaml") (yaml/load-as-edn "monitoring/prometheus-deployment.yaml")
(yaml/load-as-edn "monitoring/node-exporter-service-account.yaml") (yaml/load-as-edn "monitoring/node-exporter-service-account.yaml")
(yaml/load-as-edn "monitoring/node-exporter-cluster-role.yaml") (yaml/load-as-edn "monitoring/node-exporter-cluster-role.yaml")
@ -41,3 +42,28 @@
(yaml/load-as-edn "monitoring/kube-state-metrics-deployment.yaml") (yaml/load-as-edn "monitoring/kube-state-metrics-deployment.yaml")
(yaml/load-as-edn "monitoring/kube-state-metrics-service-account.yaml") (yaml/load-as-edn "monitoring/kube-state-metrics-service-account.yaml")
(yaml/load-as-edn "monitoring/kube-state-metrics-service.yaml")]) (yaml/load-as-edn "monitoring/kube-state-metrics-service.yaml")])
(defn-spec generate-config seq?
[config ::mon-cfg
auth ::mon-auth]
[(yaml/load-as-edn "monitoring/namespace.yaml")
(yaml/load-as-edn "monitoring/prometheus-cluster-role.yaml")
(yaml/load-as-edn "monitoring/prometheus-cluster-role-binding.yaml")
(yaml/load-as-edn "monitoring/prometheus-service.yaml")
(yaml/load-as-edn "monitoring/prometheus-service-account.yaml")
(yaml/load-as-edn "monitoring/prometheus-deployment.yaml")
(yaml/load-as-edn "monitoring/node-exporter-service-account.yaml")
(yaml/load-as-edn "monitoring/node-exporter-cluster-role.yaml")
(yaml/load-as-edn "monitoring/node-exporter-cluster-role-binding.yaml")
(yaml/load-as-edn "monitoring/node-exporter-daemon-set.yaml")
(yaml/load-as-edn "monitoring/node-exporter-service.yaml")
(yaml/load-as-edn "monitoring/kube-state-metrics-cluster-role-binding.yaml")
(yaml/load-as-edn "monitoring/kube-state-metrics-cluster-role.yaml")
(yaml/load-as-edn "monitoring/kube-state-metrics-deployment.yaml")
(yaml/load-as-edn "monitoring/kube-state-metrics-service-account.yaml")
(yaml/load-as-edn "monitoring/kube-state-metrics-service.yaml")])
(defn-spec generate-auth seq?
[config ::mon-cfg
auth ::mon-auth]
[(int/generate-config-secret config auth)])

View file

@ -82,11 +82,21 @@
grafana-cloud-password) grafana-cloud-password)
(cm/replace-all-matching "FILTER_REGEX" filter-regex-string)))) (cm/replace-all-matching "FILTER_REGEX" filter-regex-string))))
(defn-spec generate-config map? (defn-spec generate-config-secret map?
[config ::mon-cfg [config ::mon-cfg
auth ::mon-auth] auth ::mon-auth]
(-> (->
(yaml/load-as-edn "monitoring/prometheus-config.yaml") (yaml/load-as-edn "monitoring/prometheus-config-secret.yaml")
(assoc-in [:stringData :prometheus.yaml]
(yaml/to-string
(generate-prometheus-config config auth)))))
(defn-spec ^{:deprecated "6.4.1"} generate-config map?
"Use generate-config-secret instead"
[config ::mon-cfg
auth ::mon-auth]
(->
(yaml/load-as-edn "monitoring/prometheus-config-secret.yaml")
(assoc-in [:stringData :prometheus.yaml] (assoc-in [:stringData :prometheus.yaml]
(yaml/to-string (yaml/to-string
(generate-prometheus-config config auth))))) (generate-prometheus-config config auth)))))