From ec418655e4f2fc84757d4650ae82b1e234c277e3 Mon Sep 17 00:00:00 2001 From: Michael Zappa Date: Sat, 6 Apr 2024 20:27:30 -0600 Subject: [PATCH] fix flow for plugin check Signed-off-by: Michael Zappa --- opts.go | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/opts.go b/opts.go index c1b5c71..e9b18d8 100644 --- a/opts.go +++ b/opts.go @@ -316,16 +316,15 @@ func loadFromConfDir(c *libcni, max int) error { } func checkPluginExists(c *libcni, confList *cnilibrary.NetworkConfigList) error { - for _, dir := range c.pluginDirs { - for _, plug := range confList.Plugins { - plugin := plug.Network.Type - - if fileExistsInDir(dir, plugin) { - return nil + for _, plug := range confList.Plugins { + plugin := plug.Network.Type + for _, dir := range c.pluginDirs { + if !fileExistsInDir(dir, plugin) { + return fmt.Errorf("plugin %s not found in: %s %v", plugin, strings.Join(c.pluginDirs, ","), ErrCNIPluginNotFound) } } } - return ErrCNIPluginNotFound + return nil } // FileExistsInDir checks if a file exists in a specific directory