mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-07-09 21:17:09 +08:00
vendor: update buildkit to v0.14.0-rc1
Update buildkit dependency to v0.14.0-rc1. Update the tracing infrastructure to use the new detect API which updates how the delegated exporter is configured. Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
This commit is contained in:
32
vendor/github.com/moby/buildkit/frontend/dockerfile/parser/directives.go
generated
vendored
32
vendor/github.com/moby/buildkit/frontend/dockerfile/parser/directives.go
generated
vendored
@ -13,12 +13,14 @@ import (
|
||||
|
||||
const (
|
||||
keySyntax = "syntax"
|
||||
keyCheck = "check"
|
||||
keyEscape = "escape"
|
||||
)
|
||||
|
||||
var validDirectives = map[string]struct{}{
|
||||
keySyntax: {},
|
||||
keyEscape: {},
|
||||
keyCheck: {},
|
||||
}
|
||||
|
||||
type Directive struct {
|
||||
@ -110,6 +112,10 @@ func (d *DirectiveParser) ParseAll(data []byte) ([]*Directive, error) {
|
||||
// This allows for a flexible range of input formats, and appropriate syntax
|
||||
// selection.
|
||||
func DetectSyntax(dt []byte) (string, string, []Range, bool) {
|
||||
return ParseDirective(keySyntax, dt)
|
||||
}
|
||||
|
||||
func ParseDirective(key string, dt []byte) (string, string, []Range, bool) {
|
||||
dt, hadShebang, err := discardShebang(dt)
|
||||
if err != nil {
|
||||
return "", "", nil, false
|
||||
@ -119,42 +125,38 @@ func DetectSyntax(dt []byte) (string, string, []Range, bool) {
|
||||
line++
|
||||
}
|
||||
|
||||
// use default directive parser, and search for #syntax=
|
||||
// use default directive parser, and search for #key=
|
||||
directiveParser := DirectiveParser{line: line}
|
||||
if syntax, cmdline, loc, ok := detectSyntaxFromParser(dt, directiveParser); ok {
|
||||
if syntax, cmdline, loc, ok := detectDirectiveFromParser(key, dt, directiveParser); ok {
|
||||
return syntax, cmdline, loc, true
|
||||
}
|
||||
|
||||
// use directive with different comment prefix, and search for //syntax=
|
||||
// use directive with different comment prefix, and search for //key=
|
||||
directiveParser = DirectiveParser{line: line}
|
||||
directiveParser.setComment("//")
|
||||
if syntax, cmdline, loc, ok := detectSyntaxFromParser(dt, directiveParser); ok {
|
||||
if syntax, cmdline, loc, ok := detectDirectiveFromParser(key, dt, directiveParser); ok {
|
||||
return syntax, cmdline, loc, true
|
||||
}
|
||||
|
||||
// search for possible json directives
|
||||
var directive struct {
|
||||
Syntax string `json:"syntax"`
|
||||
}
|
||||
if err := json.Unmarshal(dt, &directive); err == nil {
|
||||
if directive.Syntax != "" {
|
||||
// use json directive, and search for { "key": "..." }
|
||||
jsonDirective := map[string]string{}
|
||||
if err := json.Unmarshal(dt, &jsonDirective); err == nil {
|
||||
if v, ok := jsonDirective[key]; ok {
|
||||
loc := []Range{{
|
||||
Start: Position{Line: line},
|
||||
End: Position{Line: line},
|
||||
}}
|
||||
return directive.Syntax, directive.Syntax, loc, true
|
||||
return v, v, loc, true
|
||||
}
|
||||
}
|
||||
|
||||
return "", "", nil, false
|
||||
}
|
||||
|
||||
func detectSyntaxFromParser(dt []byte, parser DirectiveParser) (string, string, []Range, bool) {
|
||||
func detectDirectiveFromParser(key string, dt []byte, parser DirectiveParser) (string, string, []Range, bool) {
|
||||
directives, _ := parser.ParseAll(dt)
|
||||
for _, d := range directives {
|
||||
// check for syntax directive before erroring out, since the error
|
||||
// might have occurred *after* the syntax directive
|
||||
if d.Name == keySyntax {
|
||||
if d.Name == key {
|
||||
p, _, _ := strings.Cut(d.Value, " ")
|
||||
return p, d.Value, d.Location, true
|
||||
}
|
||||
|
15
vendor/github.com/moby/buildkit/frontend/dockerfile/parser/line_parsers.go
generated
vendored
15
vendor/github.com/moby/buildkit/frontend/dockerfile/parser/line_parsers.go
generated
vendored
@ -154,7 +154,7 @@ func parseNameVal(rest string, key string, d *directives) (*Node, error) {
|
||||
if len(parts) < 2 {
|
||||
return nil, errors.Errorf("%s must have two arguments", key)
|
||||
}
|
||||
return newKeyValueNode(parts[0], parts[1]), nil
|
||||
return newKeyValueNode(parts[0], parts[1], ""), nil
|
||||
}
|
||||
|
||||
var rootNode *Node
|
||||
@ -165,17 +165,20 @@ func parseNameVal(rest string, key string, d *directives) (*Node, error) {
|
||||
}
|
||||
|
||||
parts := strings.SplitN(word, "=", 2)
|
||||
node := newKeyValueNode(parts[0], parts[1])
|
||||
node := newKeyValueNode(parts[0], parts[1], "=")
|
||||
rootNode, prevNode = appendKeyValueNode(node, rootNode, prevNode)
|
||||
}
|
||||
|
||||
return rootNode, nil
|
||||
}
|
||||
|
||||
func newKeyValueNode(key, value string) *Node {
|
||||
func newKeyValueNode(key, value, sep string) *Node {
|
||||
return &Node{
|
||||
Value: key,
|
||||
Next: &Node{Value: value},
|
||||
Next: &Node{
|
||||
Value: value,
|
||||
Next: &Node{Value: sep},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@ -187,7 +190,9 @@ func appendKeyValueNode(node, rootNode, prevNode *Node) (*Node, *Node) {
|
||||
prevNode.Next = node
|
||||
}
|
||||
|
||||
prevNode = node.Next
|
||||
for prevNode = node.Next; prevNode.Next != nil; {
|
||||
prevNode = prevNode.Next
|
||||
}
|
||||
return rootNode, prevNode
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user