Merge pull request #6279 from afbjorklund/image-arch

Add platform option when downloading images
pull/6791/head
Medya Ghazizadeh 2020-02-24 16:35:05 -08:00 committed by GitHub
commit 946bdff626
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 1 deletions

View File

@ -21,6 +21,7 @@ import (
"io/ioutil"
"os"
"path/filepath"
"runtime"
"time"
"github.com/docker/docker/client"
@ -33,6 +34,11 @@ import (
"k8s.io/minikube/pkg/minikube/constants"
)
var defaultPlatform = v1.Platform{
Architecture: runtime.GOARCH,
OS: "linux",
}
// DigestByDockerLib uses client by docker lib to return image digest
// img.ID in as same as image digest
func DigestByDockerLib(imgClient *client.Client, imgName string) string {
@ -81,7 +87,8 @@ func retrieveImage(ref name.Reference) (v1.Image, error) {
glog.Infof("daemon lookup for %+v: %v", ref, err)
}
img, err = remote.Image(ref, remote.WithAuthFromKeychain(authn.DefaultKeychain))
platform := defaultPlatform
img, err = remote.Image(ref, remote.WithAuthFromKeychain(authn.DefaultKeychain), remote.WithPlatform(platform))
if err == nil {
return img, nil
}