Skip to content

Commit

Permalink
add fish shell completion (#4751)
Browse files Browse the repository at this point in the history
fixes #4208

Signed-off-by: Wei Lun <weilun_95@hotmail.com>
  • Loading branch information
WLun001 authored Jul 20, 2020
1 parent 146c593 commit 85a042c
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 16 deletions.
2 changes: 1 addition & 1 deletion Dockerfile-proxy
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ RUN (proxy=$(bin/fetch-proxy $(cat proxy-version)) && \
mv "$proxy" linkerd2-proxy)

## compile proxy-identity agent
FROM gcr.io/linkerd-io/go-deps:a525d867 as golang
FROM gcr.io/linkerd-io/go-deps:61149d15 as golang
WORKDIR /linkerd-build
COPY pkg/flags pkg/flags
COPY pkg/tls pkg/tls
Expand Down
2 changes: 1 addition & 1 deletion cli/Dockerfile-bin
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
## compile binaries
FROM gcr.io/linkerd-io/go-deps:a525d867 as golang
FROM gcr.io/linkerd-io/go-deps:61149d15 as golang
WORKDIR /linkerd-build
COPY cli cli
COPY charts charts
Expand Down
21 changes: 15 additions & 6 deletions cli/cmd/completion.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,21 @@ func newCmdCompletion() *cobra.Command {
source <(linkerd completion zsh)
# zsh on osx / oh-my-zsh
linkerd completion zsh > "${fpath[1]}/_linkerd"`
linkerd completion zsh > "${fpath[1]}/_linkerd"
# fish:
linkerd completion fish | source
# To load fish shell completions for each session, execute once:
linkerd completion fish > ~/.config/fish/completions/linkerd.fish`

cmd := &cobra.Command{
Use: "completion [bash|zsh]",
Short: "Output shell completion code for the specified shell (bash or zsh)",
Long: "Output shell completion code for the specified shell (bash or zsh).",
Use: "completion [bash|zsh|fish]",
Short: "Output shell completion code for the specified shell (bash, zsh or fish)",
Long: "Output shell completion code for the specified shell (bash, zsh or fish).",
Example: example,
Args: cobra.ExactArgs(1),
ValidArgs: []string{"bash", "zsh"},
ValidArgs: []string{"bash", "zsh", "fish"},
RunE: func(cmd *cobra.Command, args []string) error {
out, err := getCompletion(args[0], cmd.Parent())
if err != nil {
Expand All @@ -62,8 +68,11 @@ func getCompletion(sh string, parent *cobra.Command) (string, error) {
err = parent.GenBashCompletion(&buf)
case "zsh":
err = parent.GenZshCompletion(&buf)
case "fish":
err = parent.GenFishCompletion(&buf, true)

default:
err = errors.New("unsupported shell type (must be bash or zsh): " + sh)
err = errors.New("unsupported shell type (must be bash, zsh or fish): " + sh)
}

if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion cni-plugin/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
## compile cni-plugin utility
FROM gcr.io/linkerd-io/go-deps:a525d867 as golang
FROM gcr.io/linkerd-io/go-deps:61149d15 as golang
WORKDIR /linkerd-build
COPY pkg pkg
COPY controller controller
Expand Down
2 changes: 1 addition & 1 deletion controller/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
## compile controller service
FROM gcr.io/linkerd-io/go-deps:a525d867 as golang
FROM gcr.io/linkerd-io/go-deps:61149d15 as golang
WORKDIR /linkerd-build
COPY controller/gen controller/gen
COPY pkg pkg
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ require (
github.com/shurcooL/httpfs v0.0.0-20190707220628-8d4bc4ba7749 // indirect
github.com/shurcooL/vfsgen v0.0.0-20181202132449-6a9ea43bcacd
github.com/sirupsen/logrus v1.6.0
github.com/spf13/cobra v0.0.5
github.com/spf13/cobra v1.0.0
github.com/spf13/pflag v1.0.5
github.com/stretchr/testify v1.5.1 // indirect
github.com/wercker/stern v0.0.0-20190705090245-4fa46dd6987f
Expand Down
35 changes: 31 additions & 4 deletions go.sum

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion web/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ COPY web/app ./web/app
RUN ./bin/web build

## compile go server
FROM gcr.io/linkerd-io/go-deps:a525d867 as golang
FROM gcr.io/linkerd-io/go-deps:61149d15 as golang
WORKDIR /linkerd-build
RUN mkdir -p web
COPY web/main.go web
Expand Down

0 comments on commit 85a042c

Please sign in to comment.