diff --git a/acceptance/bundle/includes/non_yaml_in_include/databricks.yml b/acceptance/bundle/includes/non_yaml_in_include/databricks.yml index 15c68e1cf4e..7fd2b0724d7 100644 --- a/acceptance/bundle/includes/non_yaml_in_include/databricks.yml +++ b/acceptance/bundle/includes/non_yaml_in_include/databricks.yml @@ -2,5 +2,5 @@ bundle: name: non_yaml_in_includes include: - - test.py - resources/*.yml + - "*.py" diff --git a/acceptance/bundle/includes/non_yaml_in_include/output.txt b/acceptance/bundle/includes/non_yaml_in_include/output.txt index c4f259cb087..6b9fe12d7bd 100644 --- a/acceptance/bundle/includes/non_yaml_in_include/output.txt +++ b/acceptance/bundle/includes/non_yaml_in_include/output.txt @@ -1,10 +1,15 @@ Error: Files in the 'include' configuration section must be YAML or JSON files. - in databricks.yml:5:5 + in databricks.yml:6:5 The file test.py in the 'include' configuration section is not a YAML or JSON file, and only such files are supported. To include files to sync, specify them in the 'sync.include' configuration section instead. +Error: Files in the 'include' configuration section must be YAML or JSON files. + in databricks.yml:6:5 + +The file test2.py in the 'include' configuration section is not a YAML or JSON file, and only such files are supported. To include files to sync, specify them in the 'sync.include' configuration section instead. + Name: non_yaml_in_includes -Found 1 error +Found 2 errors Exit code: 1 diff --git a/acceptance/bundle/includes/non_yaml_in_include/test2.py b/acceptance/bundle/includes/non_yaml_in_include/test2.py new file mode 100644 index 00000000000..e0aa8cdbfb6 --- /dev/null +++ b/acceptance/bundle/includes/non_yaml_in_include/test2.py @@ -0,0 +1 @@ +print("Hello again") diff --git a/bundle/config/loader/process_root_includes.go b/bundle/config/loader/process_root_includes.go index 934c777a90a..74803f9c06b 100644 --- a/bundle/config/loader/process_root_includes.go +++ b/bundle/config/loader/process_root_includes.go @@ -72,7 +72,7 @@ func (m *processRootIncludes) Apply(ctx context.Context, b *bundle.Bundle) diag. // For each glob, find all files to load. // Ordering of the list of globs is maintained in the output. // For matches that appear in multiple globs, only the first is kept. - for _, entry := range b.Config.Include { + for entryIndex, entry := range b.Config.Include { // Include paths must be relative. if filepath.IsAbs(entry) { return diag.Errorf("%s: includes must be relative paths", entry) @@ -92,7 +92,7 @@ func (m *processRootIncludes) Apply(ctx context.Context, b *bundle.Bundle) diag. // Filter matches to ones we haven't seen yet. var includes []string - for i, match := range matches { + for _, match := range matches { rel, err := filepath.Rel(b.BundleRootPath, match) if err != nil { return diag.FromErr(err) @@ -103,10 +103,11 @@ func (m *processRootIncludes) Apply(ctx context.Context, b *bundle.Bundle) diag. seen[rel] = true if filepath.Ext(rel) != ".yaml" && filepath.Ext(rel) != ".yml" && filepath.Ext(rel) != ".json" { diags = diags.Append(diag.Diagnostic{ - Severity: diag.Error, - Summary: "Files in the 'include' configuration section must be YAML or JSON files.", - Detail: fmt.Sprintf("The file %s in the 'include' configuration section is not a YAML or JSON file, and only such files are supported. To include files to sync, specify them in the 'sync.include' configuration section instead.", rel), - Locations: b.Config.GetLocations(fmt.Sprintf("include[%d]", i)), + Severity: diag.Error, + Summary: "Files in the 'include' configuration section must be YAML or JSON files.", + Detail: fmt.Sprintf("The file %s in the 'include' configuration section is not a YAML or JSON file, and only such files are supported. To include files to sync, specify them in the 'sync.include' configuration section instead.", rel), + // The match's index within the glob is unrelated to the entry's position in the include list. + Locations: b.Config.GetLocations(fmt.Sprintf("include[%d]", entryIndex)), }) continue }