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

Adding destroy attribute to the apply #63

Merged
merged 2 commits into from
May 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/Cake.Terraform.Tests/TerraformApplyTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,22 @@ public void Should_Append_Auto_Approve_When_AutoApprove_Is_True()
Assert.Contains("-auto-approve", result.Args);
}

[Fact]
public void Should_Append_Destroy_When_AutoApprove_Is_True()
{
var fixture = new Fixture
{
Settings = new TerraformApplySettings
{
Destroy = true
}
};

var result = fixture.Run();

Assert.Contains("-destroy", result.Args);
}

[Fact]
public void Should_set_plan_path()
{
Expand Down
5 changes: 5 additions & 0 deletions src/Cake.Terraform/Apply/TerraformApplyRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ public void Run(TerraformApplySettings settings)
var builder = new ProcessArgumentBuilder()
.Append("apply");

if (settings.Destroy)
{
builder.Append("-destroy");
}

// Order of AutoApprove and Plan are important.
if (settings.AutoApprove)
{
Expand Down
6 changes: 6 additions & 0 deletions src/Cake.Terraform/Apply/TerraformApplySettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,11 @@ public TerraformApplySettings()
/// <see>https://www.terraform.io/docs/commands/apply.html#input-true</see>
/// </summary>
public bool Input { get; set; }

/// <summary>
/// Does destory
/// <see>https://www.terraform.io/docs/commands/destroy.html</see>
/// </summary>
public bool Destroy { get; set; }
}
}
Loading