@@ -217,6 +217,7 @@ var allTests = integration.TestFuncs(
217
217
testPowershellInDefaultPathOnWindows ,
218
218
testOCILayoutMultiname ,
219
219
testPlatformWithOSVersion ,
220
+ testMaintainBaseOSVersion ,
220
221
)
221
222
222
223
// Tests that depend on the `security.*` entitlements
@@ -9634,6 +9635,119 @@ EOF
9634
9635
require .Equal (t , p2 .OSVersion + "\n " , string (dt ))
9635
9636
}
9636
9637
9638
+ func testMaintainBaseOSVersion (t * testing.T , sb integration.Sandbox ) {
9639
+ integration .SkipOnPlatform (t , "windows" )
9640
+ workers .CheckFeatureCompat (t , sb , workers .FeatureDirectPush )
9641
+
9642
+ ctx := sb .Context ()
9643
+
9644
+ c , err := client .New (ctx , sb .Address ())
9645
+ require .NoError (t , err )
9646
+ defer c .Close ()
9647
+
9648
+ f := getFrontend (t , sb )
9649
+
9650
+ p1 := ocispecs.Platform {
9651
+ OS : "windows" ,
9652
+ OSVersion : "10.20.30" ,
9653
+ Architecture : "amd64" ,
9654
+ }
9655
+ p1Str := platforms .FormatAll (p1 )
9656
+
9657
+ registry , err := sb .NewRegistry ()
9658
+ if errors .Is (err , integration .ErrRequirements ) {
9659
+ t .Skip (err .Error ())
9660
+ }
9661
+ require .NoError (t , err )
9662
+ target := registry + "/buildkit/testplatformwithosversion-1:latest"
9663
+
9664
+ dockerfile := []byte (`
9665
+ FROM scratch
9666
+ ARG TARGETPLATFORM
9667
+ COPY <<EOF /platform
9668
+ ${TARGETPLATFORM}
9669
+ EOF
9670
+ ` )
9671
+
9672
+ dir := integration .Tmpdir (
9673
+ t ,
9674
+ fstest .CreateFile ("Dockerfile" , dockerfile , 0600 ),
9675
+ )
9676
+
9677
+ _ , err = f .Solve (sb .Context (), c , client.SolveOpt {
9678
+ FrontendAttrs : map [string ]string {
9679
+ "platform" : p1Str ,
9680
+ },
9681
+ Exports : []client.ExportEntry {
9682
+ {
9683
+ Type : client .ExporterImage ,
9684
+ Attrs : map [string ]string {
9685
+ "name" : target ,
9686
+ "push" : "true" ,
9687
+ },
9688
+ },
9689
+ },
9690
+
9691
+ LocalMounts : map [string ]fsutil.FS {
9692
+ dockerui .DefaultLocalNameDockerfile : dir ,
9693
+ dockerui .DefaultLocalNameContext : dir ,
9694
+ },
9695
+ }, nil )
9696
+
9697
+ require .NoError (t , err )
9698
+
9699
+ desc , provider , err := contentutil .ProviderFromRef (target )
9700
+ require .NoError (t , err )
9701
+
9702
+ info , err := testutil .ReadImages (ctx , provider , desc )
9703
+ require .NoError (t , err )
9704
+ require .Len (t , info .Images , 1 )
9705
+ require .Equal (t , info .Images [0 ].Img .Platform .OSVersion , p1 .OSVersion )
9706
+
9707
+ dockerfile = []byte (fmt .Sprintf (`
9708
+ FROM %s
9709
+ COPY <<EOF /other
9710
+ hello
9711
+ EOF
9712
+ ` , target ))
9713
+
9714
+ dir = integration .Tmpdir (
9715
+ t ,
9716
+ fstest .CreateFile ("Dockerfile" , dockerfile , 0600 ),
9717
+ )
9718
+
9719
+ target2 := registry + "/buildkit/testplatformwithosversion-2:latest"
9720
+
9721
+ _ , err = f .Solve (sb .Context (), c , client.SolveOpt {
9722
+ FrontendAttrs : map [string ]string {
9723
+ "platform" : p1 .OS + "/" + p1 .Architecture ,
9724
+ },
9725
+ Exports : []client.ExportEntry {
9726
+ {
9727
+ Type : client .ExporterImage ,
9728
+ Attrs : map [string ]string {
9729
+ "name" : target2 ,
9730
+ "push" : "true" ,
9731
+ },
9732
+ },
9733
+ },
9734
+
9735
+ LocalMounts : map [string ]fsutil.FS {
9736
+ dockerui .DefaultLocalNameDockerfile : dir ,
9737
+ dockerui .DefaultLocalNameContext : dir ,
9738
+ },
9739
+ }, nil )
9740
+ require .NoError (t , err )
9741
+
9742
+ desc , provider , err = contentutil .ProviderFromRef (target2 )
9743
+ require .NoError (t , err )
9744
+
9745
+ info , err = testutil .ReadImages (ctx , provider , desc )
9746
+ require .NoError (t , err )
9747
+ require .Len (t , info .Images , 1 )
9748
+ require .Equal (t , info .Images [0 ].Img .Platform .OSVersion , p1 .OSVersion )
9749
+ }
9750
+
9637
9751
func runShell (dir string , cmds ... string ) error {
9638
9752
for _ , args := range cmds {
9639
9753
var cmd * exec.Cmd
0 commit comments