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

Switch to unix-style argument handling for addon enabling #1446

Closed
knkski opened this issue Jul 29, 2020 · 0 comments · Fixed by #1467
Closed

Switch to unix-style argument handling for addon enabling #1446

knkski opened this issue Jul 29, 2020 · 0 comments · Fixed by #1467

Comments

@knkski
Copy link
Contributor

knkski commented Jul 29, 2020

This is a proposal to switch to regular unix-style argument handling when enabling addons. Briefly, instead of this:

microk8s.enable kubeflow:"bundle=lite"

switch to this:

microk8s.enable kubeflow --bundle lite

The big issue to solve is that right now, users can enable multiple addons at once like this:

microk8s.enable gpu kubeflow

So, we run into an issue of how to handle argument parsing with multiple addons at once. The easiest thing to do would be to just disallow enabling multiple addons at once when using unix-style argument handling. The only issue with this is that an addon may want positional arguments. For example, say the kubeflow addon allowed a positional argument of which bundle size to deploy, like this:

microk8s.enable kubeflow lite

If the user types microk8s.enable kubeflow gpu dns, do we parse that as the user wanting 3 addons enabled, or only kubeflow and dns enabled, and they mistakenly typed gpu instead of full?

However, if we stick to only parameter flags such as --foo bar, it should be possible to implement unix-style argument handling in a backwards-compatible way. In pseudocode, we could have logic like this:

if all(a.split(':')[0] in ADDONS for a in ARGS):
    # We have a command line made entirely of addon names, with or without params
    # e.g. `microk8s.enable foo bar:"123" baz`
    for addon in ARGS:
        enable(addon)
else:
    # Treat as unix-style arguments, where enabling multiple addons at once is disallowed
    # Positional arguments are also disallowed
    ...

As a further proposal, I think we should move to click, which will make it easy to create a cohesive CLI experience, as it automatically handles stuff such as argument parsing and --help flags.

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

Successfully merging a pull request may close this issue.

1 participant