chore: upgrade coredns version (#550)

This commit is contained in:
naison
2025-04-19 10:06:56 +08:00
committed by GitHub
parent c42e3475f9
commit c9f1ce6522
1701 changed files with 235209 additions and 29271 deletions

81
vendor/github.com/expr-lang/expr/file/error.go generated vendored Normal file
View File

@@ -0,0 +1,81 @@
package file
import (
"fmt"
"strings"
"unicode/utf8"
)
type Error struct {
Location
Line int `json:"line"`
Column int `json:"column"`
Message string `json:"message"`
Snippet string `json:"snippet"`
Prev error `json:"prev"`
}
func (e *Error) Error() string {
return e.format()
}
func (e *Error) Bind(source Source) *Error {
e.Line = 1
for i, r := range source {
if i == e.From {
break
}
if r == '\n' {
e.Line++
e.Column = 0
} else {
e.Column++
}
}
if snippet, found := source.Snippet(e.Line); found {
snippet := strings.Replace(snippet, "\t", " ", -1)
srcLine := "\n | " + snippet
var bytes = []byte(snippet)
var indLine = "\n | "
for i := 0; i < e.Column && len(bytes) > 0; i++ {
_, sz := utf8.DecodeRune(bytes)
bytes = bytes[sz:]
if sz > 1 {
goto noind
} else {
indLine += "."
}
}
if _, sz := utf8.DecodeRune(bytes); sz > 1 {
goto noind
} else {
indLine += "^"
}
srcLine += indLine
noind:
e.Snippet = srcLine
}
return e
}
func (e *Error) Unwrap() error {
return e.Prev
}
func (e *Error) Wrap(err error) {
e.Prev = err
}
func (e *Error) format() string {
if e.Snippet == "" {
return e.Message
}
return fmt.Sprintf(
"%s (%d:%d)%s",
e.Message,
e.Line,
e.Column+1, // add one to the 0-based column for display
e.Snippet,
)
}

6
vendor/github.com/expr-lang/expr/file/location.go generated vendored Normal file
View File

@@ -0,0 +1,6 @@
package file
type Location struct {
From int `json:"from"`
To int `json:"to"`
}

48
vendor/github.com/expr-lang/expr/file/source.go generated vendored Normal file
View File

@@ -0,0 +1,48 @@
package file
import (
"strings"
"unicode/utf8"
)
type Source []rune
func NewSource(contents string) Source {
return []rune(contents)
}
func (s Source) String() string {
return string(s)
}
func (s Source) Snippet(line int) (string, bool) {
if s == nil {
return "", false
}
lines := strings.Split(string(s), "\n")
lineOffsets := make([]int, len(lines))
var offset int
for i, line := range lines {
offset = offset + utf8.RuneCountInString(line) + 1
lineOffsets[i] = offset
}
charStart, found := getLineOffset(lineOffsets, line)
if !found || len(s) == 0 {
return "", false
}
charEnd, found := getLineOffset(lineOffsets, line+1)
if found {
return string(s[charStart : charEnd-1]), true
}
return string(s[charStart:]), true
}
func getLineOffset(lineOffsets []int, line int) (int, bool) {
if line == 1 {
return 0, true
} else if line > 1 && line <= len(lineOffsets) {
offset := lineOffsets[line-2]
return offset, true
}
return -1, false
}