@@ -568,10 +568,12 @@ func installPlugin(pluginName, version string, target configtypes.Target, contex
568568 return kerrors .NewAggregate (errorList )
569569 }
570570
571+ totalPluginsToInstall = 1
572+ pluginsInstalled = 0
571573 if len (matchedPlugins ) == 1 {
572574 return installOrUpgradePlugin (& matchedPlugins [0 ], matchedPlugins [0 ].RecommendedVersion , false )
573575 }
574-
576+ // there can be only one plugin with the same name and target, so we can safely return the first one
575577 for i := range matchedPlugins {
576578 if matchedPlugins [i ].Target == target {
577579 return installOrUpgradePlugin (& matchedPlugins [i ], matchedPlugins [i ].RecommendedVersion , false )
@@ -653,6 +655,8 @@ func InstallPluginsFromGivenPluginGroup(pluginName, groupIDAndVersion string, pg
653655 if pluginsInstalled == 0 {
654656 return groupIDAndVersion , fmt .Errorf ("plugin '%s' is not part of the group '%s'" , pluginName , groupIDAndVersion )
655657 }
658+ totalPluginsToInstall = 0
659+ pluginsInstalled = 0
656660
657661 return groupIDAndVersion , nil
658662}
@@ -1190,6 +1194,8 @@ func InstallDiscoveredContextPlugins(plugins []discovery.Discovered) error {
11901194 } else {
11911195 log .Infof ("Successfully installed %v of %v required plugins" , pluginsInstalled , totalPluginsToInstall )
11921196 }
1197+ totalPluginsToInstall = 0
1198+ pluginsInstalled = 0
11931199
11941200 return nil
11951201}
@@ -1206,7 +1212,6 @@ func InstallPluginsFromLocalSource(pluginName, version string, target configtype
12061212 if err != nil {
12071213 return errors .Wrap (err , "unable to discover plugins" )
12081214 }
1209-
12101215 var errList []error
12111216
12121217 var matchedPlugins []discovery.Discovered
@@ -1234,16 +1239,24 @@ func InstallPluginsFromLocalSource(pluginName, version string, target configtype
12341239 return installOrUpgradePlugin (& matchedPlugins [0 ], version , installTestPlugin )
12351240 }
12361241
1242+ var pluginsToInstall []* discovery.Discovered
12371243 for i := range matchedPlugins {
12381244 // Install all plugins otherwise include all matching plugins
12391245 if pluginName == cli .AllPlugins || matchedPlugins [i ].Target == target {
1240- err = installOrUpgradePlugin (& matchedPlugins [i ], version , installTestPlugin )
1241- if err != nil {
1242- errList = append (errList , err )
1243- }
1246+ plugin := matchedPlugins [i ]
1247+ pluginsToInstall = append (pluginsToInstall , & plugin )
12441248 }
12451249 }
1246-
1250+ totalPluginsToInstall = len (pluginsToInstall )
1251+ pluginsInstalled = 0
1252+ for _ , plugin := range pluginsToInstall {
1253+ err = installOrUpgradePlugin (plugin , version , installTestPlugin )
1254+ if err != nil {
1255+ errList = append (errList , err )
1256+ }
1257+ }
1258+ totalPluginsToInstall = 0
1259+ pluginsInstalled = 0
12471260 err = kerrors .NewAggregate (errList )
12481261 if err != nil {
12491262 return err
0 commit comments