generated from hashicorp/terraform-provider-scaffolding
-
Notifications
You must be signed in to change notification settings - Fork 139
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
fix: netbox_permission plan constraint diff #432
Merged
fbreckle
merged 2 commits into
e-breuninger:master
from
tagur87:permission-constraint-null
Jul 20, 2023
Merged
fix: netbox_permission plan constraint diff #432
fbreckle
merged 2 commits into
e-breuninger:master
from
tagur87:permission-constraint-null
Jul 20, 2023
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tagur87
force-pushed
the
permission-constraint-null
branch
from
July 20, 2023 15:35
c25817f
to
5419e78
Compare
fbreckle
pushed a commit
to fbreckle/go-netbox
that referenced
this pull request
Jul 20, 2023
With the current configuration, if we pass a null value to clear the constraint field and make it null, the field is ommitted and thus no changes are made. With this change, we update the field to remove omitempty, which allows us to send a null value to the field, thus clearing it when it's empty. Critical part of the fix here: e-breuninger/terraform-provider-netbox#432
Every run of the `netbox_permission` resource when there was no constraint set would output the following diff: ``` netbox_permission.ipaddress_rw_permission will be updated in-place ~ resource "netbox_permission" "ipaddress_rw_permission" { - constraints = "null" -> null id = "3" name = "ipaddress_rw_permissions" ``` There are inherently two issues that cause the problem. We cannot null the field, because of the issue fixed here: fbreckle/go-netbox#30 Second, want the constraint field to be set to an empty string when a read of constraint is empty. So we check if nil, and if so we set constraint to "", and then return the function. Otherwise, we Marshal it to JSON to fill the tf state. Updates to latest fbreckle/go-netbox to support the change.
tagur87
force-pushed
the
permission-constraint-null
branch
from
July 20, 2023 15:51
5419e78
to
93b7dec
Compare
@fbreckle - ready |
I took the liberty to add test that fails without your commit to verify that it solves the issue. |
twink0r
pushed a commit
to twink0r/terraform-provider-netbox
that referenced
this pull request
Sep 15, 2023
* fix: netbox_permission plan constraint diff Every run of the `netbox_permission` resource when there was no constraint set would output the following diff: ``` netbox_permission.ipaddress_rw_permission will be updated in-place ~ resource "netbox_permission" "ipaddress_rw_permission" { - constraints = "null" -> null id = "3" name = "ipaddress_rw_permissions" ``` There are inherently two issues that cause the problem. We cannot null the field, because of the issue fixed here: fbreckle/go-netbox#30 Second, want the constraint field to be set to an empty string when a read of constraint is empty. So we check if nil, and if so we set constraint to "", and then return the function. Otherwise, we Marshal it to JSON to fill the tf state. Updates to latest fbreckle/go-netbox to support the change. * test: Add test for permission resource without constraint --------- Co-authored-by: Fabian Breckle <fabian.breckle@breuninger.de>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Every run of the
netbox_permission
resource when there was noconstraint set would output the following diff:
There are inherently two issues that cause the problem. We cannot null
the field, because of the issue fixed here:
fbreckle/go-netbox#30
Second, want the constraint field to be set to an empty string when
a read of constraint is empty. So we check if nil, and if so we
set constraint to "", and then return the function. Otherwise, we
Marshal it to JSON to fill the tf state.