Commit 70b814e
authored
Add experimental workspace open command (#4727)
## Why
Opening workspace resources in the browser requires manually
constructing URLs. A quick command to open jobs, notebooks, clusters,
etc. by type and ID saves time during development.
## Changes
**Before**: URL patterns for workspace resources were duplicated inside
per-resource `InitializeURL` methods, and BROWSER environment variable
handling was duplicated between `cmd/auth/login.go` and
`cmd/auth/token.go` (and would have been duplicated again by this
command). `bundle open` and `pipelines open` ignored BROWSER entirely.
**Now**: `databricks experimental open RESOURCE_TYPE ID_OR_PATH` opens
any supported resource directly, and all browser-opening commands share
a single BROWSER-aware helper.
- New `experimental open` command opens jobs, clusters, notebooks,
pipelines, dashboards, warehouses, queries, apps, experiments, models,
model_serving_endpoints, alerts, registered_models. For
`registered_models`, dot-separated names (`catalog.schema.model`) are
converted to slash-separated URL segments automatically.
`sql_warehouses` is accepted as an alias for `warehouses` so bundle
plural names Just Work.
- `--url` flag prints the URL to stdout without opening the browser,
useful for scripting and SSH sessions.
- New `libs/workspaceurls` package centralizes the
resource-type-to-URL-pattern mapping, `?o=<workspace-id>` handling with
a stricter `adb-<id>` hostname check, and fragment vs. path URL
formatting. Bundle `InitializeURL` methods call
`workspaceurls.ResourceURL` instead of inlining patterns. The bundle
`initialize_urls` mutator keeps its existing loose `strings.Contains`
hostname check to avoid changing `bundle summary` URL output on
non-Azure workspaces; that unification is a follow-up with its own
integration test updates.
- New `libs/browser` package centralizes BROWSER handling (empty →
default browser, `none` → prints URL, any other value → runs the value
as a command via `libs/exec` for Windows percent-encoding safety).
Adopted in `cmd/auth/login.go`, `cmd/auth/token.go`,
`cmd/experimental/workspace_open.go`, `cmd/bundle/open.go`,
`cmd/pipelines/open.go`. Minor behavior change: `bundle open` and
`pipelines open` now respect `BROWSER=none`; `auth token` does too.
## Test plan
- [x] Unit tests for URL construction across all resource types
(path-based and fragment-based)
- [x] Unit tests for shell completion, `--url` flag, workspace ID
hostname detection
- [x] Unit tests for `libs/browser.Open` (BROWSER=none) and
`libs/browser.IsDisabled`
- [x] Unit tests for `sql_warehouses` alias resolution
- [x] Acceptance test for `experimental open` (print-URL and completion)
- [x] Drift test asserting every bundle plural name with a URL resolves
via `workspaceurls.ResourceURL` (catches future rename drift)
- [x] Existing bundle mutator and bundle/pipelines open acceptance tests
still pass after refactor
- [x] `make lintfull` passes
- [x] `make checks` passes1 parent 4ae8d02 commit 70b814e
27 files changed
Lines changed: 879 additions & 80 deletions
File tree
- acceptance/experimental/open
- bundle/config
- resources
- cmd
- auth
- bundle
- experimental
- pipelines
- libs
- browser
- workspaceurls
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
| |||
52 | 53 | | |
53 | 54 | | |
54 | 55 | | |
55 | | - | |
56 | | - | |
| 56 | + | |
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
| |||
94 | 95 | | |
95 | 96 | | |
96 | 97 | | |
97 | | - | |
98 | | - | |
| 98 | + | |
99 | 99 | | |
100 | 100 | | |
101 | 101 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
| |||
47 | 48 | | |
48 | 49 | | |
49 | 50 | | |
50 | | - | |
51 | | - | |
| 51 | + | |
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
6 | 5 | | |
7 | 6 | | |
8 | 7 | | |
| 8 | + | |
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| |||
114 | 114 | | |
115 | 115 | | |
116 | 116 | | |
117 | | - | |
118 | | - | |
| 117 | + | |
119 | 118 | | |
120 | 119 | | |
121 | 120 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
| |||
54 | 55 | | |
55 | 56 | | |
56 | 57 | | |
57 | | - | |
58 | | - | |
| 58 | + | |
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
| |||
49 | 50 | | |
50 | 51 | | |
51 | 52 | | |
52 | | - | |
53 | | - | |
| 53 | + | |
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
| |||
0 commit comments