Skip to content

Commit

Permalink
cli-plugins: Simplify addPluginCandidatesFromDir
Browse files Browse the repository at this point in the history
The returned error is always nil now, so just remove it.

Signed-off-by: Paweł Gronowski <[email protected]>
  • Loading branch information
vvoland committed Nov 28, 2024
1 parent 6de3d71 commit 8a1a88c
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions cli-plugins/manager/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,12 @@ func getPluginDirs(cfg *configfile.ConfigFile) ([]string, error) {
return pluginDirs, nil
}

func addPluginCandidatesFromDir(res map[string][]string, d string) error {
func addPluginCandidatesFromDir(res map[string][]string, d string) {
dentries, err := os.ReadDir(d)
// Silently ignore any directories which we cannot list (e.g. due to
// permissions or anything else) or which is not a directory
if err != nil {
return nil
return
}
for _, dentry := range dentries {
switch dentry.Type() & os.ModeType {
Expand All @@ -101,20 +101,13 @@ func addPluginCandidatesFromDir(res map[string][]string, d string) error {
}
res[name] = append(res[name], filepath.Join(d, dentry.Name()))
}
return nil
}

// listPluginCandidates returns a map from plugin name to the list of (unvalidated) Candidates. The list is in descending order of priority.
func listPluginCandidates(dirs []string) (map[string][]string, error) {
result := make(map[string][]string)
for _, d := range dirs {
if err := addPluginCandidatesFromDir(result, d); err != nil {
// Silently ignore paths which don't exist.
if os.IsNotExist(err) {
continue
}
return nil, err // Or return partial result?
}
addPluginCandidatesFromDir(result, d)
}
return result, nil
}
Expand Down

0 comments on commit 8a1a88c

Please sign in to comment.