From 0d1636ccacc5fdf838c3a996389748f29860ba1c Mon Sep 17 00:00:00 2001 From: Jacob McCann Date: Sat, 14 Jan 2017 21:51:43 -0600 Subject: [PATCH] Add checks for required parameters --- main.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/main.go b/main.go index 57c40ca..15d4922 100644 --- a/main.go +++ b/main.go @@ -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"),