fix(indexers): don't die on failed load of custom-definitions (#303)

* fix(custom-definitions): don't die on failed load
This commit is contained in:
Kyle Sanderson 2022-06-15 14:04:15 -07:00 committed by GitHub
parent b1d7a1f555
commit 8c720ac23e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -396,7 +396,14 @@ func (s *service) LoadCustomIndexerDefinitions() error {
return nil return nil
} }
outputDirRead, _ := os.Open(s.config.CustomDefinitions) outputDirRead, err := os.Open(s.config.CustomDefinitions)
if err != nil {
s.log.Warn().Stack().Msgf("failed opening custom definitions directory %q: %s", s.config.CustomDefinitions, err)
return nil
}
defer outputDirRead.Close()
//entries, err := fs.ReadDir(Definitions, "definitions") //entries, err := fs.ReadDir(Definitions, "definitions")
entries, err := outputDirRead.ReadDir(0) entries, err := outputDirRead.ReadDir(0)
@ -404,16 +411,12 @@ func (s *service) LoadCustomIndexerDefinitions() error {
s.log.Fatal().Stack().Msgf("failed reading directory: %s", err) s.log.Fatal().Stack().Msgf("failed reading directory: %s", err)
} }
if len(entries) == 0 {
s.log.Fatal().Stack().Msgf("failed reading directory: %s", err)
return err
}
customCount := 0 customCount := 0
for _, f := range entries { for _, f := range entries {
fileExtension := filepath.Ext(f.Name()) fileExtension := filepath.Ext(f.Name())
if fileExtension != ".yaml" { if fileExtension != ".yaml" && fileExtension != ".yml" {
s.log.Warn().Stack().Msgf("skipping unknown extension definition file: %s", f.Name())
continue continue
} }