Skip to content

Commit a0ac4ed

Browse files
authored
Fixed bundle generate for not yet deployed apps (#3319)
## Changes Fixed bundle generate for not yet deployed apps ## Why It's common to run these commands next to each other ``` databricks apps create my-app databricks bundle generate app --existing-app-name my-app ``` Due to the bug, we could not generate the app correctly since the app is not yet deployed, and the source code path is empty, resulting in the `Error: Path () doesn't start with '/'` error ## Tests Added acceptance test <!-- If your PR needs to be included in the release notes for next release, add a separate entry in NEXT_CHANGELOG.md as part of your PR. -->
1 parent 65cadfb commit a0ac4ed

File tree

8 files changed

+44
-3
lines changed

8 files changed

+44
-3
lines changed

NEXT_CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
### Bundles
1313
* Modified run flag validation to allow `--refresh` and `--full-refresh` flags to be used together ([#3300](https://github.com/databricks/cli/pull/3300))
14+
* Fixed bundle generate for not yet deployed apps ([#3319](https://github.com/databricks/cli/pull/3319))
1415
* Respect export format for notebooks on bundle generate ([#3316](https://github.com/databricks/cli/pull/3316))
1516

1617
### API Changes
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
bundle:
2+
name: "app_not_yet_deployed"
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
resources:
2+
apps:
3+
out:
4+
name: my-app
5+
description: ""
6+
source_code_path: src/app
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Local = true
2+
Cloud = false
3+
4+
[EnvMatrix]
5+
DATABRICKS_CLI_DEPLOYMENT = ["terraform", "direct-exp"]
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
2+
>>> [CLI] apps create my-app
3+
{
4+
"app_status": {
5+
"message":"Application is running.",
6+
"state":"RUNNING"
7+
},
8+
"compute_status": {
9+
"message":"App compute is active.",
10+
"state":"ACTIVE"
11+
},
12+
"id":"1000",
13+
"name":"my-app",
14+
"url":"my-app-123.cloud.databricksapps.com"
15+
}
16+
17+
>>> [CLI] bundle generate app --existing-app-name my-app --config-dir . --key out
18+
Loading app 'my-app' configuration
19+
App configuration successfully saved to out.app.yml
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
trace $CLI apps create my-app
2+
trace $CLI bundle generate app --existing-app-name my-app --config-dir . --key out
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Local = true
2+
Cloud = false

cmd/bundle/generate/app.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,13 @@ func NewGenerateAppCommand() *cobra.Command {
5252
downloader := generate.NewDownloader(w, sourceDir, configDir)
5353

5454
sourceCodePath := app.DefaultSourceCodePath
55-
err = downloader.MarkDirectoryForDownload(ctx, &sourceCodePath)
56-
if err != nil {
57-
return err
55+
// If the source code path is not set, we don't need to download anything.
56+
// This is the case for apps that are not yet deployed.
57+
if sourceCodePath != "" {
58+
err = downloader.MarkDirectoryForDownload(ctx, &sourceCodePath)
59+
if err != nil {
60+
return err
61+
}
5862
}
5963

6064
// Making sure the source code path is relative to the config directory.

0 commit comments

Comments
 (0)