Skip to content

Commit

Permalink
Use constants for destroy messages
Browse files Browse the repository at this point in the history
  • Loading branch information
kmanning committed Jul 30, 2020
1 parent 1eab220 commit 024b9f5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
6 changes: 4 additions & 2 deletions src/DestroyPlugin.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ class DestroyPlugin implements TerraformPlanCommandPlugin,
TerraformApplyCommandPlugin {

private static arguments = []
public static DESTROY_CONFIRM_MESSAGE = 'WARNING! Are you absolutely sure the plan above is correct? Your environment will be IMMEDIATELY DESTROYED via "terraform destroy"'
public static DESTROY_OK_MESSAGE = "Run terraform DESTROY now"

public static void init() {
DestroyPlugin plugin = new DestroyPlugin()

ConfirmApplyPlugin.withConfirmMessage('WARNING! Are you absolutely sure the plan above is correct? Your environment will be IMMEDIATELY DESTROYED via "terraform destroy"')
ConfirmApplyPlugin.withOkMessage("Run terraform DESTROY now")
ConfirmApplyPlugin.withConfirmMessage(DESTROY_CONFIRM_MESSAGE)
ConfirmApplyPlugin.withOkMessage(DESTROY_OK_MESSAGE)
TerraformEnvironmentStage.withStageNamePattern { options -> "${options['command']}-DESTROY-${options['environment']}" }

TerraformPlanCommand.addPlugin(plugin)
Expand Down
5 changes: 2 additions & 3 deletions test/DestroyPluginTest.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,8 @@ class DestroyPluginTest {
String confirmMessage = ConfirmApplyPlugin.confirmMessage
String okMessage = ConfirmApplyPlugin.okMessage

// Lets turn these into constants
assertEquals(confirmMessage, 'WARNING! Are you absolutely sure the plan above is correct? Your environment will be IMMEDIATELY DESTROYED via "terraform destroy"')
assertEquals(okMessage, "Run terraform DESTROY now")
assertEquals(DestroyPlugin.DESTROY_CONFIRM_MESSAGE, confirmMessage)
assertEquals(DestroyPlugin.DESTROY_OK_MESSAGE, okMessage)
}

@Test
Expand Down

0 comments on commit 024b9f5

Please sign in to comment.