terragrunt plan now works

This commit is contained in:
Michael Jerger 2024-07-31 08:48:33 +02:00
parent 6046554be4
commit 9d0e0729c0
3 changed files with 39 additions and 11 deletions

View file

@ -7,15 +7,26 @@
(def default
(merge d/default {}))
(defn-spec plan nil?
(defn-spec clean-build-dir! nil?
[devops ::d/devops]
(let [final (merge default devops)]
(i/execute (domain/clean-build-dir-command final) final)))
(defn-spec copy-terragrunt! nil?
[devops ::d/devops]
(let [final (merge default devops)]
(i/execute (domain/clean-build-dir-command final) final)
(d/create-build-dir final)
(i/execute ["ls" "-la"] final)
(doseq [c (domain/copy-terragrunt-command final)]
(try (i/execute c final)
(catch Exception e (str "caught exception: " (.getMessage e)))))
(i/execute [{:dir "../../../target/test/statistics"} "terragrunt" "init"] final)
(i/execute [{:dir "../../../target/test/statistics"} "terragrunt" "plan"] final)
))
(i/execute c final))))
(defn-spec terragrunt-plan! nil?
[devops ::d/devops]
(let [final (merge default devops)]
(doseq [c (domain/terragrunt-plan-command final)]
(i/execute c final))))
(defn-spec plan nil?
[devops ::d/devops]
(clean-build-dir! devops)
(d/create-build-dir devops)
(copy-terragrunt! devops)
(terragrunt-plan! devops))

View file

@ -15,5 +15,10 @@
[devops ::devops]
(let [{:keys [module]} devops
devops-wo-module (dissoc devops :module)]
[["cp" "*.hcl" (d/build-path devops-wo-module)]
[["bash" "-c" (str "cp *.hcl " (d/build-path devops-wo-module))]
["cp" "-r" module (d/build-path devops-wo-module)]]))
(defn-spec terragrunt-plan-command seq?
[devops ::devops]
[[{:dir (d/build-path devops)} "terragrunt" "init"]
[{:dir (d/build-path devops)} "terragrunt" "plan"]])

View file

@ -19,7 +19,7 @@
:dry-run false}))))
(deftest should-calculate-copy-terragrunt-command
(is (= [["cp" "*.hcl" "../../target/test"]
(is (= [["bash" "-c" "cp *.hcl ../../target/test"]
["cp" "-r" "statistics" "../../target/test"]]
(cut/copy-terragrunt-command {:name "test"
:module "statistics"
@ -30,3 +30,15 @@
:debug false
:dry-run false}))))
(deftest should-calculate-terragrunt-plan-command
(is (= [[{:dir "../../../target/test/statistics"} "terragrunt" "init"]
[{:dir "../../../target/test/statistics"} "terragrunt" "plan"]]
(cut/terragrunt-plan-command {:name "test"
:module "statistics"
:project-root-path "../../.."
:build-dir-name "target"
:version "4.11.8-dev"
:stage "dev"
:debug false
:dry-run false}))))