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

[1.12] plugin commands with dashes cannot be invoked with their original names #540

Closed
ahmetb opened this issue Sep 25, 2018 · 6 comments
Closed
Assignees
Labels
area/kubectl kind/bug Categorizes issue or PR as related to a bug. priority/P2 sig/cli Categorizes an issue or PR as relevant to SIG CLI.

Comments

@ahmetb
Copy link
Member

ahmetb commented Sep 25, 2018

Is this a BUG REPORT or FEATURE REQUEST? (choose one): BUG REPORT
Kubernetes version (use kubectl version): 1.12.0-beta.2

What happened:

There are already plugins named with dashes (-) in the plugin name, such as:

  • open-svc
  • ca-cert
  • rm-standalone-pods

in the krew package manager. There are also many plugins outside krew, such as:

kubectl 1.12 splits the names of these plugins into separate subcommands, such as:

previously called now called as
kubectl plugin open-svc kubectl open svc [...]
kubectl plugin rm-standalone-pod kubectl rm standalone pod [...]

What you expected to happen:

This new behavior is quite unexpected for me. This makes it:

  1. impossible to write plugins with dashes in the name

    For example, if I write a plugin named port-forward-better, my users have to invoke it as kubectl port forward better (not desirable) as opposed to kubectl port-forward-better.

  2. Undesired categorization of plugins that share the same prefix:

    For example, if I'm writing a plugin named rm-standalone-pods installing a plugin with another rm- prefix (such as rm-completed-jobs). They will be (someday) grouped under kubectl rm despite they're different plugins.

I Expected: if a plugin named kubectl-delete-all exists, I should be able to call it kubectl delete-all. Being able to call it as kubectl delete all may still be ok as the artifact of the feature, but it should not prevent kubectl delete-all invocation.

I am sorry I wasn't there to review the design but I think design won't work for the broader plugin ecosystem.

/cc @soltysh
/cc @lbb

@ahmetb ahmetb changed the title [1.12] plugin command cannot have dashes in them [1.12] plugin commands with dashes cannot be invoked with their original names Sep 25, 2018
@seans3
Copy link
Contributor

seans3 commented Sep 26, 2018

/kind bug
/sig cli
/area kubectl
/priority P2
/assign @juanvallejo

@k8s-ci-robot k8s-ci-robot added kind/bug Categorizes issue or PR as related to a bug. sig/cli Categorizes an issue or PR as relevant to SIG CLI. area/kubectl priority/P2 labels Sep 26, 2018
@juanvallejo
Copy link

juanvallejo commented Sep 26, 2018

Hey @ahmetb thanks for pointing this out.
Under the new design, you can use underscores in your plugin executable's name to allow for plugin command names with dashes:

$ cat /usr/local/bin/kubectl-dash_test
#!/bin/bash

echo "I am a plugin with a dash in my name"
$ kubectl dash-test
I am a plugin with a dash in my name

I have a PR updating the website's plugin documentation here and will make sure to specifically mention this part of the design on there.

Thanks

@ahmetb
Copy link
Member Author

ahmetb commented Sep 26, 2018

@juanvallejo That sounds like good news! It's not a great hack but it seems like it can do the trick. I'll close this once I verify.

@ahmetb
Copy link
Member Author

ahmetb commented Sep 26, 2018

/assign

@juanvallejo
Copy link

@ahmetb

That sounds like good news! It's not a great hack but it seems like it can do the trick. I'll close this once I verify.

Thanks. To clarify, this does not prevent underscores from being used as part of a command's name, rather it means that plugin commands with underscores can be invoked either with an underscore or a dash:

$ kubectl dash-test
I am a plugin with a dash in my name
$ kubectl dash_test
I am a plugin with a dash in my name

@ahmetb
Copy link
Member Author

ahmetb commented Sep 26, 2018

@juanvallejo Yes, I see now. I think this gives us enough to refactor existing krew plugins to work. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/kubectl kind/bug Categorizes issue or PR as related to a bug. priority/P2 sig/cli Categorizes an issue or PR as relevant to SIG CLI.
Projects
None yet
Development

No branches or pull requests

4 participants