Skip to content

Commit 33ee677

Browse files
authored
Make "bundle open" print the url; add acceptance test (#3168)
## Why Need a test for direct deployment implementation.
1 parent e917d25 commit 33ee677

File tree

8 files changed

+64
-0
lines changed

8 files changed

+64
-0
lines changed

NEXT_CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,6 @@
1414
### Bundles
1515
* Added support for pipeline environment field ([#3153](https://github.com/databricks/cli/pull/3153))
1616
* "bundle summary" now prints diagnostic warnings to stderr ([#3123](https://github.com/databricks/cli/pull/3123))
17+
* "bundle open" will print the URL before opening the browser ([#3168](https://github.com/databricks/cli/pull/3168))
1718

1819
### API Changes
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
bundle:
2+
name: caterpillar
3+
4+
resources:
5+
jobs:
6+
foo:
7+
name: foo
8+
tasks:
9+
- task_key: task
10+
spark_python_task:
11+
python_file: ./foo.py
12+
environment_key: default
13+
14+
environments:
15+
- environment_key: default
16+
spec:
17+
client: "2"

acceptance/bundle/open/foo.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
print(1)

acceptance/bundle/open/open

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/bash
2+
echo "I AM BROWSER"

acceptance/bundle/open/output.txt

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
2+
=== no run key specified
3+
>>> [CLI] bundle open
4+
Error: expected a KEY of the resource to open
5+
6+
Exit code: 1
7+
8+
=== not deployed yet
9+
>>> [CLI] bundle open foo
10+
Error: resource does not have a URL associated with it (has it been deployed?)
11+
12+
Exit code: 1
13+
14+
>>> [CLI] bundle deploy
15+
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/caterpillar/default/files...
16+
Deploying resources...
17+
Updating deployment state...
18+
Deployment complete!
19+
20+
=== Modify PATH so that real open is not run
21+
=== open after deployment. This will fail to open browser and complain, that's ok, we only want the message
22+
>>> [CLI] bundle open foo
23+
Opening browser at [DATABRICKS_URL]/jobs/[NUMID]?o=[NUMID]
24+
Error: exec: "open": cannot run executable found relative to current directory
25+
26+
Exit code (musterr): 1

acceptance/bundle/open/script

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
title "no run key specified"
2+
errcode trace $CLI bundle open
3+
4+
title "not deployed yet"
5+
errcode trace $CLI bundle open foo
6+
7+
errcode trace $CLI bundle deploy
8+
9+
title "Modify PATH so that real open is not run"
10+
export PATH=.:$PATH
11+
12+
title "open after deployment. This will fail to open browser and complain, that's ok, we only want the message"
13+
musterr trace $CLI bundle open foo

acceptance/bundle/open/test.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
GOOS.windows = false
2+
GOOS.linux = false
3+
EnvMatrix.DATABRICKS_CLI_DEPLOYMENT = ["terraform"] # "bundle open" not implemented yet

cmd/bundle/open.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ func newOpenCommand() *cobra.Command {
117117
return errors.New("resource does not have a URL associated with it (has it been deployed?)")
118118
}
119119

120+
cmdio.LogString(ctx, "Opening browser at "+url)
120121
return browser.OpenURL(url)
121122
}
122123

0 commit comments

Comments
 (0)