Compare commits
2 commits
52db785f8b
...
198713c229
Author | SHA1 | Date | |
---|---|---|---|
198713c229 | |||
e9262382c4 |
6 changed files with 49 additions and 22 deletions
5
.bashrc
Normal file
5
.bashrc
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
_bb_tasks() {
|
||||||
|
COMPREPLY=( $(compgen -W "$(bb tasks |tail -n +3 |cut -f1 -d ' ')" -- ${COMP_WORDS[COMP_CWORD]}) );
|
||||||
|
}
|
||||||
|
# autocomplete filenames as well
|
||||||
|
complete -f -F _bb_tasks bb
|
5
bb.edn
5
bb.edn
|
@ -1,2 +1,5 @@
|
||||||
{:deps {dda/dda-devops-build {:local/root "."}}}
|
{:deps {dda/dda-devops-build {:local/root "."}}
|
||||||
|
:tasks
|
||||||
|
{:requires ([dda.devops-build.image :as image])
|
||||||
|
image-build (image/dbuild {:name "myimage"})}}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,2 @@
|
||||||
#!/usr/bin/env bb
|
#!/usr/bin/env bb
|
||||||
|
|
||||||
(require '[dda.devops-build.main :as build])
|
|
||||||
|
|
||||||
(when (= *file* (System/getProperty "babashka.file"))
|
|
||||||
(apply build/-main *command-line-args*))
|
|
12
src/main/clj/dda/devops_build/devops.clj
Normal file
12
src/main/clj/dda/devops_build/devops.clj
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
(ns dda.devops-build.devops
|
||||||
|
(:require [clojure.spec.alpha :as s]))
|
||||||
|
|
||||||
|
(s/def ::name string?)
|
||||||
|
(s/def ::module string?)
|
||||||
|
(s/def ::stage string?)
|
||||||
|
(s/def ::project-root-path string?)
|
||||||
|
(s/def ::build-dir-name string?)
|
||||||
|
|
||||||
|
(s/def ::devops
|
||||||
|
(s/keys :req-un [::name]
|
||||||
|
:opt-un [::module ::stage ::project-root-path ::build-dir-name]))
|
28
src/main/clj/dda/devops_build/image.clj
Normal file
28
src/main/clj/dda/devops_build/image.clj
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
(ns dda.devops-build.image
|
||||||
|
(:require [clojure.spec.alpha :as s]
|
||||||
|
[babashka.process :as p]
|
||||||
|
[babashka.tasks :as t]
|
||||||
|
[orchestra.core :refer [defn-spec]]
|
||||||
|
[dda.devops-build.devops :as d]))
|
||||||
|
|
||||||
|
(s/def ::options (s/* #{"-h"}))
|
||||||
|
(s/def ::cmd-args (s/cat :options ::options
|
||||||
|
:args any?))
|
||||||
|
|
||||||
|
(defn invalid-args-msg
|
||||||
|
[spec args]
|
||||||
|
(s/explain spec args)
|
||||||
|
(println (str "Bad commandline arguments\n")))
|
||||||
|
|
||||||
|
(defn-spec
|
||||||
|
dbuild any?
|
||||||
|
[devops ::d/devops]
|
||||||
|
(let [{:keys [name]} devops]
|
||||||
|
(t/shell "echo 'docker" "build" "-t" name "--file" "{path}/image/Dockerfile" "{path}/image")))
|
||||||
|
|
||||||
|
(defn drun [& 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)
|
||||||
|
(-> (p/process "docker run" "-it" "{name}" "/bin/bash")
|
||||||
|
(p/check)))))
|
|
@ -1,17 +0,0 @@
|
||||||
(ns dda.devops-build.main)
|
|
||||||
(require '[clojure.spec.alpha :as s])
|
|
||||||
|
|
||||||
(s/def ::options (s/* #{"-h"}))
|
|
||||||
(s/def ::cmd-args (s/cat :options ::options
|
|
||||||
:args any?))
|
|
||||||
|
|
||||||
(defn invalid-args-msg
|
|
||||||
[spec args]
|
|
||||||
(s/explain spec args)
|
|
||||||
(println (str "Bad commandline arguments\n")))
|
|
||||||
|
|
||||||
(defn -main [& 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)
|
|
||||||
(println parsed-args-cmd))))
|
|
Loading…
Reference in a new issue