The linkerd completion command does not work as expected on zsh.
The completion scripts are generated, but sourcing them does not provide shell completion. Not sure if this error is restricted to only zsh.
Run:
$ source <(linkerd completion zsh)
Completion does not work
(If the output is long, please create a gist and
paste the link here.)
linkerd check outputyour output here ...
Could be an issue with cobra completion script generator. Check https://github.com/spf13/cobra/issues/881
Looks like this is more about the instructions being wrong than a blocker bug itself?
I was able to get linkerd shell completion to work on oh-my-zsh on macOS (10.15) by:
autoload -U compinit && compinit to .zsrhrclinkerd completion zsh > "${fpath[1]}/_linkerd" I used linkerd completion zsh > "~/.oh-my-zsh/completions/_linkerd" (not that it matters, it's just that ${fpath[1]} pointed to another oh-my-zsh plugin)But what really got it working was changing all the lines in the _linkerd script that go:
'(-L --linkerd-namespace)'{-L,--linkerd-namespace}'[Namespace in which Linkerd is installed [$LINKERD_NAMESPACE]]:' \
to
'(-L --linkerd-namespace)'{-L,--linkerd-namespace}'[Namespace in which Linkerd is installed \[$LINKERD_NAMESPACE\]]:' \
With the [ and ] characters in the flag description escaped (thanks to clap-rs/clap#771 that pointed the way).
Indeed, it looks to be an issue with spf13/cobra, in particular, following the links from spf13/cobra#881:
Unfortunately, the changes in https://github.com/spf13/cobra/pull/1070 still haven't been released.
So... looks like we just have to wait for a new release of spf13/cobra, _or_ avoid using square brackets in the flag description.
@aisrael good investigation :+1: Cobra's releases are taking ages, so for now I'd vote for getting rid of the brackets. Would you be up for a PR? :wink:
Any updates on this issue? Is really noone using zsh completion? I'm trying out linkerd the first time and using oh-my-zsh as well (Linux). Still doesnt work. At least someone have a ready regexp for replacing the broken brackets on the fly? I will workround for now doing it manually.
Anyhows linkerd seems awesome ^^
My workaround does replace all the mentioned [$LINKERD_NAMESPACE] with [$LINKERD_NAMESPACE] but it still does not work as proposed by @aisrael
This is my complete fix that doesn't fix it unfortunately :/
autoload -U compinit && compinit
(linkerd completion zsh | sed 's/\[$LINKERD_NAMESPACE\]/\\\[$LINKERD_NAMESPACE\\\]/g') > "${fpath[1]}/_linkerd"
Another update ... it does work. Just sourcing the above files is NOT sufficient. Whoever encounters this: You need to restart the shell completely (actually I don't know why, probably a oh-my-zsh thing)
simple () will also work fine
We've been patiently waiting for the upstream fixes, but if there are workarounds we can apply within Linkerd, we'd _love_ a PR.
We've been patiently waiting for the upstream fixes, but if there are workarounds we can apply within Linkerd, we'd love a PR.
As I proposed, "simple ()" should work fine... PR 馃憜
Most helpful comment
We've been patiently waiting for the upstream fixes, but if there are workarounds we can apply within Linkerd, we'd _love_ a PR.