MCPcopy Create free account
hub / github.com/chainloop-dev/chainloop / LoadPlugins

Method LoadPlugins

app/cli/pkg/plugins/manager.go:53–75  ·  view source on GitHub ↗

LoadPlugins loads all plugins from the plugins directory.

(ctx context.Context)

Source from the content-addressed store, hash-verified

51
52// LoadPlugins loads all plugins from the plugins directory.
53func (m *Manager) LoadPlugins(ctx context.Context) error {
54 pluginsDir := GetPluginsDir("chainloop")
55
56 if err := os.MkdirAll(pluginsDir, 0755); err != nil {
57 return fmt.Errorf("failed to create plugins directory: %w", err)
58 }
59
60 plugins, err := plugin.Discover("*", pluginsDir)
61 if err != nil {
62 return fmt.Errorf("failed to discover plugins: %w", err)
63 }
64
65 for _, plugin := range plugins {
66 // Load the plugin - if there is an error just skip it - we can think of a better strategy later
67 if err := m.loadPlugin(ctx, plugin); err != nil {
68 m.logger.Error().Msgf("failed to load plugin: %s", plugin)
69 m.logger.Debug().Err(err).Msgf("plugin loading failure reason: %s", plugin)
70 continue
71 }
72 }
73
74 return nil
75}
76
77// loadPlugin loads a single plugin.
78func (m *Manager) loadPlugin(ctx context.Context, path string) error {

Callers 1

loadAllPluginsFunction · 0.80

Calls 5

loadPluginMethod · 0.95
GetPluginsDirFunction · 0.85
DiscoverMethod · 0.80
ErrorMethod · 0.65
DebugMethod · 0.45

Tested by

no test coverage detected