api key
This commit is contained in:
parent
a472d2f337
commit
f198c45f75
21
main.go
21
main.go
@ -24,6 +24,7 @@ func main() {
|
|||||||
Aliases: []string{"s"},
|
Aliases: []string{"s"},
|
||||||
Usage: "Scan a directory's manifests",
|
Usage: "Scan a directory's manifests",
|
||||||
Action: func(c *cli.Context) error {
|
Action: func(c *cli.Context) error {
|
||||||
|
everyCommand()
|
||||||
directory := getDirectory(c)
|
directory := getDirectory(c)
|
||||||
|
|
||||||
return scan(directory)
|
return scan(directory)
|
||||||
@ -33,6 +34,7 @@ func main() {
|
|||||||
Name: "verify",
|
Name: "verify",
|
||||||
Usage: "Verify .tidelift.yml configuration",
|
Usage: "Verify .tidelift.yml configuration",
|
||||||
Action: func(c *cli.Context) error {
|
Action: func(c *cli.Context) error {
|
||||||
|
everyCommand()
|
||||||
directory := getDirectory(c)
|
directory := getDirectory(c)
|
||||||
|
|
||||||
return verify(directory)
|
return verify(directory)
|
||||||
@ -43,6 +45,7 @@ func main() {
|
|||||||
Aliases: []string{"c"},
|
Aliases: []string{"c"},
|
||||||
Usage: "Configure the app",
|
Usage: "Configure the app",
|
||||||
Action: func(c *cli.Context) error {
|
Action: func(c *cli.Context) error {
|
||||||
|
everyCommand()
|
||||||
return cli.NewExitError("No Configuration provided", 4)
|
return cli.NewExitError("No Configuration provided", 4)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -63,6 +66,20 @@ func getDirectory(c *cli.Context) string {
|
|||||||
}
|
}
|
||||||
return "."
|
return "."
|
||||||
}
|
}
|
||||||
|
func checkAPIKey() 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
|
// 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
|
||||||
@ -82,6 +99,7 @@ func scan(directory string) error {
|
|||||||
// in order to upload a manifest to Tidelift
|
// in order to upload a manifest to Tidelift
|
||||||
func verify(directory string) error {
|
func verify(directory string) error {
|
||||||
// Show error if no .tidelift.yml file
|
// Show error if no .tidelift.yml file
|
||||||
|
|
||||||
if !verifyTideliftYamlExists(directory) {
|
if !verifyTideliftYamlExists(directory) {
|
||||||
return cli.NewExitError("no .tidelift.yml at supplied directory path", 6)
|
return cli.NewExitError("no .tidelift.yml at supplied directory path", 6)
|
||||||
}
|
}
|
||||||
@ -90,7 +108,10 @@ func verify(directory string) error {
|
|||||||
if missingKey != "" {
|
if missingKey != "" {
|
||||||
errorMsg := fmt.Sprintf("Missing key '%s:' in .tidelift.yml", missingKey)
|
errorMsg := fmt.Sprintf("Missing key '%s:' in .tidelift.yml", missingKey)
|
||||||
return cli.NewExitError(errorMsg, 7)
|
return cli.NewExitError(errorMsg, 7)
|
||||||
|
}
|
||||||
|
|
||||||
|
if os.Getenv("TIDELIFT_API_KEY") == "" {
|
||||||
|
return cli.NewExitError("please set TIDELIFT_API_KEY environment variable", 8)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
Loading…
Reference in New Issue
Block a user