@@ -75,10 +75,12 @@ func getPluginDirs(cfg *configfile.ConfigFile) ([]string, error) {
7575 return pluginDirs , nil
7676}
7777
78- func addPluginCandidatesFromDir (res map [string ][]string , d string ) error {
78+ func addPluginCandidatesFromDir (res map [string ][]string , d string ) {
7979 dentries , err := os .ReadDir (d )
80+ // Silently ignore any directories which we cannot list (e.g. due to
81+ // permissions or anything else) or which is not a directory
8082 if err != nil {
81- return err
83+ return
8284 }
8385 for _ , dentry := range dentries {
8486 switch dentry .Type () & os .ModeType {
@@ -99,28 +101,15 @@ func addPluginCandidatesFromDir(res map[string][]string, d string) error {
99101 }
100102 res [name ] = append (res [name ], filepath .Join (d , dentry .Name ()))
101103 }
102- return nil
103104}
104105
105106// listPluginCandidates returns a map from plugin name to the list of (unvalidated) Candidates. The list is in descending order of priority.
106- func listPluginCandidates (dirs []string ) ( map [string ][]string , error ) {
107+ func listPluginCandidates (dirs []string ) map [string ][]string {
107108 result := make (map [string ][]string )
108109 for _ , d := range dirs {
109- // Silently ignore any directories which we cannot
110- // Stat (e.g. due to permissions or anything else) or
111- // which is not a directory.
112- if fi , err := os .Stat (d ); err != nil || ! fi .IsDir () {
113- continue
114- }
115- if err := addPluginCandidatesFromDir (result , d ); err != nil {
116- // Silently ignore paths which don't exist.
117- if os .IsNotExist (err ) {
118- continue
119- }
120- return nil , err // Or return partial result?
121- }
110+ addPluginCandidatesFromDir (result , d )
122111 }
123- return result , nil
112+ return result
124113}
125114
126115// GetPlugin returns a plugin on the system by its name
@@ -130,11 +119,7 @@ func GetPlugin(name string, dockerCli command.Cli, rootcmd *cobra.Command) (*Plu
130119 return nil , err
131120 }
132121
133- candidates , err := listPluginCandidates (pluginDirs )
134- if err != nil {
135- return nil , err
136- }
137-
122+ candidates := listPluginCandidates (pluginDirs )
138123 if paths , ok := candidates [name ]; ok {
139124 if len (paths ) == 0 {
140125 return nil , errPluginNotFound (name )
@@ -160,10 +145,7 @@ func ListPlugins(dockerCli command.Cli, rootcmd *cobra.Command) ([]Plugin, error
160145 return nil , err
161146 }
162147
163- candidates , err := listPluginCandidates (pluginDirs )
164- if err != nil {
165- return nil , err
166- }
148+ candidates := listPluginCandidates (pluginDirs )
167149
168150 var plugins []Plugin
169151 var mu sync.Mutex
0 commit comments