Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #354: Add taint and untaint command #353

Merged
merged 13 commits into from
Mar 31, 2021

Conversation

duckpuppy
Copy link
Contributor

@duckpuppy duckpuppy commented Mar 24, 2021

The TerraformTaintPlugin adds new parameters to a build for resources to taint / untaint. If nothing is specified, then the plugin does nothing. If a value is provided in one of the parameters, then the corresponding command will be ran prior to the terraform plan command. It also includes support for restricting the execution to a given branch or set of branches, as well as restricting based the origin repository of the code checked out in the workspace.

// Jenkinsfile
@Library(['terraform-pipeline@v3.10']) _

Jenkinsfile.init(this, env)

// This enables the "taint" and "untaint" functionality
// It will only apply to the master branch (default behavior)
// and will only apply if the current worspace code is checked out from the
// MyOrg/myrepo repository.
TerraformTaintPlugin.init()
TerraformTaintPlugin.onlyOnOriginRepo("MyOrg/myrepo")

def validate = new TerraformValidateStage()

def destroyQa = new TerraformEnvironmentStage('qa')
def destroyUat = new TerraformEnvironmentStage('uat')
def destroyProd = new TerraformEnvironmentStage('prod')

validate.then(destroyQa)
        .then(destroyUat)
        .then(destroyProd)
        .build()

Fixes #354

@duckpuppy duckpuppy changed the title Add taint and untaint command Issue #354: Add taint and untaint command Mar 24, 2021
@kmanning
Copy link
Collaborator

In the meantime, @duckpuppy, how would you feel about removing the onlyOnOriginRepo() functionality? If it's really needed, it could be purely additive in a fast-follow PR. Otherwise, the discussion in #356 might bring up a better alternative.

class TerraformTaintCommand implements TerraformCommand, Pluggable<TerraformTaintCommandPlugin> {
private String command = "taint"
private String resource
private String environment
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is environment dead code?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gross, it's part of the TerraformCommand interface.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cutting a separate issue for that - #357

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that was part of why I moved environment management into it when I was converting it to a trait - it already had getEnvronment() in the interface.

@kmanning
Copy link
Collaborator

Looks good, :shipit:

@duckpuppy duckpuppy merged commit 70d493a into manheim:master Mar 31, 2021
@kmanning kmanning added this to the v5.16 milestone Mar 31, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for terraform taint and terraform untaint
3 participants