From 44f18c0104b7c7deb59fd5594c57cdb0c48b21f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Pra=C5=BCak?= Date: Sun, 18 Feb 2018 17:15:56 +0100 Subject: [PATCH] main: add missing preconditions to commands (#63) - fixed panic when a repository was not provided to: delete, manifest, download, vulns --- main.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/main.go b/main.go index c8b43224..f4e676f2 100644 --- a/main.go +++ b/main.go @@ -108,6 +108,10 @@ func main() { Aliases: []string{"rm"}, Usage: "delete a specific reference of a repository", Action: func(c *cli.Context) error { + if len(c.Args()) < 1 { + return fmt.Errorf("pass the name of the repository") + } + repo, ref, err := utils.GetRepoAndRef(c.Args()[0]) if err != nil { return err @@ -173,6 +177,10 @@ func main() { }, }, Action: func(c *cli.Context) error { + if len(c.Args()) < 1 { + return fmt.Errorf("pass the name of the repository") + } + repo, ref, err := utils.GetRepoAndRef(c.Args()[0]) if err != nil { return err @@ -231,6 +239,10 @@ func main() { }, }, Action: func(c *cli.Context) error { + if len(c.Args()) < 1 { + return fmt.Errorf("pass the name of the repository") + } + repo, ref, err := utils.GetRepoAndRef(c.Args()[0]) if err != nil { return err @@ -269,6 +281,9 @@ func main() { if c.String("clair") == "" { return errors.New("clair url cannot be empty, pass --clair") } + if len(c.Args()) < 1 { + return fmt.Errorf("pass the name of the repository") + } repo, ref, err := utils.GetRepoAndRef(c.Args()[0]) if err != nil {