mirror of
https://github.com/safedep/vet.git
synced 2025-12-11 09:25:44 -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
|
> 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
|
```bash
|
||||||
vet scan -D /path/to/repository
|
vet scan -D /path/to/repository
|
||||||
|
|||||||
2
auth.go
2
auth.go
@ -10,6 +10,7 @@ import (
|
|||||||
"golang.org/x/term"
|
"golang.org/x/term"
|
||||||
|
|
||||||
"github.com/safedep/vet/internal/auth"
|
"github.com/safedep/vet/internal/auth"
|
||||||
|
"github.com/safedep/vet/internal/ui"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -76,6 +77,7 @@ func verifyAuthCommand() *cobra.Command {
|
|||||||
ControlPlaneApiUrl: authControlPlaneApiBaseUrl,
|
ControlPlaneApiUrl: authControlPlaneApiBaseUrl,
|
||||||
}))
|
}))
|
||||||
|
|
||||||
|
ui.PrintSuccess("Authentication key is valid!")
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,8 +10,9 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
apiUrlEnvKey = "VET_INSIGHTS_API_URL"
|
apiUrlEnvKey = "VET_INSIGHTS_API_URL"
|
||||||
apiKeyEnvKey = "VET_INSIGHTS_API_KEY"
|
apiKeyEnvKey = "VET_INSIGHTS_API_KEY"
|
||||||
|
apiKeyAlternateEnvKey = "VET_API_KEY"
|
||||||
|
|
||||||
defaultApiUrl = "https://api.safedep.io/insights/v1"
|
defaultApiUrl = "https://api.safedep.io/insights/v1"
|
||||||
defaultControlPlaneApiUrl = "https://api.safedep.io/control-plane/v1"
|
defaultControlPlaneApiUrl = "https://api.safedep.io/control-plane/v1"
|
||||||
@ -61,6 +62,10 @@ func ApiKey() string {
|
|||||||
return key
|
return key
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if key, ok := os.LookupEnv(apiKeyAlternateEnvKey); ok {
|
||||||
|
return key
|
||||||
|
}
|
||||||
|
|
||||||
if globalConfig != nil {
|
if globalConfig != nil {
|
||||||
return globalConfig.ApiKey
|
return globalConfig.ApiKey
|
||||||
}
|
}
|
||||||
|
|||||||
@ -11,6 +11,11 @@ func PrintBanner(s string) {
|
|||||||
fmt.Fprintf(os.Stderr, s)
|
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) {
|
func PrintError(s string, args ...any) {
|
||||||
msg := fmt.Sprintf(s, args...)
|
msg := fmt.Sprintf(s, args...)
|
||||||
fmt.Fprint(os.Stderr, text.FgRed.Sprint(msg), "\n")
|
fmt.Fprint(os.Stderr, text.FgRed.Sprint(msg), "\n")
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user