From 21f17edd6abfa02ecf8d5082210d0c4d55052e88 Mon Sep 17 00:00:00 2001 From: Julien WITTOUCK Date: Wed, 28 Apr 2021 17:13:53 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20:=20make=20destroy=20jobs=20upload?= =?UTF-8?q?=20their=20plan?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/gaia_app/runner/RunnerCommandBuilder.java | 2 +- .../io/gaia_app/runner/RunnerCommandBuilderTest.java | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/main/java/io/gaia_app/runner/RunnerCommandBuilder.java b/src/main/java/io/gaia_app/runner/RunnerCommandBuilder.java index 3c4501724..0265f1af2 100644 --- a/src/main/java/io/gaia_app/runner/RunnerCommandBuilder.java +++ b/src/main/java/io/gaia_app/runner/RunnerCommandBuilder.java @@ -105,7 +105,7 @@ String buildApplyScript(Job job, Stack stack, TerraformModule module) { * @return */ String buildPlanDestroyScript(Job job, Stack stack, TerraformModule module) { - return buildScript(job, stack, module, "terraform plan -destroy -detailed-exitcode", false); + return buildScript(job, stack, module, "terraform plan -out plan.binary -destroy -detailed-exitcode", true); } /** diff --git a/src/test/java/io/gaia_app/runner/RunnerCommandBuilderTest.java b/src/test/java/io/gaia_app/runner/RunnerCommandBuilderTest.java index 1d365ea45..71d60a50f 100644 --- a/src/test/java/io/gaia_app/runner/RunnerCommandBuilderTest.java +++ b/src/test/java/io/gaia_app/runner/RunnerCommandBuilderTest.java @@ -184,7 +184,8 @@ void buildPlanDestroyScript_shouldGenerateAFullScript() { assertTrue(script.contains("echo '[gaia] generating backend configuration'")); assertTrue(script.contains("terraform version")); assertTrue(script.contains("terraform init")); - assertTrue(script.contains("terraform plan -destroy")); + assertTrue(script.contains("terraform plan -out plan.binary -destroy")); + assertTrue(script.contains("terraform show -json plan.binary > plan.json")); } @Test @@ -204,7 +205,8 @@ void buildPlanDestroyScript_shouldGenerateAFullScript_forAModuleWithoutDirectory assertTrue(script.contains("echo '[gaia] generating backend configuration'")); assertTrue(script.contains("terraform version")); assertTrue(script.contains("terraform init")); - assertTrue(script.contains("terraform plan -destroy")); + assertTrue(script.contains("terraform plan -out plan.binary -destroy")); + assertTrue(script.contains("terraform show -json plan.binary > plan.json")); } @Test @@ -226,7 +228,8 @@ void buildPlanDestroyScript_shouldGenerateAFullScript_forAModuleWithAccessToken( assertTrue(script.contains("echo '[gaia] generating backend configuration'")); assertTrue(script.contains("terraform version")); assertTrue(script.contains("terraform init")); - assertTrue(script.contains("terraform plan -destroy")); + assertTrue(script.contains("terraform plan -out plan.binary -destroy")); + assertTrue(script.contains("terraform show -json plan.binary > plan.json")); }