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