Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions acceptance/bundle/includes/non_yaml_in_include/databricks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
bundle:
name: non_yaml_in_includes

include:
- test.py
- resources/*.yml
10 changes: 10 additions & 0 deletions acceptance/bundle/includes/non_yaml_in_include/output.txt
Comment thread
andrewnester marked this conversation as resolved.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Error: non-yaml file in 'include' section
in databricks.yml:5:4

file test.py included in 'include' section but only YAML files are supported. If you want to explicitly include files to sync, use 'sync.include' configuration section

Name: non_yaml_in_includes

Found 1 error

Exit code: 1
1 change: 1 addition & 0 deletions acceptance/bundle/includes/non_yaml_in_include/script
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
$CLI bundle validate
1 change: 1 addition & 0 deletions acceptance/bundle/includes/non_yaml_in_include/test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
print("Hello world")
17 changes: 16 additions & 1 deletion bundle/config/loader/process_root_includes.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package loader

import (
"context"
"fmt"
"path/filepath"
"slices"
"strings"
Expand Down Expand Up @@ -36,6 +37,7 @@ func (m *processRootIncludes) Apply(ctx context.Context, b *bundle.Bundle) diag.
// Maintain list of files in order of files being loaded.
// This is stored in the bundle configuration for observability.
var files []string
var diags diag.Diagnostics

// For each glob, find all files to load.
// Ordering of the list of globs is maintained in the output.
Expand All @@ -60,7 +62,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 _, match := range matches {
for i, match := range matches {
rel, err := filepath.Rel(b.BundleRootPath, match)
if err != nil {
return diag.FromErr(err)
Expand All @@ -69,9 +71,22 @@ func (m *processRootIncludes) Apply(ctx context.Context, b *bundle.Bundle) diag.
continue
}
seen[rel] = true
if filepath.Ext(rel) != ".yaml" && filepath.Ext(rel) != ".yml" {
diags = diags.Append(diag.Diagnostic{
Severity: diag.Error,
Summary: "non-yaml file in 'include' section",
Comment thread
andrewnester marked this conversation as resolved.
Outdated
Detail: fmt.Sprintf("file %s included in 'include' section but only YAML files are supported. If you want to explicitly include files to sync, use 'sync.include' configuration section", rel),
Comment thread
andrewnester marked this conversation as resolved.
Outdated
Locations: b.Config.GetLocations(fmt.Sprintf("include[%d]", i)),
})
continue
}
includes = append(includes, rel)
}

if len(diags) > 0 {
return diags
}

// Add matches to list of mutators to return.
slices.Sort(includes)
files = append(files, includes...)
Expand Down