-
Notifications
You must be signed in to change notification settings - Fork 252
Support CustomField UI visibility in 3.8 #1136
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
Draft
bluikko
wants to merge
4
commits into
netbox-community:devel
Choose a base branch
from
bluikko:patch-3
base: devel
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These values are going to cause a lot of confusion, people are going to just use
yesandnowithout strings and YAML will convert them to booleans, and then the module will throw an error and they'll come here asking why it doesn't work.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exactly and that is what my comments above are about.
I 100% agree.
I need feedback on what is the preferred solution to work around this. I do not think forcing users to quote values to just one module parameter is reasonable, at all.
Two other possible options:
ui_editableas a string value:ui_editableandui_editable_hidden. Based on the combined value of these 2 parameters decide if giveyesnoorhiddento NetBox API.yesandnoas valuesui_editable: module parameters takes other values for exampleread-writeand calls NetBox API withyes; valueread-onlymeansnoandhiddenstays the same.Open to other suggestions or feedback on these 2. I had an open discussion item at the netbox project and suggestions to not use
yesandnoin the NetBox API were ignored.Both will make the module API diverge from NetBox API which will be sad.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think Option 1 of the other options is the best one. If we're diverging from the NetBox API we may as well do it the best way we can. Thanks for your work on this @bluikko
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also think option 1 is the best solution. I'm not crazy about this trilean that the netbox API is exposing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will rework this to 2x boolean then.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In looking to address the problem of
ui_visibleandui_editable, I came across this old pull request.I understand the concern of yes and no values being treated as booleans when not wrapped in quotes. However, when I was testing this out, it appears that as long as the
argument_specdict is declaringui_editableandui_visibleas atype=strinnetbox_custom_field.py, it will convert the yes and no values into strings automatically.To examine it further, I logged module output and observed the following:
When using
ui_editable: no(declared as a bool) in the Ansible task, themodule.paramsinnetbox_custom_field.pyended up as a string of 'no'. The task worked as expected and the object was created in NetBox.Log details:
When converting
ui_editabletotype=booland removing the choices, only then wasui_editable: notreated as a bool and appeared asFalsein the module params. This did throw an error, as predicted.I'm new to using Ansible, so I'm not sure if this was a change in the library or if my testing is flawed, but it appears there shouldn't be an issue even if users use
nooryeswithout quotes. In light of this, I'd like to be able to just use yes, no, and hidden as it is documented in the API. Similar with ui_visibile: I'd prefer just to have the API values available.Would this information contribute to this pull request being approved?
Versions and Misc.:
required_ifblock innetbox_custom_field.pyto be("state", "present", ["object_types", "name"])instead of("state", "present", ["content_types", "name"]). Maybe a change due to more recent netbox version? content_types wasn't useable for me and produced an error.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent research, this would remove my concern.