@@ -611,24 +611,30 @@ func InstallPluginsFromGroup(pluginName, groupIDAndVersion string, options ...Pl
611611// InstallPluginsFromGivenPluginGroup installs either the specified plugin or all plugins from given plugin group plugins.
612612func InstallPluginsFromGivenPluginGroup (pluginName , groupIDAndVersion string , pg * plugininventory.PluginGroup ) (string , error ) {
613613 numErrors := 0
614- numInstalled := 0
615614 mandatoryPluginsExist := false
616615 pluginExist := false
616+ pluginsInstalled = 0
617+
618+ pluginsToInstall := make ([]* plugininventory.PluginGroupPluginEntry , 0 )
617619 for _ , plugin := range pg .Versions [pg .RecommendedVersion ] {
618620 if pluginName == cli .AllPlugins || pluginName == plugin .Name {
619621 pluginExist = true
620622 if plugin .Mandatory {
621623 mandatoryPluginsExist = true
622- err := InstallStandalonePlugin (plugin .Name , plugin .Version , plugin .Target )
623- if err != nil {
624- numErrors ++
625- log .Warningf ("unable to install plugin '%s': %v" , plugin .Name , err .Error ())
626- } else {
627- numInstalled ++
628- }
624+ pluginsToInstall = append (pluginsToInstall , plugin ) // Add mandatory plugin to the slice
629625 }
630626 }
631627 }
628+ totalPluginsToInstall = len (pluginsToInstall )
629+ for _ , plugin := range pluginsToInstall {
630+ err := InstallStandalonePlugin (plugin .Name , plugin .Version , plugin .Target )
631+ if err != nil {
632+ numErrors ++
633+ log .Warningf ("unable to install plugin '%s': %v" , plugin .Name , err .Error ())
634+ } else {
635+ pluginsInstalled ++
636+ }
637+ }
632638
633639 if ! pluginExist {
634640 return groupIDAndVersion , fmt .Errorf ("plugin '%s' is not part of the group '%s'" , pluginName , groupIDAndVersion )
@@ -645,7 +651,7 @@ func InstallPluginsFromGivenPluginGroup(pluginName, groupIDAndVersion string, pg
645651 return groupIDAndVersion , fmt .Errorf ("could not install %d plugin(s) from group '%s'" , numErrors , groupIDAndVersion )
646652 }
647653
648- if numInstalled == 0 {
654+ if pluginsInstalled == 0 {
649655 return groupIDAndVersion , fmt .Errorf ("plugin '%s' is not part of the group '%s'" , pluginName , groupIDAndVersion )
650656 }
651657
@@ -749,6 +755,7 @@ func installOrUpgradePlugin(p *discovery.Discovered, version string, installTest
749755 installingMsg , _ , errMsg := getPluginInstallationMessage (p , version , plugin != nil , isPluginAlreadyInstalled )
750756
751757 installingMsg = fmt .Sprintf ("[%v/%v] %v" , pluginsInstalled , totalPluginsToInstall , installingMsg )
758+ errMsg = fmt .Sprintf ("[%v/%v] %v" , pluginsInstalled , totalPluginsToInstall , errMsg )
752759
753760 var spinner component.OutputWriterSpinner
754761
@@ -1191,7 +1198,6 @@ func InstallDiscoveredContextPlugins(plugins []discovery.Discovered) error {
11911198 if len (pluginsToInstall ) == 0 {
11921199 log .Info ("All required plugins are already installed and up-to-date" )
11931200 } else if pluginsInstalled == totalPluginsToInstall {
1194-
11951201 log .Infof ("Successfully installed all required %v plugins" , pluginsInstalled )
11961202 } else {
11971203 log .Infof ("Successfully installed %v of %v required plugins" , pluginsInstalled , totalPluginsToInstall )
0 commit comments