introduce debug & dry run
This commit is contained in:
parent
1b91da0e3d
commit
0cbd256547
4 changed files with 45 additions and 5 deletions
|
@ -9,9 +9,11 @@
|
||||||
(s/def ::stage string?)
|
(s/def ::stage string?)
|
||||||
(s/def ::project-root-path string?)
|
(s/def ::project-root-path string?)
|
||||||
(s/def ::build-dir-name string?)
|
(s/def ::build-dir-name string?)
|
||||||
|
(s/def ::debug boolean?)
|
||||||
|
(s/def ::dry-run boolean?)
|
||||||
|
|
||||||
(s/def ::devops
|
(s/def ::devops
|
||||||
(s/keys :req-un [::name ::stage ::project-root-path ::build-dir-name]
|
(s/keys :req-un [::name ::stage ::project-root-path ::build-dir-name ::debug ::dry-run]
|
||||||
:opt-un [::module]))
|
:opt-un [::module]))
|
||||||
|
|
||||||
(defn-spec build-path string?
|
(defn-spec build-path string?
|
||||||
|
|
13
src/dda/build/infrastructure.clj
Normal file
13
src/dda/build/infrastructure.clj
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
(ns dda.build.infrastructure
|
||||||
|
(:require [orchestra.core :refer [defn-spec]]
|
||||||
|
[babashka.tasks :as t]
|
||||||
|
[dda.build.devops.domain :as d]))
|
||||||
|
|
||||||
|
(defn-spec execute nil?
|
||||||
|
[command string?
|
||||||
|
devops ::d/devops]
|
||||||
|
(let [{:keys [dry-run debug]} devops]
|
||||||
|
(when debug
|
||||||
|
(println command))
|
||||||
|
(when-not dry-run
|
||||||
|
(apply t/shell command))))
|
17
src/dda/build/terragrunt/domain.clj
Normal file
17
src/dda/build/terragrunt/domain.clj
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
(ns dda.build.terragrunt.domain
|
||||||
|
(:require [clojure.spec.alpha :as s]
|
||||||
|
[orchestra.core :refer [defn-spec]]
|
||||||
|
[dda.build.devops.domain :as d]))
|
||||||
|
|
||||||
|
(s/def ::devops
|
||||||
|
(s/keys :req-un [::name ::stage ::project-root-path ::build-dir-name ::debug ::dry-run ::module]
|
||||||
|
:opt-un []))
|
||||||
|
|
||||||
|
(defn-spec clean-build-dir-command seq?
|
||||||
|
[devops ::devops]
|
||||||
|
["rm" "-rf" (d/build-path (dissoc devops :module))])
|
||||||
|
|
||||||
|
(defn-spec copy-terragrunt-command seq?
|
||||||
|
[devops ::devops]
|
||||||
|
(let [{:keys [module]} devops]
|
||||||
|
["cp" "." (d/build-path devops) "&&" "cp" module (d/build-path devops)]))
|
|
@ -13,14 +13,18 @@
|
||||||
:project-root-path "../.."
|
:project-root-path "../.."
|
||||||
:build-dir-name "target"
|
:build-dir-name "target"
|
||||||
:version "4.11.8-dev"
|
:version "4.11.8-dev"
|
||||||
:stage "dev"})))
|
:stage "dev"
|
||||||
|
:debug false
|
||||||
|
:dry-run false})))
|
||||||
(is (= "../../target/dda/backup"
|
(is (= "../../target/dda/backup"
|
||||||
(cut/build-path {:name "dda"
|
(cut/build-path {:name "dda"
|
||||||
:module "backup"
|
:module "backup"
|
||||||
:project-root-path "../.."
|
:project-root-path "../.."
|
||||||
:build-dir-name "target"
|
:build-dir-name "target"
|
||||||
:version "4.11.8-dev"
|
:version "4.11.8-dev"
|
||||||
:stage "dev"}))))
|
:stage "dev"
|
||||||
|
:debug false
|
||||||
|
:dry-run false}))))
|
||||||
|
|
||||||
(deftest should-calculate-clean-build-dir-command
|
(deftest should-calculate-clean-build-dir-command
|
||||||
(is (= ["rm" "-rf" "../../target/dda-backup"]
|
(is (= ["rm" "-rf" "../../target/dda-backup"]
|
||||||
|
@ -28,7 +32,9 @@
|
||||||
:project-root-path "../.."
|
:project-root-path "../.."
|
||||||
:build-dir-name "target"
|
:build-dir-name "target"
|
||||||
:version "4.11.8-dev"
|
:version "4.11.8-dev"
|
||||||
:stage "dev"}))))
|
:stage "dev"
|
||||||
|
:debug false
|
||||||
|
:dry-run false}))))
|
||||||
|
|
||||||
(deftest should-calculate-create-build-dir-command
|
(deftest should-calculate-create-build-dir-command
|
||||||
(is (= ["mkdir" "-p" "../../target/dda-backup"]
|
(is (= ["mkdir" "-p" "../../target/dda-backup"]
|
||||||
|
@ -36,5 +42,7 @@
|
||||||
:project-root-path "../.."
|
:project-root-path "../.."
|
||||||
:build-dir-name "target"
|
:build-dir-name "target"
|
||||||
:version "4.11.8-dev"
|
:version "4.11.8-dev"
|
||||||
:stage "dev"}))))
|
:stage "dev"
|
||||||
|
:debug false
|
||||||
|
:dry-run false}))))
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue