Merge pull request #4914 from blackpiglet/4912-fix-completion-zsh

Make velero completion zsh command output can be used by `source` com…
This commit is contained in:
Scott Seago
2022-05-23 10:05:12 -04:00
committed by GitHub
2 changed files with 10 additions and 1 deletions
+1
View File
@@ -0,0 +1 @@
Make velero completion zsh command output can be used by `source` command.
+9 -1
View File
@@ -66,7 +66,15 @@ $ velero completion fish > ~/.config/fish/completions/velero.fish
case "bash":
cmd.Root().GenBashCompletion(os.Stdout)
case "zsh":
cmd.Root().GenZshCompletion(os.Stdout)
// # fix #4912
// cobra does not support zsh completion ouptput used by source command
// according to https://github.com/spf13/cobra/issues/1529
// Need to append compdef manually to do that.
zshHead := "#compdef velero\ncompdef _velero velero\n"
out := os.Stdout
out.Write([]byte(zshHead))
cmd.Root().GenZshCompletion(out)
case "fish":
cmd.Root().GenFishCompletion(os.Stdout, true)
default: