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

Improve cli:cowait cluster #305

Open
OskarHandmark opened this issue Apr 21, 2021 · 3 comments
Open

Improve cli:cowait cluster #305

OskarHandmark opened this issue Apr 21, 2021 · 3 comments
Assignees
Labels
cli Command Line Tool discussion Looking for opinions documentation Improvements or additions to documentation help wanted Extra attention is needed

Comments

@OskarHandmark
Copy link
Contributor

OskarHandmark commented Apr 21, 2021

Improve the cowait cluster cli so it's a bit more intuitive. Perhaps include some examples in the the --help output.

$ cowait cluster

Usage: cowait cluster [OPTIONS] COMMAND [ARGS]...

  cluster management

Options:
  --help  Show this message and exit.

Commands:
  add          add new cluster
  default      default cluster name
  get          describe cluster
  ls           list all clusters
  rm           remove cluster
  set-default  set default cluster
$ cowait cluster add --help
Usage: cowait cluster add [OPTIONS] NAME

  add new cluster

Options:
  --type TEXT        cluster provider type
  -o, --option TEXT  specify cluster provider option
  --help             Show this message and exit.
$ cowait cluster add hello
Traceback (most recent call last):
  File "/Users/ohandmark/Library/Caches/pypoetry/virtualenvs/demo-zWrIhaRv-py3.8/bin/cowait", line 8, in <module>
    sys.exit(main())
  File "/Users/ohandmark/Library/Caches/pypoetry/virtualenvs/demo-zWrIhaRv-py3.8/lib/python3.8/site-packages/cowait/__main__.py", line 14, in main
    app(obj=config)
  File "/Users/ohandmark/Library/Caches/pypoetry/virtualenvs/demo-zWrIhaRv-py3.8/lib/python3.8/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/Users/ohandmark/Library/Caches/pypoetry/virtualenvs/demo-zWrIhaRv-py3.8/lib/python3.8/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/Users/ohandmark/Library/Caches/pypoetry/virtualenvs/demo-zWrIhaRv-py3.8/lib/python3.8/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/ohandmark/Library/Caches/pypoetry/virtualenvs/demo-zWrIhaRv-py3.8/lib/python3.8/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/ohandmark/Library/Caches/pypoetry/virtualenvs/demo-zWrIhaRv-py3.8/lib/python3.8/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Users/ohandmark/Library/Caches/pypoetry/virtualenvs/demo-zWrIhaRv-py3.8/lib/python3.8/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/Users/ohandmark/Library/Caches/pypoetry/virtualenvs/demo-zWrIhaRv-py3.8/lib/python3.8/site-packages/click/decorators.py", line 21, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/Users/ohandmark/Library/Caches/pypoetry/virtualenvs/demo-zWrIhaRv-py3.8/lib/python3.8/site-packages/cowait/cli/app/cluster.py", line 47, in add
    cowait.cli.cluster_add(ctx.obj, name, type.lower(), **parse_input_list(option))
AttributeError: 'NoneType' object has no attribute 'lower'```

Aha, maybe type is required

$ cowait cluster add --type kubernetes hello
Error: context option must be provided when creating kubernetes clusters.

What is this context option? -o? What should it be?

  -o, --option TEXT  specify cluster provider option
@johanhenriksson
Copy link
Collaborator

The --option parameter is used to set options on the cluster definition :)

context is the name of the kubernetes context to use for the cluster. It's required because omitting it would be equivalent to just using the built-in --cluster kubernetes

Some other examples:

clusters:
  dev:
    type: kubernetes
    context: backtick-hq
    domain: hq.backtick.se
    router: traefik2
    traefik2:
      certresolver: default

Since they differ by cluster type, it might be a better idea to add subcommands to add clusters of different types, e.g. cowait cluster add kubernetes <context name> --domain=hq.backtick.se

@johanhenriksson johanhenriksson added cli Command Line Tool discussion Looking for opinions documentation Improvements or additions to documentation help wanted Extra attention is needed labels Apr 21, 2021
@OskarHandmark
Copy link
Contributor Author

I see. Makes sense :)

I believe it's hard for new users to understand this. I don't think it's obvious that --option is "repeatable" and what the possible inputs could be. Perhaps this is just a documentation thing.

Couldn't we just be explicit about the different options that are available? i.e instead of --option, show which options are available. i.e:

$ cowait cluster add --help
Usage: cowait cluster add [OPTIONS] NAME

  add new cluster

Options:
  --type TEXT        cluster provider type
  --router TEXT     router to use e.g `traefik2`
  --domain TEXT   kubernetes domain
  --help             Show this message and exit.

I agree with cowait cluster add kubernetes backtick-hq --domain=hq.backtick.se, looks nice 👍

@OskarHandmark OskarHandmark self-assigned this Apr 24, 2021
@OskarHandmark
Copy link
Contributor Author

Also #126

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cli Command Line Tool discussion Looking for opinions documentation Improvements or additions to documentation help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants