build-arg add support BUILDKIT_SYNTAX

Signed-off-by: Wang Yumu <37442693@qq.com>
v0.8
Wang Yumu 2020-08-10 10:18:31 +08:00
parent 279d686fec
commit 882fc73790
1 changed files with 9 additions and 2 deletions

View File

@ -53,6 +53,7 @@ const (
keyNameDockerfile = "dockerfilekey"
keyContextSubDir = "contextsubdir"
keyContextKeepGitDir = "build-arg:BUILDKIT_CONTEXT_KEEP_GIT_DIR"
keySyntax = "build-arg:BUILDKIT_SYNTAX"
)
var httpPrefix = regexp.MustCompile(`^https?://`)
@ -317,8 +318,14 @@ func Build(ctx context.Context, c client.Client) (*client.Result, error) {
}
if _, ok := opts["cmdline"]; !ok {
ref, cmdline, loc, ok := dockerfile2llb.DetectSyntax(bytes.NewBuffer(dtDockerfile))
if ok {
if cmdline, ok := opts[keySyntax]; ok {
p := strings.SplitN(strings.TrimSpace(cmdline), " ", 2)
res, err := forwardGateway(ctx, c, p[0], cmdline)
if err != nil && len(errdefs.Sources(err)) == 0 {
return nil, errors.Wrapf(err, "failed with %s = %s", keySyntax, cmdline)
}
return res, err
} else if ref, cmdline, loc, ok := dockerfile2llb.DetectSyntax(bytes.NewBuffer(dtDockerfile)); ok {
res, err := forwardGateway(ctx, c, ref, cmdline)
if err != nil && len(errdefs.Sources(err)) == 0 {
return nil, wrapSource(err, sourceMap, loc)