mirror of
https://github.com/ceph/ceph-csi.git
synced 2025-06-13 18:43:34 +00:00
rebase: update k8s.io packages to v0.29.0
Signed-off-by: Niels de Vos <ndevos@ibm.com>
This commit is contained in:
committed by
mergify[bot]
parent
328a264202
commit
f080b9e0c9
34
vendor/k8s.io/client-go/restmapper/shortcut.go
generated
vendored
34
vendor/k8s.io/client-go/restmapper/shortcut.go
generated
vendored
@ -17,6 +17,7 @@ limitations under the License.
|
||||
package restmapper
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"k8s.io/klog/v2"
|
||||
@ -32,13 +33,15 @@ type shortcutExpander struct {
|
||||
RESTMapper meta.RESTMapper
|
||||
|
||||
discoveryClient discovery.DiscoveryInterface
|
||||
|
||||
warningHandler func(string)
|
||||
}
|
||||
|
||||
var _ meta.ResettableRESTMapper = shortcutExpander{}
|
||||
|
||||
// NewShortcutExpander wraps a restmapper in a layer that expands shortcuts found via discovery
|
||||
func NewShortcutExpander(delegate meta.RESTMapper, client discovery.DiscoveryInterface) meta.RESTMapper {
|
||||
return shortcutExpander{RESTMapper: delegate, discoveryClient: client}
|
||||
func NewShortcutExpander(delegate meta.RESTMapper, client discovery.DiscoveryInterface, warningHandler func(string)) meta.RESTMapper {
|
||||
return shortcutExpander{RESTMapper: delegate, discoveryClient: client, warningHandler: warningHandler}
|
||||
}
|
||||
|
||||
// KindFor fulfills meta.RESTMapper
|
||||
@ -145,16 +148,37 @@ func (e shortcutExpander) expandResourceShortcut(resource schema.GroupVersionRes
|
||||
}
|
||||
}
|
||||
|
||||
found := false
|
||||
var rsc schema.GroupVersionResource
|
||||
warnedAmbiguousShortcut := make(map[schema.GroupResource]bool)
|
||||
for _, item := range shortcutResources {
|
||||
if len(resource.Group) != 0 && resource.Group != item.ShortForm.Group {
|
||||
continue
|
||||
}
|
||||
if resource.Resource == item.ShortForm.Resource {
|
||||
resource.Resource = item.LongForm.Resource
|
||||
resource.Group = item.LongForm.Group
|
||||
return resource
|
||||
if found {
|
||||
if item.LongForm.Group == rsc.Group && item.LongForm.Resource == rsc.Resource {
|
||||
// It is common and acceptable that group/resource has multiple
|
||||
// versions registered in cluster. This does not introduce ambiguity
|
||||
// in terms of shortname usage.
|
||||
continue
|
||||
}
|
||||
if !warnedAmbiguousShortcut[item.LongForm] {
|
||||
if e.warningHandler != nil {
|
||||
e.warningHandler(fmt.Sprintf("short name %q could also match lower priority resource %s", resource.Resource, item.LongForm.String()))
|
||||
}
|
||||
warnedAmbiguousShortcut[item.LongForm] = true
|
||||
}
|
||||
continue
|
||||
}
|
||||
rsc.Resource = item.LongForm.Resource
|
||||
rsc.Group = item.LongForm.Group
|
||||
found = true
|
||||
}
|
||||
}
|
||||
if found {
|
||||
return rsc
|
||||
}
|
||||
|
||||
// we didn't find exact match so match on group prefixing. This allows autoscal to match autoscaling
|
||||
if len(resource.Group) == 0 {
|
||||
|
Reference in New Issue
Block a user