forked from netbox-community/go-netbox
-
Notifications
You must be signed in to change notification settings - Fork 22
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: allow permissions constraint to be nullable #30
Merged
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
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
@fbreckle - need this for the associated fix for the TF provider |
tagur87
added a commit
to tagur87/terraform-provider-netbox
that referenced
this pull request
Jul 20, 2023
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.
tagur87
added a commit
to tagur87/terraform-provider-netbox
that referenced
this pull request
Jul 20, 2023
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.
fbreckle
added a commit
to e-breuninger/terraform-provider-netbox
that referenced
this pull request
Jul 20, 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 <[email protected]>
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 <[email protected]>
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.
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