Skip to content

Commit

Permalink
exporter: normalize default platform string
Browse files Browse the repository at this point in the history
Signed-off-by: Kohei Tokunaga <[email protected]>
(cherry picked from commit ff0197b)
Signed-off-by: Tonis Tiigi <[email protected]>
  • Loading branch information
ktock authored and tonistiigi committed Apr 6, 2022
1 parent ed07491 commit 686840f
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions exporter/containerimage/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -403,10 +403,10 @@ func (e *imageExporterInstance) unpackImage(ctx context.Context, img images.Imag

topLayerRef := src.Ref
if len(src.Refs) > 0 {
if r, ok := src.Refs[platforms.DefaultString()]; ok {
if r, ok := src.Refs[defaultPlatform()]; ok {
topLayerRef = r
} else {
return errors.Errorf("no reference for default platform %s", platforms.DefaultString())
return errors.Errorf("no reference for default platform %s", defaultPlatform())
}
}

Expand Down Expand Up @@ -482,3 +482,9 @@ func addAnnotations(m map[digest.Digest]map[string]string, desc ocispecs.Descrip
a[k] = v
}
}

func defaultPlatform() string {
// Use normalized platform string to avoid the mismatch with platform options which
// are normalized using platforms.Normalize()
return platforms.Format(platforms.Normalize(platforms.DefaultSpec()))
}

0 comments on commit 686840f

Please sign in to comment.