Skip to content

Commit

Permalink
fix issue with logic
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Zappa <[email protected]>
  • Loading branch information
MikeZappa87 committed Apr 8, 2024
1 parent 49e9d56 commit 381ba27
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions opts.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,6 @@ func loadFromConfDir(c *libcni, max int) error {
}
if len(confList.Plugins) == 0 {
return fmt.Errorf("CNI config list in config file %s has no networks, skipping: %w", confFile, ErrInvalidConfig)

}

err := checkPluginExists(c, confList)
Expand Down Expand Up @@ -316,22 +315,28 @@ func loadFromConfDir(c *libcni, max int) error {
}

func checkPluginExists(c *libcni, confList *cnilibrary.NetworkConfigList) error {
var err error
missing := make(map[string]interface{})
for _, plug := range confList.Plugins {
plugin := plug.Network.Type
for _, dir := range c.pluginDirs {
if !fileExistsInDir(dir, plugin) {
err = fmt.Errorf("plugin '%s' not found in: %s %v", plugin, strings.Join(c.pluginDirs, ","), ErrCNIPluginNotFound)
missing[plugin] = plugin
} else {
err = nil
continue
break
}
}
}

if err != nil {
return err
if len(missing) > 0 {
var plugins []string
for k := range missing {
plugins = append(plugins, k)
}

return fmt.Errorf("unable to find cni plugins %s in directories %s: %w",
strings.Join(plugins, ", "), strings.Join(c.pluginDirs, ", "), ErrCNIPluginNotFound)
}

return nil
}

Expand Down

0 comments on commit 381ba27

Please sign in to comment.