From ddc8424a804437bfe149bcfd6c6bb52acc7e5749 Mon Sep 17 00:00:00 2001 From: Ilia Babanov Date: Wed, 13 Mar 2024 10:41:51 +0100 Subject: [PATCH] Don't authenticate profiles in `auth profiles --skip-validate` This makes the command almost instant, no matter how many profiles cfg file has. One downside is that we don't set AuthType for profiles that don't have it defined. We can technically infer AuthType based on ConfigAttributes tags, but their names are different from the names of actual auth providers (and some tags cover multiple providers at the same time) --- cmd/auth/profiles.go | 9 +-------- cmd/auth/profiles_test.go | 3 ++- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/cmd/auth/profiles.go b/cmd/auth/profiles.go index 7c4a7ab2f4..5ebea44406 100644 --- a/cmd/auth/profiles.go +++ b/cmd/auth/profiles.go @@ -3,7 +3,6 @@ package auth import ( "context" "fmt" - "net/http" "os" "sync" "time" @@ -45,13 +44,7 @@ func (c *profileMetadata) Load(ctx context.Context, skipValidate bool) { } if skipValidate { - err := cfg.Authenticate(&http.Request{ - Header: make(http.Header), - }) - if err != nil { - return - } - c.Host = cfg.Host + c.Host = cfg.CanonicalHostName() c.AuthType = cfg.AuthType return } diff --git a/cmd/auth/profiles_test.go b/cmd/auth/profiles_test.go index c1971705fa..8a667a6db3 100644 --- a/cmd/auth/profiles_test.go +++ b/cmd/auth/profiles_test.go @@ -21,8 +21,9 @@ func TestProfiles(t *testing.T) { err := databrickscfg.SaveToProfile(ctx, &config.Config{ ConfigFile: configFile, Profile: "profile1", - Host: "https://abc.cloud.databricks.com", + Host: "abc.cloud.databricks.com", Token: "token1", + AuthType: "pat", }) require.NoError(t, err)