diff --git a/frontend/dockerfile/dockerfile_secrets_test.go b/frontend/dockerfile/dockerfile_secrets_test.go index 966a88d1..0f0cd1de 100644 --- a/frontend/dockerfile/dockerfile_secrets_test.go +++ b/frontend/dockerfile/dockerfile_secrets_test.go @@ -29,7 +29,7 @@ func testSecretFileParams(t *testing.T, sb integration.Sandbox) { dockerfile := []byte(` FROM busybox -RUN --mount=type=secret,mode=741,uid=100,gid=102,target=/mysecret [ "$(stat -c "%u %g %f" /mysecret)" = "100 102 81e1" ] +RUN --mount=type=secret,required=false,mode=741,uid=100,gid=102,target=/mysecret [ "$(stat -c "%u %g %f" /mysecret)" = "100 102 81e1" ] `) dir, err := tmpdir( diff --git a/frontend/dockerfile/instructions/commands_runmount.go b/frontend/dockerfile/instructions/commands_runmount.go index 143525ea..ad65a41e 100644 --- a/frontend/dockerfile/instructions/commands_runmount.go +++ b/frontend/dockerfile/instructions/commands_runmount.go @@ -176,6 +176,14 @@ func parseMount(value string) (*Mount, error) { } m.ReadOnly = !rw roAuto = false + case "required": + if m.Type == "secret" || m.Type == "ssh" { + v, err := strconv.ParseBool(value) + if err != nil { + return nil, errors.Errorf("invalid value for %s: %s", key, value) + } + m.Required = v + } case "id": m.CacheID = value case "sharing":