Skip to content

Commit

Permalink
Merge pull request #13 from insidieux/issue-12-loader-panic-fix
Browse files Browse the repository at this point in the history
Skip FS item if regexp find string match failed
  • Loading branch information
insidieux authored Mar 23, 2021
2 parents 106be85 + be19049 commit f3e3a02
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
9 changes: 5 additions & 4 deletions internal/plugins/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,11 @@ func (l *Loader) Load(ctx context.Context, path string) ([]ClientInterface, erro

clients := make([]ClientInterface, 0)
for _, item := range list {
var (
parts = nameRegexp.FindStringSubmatch(item.Name())
name = parts[1]
)
parts := nameRegexp.FindStringSubmatch(item.Name())
if len(parts) < 2 {
continue
}
name := parts[1]
cfg, err := l.config.Lookup(name)
if err != nil {
cfg = newPluginConfig(name)
Expand Down
1 change: 1 addition & 0 deletions internal/plugins/loader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ func (s *loaderTestSuite) TestLoad() {

filesystem := afero.NewMemMapFs()
_ = filesystem.MkdirAll(`/path`, 0755)
_ = filesystem.MkdirAll(`/path/dir`, 0755)
_, _ = filesystem.Create(`/path/inizio-plugin-first`)
_, _ = filesystem.Create(`/path/inizio-plugin-second`)

Expand Down

0 comments on commit f3e3a02

Please sign in to comment.