Skip to content

Commit 5efd380

Browse files
authored
Merge pull request #5837 from tonistiigi/dockerfile-wcow-sbom
dockerfile: fix sbom attestation for windows targets
2 parents ae52dcc + 25bba31 commit 5efd380

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

frontend/dockerui/build.go

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -62,18 +62,9 @@ func (bc *Client) Build(ctx context.Context, fn BuildFunc) (*ResultBuilder, erro
6262
p = platforms.DefaultSpec()
6363
}
6464

65-
// in certain conditions we allow input platform to be extended from base image
66-
if p.OS == "windows" && img.OS == p.OS {
67-
if p.OSVersion == "" && img.OSVersion != "" {
68-
p.OSVersion = img.OSVersion
69-
}
70-
if p.OSFeatures == nil && len(img.OSFeatures) > 0 {
71-
p.OSFeatures = slices.Clone(img.OSFeatures)
72-
}
73-
}
74-
75-
p = platforms.Normalize(p)
7665
k := platforms.FormatAll(p)
66+
p = extendWindowsPlatform(p, img.Platform)
67+
p = platforms.Normalize(p)
7768

7869
if bc.MultiPlatformRequested {
7970
res.AddRef(k, ref)
@@ -129,3 +120,16 @@ func (rb *ResultBuilder) EachPlatform(ctx context.Context, fn func(ctx context.C
129120
}
130121
return eg.Wait()
131122
}
123+
124+
func extendWindowsPlatform(p, imgP ocispecs.Platform) ocispecs.Platform {
125+
// in certain conditions we allow input platform to be extended from base image
126+
if p.OS == "windows" && imgP.OS == p.OS {
127+
if p.OSVersion == "" && imgP.OSVersion != "" {
128+
p.OSVersion = imgP.OSVersion
129+
}
130+
if p.OSFeatures == nil && len(imgP.OSFeatures) > 0 {
131+
p.OSFeatures = slices.Clone(imgP.OSFeatures)
132+
}
133+
}
134+
return p
135+
}

0 commit comments

Comments
 (0)