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

[datadog_application_key] Stop overwriting key values in state when the API omits the key #2451

Conversation

jackakeller
Copy link
Contributor

@jackakeller jackakeller commented Jun 20, 2024

When updating or importing application key resources, if the Datadog API does not include the optional computed key field, then the field is overwritten with an empty string in terraform state. The key is immutable so it does not need to be updated once it has been initially set.

Added a check to ensure the field is set before writing it into the response.

Tested manually via integration test against API responses with and without the key field. Updated unit test to match new behavior and not depend on the API returning an optional field.

@jackakeller jackakeller self-assigned this Jun 20, 2024
@jackakeller jackakeller requested a review from a team as a code owner June 20, 2024 20:13
@jackakeller jackakeller marked this pull request as draft June 20, 2024 20:14
@jackakeller jackakeller force-pushed the jackakeller/only-update-key-attribute-if-present-application-key-resources branch from 6ffb740 to 937ed00 Compare June 27, 2024 14:56
@jackakeller jackakeller changed the title Only update key field in application key resource if the field is present in API response Stop overwriting key value in application key resources when API does not return the key attribute Jun 28, 2024
@jackakeller jackakeller changed the title Stop overwriting key value in application key resources when API does not return the key attribute Stop overwriting key values in state for application key resources when the Datadog API does not return the key attribute Jun 28, 2024
@jackakeller jackakeller force-pushed the jackakeller/only-update-key-attribute-if-present-application-key-resources branch from 937ed00 to 1eb5e9e Compare July 10, 2024 16:00
@jackakeller jackakeller marked this pull request as ready for review July 10, 2024 16:01
@jackakeller jackakeller requested a review from a team July 10, 2024 16:14
@jackakeller jackakeller changed the title Stop overwriting key values in state for application key resources when the Datadog API does not return the key attribute [datadog-application-key] Stop overwriting key values in state for application key resources when the Datadog API does not return the key attribute Jul 10, 2024
@jackakeller jackakeller changed the title [datadog-application-key] Stop overwriting key values in state for application key resources when the Datadog API does not return the key attribute [datadog_application_key] Stop overwriting key values in state for application key resources when the Datadog API does not return the key attribute Jul 10, 2024
@jackakeller jackakeller requested a review from nkzou July 11, 2024 14:04
@nkzou nkzou changed the title [datadog_application_key] Stop overwriting key values in state for application key resources when the Datadog API does not return the key attribute [datadog_application_key] Stop overwriting key values in state when the API omits the key Jul 11, 2024
@nkzou nkzou merged commit 273c2f8 into master Jul 11, 2024
13 of 16 checks passed
@nkzou nkzou deleted the jackakeller/only-update-key-attribute-if-present-application-key-resources branch July 11, 2024 14:49
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.

4 participants