diff --git a/NEXT_CHANGELOG.md b/NEXT_CHANGELOG.md index 0e4d6de08f..6f8559cfc1 100644 --- a/NEXT_CHANGELOG.md +++ b/NEXT_CHANGELOG.md @@ -9,6 +9,7 @@ * Added `--limit` flag to all paginated list commands for client-side result capping ([#4984](https://github.com/databricks/cli/pull/4984)). ### Bundles +* Fix false duplicate source code path error for git-sourced apps ([#4996](https://github.com/databricks/cli/pull/4996)) ### Dependency updates diff --git a/acceptance/bundle/apps/git_source_no_duplicate/databricks.yml b/acceptance/bundle/apps/git_source_no_duplicate/databricks.yml new file mode 100644 index 0000000000..5c06ac8a46 --- /dev/null +++ b/acceptance/bundle/apps/git_source_no_duplicate/databricks.yml @@ -0,0 +1,13 @@ +bundle: + name: test-bundle + +resources: + apps: + app1: + name: app1 + git_source: + branch: main + app2: + name: app2 + git_source: + branch: dev diff --git a/acceptance/bundle/apps/git_source_no_duplicate/out.test.toml b/acceptance/bundle/apps/git_source_no_duplicate/out.test.toml new file mode 100644 index 0000000000..d560f1de04 --- /dev/null +++ b/acceptance/bundle/apps/git_source_no_duplicate/out.test.toml @@ -0,0 +1,5 @@ +Local = true +Cloud = false + +[EnvMatrix] + DATABRICKS_BUNDLE_ENGINE = ["terraform", "direct"] diff --git a/acceptance/bundle/apps/git_source_no_duplicate/output.txt b/acceptance/bundle/apps/git_source_no_duplicate/output.txt new file mode 100644 index 0000000000..d44a21b582 --- /dev/null +++ b/acceptance/bundle/apps/git_source_no_duplicate/output.txt @@ -0,0 +1,9 @@ + +>>> [CLI] bundle validate +Name: test-bundle +Target: default +Workspace: + User: [USERNAME] + Path: /Workspace/Users/[USERNAME]/.bundle/test-bundle/default + +Validation OK! diff --git a/acceptance/bundle/apps/git_source_no_duplicate/script b/acceptance/bundle/apps/git_source_no_duplicate/script new file mode 100644 index 0000000000..5350876150 --- /dev/null +++ b/acceptance/bundle/apps/git_source_no_duplicate/script @@ -0,0 +1 @@ +trace $CLI bundle validate diff --git a/acceptance/bundle/apps/git_source_no_duplicate/test.toml b/acceptance/bundle/apps/git_source_no_duplicate/test.toml new file mode 100644 index 0000000000..a5b2fe2819 --- /dev/null +++ b/acceptance/bundle/apps/git_source_no_duplicate/test.toml @@ -0,0 +1,5 @@ +RecordRequests = false + +Ignore = [ + '.databricks', +] diff --git a/bundle/apps/validate.go b/bundle/apps/validate.go index 6c6403e06f..fdcb121e13 100644 --- a/bundle/apps/validate.go +++ b/bundle/apps/validate.go @@ -42,15 +42,17 @@ func (v *validate) Apply(ctx context.Context, b *bundle.Bundle) diag.Diagnostics continue } - if _, ok := usedSourceCodePaths[app.SourceCodePath]; ok { - diags = append(diags, diag.Diagnostic{ - Severity: diag.Error, - Summary: "Duplicate app source code path", - Detail: fmt.Sprintf("app resource '%s' has the same source code path as app resource '%s', this will lead to the app configuration being overriden by each other", key, usedSourceCodePaths[app.SourceCodePath]), - Locations: b.Config.GetLocations(fmt.Sprintf("resources.apps.%s.source_code_path", key)), - }) + if app.SourceCodePath != "" { + if _, ok := usedSourceCodePaths[app.SourceCodePath]; ok { + diags = append(diags, diag.Diagnostic{ + Severity: diag.Error, + Summary: "Duplicate app source code path", + Detail: fmt.Sprintf("app resource '%s' has the same source code path as app resource '%s', this will lead to the app configuration being overriden by each other", key, usedSourceCodePaths[app.SourceCodePath]), + Locations: b.Config.GetLocations(fmt.Sprintf("resources.apps.%s.source_code_path", key)), + }) + } + usedSourceCodePaths[app.SourceCodePath] = key } - usedSourceCodePaths[app.SourceCodePath] = key diags = diags.Extend(warnForAppResourcePermissions(b, key, app)) }