Skip to content

Commit

Permalink
fix(generate-registry): fix a bug that the order of versions in pkg.y…
Browse files Browse the repository at this point in the history
…aml is wrong (#2456)
  • Loading branch information
suzuki-shunsuke authored Nov 13, 2023
1 parent 9637b5e commit 6102460
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion pkg/controller/generate-registry/group.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,19 @@ func mergeGroups(groups []*Group) (*registry.PackageInfo, []string) { //nolint:c
pkg.VersionOverrides = append(pkg.VersionOverrides, vo)
}
pkg.VersionOverrides[len(pkg.VersionOverrides)-1].VersionConstraints = "true"
sort.Sort(sort.Reverse(sort.StringSlice(versions)))
reverse(versions)
return pkg, versions
}

func reverse(versions []string) {
// sort.Reverse doesn't work well.
// https://qiita.com/shibukawa/items/0e6e01dc41c352ccedb5
size := len(versions)
for i := 0; i < size/2; i++ {
versions[i], versions[size-i-1] = versions[size-i-1], versions[i]
}
}

func replaceVersion(assetName, version string) string {
return strings.Replace(
strings.Replace(assetName, version, "{{.Version}}", 1),
Expand Down

0 comments on commit 6102460

Please sign in to comment.