mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-07-10 13:37:08 +08:00
update github.com/compose-spec/compose-go to v1.0.8
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
10
vendor/github.com/compose-spec/godotenv/godotenv.go
generated
vendored
10
vendor/github.com/compose-spec/godotenv/godotenv.go
generated
vendored
@ -266,12 +266,12 @@ func parseLineWithLookup(line string, envMap map[string]string, lookupFn LookupF
|
||||
firstColon := strings.Index(line, ":")
|
||||
splitString := strings.SplitN(line, "=", 2)
|
||||
if firstColon != -1 && (firstColon < firstEquals || firstEquals == -1) {
|
||||
//this is a yaml-style line
|
||||
// This is a yaml-style line
|
||||
splitString = strings.SplitN(line, ":", 2)
|
||||
}
|
||||
|
||||
if len(splitString) != 2 {
|
||||
err = errors.New("Can't separate key from value")
|
||||
err = errors.New("can't separate key from value")
|
||||
return
|
||||
}
|
||||
key = exportRegex.ReplaceAllString(splitString[0], "$1")
|
||||
@ -341,15 +341,15 @@ func expandVariables(v string, envMap map[string]string, lookupFn LookupFn) stri
|
||||
if submatch[1] == "\\" || submatch[2] == "(" {
|
||||
return submatch[0][1:]
|
||||
} else if submatch[4] != "" {
|
||||
//first check if we have defined this already earlier
|
||||
// first check if we have defined this already earlier
|
||||
if envMap[submatch[4]] != "" {
|
||||
return envMap[submatch[4]]
|
||||
}
|
||||
if lookupFn == nil {
|
||||
return ""
|
||||
}
|
||||
//if we have not defined it, check the lookup function provided
|
||||
//by the user
|
||||
// if we have not defined it, check the lookup function provided
|
||||
// by the user
|
||||
s2, ok := lookupFn(submatch[4])
|
||||
if ok {
|
||||
return s2
|
||||
|
28
vendor/github.com/compose-spec/godotenv/parser.go
generated
vendored
28
vendor/github.com/compose-spec/godotenv/parser.go
generated
vendored
@ -127,15 +127,21 @@ loop:
|
||||
|
||||
// extractVarValue extracts variable value and returns rest of slice
|
||||
func extractVarValue(src []byte, envMap map[string]string, lookupFn LookupFn) (value string, rest []byte, err error) {
|
||||
quote, hasPrefix := hasQuotePrefix(src)
|
||||
if !hasPrefix {
|
||||
// unquoted value - read until whitespace
|
||||
end := bytes.IndexFunc(src, unicode.IsSpace)
|
||||
if end == -1 {
|
||||
return expandVariables(string(src), envMap, lookupFn), nil, nil
|
||||
quote, isQuoted := hasQuotePrefix(src)
|
||||
if !isQuoted {
|
||||
// unquoted value - read until new line
|
||||
end := bytes.IndexFunc(src, isNewLine)
|
||||
var rest []byte
|
||||
var value string
|
||||
if end < 0 {
|
||||
value := strings.TrimRightFunc(string(src), unicode.IsSpace)
|
||||
rest = nil
|
||||
return expandVariables(value, envMap, lookupFn), rest, nil
|
||||
}
|
||||
|
||||
return expandVariables(string(src[0:end]), envMap, lookupFn), src[end:], nil
|
||||
value = strings.TrimRightFunc(string(src[0:end]), unicode.IsSpace)
|
||||
rest = src[end:]
|
||||
return expandVariables(value, envMap, lookupFn), rest, nil
|
||||
}
|
||||
|
||||
// lookup quoted string terminator
|
||||
@ -192,7 +198,7 @@ func indexOfNonSpaceChar(src []byte) int {
|
||||
}
|
||||
|
||||
// hasQuotePrefix reports whether charset starts with single or double quote and returns quote character
|
||||
func hasQuotePrefix(src []byte) (prefix byte, isQuored bool) {
|
||||
func hasQuotePrefix(src []byte) (quote byte, isQuoted bool) {
|
||||
if len(src) == 0 {
|
||||
return 0, false
|
||||
}
|
||||
@ -221,3 +227,9 @@ func isSpace(r rune) bool {
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
// isNewLine reports whether the rune is a new line character
|
||||
func isNewLine(r rune) bool {
|
||||
return r == '\n'
|
||||
}
|
||||
|
Reference in New Issue
Block a user