Skip to content

Commit ec75364

Browse files
committed
..
1 parent aef6541 commit ec75364

File tree

3 files changed

+23
-17
lines changed

3 files changed

+23
-17
lines changed

cmd/auth/login.go

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import (
1010
"github.com/databricks/cli/libs/databrickscfg"
1111
"github.com/databricks/databricks-sdk-go"
1212
"github.com/databricks/databricks-sdk-go/config"
13-
"github.com/databricks/databricks-sdk-go/service/compute"
1413
"github.com/spf13/cobra"
1514
)
1615

@@ -28,6 +27,8 @@ func configureHost(ctx context.Context, persistentAuth *auth.PersistentAuth, arg
2827
return nil
2928
}
3029

30+
const minimalDbConnectVersion = "13.1"
31+
3132
func newLoginCommand(persistentAuth *auth.PersistentAuth) *cobra.Command {
3233
cmd := &cobra.Command{
3334
Use: "login [HOST]",
@@ -95,19 +96,11 @@ func newLoginCommand(persistentAuth *auth.PersistentAuth) *cobra.Command {
9596
return err
9697
}
9798
ctx := cmd.Context()
98-
99-
promptSpinner := cmdio.Spinner(ctx)
100-
promptSpinner <- "Loading list of clusters to select from"
101-
names, err := w.Clusters.ClusterDetailsClusterNameToClusterIdMap(ctx, compute.ListClustersRequest{})
102-
close(promptSpinner)
103-
if err != nil {
104-
return fmt.Errorf("failed to load clusters list. Original error: %w", err)
105-
}
106-
clusterId, err := cmdio.Select(ctx, names, "Choose cluster")
99+
clusterID, err := databrickscfg.AskForClusterCompatibleWithUC(ctx, w, minimalDbConnectVersion)
107100
if err != nil {
108101
return err
109102
}
110-
cfg.ClusterID = clusterId
103+
cfg.ClusterID = clusterID
111104
}
112105

113106
if profileName != "" {

libs/databrickscfg/profiles.go

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,11 @@ import (
1414
// It should only be used for prompting and filtering.
1515
// Use its name to construct a config.Config.
1616
type Profile struct {
17-
Name string
18-
Host string
19-
AccountID string
17+
Name string
18+
Host string
19+
AccountID string
20+
ClusterID string
21+
WarehouseID string
2022
}
2123

2224
func (p Profile) Cloud() string {
@@ -117,9 +119,11 @@ func LoadProfiles(fn ProfileMatchFunction) (file string, profiles Profiles, err
117119
continue
118120
}
119121
profile := Profile{
120-
Name: v.Name(),
121-
Host: host,
122-
AccountID: all["account_id"],
122+
Name: v.Name(),
123+
Host: host,
124+
AccountID: all["account_id"],
125+
ClusterID: all["cluster_id"],
126+
WarehouseID: all["warehouse_id"],
123127
}
124128
if fn(profile) {
125129
profiles = append(profiles, profile)

libs/databrickscfg/uc_clusters.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,15 @@ func AskForClusterCompatibleWithUC(ctx context.Context, w *databricks.WorkspaceC
111111
if !IsCompatibleWithUC(&v, minVersion) {
112112
continue
113113
}
114+
switch v.ClusterSource {
115+
case compute.ClusterSourceJob,
116+
compute.ClusterSourceModels,
117+
compute.ClusterSourcePipeline,
118+
compute.ClusterSourcePipelineMaintenance,
119+
compute.ClusterSourceSql:
120+
// only UI and API clusters are usable for DBConnect
121+
continue
122+
}
114123
if v.SingleUserName != "" && v.SingleUserName != me.UserName {
115124
continue
116125
}

0 commit comments

Comments
 (0)