Skip to content
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

Required options #24

Open
palourde opened this issue Feb 5, 2020 · 2 comments
Open

Required options #24

palourde opened this issue Feb 5, 2020 · 2 comments

Comments

@palourde
Copy link
Contributor

palourde commented Feb 5, 2020

Add a Required attribute to PluginConfigOption, which would automatically ensure that the option was provided, so plugins developer don't have manually loop through options to make sure they were indeed provided.

@calebhailey
Copy link

Good one!

@jspaleta
Copy link
Contributor

@palourde

the cobra package makes it easy to mark a commandline flag as required, but its not clear how useful this is considering we allow stdin json attributes to override options,

"required" gets a bit complicated for plugins because we allow the stdin event json to provide overrides using the plugin keyspace + option.path construct. The input json has to be parsed before we know if the option is really set or not...and that is well past the point where cobra's built in logic for cmdline option processing can help.

This is why the derived classes goHandler, goMutator, goCheck all use a user defined validationFunction that gets called after the json from stdin is processed and the path overrides are evaluated.

I really can't think of a clean way to avoid the user defined validation because of the json parsing overrides using the keyspace and option.Path pattern. At best I can use the cobra MarkFlagRequired() function if the option Path is not set..so we are sure that the option does not have a json based override.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants