api key check

This commit is contained in:
Tyrel Souza 2019-05-15 22:34:22 -04:00 committed by Tyrel Souza
parent f198c45f75
commit 61f6398711
No known key found for this signature in database
GPG Key ID: 5A9394D4C30AEAC0
2 changed files with 5 additions and 24 deletions

28
main.go
View File

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

View File

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