@@ -43,7 +43,6 @@ import (
43
43
)
44
44
45
45
func testProvenanceAttestation (t * testing.T , sb integration.Sandbox ) {
46
- integration .SkipOnPlatform (t , "windows" )
47
46
workers .CheckFeatureCompat (t , sb , workers .FeatureDirectPush , workers .FeatureProvenance )
48
47
ctx := sb .Context ()
49
48
@@ -59,10 +58,18 @@ func testProvenanceAttestation(t *testing.T, sb integration.Sandbox) {
59
58
60
59
f := getFrontend (t , sb )
61
60
62
- dockerfile := []byte (`
61
+ dockerfile := []byte (integration .UnixOrWindows (
62
+ `
63
63
FROM busybox:latest
64
64
RUN echo "ok" > /foo
65
- ` )
65
+ ` ,
66
+ `
67
+ FROM nanoserver
68
+ USER ContainerAdministrator
69
+ RUN echo ok> /foo
70
+ ` ,
71
+ ))
72
+
66
73
dir := integration .Tmpdir (
67
74
t ,
68
75
fstest .CreateFile ("Dockerfile" , dockerfile , 0600 ),
@@ -115,7 +122,9 @@ RUN echo "ok" > /foo
115
122
116
123
img := imgs .Find (platforms .Format (platforms .Normalize (platforms .DefaultSpec ())))
117
124
require .NotNil (t , img )
118
- require .Equal (t , []byte ("ok\n " ), img .Layers [1 ]["foo" ].Data )
125
+ outFile := integration .UnixOrWindows ("foo" , "Files/foo" )
126
+ expectedFileData := integration .UnixOrWindows ([]byte ("ok\n " ), []byte ("ok\r \n " ))
127
+ require .Equal (t , expectedFileData , img .Layers [1 ][outFile ].Data )
119
128
120
129
att := imgs .Find ("unknown/unknown" )
121
130
require .NotNil (t , att )
@@ -179,7 +188,9 @@ RUN echo "ok" > /foo
179
188
require .
Equal (
t ,
"https://xxxxx:[email protected] /foo.html" ,
args [
"context:foo" ])
180
189
}
181
190
182
- expectedBase := "pkg:docker/busybox@latest?platform=" + url .PathEscape (platforms .Format (platforms .Normalize (platforms .DefaultSpec ())))
191
+ expectedBaseImage := integration .UnixOrWindows ("busybox" , "nanoserver" )
192
+ escapedPlatform := url .PathEscape (platforms .Format (platforms .Normalize (platforms .DefaultSpec ())))
193
+ expectedBase := fmt .Sprintf ("pkg:docker/%s@latest?platform=%s" , expectedBaseImage , escapedPlatform )
183
194
if isGateway {
184
195
require .Equal (t , 2 , len (pred .Materials ), "%+v" , pred .Materials )
185
196
require .Contains (t , pred .Materials [0 ].URI , "docker/buildkit_test" )
@@ -693,7 +704,6 @@ func testClientFrontendProvenance(t *testing.T, sb integration.Sandbox) {
693
704
}
694
705
695
706
func testClientLLBProvenance (t * testing.T , sb integration.Sandbox ) {
696
- integration .SkipOnPlatform (t , "windows" )
697
707
workers .CheckFeatureCompat (t , sb , workers .FeatureDirectPush , workers .FeatureProvenance )
698
708
ctx := sb .Context ()
699
709
@@ -736,7 +746,7 @@ func testClientLLBProvenance(t *testing.T, sb integration.Sandbox) {
736
746
return nil , err
737
747
}
738
748
739
- st = llb .Image ("alpine" ).File (llb .Mkfile ("/foo" , 0600 , dt ))
749
+ st = llb .Image (integration . UnixOrWindows ( "alpine" , "nanoserver" ) ).File (llb .Mkfile ("/foo" , 0600 , dt ))
740
750
def , err = st .Marshal (ctx )
741
751
if err != nil {
742
752
return nil , err
@@ -776,8 +786,9 @@ func testClientLLBProvenance(t *testing.T, sb integration.Sandbox) {
776
786
nativePlatform := platforms .Format (platforms .Normalize (platforms .DefaultSpec ()))
777
787
778
788
img := imgs .Find (nativePlatform )
789
+ fileName := integration .UnixOrWindows ("foo" , "Files/foo" )
779
790
require .NotNil (t , img )
780
- require .Contains (t , string (img .Layers [1 ]["foo" ].Data ), "The Moby Project" )
791
+ require .Contains (t , string (img .Layers [1 ][fileName ].Data ), "The Moby Project" )
781
792
782
793
att := imgs .FindAttestation (nativePlatform )
783
794
require .NotNil (t , att )
@@ -803,7 +814,7 @@ func testClientLLBProvenance(t *testing.T, sb integration.Sandbox) {
803
814
require .Equal (t , 0 , len (pred .Invocation .Parameters .Locals ))
804
815
805
816
require .Equal (t , 2 , len (pred .Materials ), "%+v" , pred .Materials )
806
- require .Contains (t , pred .Materials [0 ].URI , "docker/alpine" )
817
+ require .Contains (t , pred .Materials [0 ].URI , integration . UnixOrWindows ( "docker/alpine" , "docker/nanoserver" ) )
807
818
require .Contains (t , pred .Materials [1 ].URI , "README.md" )
808
819
}
809
820
@@ -1020,7 +1031,6 @@ EOF
1020
1031
}
1021
1032
1022
1033
func testNilProvenance (t * testing.T , sb integration.Sandbox ) {
1023
- integration .SkipOnPlatform (t , "windows" )
1024
1034
workers .CheckFeatureCompat (t , sb , workers .FeatureProvenance )
1025
1035
ctx := sb .Context ()
1026
1036
@@ -1030,10 +1040,16 @@ func testNilProvenance(t *testing.T, sb integration.Sandbox) {
1030
1040
1031
1041
f := getFrontend (t , sb )
1032
1042
1033
- dockerfile := []byte (`
1043
+ dockerfile := []byte (integration .UnixOrWindows (
1044
+ `
1034
1045
FROM scratch
1035
1046
ENV FOO=bar
1036
- ` )
1047
+ ` ,
1048
+ `
1049
+ FROM scratch
1050
+ ENV FOO=bar
1051
+ ` ,
1052
+ ))
1037
1053
dir := integration .Tmpdir (
1038
1054
t ,
1039
1055
fstest .CreateFile ("Dockerfile" , dockerfile , 0600 ),
@@ -1058,7 +1074,6 @@ ENV FOO=bar
1058
1074
1059
1075
// https://github.com/moby/buildkit/issues/3562
1060
1076
func testDuplicatePlatformProvenance (t * testing.T , sb integration.Sandbox ) {
1061
- integration .SkipOnPlatform (t , "windows" )
1062
1077
workers .CheckFeatureCompat (t , sb , workers .FeatureProvenance )
1063
1078
ctx := sb .Context ()
1064
1079
@@ -1068,12 +1083,17 @@ func testDuplicatePlatformProvenance(t *testing.T, sb integration.Sandbox) {
1068
1083
1069
1084
f := getFrontend (t , sb )
1070
1085
1071
- dockerfile := []byte (`FROM alpine` )
1086
+ dockerfile := []byte (
1087
+ `
1088
+ FROM alpine as base-linux
1089
+ FROM nanoserver as base-windows
1090
+ FROM base-$TARGETOS
1091
+ ` ,
1092
+ )
1072
1093
dir := integration .Tmpdir (
1073
1094
t ,
1074
1095
fstest .CreateFile ("Dockerfile" , dockerfile , 0600 ),
1075
1096
)
1076
-
1077
1097
_ , err = f .Solve (sb .Context (), c , client.SolveOpt {
1078
1098
FrontendAttrs : map [string ]string {
1079
1099
"attest:provenance" : "mode=max" ,
@@ -1089,13 +1109,19 @@ func testDuplicatePlatformProvenance(t *testing.T, sb integration.Sandbox) {
1089
1109
1090
1110
// https://github.com/moby/buildkit/issues/3928
1091
1111
func testDockerIgnoreMissingProvenance (t * testing.T , sb integration.Sandbox ) {
1092
- integration .SkipOnPlatform (t , "windows" )
1093
1112
workers .CheckFeatureCompat (t , sb , workers .FeatureProvenance )
1094
1113
c , err := client .New (sb .Context (), sb .Address ())
1095
1114
require .NoError (t , err )
1096
1115
defer c .Close ()
1097
1116
1098
- dockerfile := []byte (`FROM alpine` )
1117
+ dockerfile := []byte (integration .UnixOrWindows (
1118
+ `
1119
+ FROM alpine
1120
+ ` ,
1121
+ `
1122
+ FROM nanoserver
1123
+ ` ,
1124
+ ))
1099
1125
dirDockerfile := integration .Tmpdir (
1100
1126
t ,
1101
1127
fstest .CreateFile ("Dockerfile" , dockerfile , 0600 ),
@@ -1250,20 +1276,22 @@ ADD bar bar`)
1250
1276
}
1251
1277
1252
1278
func testFrontendDeduplicateSources (t * testing.T , sb integration.Sandbox ) {
1253
- integration .SkipOnPlatform (t , "windows" )
1254
1279
ctx := sb .Context ()
1255
1280
1256
1281
c , err := client .New (ctx , sb .Address ())
1257
1282
require .NoError (t , err )
1258
1283
defer c .Close ()
1259
1284
1260
- dockerfile := []byte (`
1261
- FROM scratch as base
1285
+ dockerfile := []byte (fmt .Sprintf (
1286
+ `
1287
+ FROM %s as base
1262
1288
COPY foo foo2
1263
1289
1264
1290
FROM linked
1265
1291
COPY bar bar2
1266
- ` )
1292
+ ` ,
1293
+ integration .UnixOrWindows ("scratch" , "nanoserver" )),
1294
+ )
1267
1295
1268
1296
dir := integration .Tmpdir (
1269
1297
t ,
0 commit comments