Skip to content

Commit

Permalink
refactor: remove unneeded stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasjarosch committed Mar 13, 2024
1 parent aa6edca commit 883eeee
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,6 @@ func (pm *PluginManager) loadPluginConstructor(path string) (PluginConstructor,
return nil, fmt.Errorf("unable to find symbol '%s': %w", PluginSymbolName, err)
}

a := symbol.(*PluginConstructor)
_ = a

pluginConstructor, validPlugin := symbol.(*PluginConstructor)
if !validPlugin {
return nil, fmt.Errorf("invalid plugin: invalid symbol '%s', want=PluginConstructor, have=%T", PluginSymbolName, pluginConstructor)
Expand All @@ -120,18 +117,17 @@ func (pm *PluginManager) ConfigurePlugin(typ PluginType, name string, config dat
return err
}

// If the plugin does not need to be initialized, pretend we did and return an error.
// If the user doesn't mind about plugins not being initialized, just ignore the error.
iplugin, initializable := plugin.(ConfigurablePlugin)
if !initializable {
// If the plugin does not need to be configured, pretend we did and return an error.
// If the user doesn't mind about plugins not being configured, just ignore the error.
iplugin, configurable := plugin.(ConfigurablePlugin)
if !configurable {
pm.configuredPlugins[typ][name] = append(pm.configuredPlugins[typ][name], plugin)
return ErrUnconfigurablePlugin
}

// If the config is a slice, it means that we need to have multiple instances
// of the plugin with different configs.
if config.IsSlice() {
configs, _ := config.Slice()
if configs, err := config.Slice(); err == nil {
for _, c := range configs {
// create a new instance of the plugin and configure it using the data
plugin := pm.pluginConstructors[plugin.Type()][plugin.Name()]()
Expand Down

0 comments on commit 883eeee

Please sign in to comment.