diff options
author | Martin Polden <mpolden@mpolden.no> | 2022-03-02 14:27:56 +0100 |
---|---|---|
committer | Martin Polden <mpolden@mpolden.no> | 2022-03-02 14:29:20 +0100 |
commit | a227acd6a1b4fdf3a4afa726ae54c2d77e3b60ab (patch) | |
tree | c4876c0ae8b64d6053f240bcf10aa4ecdd71b5f3 /client | |
parent | 2cd5ada3a176716de1e0f961c5667435a9bc3450 (diff) |
Do not suggest Auth0 in CI environment
Diffstat (limited to 'client')
-rw-r--r-- | client/go/cmd/config.go | 10 | ||||
-rw-r--r-- | client/go/cmd/helpers.go | 6 | ||||
-rw-r--r-- | client/go/cmd/prod.go | 3 |
3 files changed, 13 insertions, 6 deletions
diff --git a/client/go/cmd/config.go b/client/go/cmd/config.go index 30db45c2bd2..1680e1d32b5 100644 --- a/client/go/cmd/config.go +++ b/client/go/cmd/config.go @@ -206,10 +206,12 @@ func (c *Config) UseAPIKey(system vespa.System, tenantName string) bool { } // If no Auth0 token is created, fall back to tenant api key, but warn that this functionality is deprecated // TODO: Remove this when users have had time to migrate over to Auth0 device flow authentication - a, err := auth0.GetAuth0(c.AuthConfigPath(), system.Name, system.URL) - if err != nil || !a.HasSystem() { - printWarning("Defaulting to tenant API key is deprecated.", "Use Auth0 device flow: 'vespa auth login' instead") - return util.PathExists(c.APIKeyPath(tenantName)) + if !isCI() { + a, err := auth0.GetAuth0(c.AuthConfigPath(), system.Name, system.URL) + if err != nil || !a.HasSystem() { + printWarning("Use of API key is deprecated", "Authenticate with Auth0 instead: 'vespa auth login'") + return util.PathExists(c.APIKeyPath(tenantName)) + } } return false } diff --git a/client/go/cmd/helpers.go b/client/go/cmd/helpers.go index 831cd110762..9ef40aaff40 100644 --- a/client/go/cmd/helpers.go +++ b/client/go/cmd/helpers.go @@ -342,6 +342,12 @@ func getEndpointsFromEnv() (map[string]string, error) { return urlsByCluster, nil } +// isCI returns true if running inside a continuous integration environment. +func isCI() bool { + _, ok := os.LookupEnv("CI") + return ok +} + type endpoints struct { Endpoints []endpoint `json:"endpoints"` } diff --git a/client/go/cmd/prod.go b/client/go/cmd/prod.go index b30f2e8551d..5b30a7a9b89 100644 --- a/client/go/cmd/prod.go +++ b/client/go/cmd/prod.go @@ -155,8 +155,7 @@ $ vespa prod submit`, if err := verifyTests(pkg, target); err != nil { return err } - isCI := os.Getenv("CI") != "" - if !isCI { + if !isCI() { printWarning("We recommend doing this only from a CD job", "See https://cloud.vespa.ai/en/getting-to-production") } opts, err := getDeploymentOptions(cfg, pkg, target) |