mirror of https://github.com/databricks/cli.git
Fixed error reporting when included invalid files in include section
This commit is contained in:
parent
335475095e
commit
6d6b689623
|
@ -49,6 +49,10 @@ func (m *processRootIncludes) Apply(ctx context.Context, b *bundle.Bundle) error
|
|||
return err
|
||||
}
|
||||
|
||||
if len(matches) == 0 {
|
||||
return fmt.Errorf("%s defined in 'include' section does not match any files", entry)
|
||||
}
|
||||
|
||||
// Filter matches to ones we haven't seen yet.
|
||||
var includes []string
|
||||
for _, match := range matches {
|
||||
|
|
|
@ -108,3 +108,17 @@ func TestProcessRootIncludesRemoveDups(t *testing.T) {
|
|||
require.NoError(t, err)
|
||||
assert.Equal(t, []string{"a.yml"}, bundle.Config.Include)
|
||||
}
|
||||
|
||||
func TestProcessRootIncludesNotExists(t *testing.T) {
|
||||
bundle := &bundle.Bundle{
|
||||
Config: config.Root{
|
||||
Path: t.TempDir(),
|
||||
Include: []string{
|
||||
"notexist.yml",
|
||||
},
|
||||
},
|
||||
}
|
||||
err := mutator.ProcessRootIncludes().Apply(context.Background(), bundle)
|
||||
require.Error(t, err)
|
||||
assert.Contains(t, err.Error(), "notexist.yml defined in 'include' section does not match any files")
|
||||
}
|
||||
|
|
|
@ -118,7 +118,7 @@ func (r *Root) Load(path string) error {
|
|||
}
|
||||
err = yaml.Unmarshal(raw, r)
|
||||
if err != nil {
|
||||
return err
|
||||
return fmt.Errorf("failed to load %s: %w", path, err)
|
||||
}
|
||||
|
||||
r.Path = filepath.Dir(path)
|
||||
|
|
Loading…
Reference in New Issue