Skip to content

Commit

Permalink
chore: golangcilint
Browse files Browse the repository at this point in the history
  • Loading branch information
johnsonaj committed Apr 19, 2024
1 parent f0ab769 commit 92be836
Showing 1 changed file with 25 additions and 17 deletions.
42 changes: 25 additions & 17 deletions internal/service/verifiedpermissions/policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import (
"github.com/hashicorp/terraform-provider-aws/internal/errs"
interflex "github.com/hashicorp/terraform-provider-aws/internal/flex"
"github.com/hashicorp/terraform-provider-aws/internal/framework"
"github.com/hashicorp/terraform-provider-aws/internal/framework/flex"
fwflex "github.com/hashicorp/terraform-provider-aws/internal/framework/flex"
fwtypes "github.com/hashicorp/terraform-provider-aws/internal/framework/types"
"github.com/hashicorp/terraform-provider-aws/internal/tfresource"
Expand Down Expand Up @@ -335,9 +334,9 @@ func (r *resourcePolicy) Create(ctx context.Context, req resource.CreateRequest,
return
}

plan.ID = flex.StringValueToFramework(ctx, rID)
plan.ID = fwflex.StringValueToFramework(ctx, rID)
plan.CreatedDate = timetypes.NewRFC3339TimePointerValue(out.CreatedDate)
plan.PolicyID = flex.StringToFramework(ctx, out.PolicyId)
plan.PolicyID = fwflex.StringToFramework(ctx, out.PolicyId)

resp.Diagnostics.Append(resp.State.Set(ctx, plan)...)
}
Expand Down Expand Up @@ -380,8 +379,8 @@ func (r *resourcePolicy) Read(ctx context.Context, req resource.ReadRequest, res

if val, ok := out.Definition.(*awstypes.PolicyDefinitionDetailMemberStatic); ok && val != nil {
static := fwtypes.NewListNestedObjectValueOfPtrMust(ctx, &staticPolicyDefinition{
Statement: flex.StringToFramework(ctx, val.Value.Statement),
Description: flex.StringToFramework(ctx, val.Value.Description),
Statement: fwflex.StringToFramework(ctx, val.Value.Statement),
Description: fwflex.StringToFramework(ctx, val.Value.Description),
})

state.Definition = fwtypes.NewListNestedObjectValueOfPtrMust(ctx, &policyDefinition{
Expand All @@ -397,17 +396,17 @@ func (r *resourcePolicy) Read(ctx context.Context, req resource.ReadRequest, res

if val.Value.Principal != nil {
tpl.Principal = fwtypes.NewListNestedObjectValueOfPtrMust(ctx, &templateLinkedPrincipal{
EntityID: flex.StringToFramework(ctx, val.Value.Principal.EntityId),
EntityType: flex.StringToFramework(ctx, val.Value.Principal.EntityType),
EntityID: fwflex.StringToFramework(ctx, val.Value.Principal.EntityId),
EntityType: fwflex.StringToFramework(ctx, val.Value.Principal.EntityType),
})
} else {
tpl.Principal = fwtypes.NewListNestedObjectValueOfNull[templateLinkedPrincipal](ctx)
}

if val.Value.Resource != nil {
tpl.Resource = fwtypes.NewListNestedObjectValueOfPtrMust(ctx, &templateLinkedResource{
EntityID: flex.StringToFramework(ctx, val.Value.Resource.EntityId),
EntityType: flex.StringToFramework(ctx, val.Value.Resource.EntityType),
EntityID: fwflex.StringToFramework(ctx, val.Value.Resource.EntityId),
EntityType: fwflex.StringToFramework(ctx, val.Value.Resource.EntityType),
})
} else {
tpl.Resource = fwtypes.NewListNestedObjectValueOfNull[templateLinkedResource](ctx)
Expand Down Expand Up @@ -439,10 +438,15 @@ func (r *resourcePolicy) Update(ctx context.Context, req resource.UpdateRequest,
in.PolicyId = fwflex.StringFromFramework(ctx, state.PolicyID)
in.PolicyStoreId = fwflex.StringFromFramework(ctx, state.PolicyStoreID)

defPlan, diags := plan.Definition.ToPtr(ctx)
defState, diags := state.Definition.ToPtr(ctx)
resp.Diagnostics.Append(diags...)
if diags.HasError() {
defPlan, diagsPlan := plan.Definition.ToPtr(ctx)
resp.Diagnostics.Append(diagsPlan...)
if resp.Diagnostics.HasError() {
return
}

defState, diagsState := state.Definition.ToPtr(ctx)
resp.Diagnostics.Append(diagsState...)
if resp.Diagnostics.HasError() {
return
}

Expand Down Expand Up @@ -513,10 +517,14 @@ func (r *resourcePolicy) ModifyPlan(ctx context.Context, req resource.ModifyPlan
}

if !plan.Definition.Equal(state.Definition) {
defPlan, diags := plan.Definition.ToPtr(ctx)
defState, diags := state.Definition.ToPtr(ctx)
resp.Diagnostics.Append(diags...)
if diags.HasError() {
defPlan, diagsPlan := plan.Definition.ToPtr(ctx)
resp.Diagnostics.Append(diagsPlan...)
if resp.Diagnostics.HasError() {
return
}
defState, diagsState := state.Definition.ToPtr(ctx)
resp.Diagnostics.Append(diagsState...)
if resp.Diagnostics.HasError() {
return
}

Expand Down

0 comments on commit 92be836

Please sign in to comment.