From a227acd6a1b4fdf3a4afa726ae54c2d77e3b60ab Mon Sep 17 00:00:00 2001 From: Martin Polden Date: Wed, 2 Mar 2022 14:27:56 +0100 Subject: Do not suggest Auth0 in CI environment --- client/go/cmd/config.go | 10 ++++++---- client/go/cmd/helpers.go | 6 ++++++ client/go/cmd/prod.go | 3 +-- 3 files changed, 13 insertions(+), 6 deletions(-) (limited to 'client') 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) -- cgit v1.2.3