@@ -62,6 +62,7 @@ import (
62
62
digest "github.com/opencontainers/go-digest"
63
63
ocispecs "github.com/opencontainers/image-spec/specs-go/v1"
64
64
"github.com/pkg/errors"
65
+ "github.com/stretchr/testify/assert"
65
66
"github.com/stretchr/testify/require"
66
67
statuspb "google.golang.org/genproto/googleapis/rpc/status"
67
68
)
@@ -197,6 +198,7 @@ var allTests = integration.TestFuncs(
197
198
testHistoryError ,
198
199
testHistoryFinalizeTrace ,
199
200
testEmptyStages ,
201
+ testLocalCustomSessionID ,
200
202
)
201
203
202
204
// Tests that depend on the `security.*` entitlements
@@ -6073,6 +6075,79 @@ COPY --from=base /o* /
6073
6075
require .True (t , errors .Is (err , os .ErrNotExist ))
6074
6076
}
6075
6077
6078
+ func testLocalCustomSessionID (t * testing.T , sb integration.Sandbox ) {
6079
+ integration .SkipOnPlatform (t , "windows" )
6080
+ ctx := sb .Context ()
6081
+
6082
+ c , err := client .New (ctx , sb .Address ())
6083
+ require .NoError (t , err )
6084
+ defer c .Close ()
6085
+
6086
+ dockerfile := []byte (`
6087
+ FROM scratch AS base
6088
+ FROM scratch
6089
+ COPY out /out1
6090
+ COPY --from=base /another /out2
6091
+ ` )
6092
+
6093
+ dir := integration .Tmpdir (
6094
+ t ,
6095
+ fstest .CreateFile ("Dockerfile" , dockerfile , 0600 ),
6096
+ )
6097
+
6098
+ dir2 := integration .Tmpdir (
6099
+ t ,
6100
+ fstest .CreateFile ("out" , []byte ("contents1" ), 0600 ),
6101
+ )
6102
+
6103
+ dir3 := integration .Tmpdir (
6104
+ t ,
6105
+ fstest .CreateFile ("another" , []byte ("contents2" ), 0600 ),
6106
+ )
6107
+
6108
+ f := getFrontend (t , sb )
6109
+
6110
+ destDir := t .TempDir ()
6111
+
6112
+ dirs := filesync .NewFSSyncProvider (filesync.StaticDirSource {
6113
+ dockerui .DefaultLocalNameDockerfile : dir ,
6114
+ dockerui .DefaultLocalNameContext : dir2 ,
6115
+ "basedir" : dir3 ,
6116
+ })
6117
+
6118
+ s , err := session .NewSession (ctx , "hint" )
6119
+ require .NoError (t , err )
6120
+ s .Allow (dirs )
6121
+ go func () {
6122
+ err := s .Run (ctx , c .Dialer ())
6123
+ assert .NoError (t , err )
6124
+ }()
6125
+
6126
+ _ , err = f .Solve (sb .Context (), c , client.SolveOpt {
6127
+ FrontendAttrs : map [string ]string {
6128
+ "context:base" : "local:basedir" ,
6129
+ "local-sessionid:" + dockerui .DefaultLocalNameDockerfile : s .ID (),
6130
+ "local-sessionid:" + dockerui .DefaultLocalNameContext : s .ID (),
6131
+ "local-sessionid:basedir" : s .ID (),
6132
+ },
6133
+ Exports : []client.ExportEntry {
6134
+ {
6135
+ Type : client .ExporterLocal ,
6136
+ OutputDir : destDir ,
6137
+ },
6138
+ },
6139
+ }, nil )
6140
+ require .NoError (t , err )
6141
+
6142
+ dt , err := os .ReadFile (filepath .Join (destDir , "out1" ))
6143
+ require .NoError (t , err )
6144
+ require .Equal (t , "contents1" , string (dt ))
6145
+
6146
+ dt , err = os .ReadFile (filepath .Join (destDir , "out2" ))
6147
+ require .NoError (t , err )
6148
+ require .Equal (t , "contents2" , string (dt ))
6149
+ }
6150
+
6076
6151
func testNamedOCILayoutContext (t * testing.T , sb integration.Sandbox ) {
6077
6152
integration .SkipOnPlatform (t , "windows" )
6078
6153
workers .CheckFeatureCompat (t , sb , workers .FeatureOCIExporter , workers .FeatureOCILayout )
0 commit comments