Skip to content

Commit

Permalink
chore: changes from review
Browse files Browse the repository at this point in the history
Signed-off-by: Richard Case <[email protected]>
  • Loading branch information
richardcase committed Jul 13, 2021
1 parent cbdd874 commit c7b48b9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 18 deletions.
12 changes: 0 additions & 12 deletions pkg/provider/registry/errors.go

This file was deleted.

10 changes: 4 additions & 6 deletions pkg/provider/registry/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func RegisterProvider(name string, factory provider.Factory) error {
defer pluginsLock.Unlock()

if _, exists := plugins[name]; exists {
return ErrDuplicatePlugin
return fmt.Errorf("plugin %s has already been registered", name)
}

plugins[name] = factory
Expand All @@ -37,19 +37,17 @@ func GetPluginInstance(ctx context.Context, name string, runtime *provider.Runti
return factoryFunc(ctx, runtime)
}

return nil, fmt.Errorf("getting plugin %s: %w", name, ErrPluginNotFound)
return nil, fmt.Errorf("plugin %s not found", name)
}

// ListPlugins returns a list of the plugin names that have been registered.
func ListPlugins() []string {
pluginsLock.RLock()
defer pluginsLock.RUnlock()

names := make([]string, len(plugins))
i := 0
names := []string{}
for name := range plugins {
names[i] = name
i++
names = append(names, name)
}

return names
Expand Down

0 comments on commit c7b48b9

Please sign in to comment.