buildkit/frontend/dockerfile/dockerfile2llb/convert_runsecurity.go

26 lines
652 B
Go

//go:build dfrunsecurity
// +build dfrunsecurity
package dockerfile2llb
import (
"github.com/pkg/errors"
"github.com/moby/buildkit/client/llb"
"github.com/moby/buildkit/frontend/dockerfile/instructions"
"github.com/moby/buildkit/solver/pb"
)
func dispatchRunSecurity(c *instructions.RunCommand) (llb.RunOption, error) {
security := instructions.GetSecurity(c)
switch security {
case instructions.SecurityInsecure:
return llb.Security(pb.SecurityMode_INSECURE), nil
case instructions.SecuritySandbox:
return llb.Security(pb.SecurityMode_SANDBOX), nil
default:
return nil, errors.Errorf("unsupported security mode %q", security)
}
}