github.com/pluralsh/plural-cli@v0.9.5/cmd/plural/app.go (about) 1 package plural 2 3 import ( 4 "fmt" 5 "os/exec" 6 "strings" 7 8 tm "github.com/buger/goterm" 9 "github.com/urfave/cli" 10 11 "github.com/pluralsh/plural-cli/pkg/application" 12 "github.com/pluralsh/plural-cli/pkg/config" 13 "github.com/pluralsh/plural-cli/pkg/kubernetes" 14 "github.com/pluralsh/plural-cli/pkg/utils" 15 16 "sigs.k8s.io/application/api/v1beta1" 17 ) 18 19 func handleWatch(c *cli.Context) error { 20 repo := c.Args().Get(0) 21 kubeConf, err := kubernetes.KubeConfig() 22 if err != nil { 23 return err 24 } 25 kube, err := kubernetes.Kubernetes() 26 if err != nil { 27 return err 28 } 29 30 timeout := func() error { return nil } 31 return application.Waiter(kubeConf, repo, func(app *v1beta1.Application) (bool, error) { 32 tm.MoveCursor(1, 1) 33 application.Print(kube.GetClient(), app) 34 application.Flush() 35 return false, nil 36 }, timeout) 37 } 38 39 func handleWait(c *cli.Context) error { 40 repo := c.Args().Get(0) 41 kubeConf, err := kubernetes.KubeConfig() 42 if err != nil { 43 return err 44 } 45 46 return application.Wait(kubeConf, repo) 47 } 48 49 func handleInfo(c *cli.Context) error { 50 repo := c.Args().Get(0) 51 conf := config.Read() 52 53 _, err := exec.LookPath("k9s") 54 if err != nil { 55 utils.LogError().Println(err) 56 if strings.Contains(err.Error(), exec.ErrNotFound.Error()) { 57 utils.Error("Application k9s not installed.\n") 58 fmt.Println("Please install it first from here: https://k9scli.io/topics/install/ and try again") 59 return nil 60 } 61 } 62 63 cmd := exec.Command("k9s", "-n", conf.Namespace(repo)) 64 return cmd.Run() 65 }