Add warning when include is used in config files other than databricks.yml (#2389)

## Changes
Defining an include section in config files other than the main
`databricks.yml` file fails silently. With this PR users will get a
warning when they try this.

## Tests
Acceptance test.
This commit is contained in:
shreyas-goenka 2025-02-27 20:29:00 +05:30 committed by GitHub
parent bf2aded8e9
commit eb57dbd844
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 39 additions and 0 deletions

View File

@ -0,0 +1,4 @@
include:
- b.yml
- c.yml

View File

@ -0,0 +1,5 @@
bundle:
name: include_outside_root
include:
- a.yml

View File

@ -0,0 +1,16 @@
Warning: Include section is defined outside root file
at include
in a.yml:2:3
The include section is defined in a file that is not the root file.
These values will be ignored because only the includes defined in
the bundle root file (that is databricks.yml or databricks.yaml)
are loaded.
Name: include_outside_root
Target: default
Workspace:
User: [USERNAME]
Path: /Workspace/Users/[USERNAME]/.bundle/include_outside_root/default
Found 1 warning

View File

@ -0,0 +1 @@
$CLI bundle validate

View File

@ -161,6 +161,19 @@ func (m *processInclude) Apply(_ context.Context, b *bundle.Bundle) diag.Diagnos
return diags
}
if len(this.Include) > 0 {
diags = diags.Append(diag.Diagnostic{
Severity: diag.Warning,
Summary: "Include section is defined outside root file",
Detail: `The include section is defined in a file that is not the root file.
These values will be ignored because only the includes defined in
the bundle root file (that is databricks.yml or databricks.yaml)
are loaded.`,
Locations: this.GetLocations("include"),
Paths: []dyn.Path{dyn.MustPathFromString("include")},
})
}
err := b.Config.Merge(this)
if err != nil {
diags = diags.Extend(diag.FromErr(err))