Skip to content

Commit

Permalink
feat(controller): multi-platform images support
Browse files Browse the repository at this point in the history
  • Loading branch information
Hennadii Mykhailiuta authored and paullaffitte committed Oct 23, 2023
1 parent 5129d19 commit 47d2590
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions internal/registry/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/google/go-containerregistry/pkg/name"
"github.com/google/go-containerregistry/pkg/v1/remote"
"github.com/google/go-containerregistry/pkg/v1/remote/transport"
"github.com/google/go-containerregistry/pkg/v1/types"
)

var Endpoint = ""
Expand Down Expand Up @@ -105,7 +106,7 @@ func CacheImage(imageName string, keychain authn.Keychain) error {
}

auth := remote.WithAuthFromKeychain(keychain)
image, err := remote.Image(sourceRef, auth)
desc, err := remote.Get(sourceRef, auth)
if err != nil {
if errIsImageNotFound(err) {

Expand All @@ -114,8 +115,23 @@ func CacheImage(imageName string, keychain authn.Keychain) error {
return err
}

if err := remote.Write(destRef, image); err != nil {
return err
switch desc.MediaType {
case types.OCIImageIndex, types.DockerManifestList:
index, err := desc.ImageIndex()
if err != nil {
return err
}
if err := remote.WriteIndex(destRef, index); err != nil {
return err
}
default:
image, err := desc.Image()
if err != nil {
return err
}
if err := remote.Write(destRef, image); err != nil {
return err
}
}
return nil
}
Expand Down

0 comments on commit 47d2590

Please sign in to comment.