mirror of
https://github.com/ceph/ceph-csi.git
synced 2025-06-14 18:53:35 +00:00
rebase: update controller-runtime package to v0.9.2
This commit updates controller-runtime to v0.9.2 and makes changes in persistentvolume.go to add context to various functions and function calls made here instead of context.TODO(). Signed-off-by: Rakshith R <rar@redhat.com>
This commit is contained in:
go.modgo.summodules.txt
internal/controller/persistentvolume
vendor
github.com
evanphx
json-patch
google
go-cmp
googleapis
gnostic
compiler
extensions
jsonschema
openapiv2
hashicorp
golang-lru
imdario
json-iterator
prometheus
golang.org
x
time
rate
gomodules.xyz
jsonpatch
google.golang.org
appengine
internal
protobuf
encoding
internal
descfmt
detrand
encoding
fieldsort
filedesc
impl
api_export.gocodec_field.gocodec_gen.gocodec_map.gocodec_message.gocodec_messageset.gocodec_reflect.goconvert.godecode.goencode.golegacy_export.golegacy_extension.golegacy_message.gomerge.gomessage.gomessage_reflect.gomessage_reflect_field.gopointer_reflect.gopointer_unsafe.go
mapsort
order
version
proto
reflect
protodesc
protoreflect
protoregistry
types
descriptorpb
known
gopkg.in
fsnotify.v1
.editorconfig.gitignore.travis.ymlAUTHORSCHANGELOG.mdCONTRIBUTING.mdLICENSEREADME.mdfen.gofsnotify.goinotify.goinotify_poller.gokqueue.goopen_mode_bsd.goopen_mode_darwin.gowindows.go
yaml.v3
k8s.io
client-go
metadata
component-base
config
utils
sigs.k8s.io
controller-runtime
pkg
cache
certwatcher
client
apiutil
client.goclient_cache.gocodec.goconfig
dryrun.gointerfaces.gometadata_client.gonamespaced_client.goobject.gooptions.gopatch.gosplit.gotyped_client.gounstructured_client.gowatch.gocluster
config
controller
event
handler
healthz
internal
leaderelection
log
manager
metrics
predicate
reconcile
runtime
inject
scheme
source
webhook
78
vendor/sigs.k8s.io/controller-runtime/pkg/internal/objectutil/objectutil.go
generated
vendored
Normal file
78
vendor/sigs.k8s.io/controller-runtime/pkg/internal/objectutil/objectutil.go
generated
vendored
Normal file
@ -0,0 +1,78 @@
|
||||
/*
|
||||
Copyright 2018 The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package objectutil
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
apimeta "k8s.io/apimachinery/pkg/api/meta"
|
||||
"k8s.io/apimachinery/pkg/labels"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
"sigs.k8s.io/controller-runtime/pkg/client/apiutil"
|
||||
)
|
||||
|
||||
// FilterWithLabels returns a copy of the items in objs matching labelSel.
|
||||
func FilterWithLabels(objs []runtime.Object, labelSel labels.Selector) ([]runtime.Object, error) {
|
||||
outItems := make([]runtime.Object, 0, len(objs))
|
||||
for _, obj := range objs {
|
||||
meta, err := apimeta.Accessor(obj)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if labelSel != nil {
|
||||
lbls := labels.Set(meta.GetLabels())
|
||||
if !labelSel.Matches(lbls) {
|
||||
continue
|
||||
}
|
||||
}
|
||||
outItems = append(outItems, obj.DeepCopyObject())
|
||||
}
|
||||
return outItems, nil
|
||||
}
|
||||
|
||||
// IsAPINamespaced returns true if the object is namespace scoped.
|
||||
// For unstructured objects the gvk is found from the object itself.
|
||||
func IsAPINamespaced(obj runtime.Object, scheme *runtime.Scheme, restmapper apimeta.RESTMapper) (bool, error) {
|
||||
gvk, err := apiutil.GVKForObject(obj, scheme)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
return IsAPINamespacedWithGVK(gvk, scheme, restmapper)
|
||||
}
|
||||
|
||||
// IsAPINamespacedWithGVK returns true if the object having the provided
|
||||
// GVK is namespace scoped.
|
||||
func IsAPINamespacedWithGVK(gk schema.GroupVersionKind, scheme *runtime.Scheme, restmapper apimeta.RESTMapper) (bool, error) {
|
||||
restmapping, err := restmapper.RESTMapping(schema.GroupKind{Group: gk.Group, Kind: gk.Kind})
|
||||
if err != nil {
|
||||
return false, fmt.Errorf("failed to get restmapping: %w", err)
|
||||
}
|
||||
|
||||
scope := restmapping.Scope.Name()
|
||||
|
||||
if scope == "" {
|
||||
return false, errors.New("scope cannot be identified, empty scope returned")
|
||||
}
|
||||
|
||||
if scope != apimeta.RESTScopeNameRoot {
|
||||
return true, nil
|
||||
}
|
||||
return false, nil
|
||||
}
|
Reference in New Issue
Block a user