Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[data_source_datadog_service_account] fix exact_match pointer bug #2572

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions datadog/fwprovider/data_source_datadog_service_account.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ func (d *datadogServiceAccountDatasource) Read(ctx context.Context, req datasour
if resp.Diagnostics.HasError() {
return
}
var userData *datadogV2.User
var userData datadogV2.User
if !state.ID.IsNull() {
serviceAccountID := state.ID.ValueString()
ddResp, _, err := d.Api.GetUser(d.Auth, serviceAccountID)
Expand All @@ -135,7 +135,7 @@ func (d *datadogServiceAccountDatasource) Read(ctx context.Context, req datasour
resp.Diagnostics.AddError("Obtained entity was not a service account", "")
return
}
userData = ddResp.Data
userData = *ddResp.Data
} else {
optionalParams := datadogV2.ListUsersOptionalParameters{}
filter := state.Filter.ValueString()
Expand Down Expand Up @@ -166,17 +166,17 @@ func (d *datadogServiceAccountDatasource) Read(ctx context.Context, req datasour
resp.Diagnostics.AddError("filter keyword returned no results", "")
return
}
userData = &serviceAccounts[0]
userData = serviceAccounts[0]
if isExactMatch {
matchCount := 0
for _, serviceAccount := range serviceAccounts {
if *serviceAccount.GetAttributes().Email == filter {
userData = &serviceAccount
userData = serviceAccount
matchCount++
continue
}
if *serviceAccount.GetAttributes().Name.Get() == filter {
userData = &serviceAccount
userData = serviceAccount
matchCount++
continue
}
Expand All @@ -191,7 +191,7 @@ func (d *datadogServiceAccountDatasource) Read(ctx context.Context, req datasour
}
}
}
d.updateState(ctx, &state, userData)
d.updateState(ctx, &state, &userData)
resp.Diagnostics.Append(resp.State.Set(ctx, &state)...)
}

Expand Down
Loading