Add checks for required parameters

This commit is contained in:
Jacob McCann 2017-01-14 21:51:43 -06:00
parent 01e2500003
commit 0d1636ccac

15
main.go
View File

@ -1,6 +1,7 @@
package main
import (
"fmt"
"os"
"github.com/Sirupsen/logrus"
@ -58,6 +59,20 @@ func run(c *cli.Context) error {
"Revision": revision,
}).Info("Drone Clair Plugin Version")
// Validate required values provided
if c.String("url") == "" {
return fmt.Errorf("Please provide the URL to your Clair server.")
}
if c.String("username") == "" {
return fmt.Errorf("Please provide the username to your Docker Registry.")
}
if c.String("password") == "" {
return fmt.Errorf("Please provide the password to your Docker Registry.")
}
if c.String("scan_image") == "" {
return fmt.Errorf("Please provide the image you want to scan.")
}
plugin := Plugin{
Url: c.String("url"),
Username: c.String("username"),