mirror of
https://github.com/safedep/vet.git
synced 2025-12-10 00:22:08 -06:00
#7: Show success msg for auth verification
This commit is contained in:
parent
b9530c0fbe
commit
8097829f54
11
README.md
11
README.md
@ -55,9 +55,16 @@ vet auth configure
|
||||
```
|
||||
|
||||
> Insights API is used to enrich OSS packages with meta-data for rich query and policy
|
||||
> decisions
|
||||
> decisions. Alternatively, the API key can be passed through environment
|
||||
> variable `VET_API_KEY`
|
||||
|
||||
Run `vet` to identify risks
|
||||
Verify authentication token is valid
|
||||
|
||||
```bash
|
||||
vet auth verify
|
||||
```
|
||||
|
||||
Run `vet` to identify risks in a source repository
|
||||
|
||||
```bash
|
||||
vet scan -D /path/to/repository
|
||||
|
||||
2
auth.go
2
auth.go
@ -10,6 +10,7 @@ import (
|
||||
"golang.org/x/term"
|
||||
|
||||
"github.com/safedep/vet/internal/auth"
|
||||
"github.com/safedep/vet/internal/ui"
|
||||
)
|
||||
|
||||
var (
|
||||
@ -76,6 +77,7 @@ func verifyAuthCommand() *cobra.Command {
|
||||
ControlPlaneApiUrl: authControlPlaneApiBaseUrl,
|
||||
}))
|
||||
|
||||
ui.PrintSuccess("Authentication key is valid!")
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
||||
@ -10,8 +10,9 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
apiUrlEnvKey = "VET_INSIGHTS_API_URL"
|
||||
apiKeyEnvKey = "VET_INSIGHTS_API_KEY"
|
||||
apiUrlEnvKey = "VET_INSIGHTS_API_URL"
|
||||
apiKeyEnvKey = "VET_INSIGHTS_API_KEY"
|
||||
apiKeyAlternateEnvKey = "VET_API_KEY"
|
||||
|
||||
defaultApiUrl = "https://api.safedep.io/insights/v1"
|
||||
defaultControlPlaneApiUrl = "https://api.safedep.io/control-plane/v1"
|
||||
@ -61,6 +62,10 @@ func ApiKey() string {
|
||||
return key
|
||||
}
|
||||
|
||||
if key, ok := os.LookupEnv(apiKeyAlternateEnvKey); ok {
|
||||
return key
|
||||
}
|
||||
|
||||
if globalConfig != nil {
|
||||
return globalConfig.ApiKey
|
||||
}
|
||||
|
||||
@ -11,6 +11,11 @@ func PrintBanner(s string) {
|
||||
fmt.Fprintf(os.Stderr, s)
|
||||
}
|
||||
|
||||
func PrintSuccess(s string, args ...any) {
|
||||
msg := fmt.Sprintf(s, args...)
|
||||
fmt.Fprint(os.Stderr, text.FgGreen.Sprint(msg), "\n")
|
||||
}
|
||||
|
||||
func PrintError(s string, args ...any) {
|
||||
msg := fmt.Sprintf(s, args...)
|
||||
fmt.Fprint(os.Stderr, text.FgRed.Sprint(msg), "\n")
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user