mirror of
https://github.com/kubernetes-sigs/prometheus-adapter.git
synced 2026-04-07 10:17:51 +00:00
vendor: Update vendor logic
This commit is contained in:
parent
c6ac5cbc87
commit
4ca64b85f0
1540 changed files with 265304 additions and 91616 deletions
38
vendor/sigs.k8s.io/structured-merge-diff/fieldpath/path.go
generated
vendored
38
vendor/sigs.k8s.io/structured-merge-diff/fieldpath/path.go
generated
vendored
|
|
@ -35,6 +35,40 @@ func (fp Path) String() string {
|
|||
return strings.Join(strs, "")
|
||||
}
|
||||
|
||||
// Equals returns true if the two paths are equivalent.
|
||||
func (fp Path) Equals(fp2 Path) bool {
|
||||
return !fp.Less(fp2) && !fp2.Less(fp)
|
||||
}
|
||||
|
||||
// Less provides a lexical order for Paths.
|
||||
func (fp Path) Less(rhs Path) bool {
|
||||
i := 0
|
||||
for {
|
||||
if i >= len(fp) && i >= len(rhs) {
|
||||
// Paths are the same length and all items are equal.
|
||||
return false
|
||||
}
|
||||
if i >= len(fp) {
|
||||
// LHS is shorter.
|
||||
return true
|
||||
}
|
||||
if i >= len(rhs) {
|
||||
// RHS is shorter.
|
||||
return false
|
||||
}
|
||||
if fp[i].Less(rhs[i]) {
|
||||
// LHS is less; return
|
||||
return true
|
||||
}
|
||||
if rhs[i].Less(fp[i]) {
|
||||
// RHS is less; return
|
||||
return false
|
||||
}
|
||||
// The items are equal; continue.
|
||||
i++
|
||||
}
|
||||
}
|
||||
|
||||
func (fp Path) Copy() Path {
|
||||
new := make(Path, len(fp))
|
||||
copy(new, fp)
|
||||
|
|
@ -54,8 +88,8 @@ func MakePath(parts ...interface{}) (Path, error) {
|
|||
fp = append(fp, PathElement{Index: &t})
|
||||
case string:
|
||||
fp = append(fp, PathElement{FieldName: &t})
|
||||
case []value.Field:
|
||||
if len(t) == 0 {
|
||||
case *value.FieldList:
|
||||
if len(*t) == 0 {
|
||||
return nil, fmt.Errorf("associative list key type path elements must have at least one key (got zero)")
|
||||
}
|
||||
fp = append(fp, PathElement{Key: t})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue