Skip to content

Commit

Permalink
Use map of pre-existing versions to improve lookup of recent versions…
Browse files Browse the repository at this point in the history
… in UI before appending all versions
  • Loading branch information
MatthewJohn committed Jun 7, 2024
1 parent ecfbfc8 commit 927f999
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions lib/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,26 +291,22 @@ type VersionSelector struct {
func InstallProductOption(product Product, listAll, dryRun bool, customBinaryPath, installPath string, mirrorURL string) {
var selectVersions []VersionSelector

var versionMap map[string]bool = make(map[string]bool)

// Add recent versions
recentVersions, _ := getRecentVersions(installPath, product)
for _, version := range recentVersions {
selectVersions = append(selectVersions, VersionSelector{
Version: version,
Label: version + " *recent",
})
versionMap[version] = true
}

// Add all versions
tfList, _ := getTFList(mirrorURL, listAll)
for _, version := range tfList {
isRecentVersion := false
for _, recentVersion := range recentVersions {
if recentVersion == version {
isRecentVersion = true
break
}
}
if !isRecentVersion {
if !versionMap[version] {
selectVersions = append(selectVersions, VersionSelector{
Version: version,
Label: version,
Expand Down

0 comments on commit 927f999

Please sign in to comment.