-
Notifications
You must be signed in to change notification settings - Fork 522
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
apiclient: add high-level 'set' subcommand for changing settings #1278
Conversation
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 continue to be concerned by lack of testing. I think we should open an issue to test the parts of this lib and main that are testable (arg parsing at least).
``` | ||
|
||
It can also be useful if your desired value is "complex" or looks like a different type. | ||
For example, the "vm.max_map_count" value set above looks like an integer, but the kernel requires a string, so it has to be specified in JSON form and as a string. |
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.
👍
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.
🏐
This gives a more natural key=value input format suitable for most changes, and takes care of committing and applying the API transaction.
5438fec
to
357bfc0
Compare
^ This push addresses @bcressey's concern by preventing a second |
Issue number:
Fixes #1238.
Description of changes:
Unfortunately, I don't know that it's possible right now to handle all our keys in the simpler key=value form. I tried, but deserialization into the model requires knowledge of the type, and unless we require the user to annotate their inputs (removing a good portion of the benefit of this) then we can't be sure what they intend, and we can't introspect the model for the type we need. I'd really like to fix this, but I think it requires improving/replacing the ser/de code of the data store.
What that actually means - you can't set
settings.kernel.sysctl."vm.max_map_count"=262144
(regardless of whether you quote the number) and instead have to do the JSON form, for now.Testing done:
apiclient reboot
still reboots successfully.key=value form works with and without the settings. prefix:
Similarly, JSON form will remove the unnecessary settings layer:
Plain quoting works for handling spaces:
Quoting of "fancy keys" with internal dots works:
Here's an example of the (hopefully clear) message when key=value form can't handle a type:
The error is simpler with JSON, since the JSON input specifies the type through its format:
Setting multiple values works:
JSON form, with multiple values, internal dots, and quotes/types working as expected:
Setting an integer, in key=value and JSON form, works:
Terms of contribution:
By submitting this pull request, I agree that this contribution is dual-licensed under the terms of both the Apache License, version 2.0, and the MIT license.