api key check
This commit is contained in:
parent
f198c45f75
commit
61f6398711
28
main.go
28
main.go
@ -32,7 +32,7 @@ func main() {
|
||||
},
|
||||
{
|
||||
Name: "verify",
|
||||
Usage: "Verify .tidelift.yml configuration",
|
||||
Usage: "Verify .tidelift.yml configuration and your ability to upload scans",
|
||||
Action: func(c *cli.Context) error {
|
||||
everyCommand()
|
||||
directory := getDirectory(c)
|
||||
@ -40,15 +40,6 @@ func main() {
|
||||
return verify(directory)
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "configure",
|
||||
Aliases: []string{"c"},
|
||||
Usage: "Configure the app",
|
||||
Action: func(c *cli.Context) error {
|
||||
everyCommand()
|
||||
return cli.NewExitError("No Configuration provided", 4)
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
err := app.Run(os.Args)
|
||||
@ -66,21 +57,15 @@ func getDirectory(c *cli.Context) string {
|
||||
}
|
||||
return "."
|
||||
}
|
||||
func checkAPIKey() error {
|
||||
|
||||
/// everyCommand is things to run for every command
|
||||
func everyCommand() error {
|
||||
if os.Getenv("TIDELIFT_API_KEY") == "" {
|
||||
return cli.NewExitError("please set TIDELIFT_API_KEY environment variable", 8)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func everyCommand() error {
|
||||
err := checkAPIKey()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Scan will scan a directory's manifests for all supported manifest files
|
||||
// then it will upload them to tidelift for scanning
|
||||
func scan(directory string) error {
|
||||
@ -110,9 +95,6 @@ func verify(directory string) error {
|
||||
return cli.NewExitError(errorMsg, 7)
|
||||
}
|
||||
|
||||
if os.Getenv("TIDELIFT_API_KEY") == "" {
|
||||
return cli.NewExitError("please set TIDELIFT_API_KEY environment variable", 8)
|
||||
}
|
||||
|
||||
fmt.Println("Your team-name, repo-name and TIDELIFT_API_KEY are all set! Feel free to use `scan`")
|
||||
return nil
|
||||
}
|
||||
|
@ -12,7 +12,6 @@ func TestVerifyTideliftYamlExists(t *testing.T) {
|
||||
|
||||
verifiedTrue := verifyTideliftYamlExists("test/bad_config")
|
||||
assert.True(t, verifiedTrue, "should be a .tidelift.yml in test/bad_config")
|
||||
|
||||
}
|
||||
|
||||
func TestPassesMinimumRequirements(t *testing.T) {
|
||||
|
Loading…
Reference in New Issue
Block a user