Skip to content

Commit

Permalink
SUP-1320: Remove deprecated deletion_protection from pipeline (#373)
Browse files Browse the repository at this point in the history
* Remove deletion_protection from pipeline

* Update CHANGELOG.md and remove references to deletion_protection in pipeline.md

* Fix build errors introduced when mergin from main

* Fix accidental typo on the test's config

* Removed deprecation notice retained after mergin from main
  • Loading branch information
lizrabuya authored Aug 24, 2023
1 parent 7236423 commit 2d834b1
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 15 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ All notable changes to this project will be documented in this file.
- SUP-1375 Use context everywhere [[PR #362](https://github.com/buildkite/terraform-provider-buildkite/pull/362)] @jradtilbrook
- SUP-1319: Removal of archive_on_delete from pipeline resource [[PR #369](https://github.com/buildkite/terraform-provider-buildkite/pull/369)] @james2791
- SUP-1383 Fix teams block bug in v0.25.0 [[PR #370](https://github.com/buildkite/terraform-provider-buildkite/pull/370)] @jradtilbrook
- SUP-1320 Remove deletion_protection from pipeline resource [[PR #373](https://github.com/buildkite/terraform-provider-buildkite/pull/373)] @lizrabuya
- SUP-1337 Remove org settings resource [[PR #368](https://github.com/buildkite/terraform-provider-buildkite/pull/368)] @lizrabuya
- SUP-1380 Use ID for Cluster importing [[PR #372](https://github.com/buildkite/terraform-provider-buildkite/pull/372)] @mcncl
- SUP-1388 Implement planmodifier.String for slugs [[PR #374](https://github.com/buildkite/terraform-provider-buildkite/pull/374)] @jradtilbrook
Expand All @@ -15,6 +16,9 @@ All notable changes to this project will be documented in this file.

The `archive_on_delete` attribute has been removed from the `buildkite_pipeline` resource in this release. Please use the provider configuration `archive_pipeline_on_delete` instead.

The `deletion_protection` attribute has also been removed from the `buildkite_pipeline` resource in this release. This feature offers similar
functionality to [lifecycles](https://developer.hashicorp.com/terraform/language/meta-arguments/lifecycle) which are supported by Terraform.

## [v0.25.0](https://github.com/buildkite/terraform-provider-buildkite/compare/v0.24.0...v0.25.0)

- Move archive pipeline config to provider [[PR #354](https://github.com/buildkite/terraform-provider-buildkite/pull/354)] @jradtilbrook
Expand Down
11 changes: 0 additions & 11 deletions buildkite/resource_pipeline.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ type pipelineResourceModel struct {
ClusterId types.String `tfsdk:"cluster_id"`
DefaultBranch types.String `tfsdk:"default_branch"`
DefaultTimeoutInMinutes types.Int64 `tfsdk:"default_timeout_in_minutes"`
DeletionProtection types.Bool `tfsdk:"deletion_protection"`
Description types.String `tfsdk:"description"`
Id types.String `tfsdk:"id"`
MaximumTimeoutInMinutes types.Int64 `tfsdk:"maximum_timeout_in_minutes"`
Expand Down Expand Up @@ -236,7 +235,6 @@ func (p *pipelineResource) Create(ctx context.Context, req resource.CreateReques
}
}
state.Teams = teams
state.DeletionProtection = plan.DeletionProtection

if len(plan.ProviderSettings) > 0 {
pipelineExtraInfo, err := updatePipelineExtraInfo(ctx, response.PipelineCreate.Pipeline.Slug, plan.ProviderSettings[0], p.client)
Expand Down Expand Up @@ -398,14 +396,6 @@ func (*pipelineResource) Schema(ctx context.Context, req resource.SchemaRequest,
int64planmodifier.UseStateForUnknown(),
},
},
"deletion_protection": schema.BoolAttribute{
Optional: true,
Computed: true,
Default: booldefault.StaticBool(false),
Description: "If set to 'true', deletion of a pipeline via `terraform destroy` will fail, until set to 'false'.",
DeprecationMessage: "Deletion protection will be removed in a future release. A similar solution already " +
"exists and is supported by Terraform. See https://developer.hashicorp.com/terraform/language/meta-arguments/lifecycle.",
},
"maximum_timeout_in_minutes": schema.Int64Attribute{
Computed: true,
Optional: true,
Expand Down Expand Up @@ -631,7 +621,6 @@ func (p *pipelineResource) Update(ctx context.Context, req resource.UpdateReques
}

setPipelineModel(&state, &response.PipelineUpdate.Pipeline)
state.DeletionProtection = plan.DeletionProtection

// plan.Teams has what we want. state.Teams has what exists on the server. we need to make them match
err = p.reconcileTeamPipelinesToPlan(ctx, plan.Teams, state.Teams, &response.PipelineUpdate.Pipeline, response.PipelineUpdate.Pipeline.Id)
Expand Down
1 change: 0 additions & 1 deletion buildkite/resource_pipeline_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ func TestAccBuildkitePipeline(t *testing.T) {
resource.TestCheckResourceAttr("buildkite_pipeline.pipeline", "cancel_intermediate_builds_branch_filter", ""),
resource.TestCheckResourceAttr("buildkite_pipeline.pipeline", "default_branch", ""),
resource.TestCheckResourceAttr("buildkite_pipeline.pipeline", "default_timeout_in_minutes", "0"),
resource.TestCheckResourceAttr("buildkite_pipeline.pipeline", "deletion_protection", "false"),
resource.TestCheckResourceAttr("buildkite_pipeline.pipeline", "description", ""),
resource.TestCheckResourceAttr("buildkite_pipeline.pipeline", "maximum_timeout_in_minutes", "0"),
resource.TestCheckResourceAttr("buildkite_pipeline.pipeline", "name", pipelineName),
Expand Down
4 changes: 1 addition & 3 deletions docs/resources/pipeline.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ resource "buildkite_pipeline" "test_new" {
[Lifecycles](https://developer.hashicorp.com/terraform/language/meta-arguments/lifecycle) allow you to set general rules
for resources, including the prevention of destruction of a resource. In the above example, the `destroy` command on the `Testing TImeouts` pipeline will fail.

Lifecycles will replace the deprecated `deletion_protection` in `v1` of the provider in favour of `lifecycle` rules.

## Example Usage with GitHub Provider Settings

```hcl
Expand Down Expand Up @@ -103,7 +101,7 @@ resource "buildkite_pipeline" "repo2-release" {
- `team` - (Optional) **DEPRECATED** Set team access for the pipeline. Can be specified multiple times for each team.
- `tags` - (Optional) A set of tags to be set to the pipeline. For example `["terraform", "provider"]`.
- `provider_settings` - (Optional) Source control provider settings for the pipeline. See [Provider Settings Configuration](#provider-settings-configuration) below for details.
- `deletion_protection` - **DEPRECATED** (Optional) Set to either `true` or `false`. When set to `true`, `destroy` actions on a pipeline will be blocked and fail with a message "Deletion protection is enabled for pipeline: <pipeline name>"


### Provider Settings Configuration

Expand Down

0 comments on commit 2d834b1

Please sign in to comment.