Skip to content

Commit

Permalink
Merge pull request #1995 from Adirio/fix-sort
Browse files Browse the repository at this point in the history
🐛 Fix sorting issue with plugin versions and their supported project versions
  • Loading branch information
k8s-ci-robot committed Feb 8, 2021
2 parents 3c8e370 + f1685b8 commit 89c42c4
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pkg/cli/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func (c cli) getPluginTable() string {
maxPluginKeyLength = len(pluginKeysHeader)
pluginKeys = make([]string, 0, len(c.plugins))
maxProjectVersionLength = len(projectVersionsHeader)
projectVersions = make([]string, 0, len(c.plugins))
projectVersions = make(map[string]string, len(c.plugins))
)

for pluginKey, plugin := range c.plugins {
Expand All @@ -106,7 +106,7 @@ func (c cli) getPluginTable() string {
if len(supportedProjectVersionsStr) > maxProjectVersionLength {
maxProjectVersionLength = len(supportedProjectVersionsStr)
}
projectVersions = append(projectVersions, supportedProjectVersionsStr)
projectVersions[pluginKey] = supportedProjectVersionsStr
}

lines := make([]string, 0, len(c.plugins)+2)
Expand All @@ -116,8 +116,8 @@ func (c cli) getPluginTable() string {
strings.Repeat("-", maxProjectVersionLength+2))

sort.Strings(pluginKeys)
for i, pluginKey := range pluginKeys {
supportedProjectVersions := projectVersions[i]
for _, pluginKey := range pluginKeys {
supportedProjectVersions := projectVersions[pluginKey]
lines = append(lines, fmt.Sprintf(" %[1]*[2]s | %[3]*[4]s",
maxPluginKeyLength, pluginKey, maxProjectVersionLength, supportedProjectVersions))
}
Expand Down

0 comments on commit 89c42c4

Please sign in to comment.