Skip to content

Commit

Permalink
bugfix: missed error return
Browse files Browse the repository at this point in the history
  • Loading branch information
IanSmith123 committed Jul 23, 2021
1 parent fb2a075 commit 7f87cf8
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -340,11 +340,11 @@ func (f *File) validateAndReset(dir, prefix string) error {
return f.Schema.validateAndReset(fmt.Sprintf("%s.schema", prefix))
}

func (f *File) expandFiles(dir string) (files []*File) {
func (f *File) expandFiles(dir string) (err error, files []*File) {
if base.HasHttpPrefix(*f.Path) {
files = append(files, f)

return files
return err, files
} else {
if !filepath.IsAbs(*f.Path) {
absPath := filepath.Join(dir, *f.Path)
Expand All @@ -354,6 +354,7 @@ func (f *File) expandFiles(dir string) (files []*File) {
fileNames, err := filepath.Glob(*f.Path)
if err != nil || len(fileNames) == 0 {
logger.Errorf("error file path: %s", *f.Path)
return err, files
}

for _, name := range fileNames {
Expand All @@ -365,7 +366,7 @@ func (f *File) expandFiles(dir string) (files []*File) {
}
}

return files
return err, files
}

func (c *CSVConfig) validateAndReset(prefix string) error {
Expand Down Expand Up @@ -860,8 +861,13 @@ func (config *YAMLConfig) expandDirectoryToFilesNg(dir string) (err error) {
// change config.Files in its own iter is not a good idea, so save value and change it later
var newFiles []*File

for i := range config.Files {
for _, f := range config.Files[i].expandFiles(dir) {
for _, file := range config.Files {
err, files := file.expandFiles(dir)
if err != nil {
logger.Errorf("error when expand file: %s", err)
return err
}
for _, f := range files {
newFiles = append(newFiles, f)
}
}
Expand Down

0 comments on commit 7f87cf8

Please sign in to comment.