Skip to content

Commit 665d862

Browse files
committed
data source service account: fix exact_match pointer bug
1 parent 27395b7 commit 665d862

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

datadog/fwprovider/data_source_datadog_service_account.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ func (d *datadogServiceAccountDatasource) Read(ctx context.Context, req datasour
122122
if resp.Diagnostics.HasError() {
123123
return
124124
}
125-
var userData *datadogV2.User
125+
var userData datadogV2.User
126126
if !state.ID.IsNull() {
127127
serviceAccountID := state.ID.ValueString()
128128
ddResp, _, err := d.Api.GetUser(d.Auth, serviceAccountID)
@@ -135,7 +135,7 @@ func (d *datadogServiceAccountDatasource) Read(ctx context.Context, req datasour
135135
resp.Diagnostics.AddError("Obtained entity was not a service account", "")
136136
return
137137
}
138-
userData = ddResp.Data
138+
userData = *ddResp.Data
139139
} else {
140140
optionalParams := datadogV2.ListUsersOptionalParameters{}
141141
filter := state.Filter.ValueString()
@@ -166,17 +166,17 @@ func (d *datadogServiceAccountDatasource) Read(ctx context.Context, req datasour
166166
resp.Diagnostics.AddError("filter keyword returned no results", "")
167167
return
168168
}
169-
userData = &serviceAccounts[0]
169+
userData = serviceAccounts[0]
170170
if isExactMatch {
171171
matchCount := 0
172172
for _, serviceAccount := range serviceAccounts {
173173
if *serviceAccount.GetAttributes().Email == filter {
174-
userData = &serviceAccount
174+
userData = serviceAccount
175175
matchCount++
176176
continue
177177
}
178178
if *serviceAccount.GetAttributes().Name.Get() == filter {
179-
userData = &serviceAccount
179+
userData = serviceAccount
180180
matchCount++
181181
continue
182182
}
@@ -191,7 +191,7 @@ func (d *datadogServiceAccountDatasource) Read(ctx context.Context, req datasour
191191
}
192192
}
193193
}
194-
d.updateState(ctx, &state, userData)
194+
d.updateState(ctx, &state, &userData)
195195
resp.Diagnostics.Append(resp.State.Set(ctx, &state)...)
196196
}
197197

0 commit comments

Comments
 (0)