Add checks for required parameters
This commit is contained in:
parent
01e2500003
commit
0d1636ccac
15
main.go
15
main.go
@ -1,6 +1,7 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/Sirupsen/logrus"
|
"github.com/Sirupsen/logrus"
|
||||||
@ -58,6 +59,20 @@ func run(c *cli.Context) error {
|
|||||||
"Revision": revision,
|
"Revision": revision,
|
||||||
}).Info("Drone Clair Plugin Version")
|
}).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{
|
plugin := Plugin{
|
||||||
Url: c.String("url"),
|
Url: c.String("url"),
|
||||||
Username: c.String("username"),
|
Username: c.String("username"),
|
||||||
|
Loading…
Reference in New Issue
Block a user