mirror of
https://github.com/mudler/luet.git
synced 2025-09-09 19:19:49 +00:00
Update gomod and vendor
This commit is contained in:
38
vendor/github.com/moby/buildkit/frontend/dockerfile/dockerfile2llb/directives.go
generated
vendored
Normal file
38
vendor/github.com/moby/buildkit/frontend/dockerfile/dockerfile2llb/directives.go
generated
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
package dockerfile2llb
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"io"
|
||||
"regexp"
|
||||
"strings"
|
||||
)
|
||||
|
||||
const keySyntax = "syntax"
|
||||
|
||||
var reDirective = regexp.MustCompile(`^#\s*([a-zA-Z][a-zA-Z0-9]*)\s*=\s*(.+?)\s*$`)
|
||||
|
||||
func DetectSyntax(r io.Reader) (string, string, bool) {
|
||||
directives := ParseDirectives(r)
|
||||
if len(directives) == 0 {
|
||||
return "", "", false
|
||||
}
|
||||
v, ok := directives[keySyntax]
|
||||
if !ok {
|
||||
return "", "", false
|
||||
}
|
||||
p := strings.SplitN(v, " ", 2)
|
||||
return p[0], v, true
|
||||
}
|
||||
|
||||
func ParseDirectives(r io.Reader) map[string]string {
|
||||
m := map[string]string{}
|
||||
s := bufio.NewScanner(r)
|
||||
for s.Scan() {
|
||||
match := reDirective.FindStringSubmatch(s.Text())
|
||||
if len(match) == 0 {
|
||||
return m
|
||||
}
|
||||
m[strings.ToLower(match[1])] = match[2]
|
||||
}
|
||||
return m
|
||||
}
|
Reference in New Issue
Block a user