Merge pull request #18107 from spowelljr/fixLatestIngressVersion

CI: Fix ingress auto update not getting newest version
pull/18122/head
Medya Ghazizadeh 2024-02-06 10:57:59 -08:00 committed by GitHub
commit 153775508c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 14 additions and 3 deletions

View File

@ -26,6 +26,7 @@ import (
"time"
"github.com/google/go-github/v58/github"
"golang.org/x/mod/semver"
"k8s.io/klog/v2"
"k8s.io/minikube/hack/update"
@ -84,7 +85,9 @@ func main() {
}
func LatestControllerTag(ctx context.Context) (string, error) {
latest := "v0.0.0"
ghc := github.NewClient(nil)
re := regexp.MustCompile(`controller-(.*)`)
// walk through the paginated list of up to ghSearchLimit newest releases
opts := &github.ListOptions{PerPage: ghListPerPage}
@ -95,8 +98,16 @@ func LatestControllerTag(ctx context.Context) (string, error) {
}
for _, rl := range rls {
ver := rl.GetTagName()
if strings.HasPrefix(ver, "controller-") {
return ver, nil
if !strings.HasPrefix(ver, "controller-") {
continue
}
s := re.FindStringSubmatch(ver)
if len(s) < 2 {
continue
}
vTag := s[1]
if semver.Compare(vTag, latest) == 1 {
latest = vTag
}
}
if resp.NextPage == 0 {
@ -104,5 +115,5 @@ func LatestControllerTag(ctx context.Context) (string, error) {
}
opts.Page = resp.NextPage
}
return "", fmt.Errorf("no version found")
return fmt.Sprintf("controller-%s", latest), nil
}