-
Notifications
You must be signed in to change notification settings - Fork 14
azure-init: Accept providing user groups via the CLI #108
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
Conversation
b874663 to
1f00300
Compare
anhvoms
left a comment
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.
Can you add a unit test for this?
Sure thing. I take it you're okay with the general idea, then? Also, I had to force clap <= 4.4 because our MSRV is 1.71 and clap bumped from 1.70 to 1.74 in 4.5. Sadly, I can't just specify "4" and have cargo find the latest one with a MSRV of the current toolchain... Maybe there's a way to make this work without having to artificially pin minor releases when we work with both. |
Yeah, I'm good with providing the configurable groups via CLI and env var. One concern is that as we start adding more features, the list of cli arguments will start growing longer and longer, which is probably not a big deal. |
|
Okay, I've dropped a few functional tests in that use the CLI a little bit. It's tricky to unit test this sort of thing without mocking out everything. I could add a For what it's worth, my plan with #105 is to have it run on PRs so it'll actually run on a handful of distributions and that'll definitely exercise this, and I'm happy to not have this merged until then. If you'd prefer everything live in a configuration file, I can change this to do a config file, as well. |
Debian uses "sudo" as the group for having do-anything sudo permissions, where-as Fedora uses "wheel". Otherwise the same binary works fine for both. I don't see an advantage to baking the groups into the binary, so this is a take on runtime configuration. Accept a list of supplementary groups to use when provisioning the user so the same binary can be used for both. Values can be provided using the "-g" or "--groups" argument, or by setting the "AZURE_INIT_USER_GROUPS" environment variable. If no groups are provided, the default remains "wheel". I found this helpful when testing Azure#105. We could expand this to allow more runtime tweaks to, for example, the backend in use if folks like this.
This looks fine for me. The cli arguments and configuration files aren't mutually exclusive. We should have a configuration builder at some point (See #65). Once we do that, we just need to clarify/document the order of precedence when applying configs (cli vs env var vs config file). Btw, we need to document here what is the behavior of env var vs cli (I read clap documentation but it is not obvious to me what happens when the user specifies both, whether unintentionally or intentionally) |
Arguments provided as CLI arguments (`azure-init --groups=wheel,deal`) override any arguments provided by environment variables. They are not merged.
I'm pleased to report clap does what one would expect: arguments override environment variables and there is no merging. e.g. I've added a note to the CLI help text spelling that out. It would probably be good to add a test to assert this behavior in case clap breaks it at some point. I'll need to think a bit about how best to test this. |
dongsupark
left a comment
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.
Happy to see CLI parameters added again.
Debian uses "sudo" as the group for having do-anything sudo permissions, where-as Fedora uses "wheel". Otherwise the same binary works fine for both. I don't see an advantage to baking the groups into the binary, so this is a take on runtime configuration.
Accept a list of supplementary groups to use when provisioning the user so the same binary can be used for both. Values can be provided using the "-g" or "--groups" argument, or by setting the "AZURE_INIT_USER_GROUPS" environment variable. If no groups are provided, the default remains "wheel".
I found this helpful when testing #105. We could expand this to allow more runtime tweaks to, for example, the backend in use if folks like this.
Help text for the CLI is: