@@ -1139,9 +1139,9 @@ func testSecretMounts(t *testing.T, sb integration.Sandbox) {
1139
1139
}, nil )
1140
1140
require .NoError (t , err )
1141
1141
1142
- // test optional
1142
+ // test optional, mount should not exist when secret not present in SolveOpt
1143
1143
st = llb .Image ("busybox:latest" ).
1144
- Run (llb .Shlex (`echo secret2 ` ), llb .AddSecret ("/run/secrets/mysecret2" , llb .SecretOptional ))
1144
+ Run (llb .Shlex (`test ! -f /run/secrets/mysecret2 ` ), llb .AddSecret ("/run/secrets/mysecret2" , llb .SecretOptional ))
1145
1145
1146
1146
def , err = st .Marshal (sb .Context ())
1147
1147
require .NoError (t , err )
@@ -1178,6 +1178,20 @@ func testSecretMounts(t *testing.T, sb integration.Sandbox) {
1178
1178
})},
1179
1179
}, nil )
1180
1180
require .NoError (t , err )
1181
+
1182
+ // test empty cert still creates secret file
1183
+ st = llb .Image ("busybox:latest" ).
1184
+ Run (llb .Shlex (`test -f /run/secrets/mysecret5` ), llb .AddSecret ("/run/secrets/mysecret5" , llb .SecretID ("mysecret" )))
1185
+
1186
+ def , err = st .Marshal (sb .Context ())
1187
+ require .NoError (t , err )
1188
+
1189
+ _ , err = c .Solve (sb .Context (), def , SolveOpt {
1190
+ Session : []session.Attachable {secretsprovider .FromMap (map [string ][]byte {
1191
+ "mysecret" : []byte ("" ),
1192
+ })},
1193
+ }, nil )
1194
+ require .NoError (t , err )
1181
1195
}
1182
1196
1183
1197
func testSecretEnv (t * testing.T , sb integration.Sandbox ) {
0 commit comments