hack: fix amd-gpu-device-plugin update script version tag mismatch
The GitHub release tag (e.g. v1.25.2) differs from the Docker Hub image tag (e.g. v1.25.2.8). Update the script to find the correct image tag by querying available tags that match the release version prefix.pull/22777/head
parent
d5796e6cc5
commit
b2bf7c1dfb
|
|
@ -19,6 +19,7 @@ package main
|
|||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"k8s.io/minikube/hack/update"
|
||||
|
|
@ -39,6 +40,19 @@ type Data struct {
|
|||
SHA string
|
||||
}
|
||||
|
||||
// findMatchingImageTag finds the Docker Hub image tag corresponding to a GitHub release tag.
|
||||
// Docker Hub tags may include a numeric patch suffix not present in the GitHub release tag
|
||||
// (e.g. GitHub "v1.25.2" may correspond to Docker Hub "v1.25.2.8").
|
||||
// Tags should be provided newest-first (Docker Hub API default); the first match is returned.
|
||||
func findMatchingImageTag(tags []string, ghTag string) (string, error) {
|
||||
for _, tag := range tags {
|
||||
if tag == ghTag || strings.HasPrefix(tag, ghTag+".") {
|
||||
return tag, nil
|
||||
}
|
||||
}
|
||||
return "", fmt.Errorf("no Docker Hub image tag found matching GitHub release tag %s", ghTag)
|
||||
}
|
||||
|
||||
func main() {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute)
|
||||
defer cancel()
|
||||
|
|
@ -47,12 +61,23 @@ func main() {
|
|||
if err != nil {
|
||||
klog.Fatalf("Unable to get stable version: %v", err)
|
||||
}
|
||||
sha, err := update.GetImageSHA(fmt.Sprintf("rocm/k8s-device-plugin:%s", stable.Tag))
|
||||
|
||||
dockerTags, err := update.ImageTagsFromDockerHub("rocm/k8s-device-plugin")
|
||||
if err != nil {
|
||||
klog.Fatalf("failed to get Docker Hub tags for rocm/k8s-device-plugin: %v", err)
|
||||
}
|
||||
|
||||
imageTag, err := findMatchingImageTag(dockerTags, stable.Tag)
|
||||
if err != nil {
|
||||
klog.Fatalf("failed to find Docker Hub image tag matching GitHub release tag %s: %v", stable.Tag, err)
|
||||
}
|
||||
|
||||
sha, err := update.GetImageSHA(fmt.Sprintf("rocm/k8s-device-plugin:%s", imageTag))
|
||||
if err != nil {
|
||||
klog.Fatalf("failed to get image SHA: %v", err)
|
||||
}
|
||||
|
||||
data := Data{Version: stable.Tag, SHA: sha}
|
||||
data := Data{Version: imageTag, SHA: sha}
|
||||
|
||||
if err := update.Apply(schema, data); err != nil {
|
||||
klog.Fatalf("unable to apply update: %v", err)
|
||||
|
|
|
|||
Loading…
Reference in New Issue