Compare commits

..

No commits in common. "198713c229693a7c4533d1c7c20fd1ef8b49581a" and "52db785f8b3346f517d45af4e3c562c8e58b1258" have entirely different histories.

6 changed files with 22 additions and 49 deletions

View file

@ -1,5 +0,0 @@
_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
View file

@ -1,5 +1,2 @@
{:deps {dda/dda-devops-build {:local/root "."}}
:tasks
{:requires ([dda.devops-build.image :as image])
image-build (image/dbuild {:name "myimage"})}}
{:deps {dda/dda-devops-build {:local/root "."}}}

View file

@ -1,2 +1,6 @@
#!/usr/bin/env bb
(require '[dda.devops-build.main :as build])
(when (= *file* (System/getProperty "babashka.file"))
(apply build/-main *command-line-args*))

View file

@ -1,12 +0,0 @@
(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]))

View file

@ -1,28 +0,0 @@
(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)))))

View file

@ -0,0 +1,17 @@
(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))))