Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: allow plugins block in plugin files #2770

Merged
merged 1 commit into from
Aug 16, 2024
Merged
Changes from all 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
14 changes: 11 additions & 3 deletions internal/config/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,21 @@ func (p Plugins) loadPluginDir(dir string) error {
if file.IsDir() || !isYamlFile(file.Name()) {
continue
}
bb, err := os.ReadFile(filepath.Join(dir, file.Name()))
fileName := filepath.Join(dir, file.Name())
fileContent, err := os.ReadFile(fileName)
if err != nil {
errs = errors.Join(errs, err)
}
var plugin Plugin
if err = yaml.Unmarshal(bb, &plugin); err != nil {
return err
if err = yaml.Unmarshal(fileContent, &plugin); err != nil {
var plugins Plugins
if err = yaml.Unmarshal(fileContent, &plugins); err != nil {
return fmt.Errorf("cannot parse %s into either a single plugin nor plugins: %w", fileName, err)
}
for name, plugin := range plugins.Plugins {
p.Plugins[name] = plugin
}
continue
}
p.Plugins[strings.TrimSuffix(file.Name(), filepath.Ext(file.Name()))] = plugin
}
Expand Down