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

Conversation

pablito-perez
Copy link
Contributor

@pablito-perez pablito-perez commented Sep 10, 2024

Fixes #2571

TL;DR: select the correct item when specifying an exact_match filter on the service_account data source

Passes the test added in the previous PR

Longer explanation: when iterating over multiple service account objects returned by the API, the userData variable is assigned to the pointer of the iterator serviceAccount. The underlying value keeps changing as we iterate over all items. It always ends up pointing to the last item in the collection, even if we did hit an exact match (matchCount == 1).

Copy link
Contributor Author

pablito-perez commented Sep 10, 2024

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

Join @pablito-perez and the rest of your teammates on Graphite Graphite

@pablito-perez pablito-perez force-pushed the pablo.perez/data-service-account-exact-match branch from eba2742 to 2b42957 Compare September 11, 2024 08:40
@pablito-perez pablito-perez changed the base branch from master to pablo.perez/data-service-account-exact-match-test September 11, 2024 08:40
@pablito-perez pablito-perez marked this pull request as ready for review September 11, 2024 08:42
@pablito-perez pablito-perez requested review from a team as code owners September 11, 2024 08:42
@pablito-perez pablito-perez changed the title data source service account: fix exact_match pointer bug [data_source_datadog_service_account] fix exact_match pointer bug Sep 11, 2024
@pablito-perez pablito-perez force-pushed the pablo.perez/data-service-account-exact-match-test branch from f69b899 to 27395b7 Compare September 11, 2024 09:10
@pablito-perez pablito-perez force-pushed the pablo.perez/data-service-account-exact-match branch from 2b42957 to 665d862 Compare September 11, 2024 09:10
@pablito-perez pablito-perez force-pushed the pablo.perez/data-service-account-exact-match-test branch from 27395b7 to ccda8e7 Compare September 11, 2024 09:20
@pablito-perez pablito-perez force-pushed the pablo.perez/data-service-account-exact-match branch from 665d862 to 30ab069 Compare September 11, 2024 09:20
@pablito-perez pablito-perez force-pushed the pablo.perez/data-service-account-exact-match-test branch from ccda8e7 to 15271e3 Compare September 12, 2024 14:36
@pablito-perez pablito-perez force-pushed the pablo.perez/data-service-account-exact-match branch from 30ab069 to b046b0c Compare September 12, 2024 14:36
@pablito-perez
Copy link
Contributor Author

The issue is fixed "accidentally" in latest versions of the provider, which include this golang change: https://go.dev/blog/loopvar-preview

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Data source service_account: fails on exact_match filter
1 participant