Skip to content

Commit

Permalink
fix: allow permissions constraint to be nullable
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Joel Tague authored and fbreckle committed Jul 20, 2023
1 parent 9a27bb3 commit dd0b7c4
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion netbox/models/writable_object_permission.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions preprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,10 @@
logging.info(f"set x-omitempty = false on WritableRack.{prop}")

data["definitions"]["WritableCustomField"]["properties"]["required"][
"x-omitempty"
] = False
"x-omitempty"] = False

data["definitions"]["WritableObjectPermission"]["properties"]["constraints"][
"x-omitempty"] = False

# This implements https://github.com/fbreckle/go-netbox/commit/1363e14cfc7bce4bd3d5ee93c09ca70543c51279
for prop, prop_spec in data["definitions"]["WritableVirtualMachineWithConfigContext"][
Expand Down
3 changes: 2 additions & 1 deletion swagger.processed.json
Original file line number Diff line number Diff line change
Expand Up @@ -94818,7 +94818,8 @@
"title": "Constraints",
"description": "Queryset filter matching the applicable objects of the selected type(s)",
"type": "object",
"x-nullable": true
"x-nullable": true,
"x-omitempty": false
}
}
},
Expand Down

0 comments on commit dd0b7c4

Please sign in to comment.