MCPcopy
hub / github.com/apache/devlake / LoadRemotePlugins

Function LoadRemotePlugins

backend/core/runner/loader.go:91–127  ·  view source on GitHub ↗
(basicRes context.BasicRes)

Source from the content-addressed store, hash-verified

89}
90
91func LoadRemotePlugins(basicRes context.BasicRes) errors.Error {
92 remotePluginDir := basicRes.GetConfig("REMOTE_PLUGIN_DIR")
93 if remotePluginDir != "" {
94 basicRes.GetLogger().Info("Loading remote plugins")
95 remote.Init(basicRes)
96 walkErr := filepath.WalkDir(remotePluginDir, func(path string, d fs.DirEntry, err error) error {
97 if err != nil {
98 return err
99 }
100 fileName := d.Name()
101 if fileName == "run.sh" {
102 invoker := bridge.NewCmdInvoker(path)
103 result := invoker.Call("plugin-info", bridge.DefaultContext)
104 if result.Err != nil {
105 return errors.Default.Wrap(result.Err, "Error calling plugin-info")
106 }
107 pluginInfo := &models.PluginInfo{}
108 err := result.Get(pluginInfo)
109 if err != nil {
110 return err
111 }
112 remotePlugin, err := remote.NewRemotePlugin(pluginInfo)
113 if err != nil {
114 return err
115 }
116 err = plugin.RegisterPlugin(pluginInfo.Name, remotePlugin)
117 if err != nil {
118 return err
119 }
120 basicRes.GetLogger().Info(`remote plugin loaded %s`, pluginInfo.Name)
121 }
122 return nil
123 })
124 return errors.Convert(walkErr)
125 }
126 return nil
127}

Callers 1

LoadPluginsFunction · 0.85

Calls 9

CallMethod · 0.95
WrapMethod · 0.80
GetConfigMethod · 0.65
InfoMethod · 0.65
GetLoggerMethod · 0.65
InitMethod · 0.65
NameMethod · 0.65
GetMethod · 0.65
ConvertMethod · 0.45

Tested by

no test coverage detected