Skip to content

Commit

Permalink
Removes unneeded RequiresReplace
Browse files Browse the repository at this point in the history
  • Loading branch information
gdavison committed May 7, 2024
1 parent 260aa0a commit d7b4f6e
Showing 1 changed file with 7 additions and 15 deletions.
22 changes: 7 additions & 15 deletions internal/service/securitylake/subscriber_notification.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (
"github.com/hashicorp/terraform-plugin-framework/path"
"github.com/hashicorp/terraform-plugin-framework/resource"
"github.com/hashicorp/terraform-plugin-framework/resource/schema"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/listplanmodifier"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier"
"github.com/hashicorp/terraform-plugin-framework/schema/validator"
Expand Down Expand Up @@ -77,20 +76,13 @@ func (r *subscriberNotificationResource) Schema(ctx context.Context, req resourc
listvalidator.IsRequired(),
listvalidator.SizeAtMost(1),
},
PlanModifiers: []planmodifier.List{
listplanmodifier.UseStateForUnknown(),
},
NestedObject: schema.NestedBlockObject{
Blocks: map[string]schema.Block{
"https_notification_configuration": schema.ListNestedBlock{
CustomType: fwtypes.NewListNestedObjectTypeOf[httpsNotificationConfigurationModel](ctx),
Validators: []validator.List{
listvalidator.SizeAtMost(1),
},
PlanModifiers: []planmodifier.List{
listplanmodifier.UseStateForUnknown(),
listplanmodifier.RequiresReplace(),
},
NestedObject: schema.NestedBlockObject{
Attributes: map[string]schema.Attribute{
"authorization_api_key_name": schema.StringAttribute{
Expand Down Expand Up @@ -119,10 +111,6 @@ func (r *subscriberNotificationResource) Schema(ctx context.Context, req resourc
Validators: []validator.List{
listvalidator.SizeAtMost(1),
},
PlanModifiers: []planmodifier.List{
listplanmodifier.UseStateForUnknown(),
listplanmodifier.RequiresReplace(),
},
},
},
},
Expand Down Expand Up @@ -212,12 +200,12 @@ func (r *subscriberNotificationResource) Read(ctx context.Context, request resou

func (r *subscriberNotificationResource) Update(ctx context.Context, request resource.UpdateRequest, response *resource.UpdateResponse) {
var old, new subscriberNotificationResourceModel
response.Diagnostics.Append(request.Plan.Get(ctx, &old)...)
response.Diagnostics.Append(request.Plan.Get(ctx, &new)...)
if response.Diagnostics.HasError() {
return
}

response.Diagnostics.Append(request.State.Get(ctx, &new)...)
response.Diagnostics.Append(request.State.Get(ctx, &old)...)
if response.Diagnostics.HasError() {
return
}
Expand All @@ -242,14 +230,18 @@ func (r *subscriberNotificationResource) Update(ctx context.Context, request res
Configuration: configuration,
}

_, err := conn.UpdateSubscriberNotification(ctx, in)
output, err := conn.UpdateSubscriberNotification(ctx, in)
if err != nil {
response.Diagnostics.AddError(
create.ProblemStandardMessage(names.SecurityLake, create.ErrActionUpdating, ResNameSubscriberNotification, new.ID.String(), err),
err.Error(),
)
return
}

new.EndpointID = fwflex.StringToFramework(ctx, output.SubscriberEndpoint)
new.SubscriberEndpoint = fwflex.StringToFramework(ctx, output.SubscriberEndpoint)
new.setID()
}

response.Diagnostics.Append(response.State.Set(ctx, &new)...)
Expand Down

0 comments on commit d7b4f6e

Please sign in to comment.