diff --git a/src/k16/kl/api/proxy.clj b/src/k16/kl/api/proxy.clj index 8b58100..d1e153c 100644 --- a/src/k16/kl/api/proxy.clj +++ b/src/k16/kl/api/proxy.clj @@ -1,5 +1,6 @@ (ns k16.kl.api.proxy (:require + [k16.kl.log :as log] [clj-yaml.core :as yaml] [k16.kl.api.fs :as api.fs])) @@ -19,18 +20,24 @@ endpoint-name (or (:endpoint route) (:default-endpoint service)) - endpoint (get-in service [:endpoints endpoint-name]) - - traefik-service-name (str (name service-name) "-" (name endpoint-name))] + endpoint (get-in service [:endpoints endpoint-name])] (if (and service endpoint) - (-> acc - (assoc-in [:http :routers (name route-name)] - {:rule (route->traefik-rule route) - :service traefik-service-name}) - (assoc-in [:http :services traefik-service-name :loadbalancer :servers] - [{:url (:url endpoint)}])) - acc))) + (let [traefik-service-name (str (name service-name) + "-" + (name endpoint-name))] + (-> acc + (assoc-in [:http :routers (name route-name)] + {:rule (route->traefik-rule route) + :service traefik-service-name}) + (assoc-in [:http :services traefik-service-name :loadbalancer :servers] + [{:url (:url endpoint)}]))) + (do (when-not service + (log/warn (str "Unknown service " service-name))) + (when (and endpoint-name + (not endpoint)) + (log/warn (str "Unknown endpoint " endpoint-name))) + acc)))) {}))) (defn write-proxy-config! [{:keys [module-name module]}] diff --git a/src/k16/kl/log.clj b/src/k16/kl/log.clj index 540810f..7a57f21 100644 --- a/src/k16/kl/log.clj +++ b/src/k16/kl/log.clj @@ -1,6 +1,6 @@ (ns k16.kl.log - (:require - [jansi-clj.core :as color])) + (:require + [jansi-clj.core :as color])) (def ^:private lock (Object.)) @@ -12,6 +12,10 @@ (locking lock (println (color/render (str "@|red " (color/render msg) "|@"))))) +(defn warn [msg] + (locking lock + (println (color/render (str "@|yellow " (color/render msg) "|@"))))) + (defn debug [msg] (locking lock (println (color/render (str "@|white " (color/render msg) "|@")))))