Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
52 lines (41 sloc) 1.51 KB
(ns hubble.env
(:require [mount.core :refer [defstate]]
[cprop.core :refer [load-config]]
[cprop.source :refer [from-system-props
[envoy.core :as envoy]
[ :as log]
[ :as vault]))
(defn to-consul-path
"consul config to 'host/kv-prefix/path'"
(->> cconf
(apply str)))
(defn with-creds [conf at token]
(-> (vault/merge-config conf {:at at
:vhost [:hubble :vault :url]
:token token})
(get-in at)))
(defn create-config []
(let [conf (load-config :merge [(from-system-props)
(->> (conf :consul)
(envoy/merge-with-consul conf))))
(defstate config :start (create-config))
;; playground
(defn init-consul
"load config to consul without consul props and creds
this is done once (usually before the app is deployed),
and here is mostly for demo / repro purposes"
(let [{:keys [] {host :host
kv :kv-prefix} :consul :as conf} (load-config)
cpath (str host kv)]
(log/info "initializing Consul at" cpath)
(as-> (dissoc conf :consul) $
(update-in $ [:hubble :log] dissoc :auth-token)
(update-in $ [:hubble :log :hazelcast] dissoc :group-name
(envoy/map->consul cpath $))))