Skip to content

Commit

Permalink
update count
Browse files Browse the repository at this point in the history
  • Loading branch information
chandrareddyp committed Apr 16, 2024
1 parent 48c0be6 commit f7a024f
Showing 1 changed file with 20 additions and 7 deletions.
27 changes: 20 additions & 7 deletions pkg/pluginmanager/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -568,10 +568,12 @@ func installPlugin(pluginName, version string, target configtypes.Target, contex
return kerrors.NewAggregate(errorList)
}

totalPluginsToInstall = 1
pluginsInstalled = 0
if len(matchedPlugins) == 1 {
return installOrUpgradePlugin(&matchedPlugins[0], matchedPlugins[0].RecommendedVersion, false)
}

// there can be only one plugin with the same name and target, so we can safely return the first one
for i := range matchedPlugins {
if matchedPlugins[i].Target == target {
return installOrUpgradePlugin(&matchedPlugins[i], matchedPlugins[i].RecommendedVersion, false)
Expand Down Expand Up @@ -653,6 +655,8 @@ func InstallPluginsFromGivenPluginGroup(pluginName, groupIDAndVersion string, pg
if pluginsInstalled == 0 {
return groupIDAndVersion, fmt.Errorf("plugin '%s' is not part of the group '%s'", pluginName, groupIDAndVersion)
}
totalPluginsToInstall = 0
pluginsInstalled = 0

return groupIDAndVersion, nil
}
Expand Down Expand Up @@ -1190,6 +1194,8 @@ func InstallDiscoveredContextPlugins(plugins []discovery.Discovered) error {
} else {
log.Infof("Successfully installed %v of %v required plugins", pluginsInstalled, totalPluginsToInstall)
}
totalPluginsToInstall = 0
pluginsInstalled = 0

return nil
}
Expand All @@ -1206,7 +1212,6 @@ func InstallPluginsFromLocalSource(pluginName, version string, target configtype
if err != nil {
return errors.Wrap(err, "unable to discover plugins")
}

var errList []error

var matchedPlugins []discovery.Discovered
Expand Down Expand Up @@ -1234,16 +1239,24 @@ func InstallPluginsFromLocalSource(pluginName, version string, target configtype
return installOrUpgradePlugin(&matchedPlugins[0], version, installTestPlugin)
}

var pluginsToInstall []*discovery.Discovered
for i := range matchedPlugins {
// Install all plugins otherwise include all matching plugins
if pluginName == cli.AllPlugins || matchedPlugins[i].Target == target {
err = installOrUpgradePlugin(&matchedPlugins[i], version, installTestPlugin)
if err != nil {
errList = append(errList, err)
}
plugin := matchedPlugins[i]
pluginsToInstall = append(pluginsToInstall, &plugin)
}
}

totalPluginsToInstall = len(pluginsToInstall)
pluginsInstalled = 0
for _, plugin := range pluginsToInstall {
err = installOrUpgradePlugin(plugin, version, installTestPlugin)
if err != nil {
errList = append(errList, err)
}
}
totalPluginsToInstall = 0
pluginsInstalled = 0
err = kerrors.NewAggregate(errList)
if err != nil {
return err
Expand Down

0 comments on commit f7a024f

Please sign in to comment.