MCPcopy Index your code
hub / github.com/docker/cli / addPluginCandidatesFromDir

Function addPluginCandidatesFromDir

cli-plugins/manager/manager.go:54–88  ·  view source on GitHub ↗
(res map[string][]string, d string)

Source from the content-addressed store, hash-verified

52}
53
54func addPluginCandidatesFromDir(res map[string][]string, d string) {
55 dentries, err := os.ReadDir(d)
56 // Silently ignore any directories which we cannot list (e.g. due to
57 // permissions or anything else) or which is not a directory
58 if err != nil {
59 return
60 }
61 for _, dentry := range dentries {
62 switch mode := dentry.Type() & os.ModeType; mode { //nolint:exhaustive,nolintlint // no need to include all possible file-modes in this list
63 case os.ModeSymlink:
64 if !debug.IsEnabled() {
65 // Skip broken symlinks unless debug is enabled. With debug
66 // enabled, this will print a warning in "docker info".
67 if _, err := os.Stat(filepath.Join(d, dentry.Name())); errors.Is(err, os.ErrNotExist) {
68 continue
69 }
70 }
71 case 0:
72 // Regular file, keep going
73 default:
74 // Something else, ignore.
75 continue
76 }
77 name := dentry.Name()
78 if !strings.HasPrefix(name, metadata.NamePrefix) {
79 continue
80 }
81 name = strings.TrimPrefix(name, metadata.NamePrefix)
82 var err error
83 if name, err = trimExeSuffix(name); err != nil {
84 continue
85 }
86 res[name] = append(res[name], filepath.Join(d, dentry.Name()))
87 }
88}
89
90// listPluginCandidates returns a map from plugin name to the list of (unvalidated) Candidates. The list is in descending order of priority.
91func listPluginCandidates(dirs []string) map[string][]string {

Callers 1

listPluginCandidatesFunction · 0.85

Calls 3

trimExeSuffixFunction · 0.70
TypeMethod · 0.45
NameMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…