main: add missing preconditions to commands (#63)

- fixed panic when a repository was not provided to:
  delete, manifest, download, vulns
This commit is contained in:
Paweł Prażak 2018-02-18 17:15:56 +01:00 committed by Jess Frazelle
parent 22cbb0f2a0
commit 44f18c0104

15
main.go
View file

@ -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 {