Skip to content

Commit

Permalink
improve error handling for not installed k9s (#249)
Browse files Browse the repository at this point in the history
Co-authored-by: test <[email protected]>
  • Loading branch information
zreigz and test authored Nov 3, 2022
1 parent 047018c commit 907ed4e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
13 changes: 13 additions & 0 deletions cmd/plural/app.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
package main

import (
"fmt"
"os/exec"
"strings"

tm "github.com/buger/goterm"
"github.com/urfave/cli"

"github.com/pluralsh/plural/pkg/application"
"github.com/pluralsh/plural/pkg/config"
"github.com/pluralsh/plural/pkg/kubernetes"
"github.com/pluralsh/plural/pkg/utils"

"sigs.k8s.io/application/api/v1beta1"
)
Expand Down Expand Up @@ -46,6 +49,16 @@ func handleWait(c *cli.Context) error {
func handleInfo(c *cli.Context) error {
repo := c.Args().Get(0)
conf := config.Read()

_, err := exec.LookPath("k9s")
if err != nil {
if strings.Contains(err.Error(), exec.ErrNotFound.Error()) {
utils.Error("Application k9s not installed.\n")
fmt.Println("Please install it first from here: https://k9scli.io/topics/install/ and try again")
return nil
}
}

cmd := exec.Command("k9s", "-n", conf.Namespace(repo))
return cmd.Run()
}
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ require (
github.com/docker/go-metrics v0.0.1 // indirect
github.com/docker/go-units v0.4.0 // indirect
github.com/emirpasic/gods v1.12.0 // indirect
github.com/evanphx/json-patch v4.12.0+incompatible // indirect
github.com/evanphx/json-patch v4.12.0+incompatible
github.com/exponent-io/jsonpath v0.0.0-20151013193312-d6023ce2651d // indirect
github.com/ghodss/yaml v1.0.0 // indirect
github.com/gin-contrib/sse v0.1.0 // indirect
Expand Down Expand Up @@ -241,7 +241,7 @@ require (
golang.org/x/text v0.3.7
golang.org/x/time v0.0.0-20220411224347-583f2d630306 // indirect
golang.org/x/xerrors v0.0.0-20220609144429-65e65417b02f // indirect
google.golang.org/api v0.84.0 // indirect
google.golang.org/api v0.84.0
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/grpc v1.48.0 // indirect
google.golang.org/protobuf v1.28.1 // indirect
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -944,8 +944,6 @@ github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/sftp v1.10.1/go.mod h1:lYOWFsE0bwd1+KfKJaKeuokY15vzFx25BLbzYYoAxZI=
github.com/pluralsh/gqlclient v1.1.6 h1:lj6KVfUET9DPyB95+T+hXtCGqqOm+TXOB3jYzuBX1Zc=
github.com/pluralsh/gqlclient v1.1.6/go.mod h1:qcE4KD7hBGl/JFCoXXy8zgUP0mWHJsAM6bhDAf592AE=
github.com/pluralsh/gqlclient v1.1.7 h1:wczOD8H1J2N/ov4ohNcDY6mdbARZ1WulMaZToGCHCS0=
github.com/pluralsh/gqlclient v1.1.7/go.mod h1:qcE4KD7hBGl/JFCoXXy8zgUP0mWHJsAM6bhDAf592AE=
github.com/pluralsh/oauth v0.9.1-0.20220520000222-d76c0e7a0db9 h1:bMkXXUksi9ym+enaNlvds/BUg7SkZ/3ir8D3OsznA+E=
Expand Down

0 comments on commit 907ed4e

Please sign in to comment.