mirror of
https://github.com/projectcapsule/capsule.git
synced 2026-02-14 09:59:57 +00:00
* chore(deps): update dependency golangci/golangci-lint to v2.8.0 * chore(deps): update dependency golangci/golangci-lint to v2.8.0 Signed-off-by: Hristo Hristov <me@hhristov.info> * chore(deps): update dependency golangci/golangci-lint to v2.8.0 Signed-off-by: Hristo Hristov <me@hhristov.info> * chore(deps): update dependency golangci/golangci-lint to v2.8.0 Signed-off-by: Hristo Hristov <me@hhristov.info> --------- Signed-off-by: Hristo Hristov <me@hhristov.info> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Hristo Hristov <me@hhristov.info>
42 lines
814 B
Go
42 lines
814 B
Go
// Copyright 2020-2026 Project Capsule Authors
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
package v1beta1
|
|
|
|
import (
|
|
"sort"
|
|
)
|
|
|
|
type OwnerListSpec []OwnerSpec
|
|
|
|
func (in OwnerListSpec) FindOwner(name string, kind OwnerKind) (owner OwnerSpec) {
|
|
sort.Sort(ByKindAndName(in))
|
|
i := sort.Search(len(in), func(i int) bool {
|
|
return in[i].Kind >= kind && in[i].Name >= name
|
|
})
|
|
|
|
if i < len(in) && in[i].Kind == kind && in[i].Name == name {
|
|
return in[i]
|
|
}
|
|
|
|
return owner
|
|
}
|
|
|
|
type ByKindAndName OwnerListSpec
|
|
|
|
func (in ByKindAndName) Len() int {
|
|
return len(in)
|
|
}
|
|
|
|
func (in ByKindAndName) Less(i, j int) bool {
|
|
if in[i].Kind.String() != in[j].Kind.String() {
|
|
return in[i].Kind.String() < in[j].Kind.String()
|
|
}
|
|
|
|
return in[i].Name < in[j].Name
|
|
}
|
|
|
|
func (in ByKindAndName) Swap(i, j int) {
|
|
in[i], in[j] = in[j], in[i]
|
|
}
|