use new commons with improved main
cljs browser still uses the old code, needs another look
This commit is contained in:
parent
fef1ea5331
commit
808c3aff45
3 changed files with 5 additions and 62 deletions
|
@ -5,7 +5,7 @@
|
||||||
:url "https://www.apache.org/licenses/LICENSE-2.0.html"}
|
:url "https://www.apache.org/licenses/LICENSE-2.0.html"}
|
||||||
:dependencies [[org.clojure/clojure "1.10.3"]
|
:dependencies [[org.clojure/clojure "1.10.3"]
|
||||||
[org.clojure/tools.reader "1.3.6"]
|
[org.clojure/tools.reader "1.3.6"]
|
||||||
[org.domaindrivenarchitecture/c4k-common-clj "1.1.0"]
|
[org.domaindrivenarchitecture/c4k-common-clj "1.1.4"]
|
||||||
[hickory "0.7.1"]]
|
[hickory "0.7.1"]]
|
||||||
:target-path "target/%s/"
|
:target-path "target/%s/"
|
||||||
:source-paths ["src/main/cljc"
|
:source-paths ["src/main/cljc"
|
||||||
|
|
|
@ -1,65 +1,8 @@
|
||||||
(ns dda.c4k-shynet.uberjar
|
(ns dda.c4k-shynet.uberjar
|
||||||
(:gen-class)
|
(:gen-class)
|
||||||
(:require
|
(:require
|
||||||
[clojure.spec.alpha :as s]
|
[dda.c4k-shynet.core :as core]
|
||||||
[clojure.string :as cs]
|
[dda.c4k-common.common :as common]))
|
||||||
[clojure.tools.reader.edn :as edn]
|
|
||||||
[expound.alpha :as expound]
|
|
||||||
[dda.c4k-shynet.core :as core]))
|
|
||||||
|
|
||||||
(def usage
|
|
||||||
"usage:
|
|
||||||
|
|
||||||
c4k-shynet {your configuraton file} {your authorization file}")
|
|
||||||
|
|
||||||
(s/def ::options (s/* #{"-h"}))
|
|
||||||
(s/def ::filename (s/and string?
|
|
||||||
#(not (cs/starts-with? % "-"))))
|
|
||||||
(s/def ::cmd-args (s/cat :options ::options
|
|
||||||
:args (s/?
|
|
||||||
(s/cat :config ::filename
|
|
||||||
:auth ::filename))))
|
|
||||||
|
|
||||||
(defn expound-config
|
|
||||||
[config]
|
|
||||||
(expound/expound ::core/config config))
|
|
||||||
|
|
||||||
(defn invalid-args-msg
|
|
||||||
[spec args]
|
|
||||||
(s/explain spec args)
|
|
||||||
(println (str "Bad commandline arguments\n" usage)))
|
|
||||||
|
|
||||||
(defn generate-common [my-config my-auth config-defaults k8s-objects]
|
|
||||||
(let [resulting-config (merge config-defaults my-config my-auth)]
|
|
||||||
(cs/join
|
|
||||||
"\n---\n"
|
|
||||||
(k8s-objects resulting-config))))
|
|
||||||
|
|
||||||
(defn main-common [config-spec? auth-spec? config-defaults k8s-objects cmd-args]
|
|
||||||
(let [parsed-args-cmd (s/conform ::cmd-args cmd-args)]
|
|
||||||
(if (= ::s/invalid parsed-args-cmd)
|
|
||||||
(invalid-args-msg ::cmd-args cmd-args)
|
|
||||||
(let [{:keys [options args]} parsed-args-cmd
|
|
||||||
{:keys [config auth]} args]
|
|
||||||
(cond
|
|
||||||
(some #(= "-h" %) options)
|
|
||||||
(println usage)
|
|
||||||
:default
|
|
||||||
(let [config-str (slurp config)
|
|
||||||
auth-str (slurp auth)
|
|
||||||
config-edn (edn/read-string config-str)
|
|
||||||
auth-edn (edn/read-string auth-str)
|
|
||||||
config-valid? (s/valid? config-spec? config-edn)
|
|
||||||
auth-valid? (s/valid? auth-spec? auth-edn)]
|
|
||||||
(if (and config-valid? auth-valid?)
|
|
||||||
(println (generate-common config-edn auth-edn config-defaults k8s-objects))
|
|
||||||
(do
|
|
||||||
(when (not config-valid?)
|
|
||||||
(println
|
|
||||||
(expound/expound-str config-spec? config-edn {:print-specs? false})))
|
|
||||||
(when (not auth-valid?)
|
|
||||||
(println
|
|
||||||
(expound/expound-str auth-spec? auth-edn {:print-specs? false})))))))))))
|
|
||||||
|
|
||||||
(defn -main [& cmd-args]
|
(defn -main [& cmd-args]
|
||||||
(main-common core/config? core/auth? core/config-defaults core/k8s-objects cmd-args))
|
(common/main-common "c4k-shynet" core/config? core/auth? core/config-defaults core/k8s-objects cmd-args))
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
[clojure.spec.alpha :as s]
|
[clojure.spec.alpha :as s]
|
||||||
#?(:clj [orchestra.core :refer [defn-spec]]
|
#?(:clj [orchestra.core :refer [defn-spec]]
|
||||||
:cljs [orchestra.core :refer-macros [defn-spec]])
|
:cljs [orchestra.core :refer-macros [defn-spec]])
|
||||||
[dda.c4k-common.common :as cm]
|
|
||||||
[dda.c4k-common.yaml :as yaml]
|
[dda.c4k-common.yaml :as yaml]
|
||||||
[dda.c4k-common.postgres :as postgres]
|
[dda.c4k-common.postgres :as postgres]
|
||||||
[dda.c4k-shynet.shynet :as shynet]))
|
[dda.c4k-shynet.shynet :as shynet]))
|
||||||
|
@ -38,6 +37,7 @@
|
||||||
(shynet/generate-service-webserver)
|
(shynet/generate-service-webserver)
|
||||||
(shynet/generate-statefulset)])))
|
(shynet/generate-statefulset)])))
|
||||||
|
|
||||||
|
; TODO: Remove once cljs release of common worked
|
||||||
(defn-spec generate any?
|
(defn-spec generate any?
|
||||||
[my-config config?
|
[my-config config?
|
||||||
my-auth auth?]
|
my-auth auth?]
|
||||||
|
|
Loading…
Reference in a new issue