Don't die on an empty config.yaml.
This commit is contained in:
parent
074f7c77c3
commit
4c230226bb
@ -481,7 +481,7 @@
|
|||||||
|
|
||||||
|
|
||||||
(defn build-config [config cli-config secrets]
|
(defn build-config [config cli-config secrets]
|
||||||
(util/deep-merge default-config config cli-config secrets))
|
(util/deep-merge default-config oconfig cli-config secrets))
|
||||||
|
|
||||||
(defn main [& args]
|
(defn main [& args]
|
||||||
(-> commander
|
(-> commander
|
||||||
@ -501,9 +501,6 @@
|
|||||||
cli-config (build-config-from-commander commander)
|
cli-config (build-config-from-commander commander)
|
||||||
secrets (util/read-config (.-secrets commander))
|
secrets (util/read-config (.-secrets commander))
|
||||||
config (build-config base-config cli-config secrets)
|
config (build-config base-config cli-config secrets)
|
||||||
_1 (pprint/pprint base-config)
|
|
||||||
_2 (pprint/pprint cli-config)
|
|
||||||
_3 (pprint/pprint config)
|
|
||||||
db (read-history-db (:history-db-path config))
|
db (read-history-db (:history-db-path config))
|
||||||
data (get-adsbexchange-live-data
|
data (get-adsbexchange-live-data
|
||||||
{:url (get-in config [:adsbx :url])
|
{:url (get-in config [:adsbx :url])
|
||||||
|
@ -30,8 +30,9 @@
|
|||||||
(defn read-config [path]
|
(defn read-config [path]
|
||||||
(log-verbose "Reading config file %s" path)
|
(log-verbose "Reading config file %s" path)
|
||||||
(p/let [data (read-file path {:encoding "utf-8"})]
|
(p/let [data (read-file path {:encoding "utf-8"})]
|
||||||
(-> (yaml/safeLoad data)
|
(let [config (-> (yaml/safeLoad data)
|
||||||
(js->clj :keywordize-keys true))))
|
(js->clj :keywordize-keys true))]
|
||||||
|
(or config {}))))
|
||||||
|
|
||||||
|
|
||||||
;; Fetches a URL. Returns a promise that resolves to the body of the
|
;; Fetches a URL. Returns a promise that resolves to the body of the
|
||||||
|
@ -7,4 +7,9 @@
|
|||||||
{:adsbx {:url "http://bar"}}
|
{:adsbx {:url "http://bar"}}
|
||||||
{:adsbx {:url "http://foo"}}
|
{:adsbx {:url "http://foo"}}
|
||||||
{:adsbx {:secret "123"}})
|
{:adsbx {:secret "123"}})
|
||||||
{:adsbx {:url "http://foo", :secret "123"}})))
|
{:adsbx {:url "http://foo", :secret "123"}}))
|
||||||
|
(is (= (util/deep-merge
|
||||||
|
{:adsbx {:url "http://bar"}}
|
||||||
|
{}
|
||||||
|
{:adsbx {:secret "123"}})
|
||||||
|
{:adsbx {:url "http://bar", :secret "123"}})))
|
||||||
|
@ -37,7 +37,7 @@
|
|||||||
|
|
||||||
(deftest prune-history
|
(deftest prune-history
|
||||||
(let [hist [{:time 0 :id 0} {:time 1000000 :id 1} {:time 2000000 :id 2}]]
|
(let [hist [{:time 0 :id 0} {:time 1000000 :id 1} {:time 2000000 :id 2}]]
|
||||||
(is (= (circlebot/prune-history hist 2500000)
|
(is (= (circlebot/prune-history hist 2500000 circlebot/default-config)
|
||||||
[{:time 2000000 :id 2}]))))
|
[{:time 2000000 :id 2}]))))
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user