diff --git a/acceptance/bundle/includes/include_outside_root/a.yml b/acceptance/bundle/includes/include_outside_root/a.yml new file mode 100644 index 000000000..b4addb99b --- /dev/null +++ b/acceptance/bundle/includes/include_outside_root/a.yml @@ -0,0 +1,4 @@ +include: + - b.yml + - c.yml + diff --git a/acceptance/bundle/includes/include_outside_root/databricks.yml b/acceptance/bundle/includes/include_outside_root/databricks.yml new file mode 100644 index 000000000..6addb7d2f --- /dev/null +++ b/acceptance/bundle/includes/include_outside_root/databricks.yml @@ -0,0 +1,5 @@ +bundle: + name: include_outside_root + +include: + - a.yml diff --git a/acceptance/bundle/includes/include_outside_root/output.txt b/acceptance/bundle/includes/include_outside_root/output.txt new file mode 100644 index 000000000..720c3a826 --- /dev/null +++ b/acceptance/bundle/includes/include_outside_root/output.txt @@ -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 diff --git a/acceptance/bundle/includes/include_outside_root/script b/acceptance/bundle/includes/include_outside_root/script new file mode 100644 index 000000000..72555b332 --- /dev/null +++ b/acceptance/bundle/includes/include_outside_root/script @@ -0,0 +1 @@ +$CLI bundle validate diff --git a/bundle/config/loader/process_include.go b/bundle/config/loader/process_include.go index f82f5db1e..4f7dd47ca 100644 --- a/bundle/config/loader/process_include.go +++ b/bundle/config/loader/process_include.go @@ -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))