diff --git a/source/containerimage/pull.go b/source/containerimage/pull.go index 244c6347..59849600 100644 --- a/source/containerimage/pull.go +++ b/source/containerimage/pull.go @@ -113,7 +113,7 @@ func (is *Source) Resolve(ctx context.Context, id source.Identifier, sm *session pullerUtil := &pull.Puller{ ContentStore: is.ContentStore, - Platform: &platform, + Platform: platform, Src: imageIdentifier.Reference, } p := &puller{ @@ -150,22 +150,18 @@ type puller struct { *pull.Puller } -func mainManifestKey(ctx context.Context, desc specs.Descriptor, platform *specs.Platform) (digest.Digest, error) { - keyStruct := struct { +func mainManifestKey(ctx context.Context, desc specs.Descriptor, platform specs.Platform) (digest.Digest, error) { + dt, err := json.Marshal(struct { Digest digest.Digest OS string Arch string Variant string `json:",omitempty"` }{ - Digest: desc.Digest, - } - if platform != nil { - keyStruct.OS = platform.OS - keyStruct.Arch = platform.Architecture - keyStruct.Variant = platform.Variant - } - - dt, err := json.Marshal(keyStruct) + Digest: desc.Digest, + OS: platform.OS, + Arch: platform.Architecture, + Variant: platform.Variant, + }) if err != nil { return "", err } @@ -312,7 +308,7 @@ func (p *puller) Snapshot(ctx context.Context, g session.Group) (ir cache.Immuta } } - if current != nil && p.Platform != nil && p.Platform.OS == "windows" && runtime.GOOS != "windows" { + if current != nil && p.Platform.OS == "windows" && runtime.GOOS != "windows" { if err := markRefLayerTypeWindows(current); err != nil { return nil, err } diff --git a/util/pull/pull.go b/util/pull/pull.go index 5efb6c53..ba9ec88a 100644 --- a/util/pull/pull.go +++ b/util/pull/pull.go @@ -24,7 +24,7 @@ type Puller struct { ContentStore content.Store Resolver remotes.Resolver Src reference.Spec - Platform *ocispec.Platform + Platform ocispec.Platform resolveOnce sync.Once resolveErr error @@ -99,12 +99,7 @@ func (p *Puller) PullManifests(ctx context.Context) (*PulledManifests, error) { // workaround for gcr, authentication not supported on blob endpoints EnsureManifestRequested(ctx, p.Resolver, p.ref) - var platform platforms.MatchComparer - if p.Platform != nil { - platform = platforms.Only(*p.Platform) - } else { - platform = platforms.Default() - } + platform := platforms.Only(p.Platform) var mu sync.Mutex // images.Dispatch calls handlers in parallel metadata := make(map[digest.Digest]ocispec.Descriptor)