added apply & destroy

This commit is contained in:
Michael Jerger 2024-08-02 14:14:34 +02:00
parent 9d0e0729c0
commit 66603630f2
3 changed files with 74 additions and 2 deletions

View file

@ -1,11 +1,14 @@
(ns dda.build.terragrunt
(:require [orchestra.core :refer [defn-spec]]
[clojure.spec.test.alpha :as st]
[dda.build.devops :as d]
[dda.build.terragrunt.domain :as domain]
[dda.build.infrastructure :as i]))
(st/instrument `clean-build-dir!)
(def default
(merge d/default {}))
(merge d/default {:autoapply false}))
(defn-spec clean-build-dir! nil?
[devops ::d/devops]
@ -24,9 +27,41 @@
(doseq [c (domain/terragrunt-plan-command final)]
(i/execute c final))))
(defn-spec plan nil?
(defn-spec terragrunt-apply! nil?
[devops ::d/devops]
(let [final (merge default devops)]
(doseq [c (domain/terragrunt-apply-command final)]
(i/execute c final))))
(defn-spec terragrunt-destroy! nil?
[devops ::d/devops]
(let [final (merge default devops)]
(doseq [c (domain/terragrunt-destroy-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))
(defn-spec apply! nil?
[devops ::d/devops]
(clean-build-dir! devops)
(d/create-build-dir devops)
(copy-terragrunt! devops)
(terragrunt-apply! devops))
(defn-spec destroy! nil?
[devops ::d/devops]
(clean-build-dir! devops)
(d/create-build-dir devops)
(copy-terragrunt! devops)
(terragrunt-destroy! devops))
(st/instrument `clean-build-dir!)
(st/instrument `copy-terragrunt!)
(st/instrument `terragrunt-plan!)
(st/instrument `terragrunt-apply!)
(st/instrument `terragrunt-destroy!)

View file

@ -22,3 +22,13 @@
[devops ::devops]
[[{:dir (d/build-path devops)} "terragrunt" "init"]
[{:dir (d/build-path devops)} "terragrunt" "plan"]])
(defn-spec terragrunt-apply-command seq?
[devops ::devops]
[[{:dir (d/build-path devops)} "terragrunt" "init"]
[{:dir (d/build-path devops)} "terragrunt" "apply"]])
(defn-spec terragrunt-destroy-command seq?
[devops ::devops]
[[{:dir (d/build-path devops)} "terragrunt" "init"]
[{:dir (d/build-path devops)} "terragrunt" "destroy"]])

View file

@ -6,6 +6,9 @@
(st/instrument `cut/clean-build-dir-command)
(st/instrument `cut/copy-terragrunt-command)
(st/instrument `cut/terragrunt-plan-command)
(st/instrument `cut/terragrunt-apply-command)
(st/instrument `cut/terragrunt-destroy-command)
(deftest should-calculate-clean-build-dir-command
(is (= ["rm" "-rf" "../../target/test"]
@ -42,3 +45,27 @@
:debug false
:dry-run false}))))
(deftest should-calculate-terragrunt-apply-command
(is (= [[{:dir "../../../target/test/statistics"} "terragrunt" "init"]
[{:dir "../../../target/test/statistics"} "terragrunt" "apply"]]
(cut/terragrunt-apply-command {:name "test"
:module "statistics"
:project-root-path "../../.."
:build-dir-name "target"
:version "4.11.8-dev"
:stage "dev"
:debug false
:dry-run false}))))
(deftest should-calculate-terragrunt-destroy-command
(is (= [[{:dir "../../../target/test/statistics"} "terragrunt" "init"]
[{:dir "../../../target/test/statistics"} "terragrunt" "destroy"]]
(cut/terragrunt-destroy-command {:name "test"
:module "statistics"
:project-root-path "../../.."
:build-dir-name "target"
:version "4.11.8-dev"
:stage "dev"
:debug false
:dry-run false}))))