Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
change
Browse files Browse the repository at this point in the history
chandrareddyp committed May 6, 2024
1 parent 49a1005 commit 9a109b0
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions pkg/pluginmanager/manager.go
Original file line number Diff line number Diff line change
@@ -58,7 +58,7 @@ const (
)

var totalPluginsToInstall = 0
var pluginsInstalledCount = 0
var pluginNumberBeingInstalled = 1
var execCommand = exec.Command
var spinner component.OutputWriterSpinner

@@ -81,7 +81,7 @@ func StopSpinner() {
// ResetPluginInstallationCounts resets the total number of plugins to install and the number of plugins installed
func ResetPluginInstallationCounts() {
SetTotalPluginsToInstall(0)
SetPluginsInstalledCount(0)
SetPluginBeingInstalledCount(1)
}

type DeletePluginOptions struct {
@@ -507,19 +507,19 @@ func SetTotalPluginsToInstall(total int) {
totalPluginsToInstall = total
}

// SetPluginsInstalledCount sets the number of plugins installed already
func SetPluginsInstalledCount(count int) {
pluginsInstalledCount = count
// SetPluginBeingInstalledCount sets the number of plugins installed already
func SetPluginBeingInstalledCount(count int) {
pluginNumberBeingInstalled = count
}

// GetPluginsInstalledCount returns the number of plugins installed
func GetPluginsInstalledCount() int {
return pluginsInstalledCount
// GetPluginBeingInstalledCount returns the number of plugin being installed
func GetPluginBeingInstalledCount() int {
return pluginNumberBeingInstalled
}

// IncrementPluginsInstalledCount increments the number of plugins installed
func IncrementPluginsInstalledCount(count int) {
pluginsInstalledCount += count
pluginNumberBeingInstalled += count
}

// installs a plugin by name, version and target.
@@ -659,7 +659,7 @@ func InstallPluginsFromGivenPluginGroup(pluginName, groupIDAndVersion string, pg
}
}
SetTotalPluginsToInstall(len(pluginsToInstall))
SetPluginsInstalledCount(0)
SetPluginBeingInstalledCount(1)
defer StopSpinner()
defer ResetPluginInstallationCounts()
for _, plugin := range pluginsToInstall {
@@ -686,7 +686,7 @@ func InstallPluginsFromGivenPluginGroup(pluginName, groupIDAndVersion string, pg
return groupIDAndVersion, fmt.Errorf("could not install %d plugin(s) from group '%s'", numErrors, groupIDAndVersion)
}

if GetPluginsInstalledCount() == 0 {
if GetPluginBeingInstalledCount() == 0 {
return groupIDAndVersion, fmt.Errorf("plugin '%s' is not part of the group '%s'", pluginName, groupIDAndVersion)
}

@@ -789,9 +789,9 @@ func installOrUpgradePlugin(p *discovery.Discovered, version string, installTest
// Log message based on different installation conditions
installingMsg, _, errMsg := getPluginInstallationMessage(p, version, plugin != nil, isPluginAlreadyInstalled)

installingMsg = fmt.Sprintf("[%v/%v] %v", pluginsInstalledCount, totalPluginsToInstall, installingMsg)
errMsg = fmt.Sprintf("[%v/%v] %v", pluginsInstalledCount, totalPluginsToInstall, errMsg)
numPluginsInstalled := fmt.Sprintf("%d plugins installed out of %d", pluginsInstalledCount, totalPluginsToInstall)
installingMsg = fmt.Sprintf("[%v/%v] %v", pluginNumberBeingInstalled, totalPluginsToInstall, installingMsg)
errMsg = fmt.Sprintf("[%v/%v] %v", pluginNumberBeingInstalled, totalPluginsToInstall, errMsg)
numPluginsInstalled := fmt.Sprintf("%d plugins installed out of %d", pluginNumberBeingInstalled, totalPluginsToInstall)
numPluginsInstalledWithLog := fmt.Sprintf("%s%s", log.GetLogTypeIndicator(log.LogTypeERROR), numPluginsInstalled)
errMsg = fmt.Sprintf("%s\n%s", errMsg, numPluginsInstalledWithLog)

@@ -1196,7 +1196,7 @@ func InstallPluginsFromLocalSource(pluginName, version string, target configtype
}
}
SetTotalPluginsToInstall(len(pluginsToInstall))
SetPluginsInstalledCount(0)
SetPluginBeingInstalledCount(1)
defer ResetPluginInstallationCounts()
for _, plugin := range pluginsToInstall {
err = installOrUpgradePlugin(plugin, version, installTestPlugin)

0 comments on commit 9a109b0

Please sign in to comment.