From 57a1d712eddd811d1b5120fed39d7467b3c702c3 Mon Sep 17 00:00:00 2001 From: Rick <1450685+LinuxSuRen@users.noreply.github.com> Date: Fri, 1 Apr 2022 15:48:50 +0800 Subject: [PATCH] Fix the exit code is 0 when errors happened (#257) * Fix the exit code is 0 when errors happened * Fix the lint issues --- go.mod | 2 +- go.sum | 4 ++-- kubectl-plugin/app/root.go | 1 + kubectl-plugin/common/exec.go | 1 + 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index a2d8845..c84221d 100644 --- a/go.mod +++ b/go.mod @@ -14,7 +14,7 @@ require ( github.com/huandu/xstrings v1.3.2 // indirect github.com/jenkins-x/go-scm v1.11.1 github.com/linuxsuren/cobra-extension v0.0.11 - github.com/linuxsuren/go-cli-alias v0.0.8 + github.com/linuxsuren/go-cli-alias v0.0.10 github.com/linuxsuren/http-downloader v0.0.35 github.com/mitchellh/copystructure v1.1.1 // indirect github.com/rivo/tview v0.0.0-20210923051754-2cb20002bc4c diff --git a/go.sum b/go.sum index 37544af..07edb21 100644 --- a/go.sum +++ b/go.sum @@ -379,8 +379,8 @@ github.com/linuxsuren/cobra-extension v0.0.6/go.mod h1:qcEJv7BbL0UpK6MbrTESP/nKf github.com/linuxsuren/cobra-extension v0.0.10/go.mod h1:nDsXgvm0lSWVV+byAEfwhIGFDoIp0Sq9wkfNUDBp5do= github.com/linuxsuren/cobra-extension v0.0.11 h1:Z2Sx8dBPvJK3s3loguFXJtrtiwh1Od3O2xoB6vCOl5M= github.com/linuxsuren/cobra-extension v0.0.11/go.mod h1:gn69Dtq72JCGZbjW46c14MoE0z/BtDAQWV9Jvr9KczY= -github.com/linuxsuren/go-cli-alias v0.0.8 h1:iTArwDhhrZaXlk9m7ZnvzjHFyguJEJA3uDdCEXt8ccw= -github.com/linuxsuren/go-cli-alias v0.0.8/go.mod h1:g+k4hlbE/lilrEq/5emhMznb9my/lOXSH++/mPli6gw= +github.com/linuxsuren/go-cli-alias v0.0.10 h1:qzaz9RiTVKIWryxw3Hx0q//wjt+VIP+BElgRlSWrDhU= +github.com/linuxsuren/go-cli-alias v0.0.10/go.mod h1:g+k4hlbE/lilrEq/5emhMznb9my/lOXSH++/mPli6gw= github.com/linuxsuren/http-downloader v0.0.2-0.20201207132639-19888a6beaec/go.mod h1:zRZY9FCDBuYNDxbI2Ny5suasZsMk7J6q9ecQ3V3PIqI= github.com/linuxsuren/http-downloader v0.0.6/go.mod h1:xxgh2OE7WGL9TwDE9L8Gh7Lqq9fFPuHbh5tofUitEfE= github.com/linuxsuren/http-downloader v0.0.23/go.mod h1:rUjrcLzC9cAgKSgwEhwDXH5LL0Y/aK5KpTJrA3eqW1s= diff --git a/kubectl-plugin/app/root.go b/kubectl-plugin/app/root.go index 88296a0..3bceabc 100644 --- a/kubectl-plugin/app/root.go +++ b/kubectl-plugin/app/root.go @@ -6,6 +6,7 @@ import ( "k8s.io/client-go/kubernetes" ) +// NewAppCmd creates a root command of the application func NewAppCmd(client dynamic.Interface, clientset *kubernetes.Clientset) (cmd *cobra.Command) { cmd = &cobra.Command{ Use: "app", diff --git a/kubectl-plugin/common/exec.go b/kubectl-plugin/common/exec.go index b4721cf..65dd159 100644 --- a/kubectl-plugin/common/exec.go +++ b/kubectl-plugin/common/exec.go @@ -12,6 +12,7 @@ func ExecCommand(name string, arg ...string) error { return ExecCommandInDirectory(name, "", arg...) } +// ExecCommandInDirectory runs a command in a particular directory func ExecCommandInDirectory(name, dir string, arg ...string) (err error) { command := exec.Command(name, arg...) command.Dir = dir