Skip to content

Commit

Permalink
add warning on delete
Browse files Browse the repository at this point in the history
  • Loading branch information
jharley committed Jul 18, 2024
1 parent 81a0959 commit 1b1f2d6
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions internal/provider/environment_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
var (
_ resource.Resource = &environmentResource{}
_ resource.ResourceWithConfigure = &environmentResource{}
_ resource.ResourceWithModifyPlan = &environmentResource{}
_ resource.ResourceWithImportState = &environmentResource{}
)

Expand Down Expand Up @@ -128,6 +129,17 @@ func (r *environmentResource) ImportState(ctx context.Context, req resource.Impo
})...)
}

func (r *environmentResource) ModifyPlan(ctx context.Context, req resource.ModifyPlanRequest, resp *resource.ModifyPlanResponse) {
if req.Plan.Raw.IsNull() {
// If the entire plan is null, the resource is planned for destruction -- let's add a warning
resp.Diagnostics.AddWarning(
"Resource Destruction Warning",
"Appling this plan will delete the Environment and all of its contents. "+
"This is an irreversible operation.",
)
}
}

func (r *environmentResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) {
var plan models.EnvironmentResourceModel
resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...)
Expand Down

0 comments on commit 1b1f2d6

Please sign in to comment.