Skip to content

Commit 637d42e

Browse files
committed
Connect sandbox SSH through authenticated WebSocket port forwarding
1 parent cb5c0cf commit 637d42e

36 files changed

Lines changed: 3809 additions & 557 deletions
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* Use local SSH keys and authenticated WebSocket port forwarding for `databricks sandbox ssh`, including sandboxes created through the public API. ([#7589](https://github.com/databricks/cli/pull/7589))

‎NOTICE‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ This Software includes software developed at Databricks (https://www.databricks.
44

55
This Software contains code from the following open source projects, licensed under the Apache 2.0 license:
66

7+
grpc/grpc-go - https://github.com/grpc/grpc-go
8+
Copyright The gRPC Authors
9+
License - https://github.com/grpc/grpc-go/blob/master/LICENSE
10+
711
spf13/cobra - https://github.com/spf13/cobra
812
Copyright cobra authors
913
License - https://github.com/spf13/cobra/blob/main/LICENSE.txt
@@ -33,6 +37,10 @@ License - https://github.com/gorilla/websocket/blob/main/LICENSE
3337

3438
This Software contains code from the following open source projects, licensed under the BSD (3-clause) license:
3539

40+
protocolbuffers/protobuf-go - https://github.com/protocolbuffers/protobuf-go
41+
Copyright The Go Authors
42+
License - https://github.com/protocolbuffers/protobuf-go/blob/master/LICENSE
43+
3644
spf13/pflag - https://github.com/spf13/pflag
3745
Copyright (c) 2012 Alex Ogier. All rights reserved.
3846
Copyright (c) 2012 The Go Authors. All rights reserved.

‎cmd/cmd.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ func New(ctx context.Context) *cobra.Command {
7070
// Hand-written commands that replace a generated workspace command of the
7171
// same name. Cobra resolves duplicate names by position after an unstable
7272
// sort, so the generated command must not be registered at all.
73-
sandboxCmd := sandbox.New()
73+
sandboxCmd := sandbox.New(sandboxssh.NewSSHCommand(sandboxssh.CommandDependencies{ResolveName: sandbox.ResolveSSHName, Complete: sandbox.CompleteSandboxIDs}))
7474
sandboxCmd.AddCommand(sandboxssh.NewServerCommand())
7575
replacedWorkspaceCommands := map[string]bool{
7676
sandboxCmd.Name(): true,

‎cmd/sandbox/completion.go‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,8 @@ func completionProfile(cmd *cobra.Command, args []string) string {
7070
}
7171
return w.Config.Host
7272
}
73+
74+
// CompleteSandboxIDs completes sandbox selections without making API requests.
75+
func CompleteSandboxIDs(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
76+
return completeSandboxIDs(cmd, args, toComplete)
77+
}

‎cmd/sandbox/sandbox.go‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
)
66

77
// New returns the root command for the sandbox subcommand.
8-
func New() *cobra.Command {
8+
func New(sshCommands ...*cobra.Command) *cobra.Command {
99
cmd := &cobra.Command{
1010
Use: "sandbox",
1111
Short: "*Beta* Manage Databricks Sandbox environments",
@@ -18,7 +18,6 @@ tooling (Python, Node.js, Rust, Databricks CLI) and persistent storage.
1818
1919
Getting started:
2020
databricks auth login --host https://... # authenticate to a Databricks workspace
21-
databricks sandbox register # generate and register an SSH key
2221
databricks sandbox create # provision a sandbox (becomes your default)
2322
databricks sandbox ssh # SSH to your default sandbox
2423
@@ -35,7 +34,7 @@ Common workflows:
3534
cmd.AddCommand(newRegisterCommand())
3635
cmd.AddCommand(newSSHKeyCommand())
3736
cmd.AddCommand(newSetDefaultCommand())
38-
cmd.AddCommand(newSSHCommand())
37+
cmd.AddCommand(sshCommands...)
3938
cmd.AddCommand(newListCommand())
4039
cmd.AddCommand(newCreateCommand())
4140
cmd.AddCommand(newDeleteCommand())

0 commit comments

Comments
 (0)