diff --git a/NEXT_CHANGELOG.md b/NEXT_CHANGELOG.md index 3a2cbd4688..8b59b8a1f3 100644 --- a/NEXT_CHANGELOG.md +++ b/NEXT_CHANGELOG.md @@ -14,5 +14,6 @@ ### Bundles * Added support for pipeline environment field ([#3153](https://github.com/databricks/cli/pull/3153)) * "bundle summary" now prints diagnostic warnings to stderr ([#3123](https://github.com/databricks/cli/pull/3123)) +* "bundle open" will print the URL before opening the browser ([#3168](https://github.com/databricks/cli/pull/3168)) ### API Changes diff --git a/acceptance/bundle/open/databricks.yml b/acceptance/bundle/open/databricks.yml new file mode 100644 index 0000000000..2f787bb9e6 --- /dev/null +++ b/acceptance/bundle/open/databricks.yml @@ -0,0 +1,17 @@ +bundle: + name: caterpillar + +resources: + jobs: + foo: + name: foo + tasks: + - task_key: task + spark_python_task: + python_file: ./foo.py + environment_key: default + + environments: + - environment_key: default + spec: + client: "2" diff --git a/acceptance/bundle/open/foo.py b/acceptance/bundle/open/foo.py new file mode 100644 index 0000000000..b917a726c9 --- /dev/null +++ b/acceptance/bundle/open/foo.py @@ -0,0 +1 @@ +print(1) diff --git a/acceptance/bundle/open/open b/acceptance/bundle/open/open new file mode 100755 index 0000000000..5c6c78d6a7 --- /dev/null +++ b/acceptance/bundle/open/open @@ -0,0 +1,2 @@ +#!/bin/bash +echo "I AM BROWSER" diff --git a/acceptance/bundle/open/output.txt b/acceptance/bundle/open/output.txt new file mode 100644 index 0000000000..6b98a30871 --- /dev/null +++ b/acceptance/bundle/open/output.txt @@ -0,0 +1,26 @@ + +=== no run key specified +>>> [CLI] bundle open +Error: expected a KEY of the resource to open + +Exit code: 1 + +=== not deployed yet +>>> [CLI] bundle open foo +Error: resource does not have a URL associated with it (has it been deployed?) + +Exit code: 1 + +>>> [CLI] bundle deploy +Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/caterpillar/default/files... +Deploying resources... +Updating deployment state... +Deployment complete! + +=== Modify PATH so that real open is not run +=== open after deployment. This will fail to open browser and complain, that's ok, we only want the message +>>> [CLI] bundle open foo +Opening browser at [DATABRICKS_URL]/jobs/[NUMID]?o=[NUMID] +Error: exec: "open": cannot run executable found relative to current directory + +Exit code (musterr): 1 diff --git a/acceptance/bundle/open/script b/acceptance/bundle/open/script new file mode 100644 index 0000000000..dcb29c60c3 --- /dev/null +++ b/acceptance/bundle/open/script @@ -0,0 +1,13 @@ +title "no run key specified" +errcode trace $CLI bundle open + +title "not deployed yet" +errcode trace $CLI bundle open foo + +errcode trace $CLI bundle deploy + +title "Modify PATH so that real open is not run" +export PATH=.:$PATH + +title "open after deployment. This will fail to open browser and complain, that's ok, we only want the message" +musterr trace $CLI bundle open foo diff --git a/acceptance/bundle/open/test.toml b/acceptance/bundle/open/test.toml new file mode 100644 index 0000000000..956e2affc9 --- /dev/null +++ b/acceptance/bundle/open/test.toml @@ -0,0 +1,3 @@ +GOOS.windows = false +GOOS.linux = false +EnvMatrix.DATABRICKS_CLI_DEPLOYMENT = ["terraform"] # "bundle open" not implemented yet diff --git a/cmd/bundle/open.go b/cmd/bundle/open.go index 73b1bc2d36..37fdf8875a 100644 --- a/cmd/bundle/open.go +++ b/cmd/bundle/open.go @@ -117,6 +117,7 @@ func newOpenCommand() *cobra.Command { return errors.New("resource does not have a URL associated with it (has it been deployed?)") } + cmdio.LogString(ctx, "Opening browser at "+url) return browser.OpenURL(url) }