@@ -568,10 +568,12 @@ func installPlugin(pluginName, version string, target configtypes.Target, contex
568
568
return kerrors .NewAggregate (errorList )
569
569
}
570
570
571
+ totalPluginsToInstall = 1
572
+ pluginsInstalled = 0
571
573
if len (matchedPlugins ) == 1 {
572
574
return installOrUpgradePlugin (& matchedPlugins [0 ], matchedPlugins [0 ].RecommendedVersion , false )
573
575
}
574
-
576
+ // there can be only one plugin with the same name and target, so we can safely return the first one
575
577
for i := range matchedPlugins {
576
578
if matchedPlugins [i ].Target == target {
577
579
return installOrUpgradePlugin (& matchedPlugins [i ], matchedPlugins [i ].RecommendedVersion , false )
@@ -653,6 +655,8 @@ func InstallPluginsFromGivenPluginGroup(pluginName, groupIDAndVersion string, pg
653
655
if pluginsInstalled == 0 {
654
656
return groupIDAndVersion , fmt .Errorf ("plugin '%s' is not part of the group '%s'" , pluginName , groupIDAndVersion )
655
657
}
658
+ totalPluginsToInstall = 0
659
+ pluginsInstalled = 0
656
660
657
661
return groupIDAndVersion , nil
658
662
}
@@ -1190,6 +1194,8 @@ func InstallDiscoveredContextPlugins(plugins []discovery.Discovered) error {
1190
1194
} else {
1191
1195
log .Infof ("Successfully installed %v of %v required plugins" , pluginsInstalled , totalPluginsToInstall )
1192
1196
}
1197
+ totalPluginsToInstall = 0
1198
+ pluginsInstalled = 0
1193
1199
1194
1200
return nil
1195
1201
}
@@ -1206,7 +1212,6 @@ func InstallPluginsFromLocalSource(pluginName, version string, target configtype
1206
1212
if err != nil {
1207
1213
return errors .Wrap (err , "unable to discover plugins" )
1208
1214
}
1209
-
1210
1215
var errList []error
1211
1216
1212
1217
var matchedPlugins []discovery.Discovered
@@ -1234,16 +1239,24 @@ func InstallPluginsFromLocalSource(pluginName, version string, target configtype
1234
1239
return installOrUpgradePlugin (& matchedPlugins [0 ], version , installTestPlugin )
1235
1240
}
1236
1241
1242
+ var pluginsToInstall []* discovery.Discovered
1237
1243
for i := range matchedPlugins {
1238
1244
// Install all plugins otherwise include all matching plugins
1239
1245
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 )
1244
1248
}
1245
1249
}
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
1247
1260
err = kerrors .NewAggregate (errList )
1248
1261
if err != nil {
1249
1262
return err
0 commit comments