Skip to content

fix: terraform-plugin-sdk zeros *int fields #123

New issue

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

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

Already on ? Sign in to your account

Merged
merged 14 commits into from
Jun 1, 2023

Conversation

mtojek
Copy link
Member

@mtojek mtojek commented May 30, 2023

Related: coder/coder#7582 (comment)

Changes:

  • add computed fields min_ok and max_ok to Validation. These fields substitute the impaired logic in terraform-plugin-sdk (can't handle *ptr).
  • replace *int with int (revert last change) as pointers don't give any benefits now.

For some reason, the Terraform state contains validation.0.min = 0. I managed to fix parameterDataSource to handle nils.

If you look at the state, it doesn't contain absent root properties of coder_parameter (like display_name), but it contains all for Validation. Why :) ?

_, foundDisplayName := state.Primary.Attributes["display_name"]
require.False(t, foundDisplayName, "display_name = "+state.Primary.Attributes["display_name"])
_, foundValidationMin := state.Primary.Attributes["validation.0.min"]
require.False(t, foundValidationMin, "validation.0.min = "+state.Primary.Attributes["validation.0.min"])
Copy link
Member Author

@mtojek mtojek May 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kylecarbs Maybe you have a clue what is the reason.

@mtojekmtojek force-pushed the bug-validation-min branch from 79a241d to 5f4b94b Compare May 31, 2023 08:26
@mtojekmtojek changed the title bug: validation min = 0 fix: terraform-plugin-sdk zeros *int fields May 31, 2023
@mtojekmtojek self-assigned this May 31, 2023
@mtojekmtojek requested a review from mafredri May 31, 2023 09:21
@mtojekmtojek requested a review from spikecurtis May 31, 2023 09:57
@mtojekmtojek marked this pull request as ready for review May 31, 2023 09:57
@mtojekmtojek requested a review from spikecurtis May 31, 2023 11:39
@mtojek
Copy link
Member Author

Thanks, @mafredri, for taking a look! I will wait for the final approval from @spikecurtis and merge it 👍

@mtojekmtojek merged commit 547f1b6 into coder:main Jun 1, 2023
@github-actions-actions bot locked and limited conversation to collaborators Jun 1, 2023
Sign up for free to subscribe to this conversation on . Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants