MCPcopy
hub / github.com/helm/helm / LoadAllDir

Function LoadAllDir

internal/plugin/loader.go:173–200  ·  view source on GitHub ↗

LoadAllDir load all plugins found beneath the base directory, using the provided error filter to determine whether to fail on individual plugin load errors. This scans only one directory level.

(basedir string, errorFilter ErrorFilterFunc)

Source from the content-addressed store, hash-verified

171//
172// This scans only one directory level.
173func LoadAllDir(basedir string, errorFilter ErrorFilterFunc) ([]Plugin, error) {
174 // We want <basedir>/*/plugin.yaml
175 scanpath := filepath.Join(basedir, "*", PluginFileName)
176 matches, err := filepath.Glob(scanpath)
177 if err != nil {
178 return nil, fmt.Errorf("failed to search for plugins in %q: %w", scanpath, err)
179 }
180
181 plugins := make([]Plugin, 0, len(matches))
182
183 // empty dir should load
184 if len(matches) == 0 {
185 return plugins, nil
186 }
187
188 for _, yamlFile := range matches {
189 dir := filepath.Dir(yamlFile)
190 p, err := LoadDir(dir)
191 if err != nil {
192 if errNew := errorFilter(yamlFile, err); errNew != nil {
193 return plugins, errNew
194 }
195 } else {
196 plugins = append(plugins, p)
197 }
198 }
199 return plugins, detectDuplicates(plugins)
200}
201
202// findFunc is a function that finds plugins in a directory
203type findFunc func(pluginsDir string) ([]Plugin, error)

Callers 7

runMethod · 0.92
runMethod · 0.92
TestLoadAllDir_EmptyFunction · 0.85
TestLoadAllPluginsDirFunction · 0.85
FindPluginsFunction · 0.85
FindPluginFunction · 0.85

Calls 4

detectDuplicatesFunction · 0.85
GlobMethod · 0.80
LoadDirFunction · 0.70
DirMethod · 0.65

Tested by 3

TestLoadAllDir_EmptyFunction · 0.68
TestLoadAllPluginsDirFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…