@@ -75,10 +75,12 @@ func getPluginDirs(cfg *configfile.ConfigFile) ([]string, error) {
75
75
return pluginDirs , nil
76
76
}
77
77
78
- func addPluginCandidatesFromDir (res map [string ][]string , d string ) error {
78
+ func addPluginCandidatesFromDir (res map [string ][]string , d string ) {
79
79
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
80
82
if err != nil {
81
- return err
83
+ return
82
84
}
83
85
for _ , dentry := range dentries {
84
86
switch dentry .Type () & os .ModeType {
@@ -99,28 +101,15 @@ func addPluginCandidatesFromDir(res map[string][]string, d string) error {
99
101
}
100
102
res [name ] = append (res [name ], filepath .Join (d , dentry .Name ()))
101
103
}
102
- return nil
103
104
}
104
105
105
106
// 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 {
107
108
result := make (map [string ][]string )
108
109
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 )
122
111
}
123
- return result , nil
112
+ return result
124
113
}
125
114
126
115
// 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
130
119
return nil , err
131
120
}
132
121
133
- candidates , err := listPluginCandidates (pluginDirs )
134
- if err != nil {
135
- return nil , err
136
- }
137
-
122
+ candidates := listPluginCandidates (pluginDirs )
138
123
if paths , ok := candidates [name ]; ok {
139
124
if len (paths ) == 0 {
140
125
return nil , errPluginNotFound (name )
@@ -160,10 +145,7 @@ func ListPlugins(dockerCli command.Cli, rootcmd *cobra.Command) ([]Plugin, error
160
145
return nil , err
161
146
}
162
147
163
- candidates , err := listPluginCandidates (pluginDirs )
164
- if err != nil {
165
- return nil , err
166
- }
148
+ candidates := listPluginCandidates (pluginDirs )
167
149
168
150
var plugins []Plugin
169
151
var mu sync.Mutex
0 commit comments