Skip to content

Commit

Permalink
fix state setting resource building
Browse files Browse the repository at this point in the history
  • Loading branch information
skarimo committed Oct 31, 2024
1 parent fb4940f commit 3d8d410
Showing 1 changed file with 8 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,10 @@ func (r *integrationCloudflareAccountResource) updateState(ctx context.Context,
if name, ok := attributes.GetNameOk(); ok {
state.Name = types.StringValue(*name)
}

if resources, ok := attributes.GetResourcesOk(); ok {
state.Resources, _ = types.ListValueFrom(ctx, types.StringType, resources)
}
}

func (r *integrationCloudflareAccountResource) buildIntegrationCloudflareAccountRequestBody(ctx context.Context, state *integrationCloudflareAccountModel) (*datadogV2.CloudflareAccountCreateRequest, diag.Diagnostics) {
Expand All @@ -212,11 +216,8 @@ func (r *integrationCloudflareAccountResource) buildIntegrationCloudflareAccount
attributes.SetName(state.Name.ValueString())

if !state.Resources.IsNull() {
resourceElements := state.Resources.Elements()
resources := make([]string, len(resourceElements))
for i, resource := range resourceElements {
resources[i] = resource.(types.String).ValueString()
}
var resources []string
diags.Append(state.Resources.ElementsAs(ctx, &resources, false)...)
attributes.SetResources(resources)
}

Expand All @@ -237,11 +238,8 @@ func (r *integrationCloudflareAccountResource) buildIntegrationCloudflareAccount
}

if !state.Resources.IsNull() {
resourceElements := state.Resources.Elements()
resources := make([]string, len(resourceElements))
for i, resource := range resourceElements {
resources[i] = resource.(types.String).ValueString()
}
var resources []string
diags.Append(state.Resources.ElementsAs(ctx, &resources, false)...)
attributes.SetResources(resources)
}

Expand Down

0 comments on commit 3d8d410

Please sign in to comment.