Skip to content

Commit c7e351b

Browse files
committed
Remove default profile resolution (not yet available on this branch)
The GetConfiguredDefaultProfile function is from the auth switch PR which has not been merged into this branch's base yet. Remove the dependency to fix the build. Co-authored-by: Isaac
1 parent 452bd21 commit c7e351b

File tree

2 files changed

+0
-50
lines changed

2 files changed

+0
-50
lines changed

cmd/doctor/checks.go

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import (
1010
"time"
1111

1212
"github.com/databricks/cli/internal/build"
13-
"github.com/databricks/cli/libs/databrickscfg"
1413
"github.com/databricks/cli/libs/databrickscfg/profile"
1514
"github.com/databricks/cli/libs/env"
1615
"github.com/databricks/cli/libs/log"
@@ -156,18 +155,6 @@ func resolveConfig(cmd *cobra.Command) (*config.Config, error) {
156155
cfg.Profile = profileFlag.Value.String()
157156
}
158157

159-
// Apply the configured default profile when no explicit profile is set.
160-
// This mirrors cmd/root/auth.go's resolveDefaultProfile.
161-
if cfg.Profile == "" && env.Get(ctx, "DATABRICKS_CONFIG_PROFILE") == "" {
162-
configFilePath := env.Get(ctx, "DATABRICKS_CONFIG_FILE")
163-
resolvedProfile, err := databrickscfg.GetConfiguredDefaultProfile(ctx, configFilePath)
164-
if err != nil {
165-
log.Warnf(ctx, "Failed to load default profile: %v", err)
166-
} else if resolvedProfile != "" {
167-
cfg.Profile = resolvedProfile
168-
}
169-
}
170-
171158
return cfg, cfg.EnsureResolved()
172159
}
173160

cmd/doctor/doctor_test.go

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -184,43 +184,6 @@ func TestCheckCurrentProfileFlagOverridesEnv(t *testing.T) {
184184
assert.Equal(t, "from-flag", result.Message)
185185
}
186186

187-
func TestResolveConfigUsesConfiguredDefaultProfile(t *testing.T) {
188-
clearConfigEnv(t)
189-
190-
configFile := filepath.Join(t.TempDir(), ".databrickscfg")
191-
err := os.WriteFile(configFile, []byte("[__settings__]\ndefault_profile = my-ws\n\n[my-ws]\nhost = https://my-ws.cloud.databricks.com\ntoken = my-token\n"), 0o600)
192-
require.NoError(t, err)
193-
194-
ctx := cmdio.MockDiscard(t.Context())
195-
ctx = env.Set(ctx, "DATABRICKS_CONFIG_FILE", configFile)
196-
cmd := newTestCmd(ctx)
197-
198-
cfg, resolveErr := resolveConfig(cmd)
199-
require.NoError(t, resolveErr)
200-
assert.Equal(t, "my-ws", cfg.Profile)
201-
assert.Equal(t, "https://my-ws.cloud.databricks.com", cfg.Host)
202-
}
203-
204-
func TestResolveConfigDefaultProfileIgnoredWhenFlagSet(t *testing.T) {
205-
clearConfigEnv(t)
206-
207-
configFile := filepath.Join(t.TempDir(), ".databrickscfg")
208-
err := os.WriteFile(configFile, []byte("[__settings__]\ndefault_profile = my-ws\n\n[my-ws]\nhost = https://my-ws.cloud.databricks.com\ntoken = ws-token\n\n[other]\nhost = https://other.cloud.databricks.com\ntoken = other-token\n"), 0o600)
209-
require.NoError(t, err)
210-
211-
ctx := cmdio.MockDiscard(t.Context())
212-
ctx = env.Set(ctx, "DATABRICKS_CONFIG_FILE", configFile)
213-
cmd := newTestCmd(ctx)
214-
err = cmd.Flag("profile").Value.Set("other")
215-
require.NoError(t, err)
216-
cmd.Flag("profile").Changed = true
217-
218-
cfg, resolveErr := resolveConfig(cmd)
219-
require.NoError(t, resolveErr)
220-
assert.Equal(t, "other", cfg.Profile)
221-
assert.Equal(t, "https://other.cloud.databricks.com", cfg.Host)
222-
}
223-
224187
func TestCheckAuthSuccess(t *testing.T) {
225188
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
226189
w.WriteHeader(http.StatusOK)

0 commit comments

Comments
 (0)