mirror of
https://github.com/ceph/ceph-csi.git
synced 2025-06-13 10:33:35 +00:00
rebase: Bump sigs.k8s.io/controller-runtime from 0.14.4 to 0.14.6
Bumps [sigs.k8s.io/controller-runtime](https://github.com/kubernetes-sigs/controller-runtime) from 0.14.4 to 0.14.6. - [Release notes](https://github.com/kubernetes-sigs/controller-runtime/releases) - [Changelog](https://github.com/kubernetes-sigs/controller-runtime/blob/main/RELEASE.md) - [Commits](https://github.com/kubernetes-sigs/controller-runtime/compare/v0.14.4...v0.14.6) --- updated-dependencies: - dependency-name: sigs.k8s.io/controller-runtime dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com>
This commit is contained in:
committed by
mergify[bot]
parent
d8e6c37743
commit
08f32b8cf2
40
vendor/sigs.k8s.io/controller-runtime/pkg/client/apiutil/apimachinery.go
generated
vendored
40
vendor/sigs.k8s.io/controller-runtime/pkg/client/apiutil/apimachinery.go
generated
vendored
@ -95,6 +95,7 @@ func GVKForObject(obj runtime.Object, scheme *runtime.Scheme) (schema.GroupVersi
|
||||
return gvk, nil
|
||||
}
|
||||
|
||||
// Use the given scheme to retrieve all the GVKs for the object.
|
||||
gvks, isUnversioned, err := scheme.ObjectKinds(obj)
|
||||
if err != nil {
|
||||
return schema.GroupVersionKind{}, err
|
||||
@ -103,16 +104,39 @@ func GVKForObject(obj runtime.Object, scheme *runtime.Scheme) (schema.GroupVersi
|
||||
return schema.GroupVersionKind{}, fmt.Errorf("cannot create group-version-kind for unversioned type %T", obj)
|
||||
}
|
||||
|
||||
if len(gvks) < 1 {
|
||||
return schema.GroupVersionKind{}, fmt.Errorf("no group-version-kinds associated with type %T", obj)
|
||||
}
|
||||
if len(gvks) > 1 {
|
||||
// this should only trigger for things like metav1.XYZ --
|
||||
// normal versioned types should be fine
|
||||
switch {
|
||||
case len(gvks) < 1:
|
||||
// If the object has no GVK, the object might not have been registered with the scheme.
|
||||
// or it's not a valid object.
|
||||
return schema.GroupVersionKind{}, fmt.Errorf("no GroupVersionKind associated with Go type %T, was the type registered with the Scheme?", obj)
|
||||
case len(gvks) > 1:
|
||||
err := fmt.Errorf("multiple GroupVersionKinds associated with Go type %T within the Scheme, this can happen when a type is registered for multiple GVKs at the same time", obj)
|
||||
|
||||
// We've found multiple GVKs for the object.
|
||||
currentGVK := obj.GetObjectKind().GroupVersionKind()
|
||||
if !currentGVK.Empty() {
|
||||
// If the base object has a GVK, check if it's in the list of GVKs before using it.
|
||||
for _, gvk := range gvks {
|
||||
if gvk == currentGVK {
|
||||
return gvk, nil
|
||||
}
|
||||
}
|
||||
|
||||
return schema.GroupVersionKind{}, fmt.Errorf(
|
||||
"%w: the object's supplied GroupVersionKind %q was not found in the Scheme's list; refusing to guess at one: %q", err, currentGVK, gvks)
|
||||
}
|
||||
|
||||
// This should only trigger for things like metav1.XYZ --
|
||||
// normal versioned types should be fine.
|
||||
//
|
||||
// See https://github.com/kubernetes-sigs/controller-runtime/issues/362
|
||||
// for more information.
|
||||
return schema.GroupVersionKind{}, fmt.Errorf(
|
||||
"multiple group-version-kinds associated with type %T, refusing to guess at one", obj)
|
||||
"%w: callers can either fix their type registration to only register it once, or specify the GroupVersionKind to use for object passed in; refusing to guess at one: %q", err, gvks)
|
||||
default:
|
||||
// In any other case, we've found a single GVK for the object.
|
||||
return gvks[0], nil
|
||||
}
|
||||
return gvks[0], nil
|
||||
}
|
||||
|
||||
// RESTClientForGVK constructs a new rest.Interface capable of accessing the resource associated
|
||||
|
68
vendor/sigs.k8s.io/controller-runtime/pkg/client/apiutil/lazyrestmapper.go
generated
vendored
68
vendor/sigs.k8s.io/controller-runtime/pkg/client/apiutil/lazyrestmapper.go
generated
vendored
@ -33,7 +33,7 @@ type lazyRESTMapper struct {
|
||||
mapper meta.RESTMapper
|
||||
client *discovery.DiscoveryClient
|
||||
knownGroups map[string]*restmapper.APIGroupResources
|
||||
apiGroups *metav1.APIGroupList
|
||||
apiGroups []metav1.APIGroup
|
||||
|
||||
// mutex to provide thread-safe mapper reloading.
|
||||
mu sync.Mutex
|
||||
@ -45,6 +45,7 @@ func newLazyRESTMapperWithClient(discoveryClient *discovery.DiscoveryClient) (me
|
||||
mapper: restmapper.NewDiscoveryRESTMapper([]*restmapper.APIGroupResources{}),
|
||||
client: discoveryClient,
|
||||
knownGroups: map[string]*restmapper.APIGroupResources{},
|
||||
apiGroups: []metav1.APIGroup{},
|
||||
}, nil
|
||||
}
|
||||
|
||||
@ -147,7 +148,7 @@ func (m *lazyRESTMapper) addKnownGroupAndReload(groupName string, versions ...st
|
||||
// This operation requires 2 requests: /api and /apis, but only once. For all subsequent calls
|
||||
// this data will be taken from cache.
|
||||
if len(versions) == 0 {
|
||||
apiGroup, err := m.findAPIGroupByName(groupName)
|
||||
apiGroup, err := m.findAPIGroupByNameLocked(groupName)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -176,11 +177,22 @@ func (m *lazyRESTMapper) addKnownGroupAndReload(groupName string, versions ...st
|
||||
}
|
||||
|
||||
// Update information for group resources about the API group by adding new versions.
|
||||
// Ignore the versions that are already registered.
|
||||
for _, version := range versions {
|
||||
groupResources.Group.Versions = append(groupResources.Group.Versions, metav1.GroupVersionForDiscovery{
|
||||
GroupVersion: metav1.GroupVersion{Group: groupName, Version: version}.String(),
|
||||
Version: version,
|
||||
})
|
||||
found := false
|
||||
for _, v := range groupResources.Group.Versions {
|
||||
if v.Version == version {
|
||||
found = true
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if !found {
|
||||
groupResources.Group.Versions = append(groupResources.Group.Versions, metav1.GroupVersionForDiscovery{
|
||||
GroupVersion: metav1.GroupVersion{Group: groupName, Version: version}.String(),
|
||||
Version: version,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// Update data in the cache.
|
||||
@ -197,28 +209,34 @@ func (m *lazyRESTMapper) addKnownGroupAndReload(groupName string, versions ...st
|
||||
return nil
|
||||
}
|
||||
|
||||
// findAPIGroupByName returns API group by its name.
|
||||
func (m *lazyRESTMapper) findAPIGroupByName(groupName string) (metav1.APIGroup, error) {
|
||||
// Ensure that required info about existing API groups is received and stored in the mapper.
|
||||
// It will make 2 API calls to /api and /apis, but only once.
|
||||
if m.apiGroups == nil {
|
||||
apiGroups, err := m.client.ServerGroups()
|
||||
if err != nil {
|
||||
return metav1.APIGroup{}, fmt.Errorf("failed to get server groups: %w", err)
|
||||
}
|
||||
if len(apiGroups.Groups) == 0 {
|
||||
return metav1.APIGroup{}, fmt.Errorf("received an empty API groups list")
|
||||
}
|
||||
|
||||
m.apiGroups = apiGroups
|
||||
}
|
||||
|
||||
for i := range m.apiGroups.Groups {
|
||||
if groupName == (&m.apiGroups.Groups[i]).Name {
|
||||
return m.apiGroups.Groups[i], nil
|
||||
// findAPIGroupByNameLocked returns API group by its name.
|
||||
func (m *lazyRESTMapper) findAPIGroupByNameLocked(groupName string) (metav1.APIGroup, error) {
|
||||
// Looking in the cache first.
|
||||
for _, apiGroup := range m.apiGroups {
|
||||
if groupName == apiGroup.Name {
|
||||
return apiGroup, nil
|
||||
}
|
||||
}
|
||||
|
||||
// Update the cache if nothing was found.
|
||||
apiGroups, err := m.client.ServerGroups()
|
||||
if err != nil {
|
||||
return metav1.APIGroup{}, fmt.Errorf("failed to get server groups: %w", err)
|
||||
}
|
||||
if len(apiGroups.Groups) == 0 {
|
||||
return metav1.APIGroup{}, fmt.Errorf("received an empty API groups list")
|
||||
}
|
||||
|
||||
m.apiGroups = apiGroups.Groups
|
||||
|
||||
// Looking in the cache again.
|
||||
for _, apiGroup := range m.apiGroups {
|
||||
if groupName == apiGroup.Name {
|
||||
return apiGroup, nil
|
||||
}
|
||||
}
|
||||
|
||||
// If there is still nothing, return an error.
|
||||
return metav1.APIGroup{}, fmt.Errorf("failed to find API group %s", groupName)
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user