mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-24 20:24:09 +00:00
Allow ObjectReferences to be passed to Eventf
... in place of the object they reference.
This commit is contained in:
parent
f4cffdc7cf
commit
ecebe958d2
@ -36,6 +36,10 @@ func GetReference(obj runtime.Object) (*ObjectReference, error) {
|
||||
if obj == nil {
|
||||
return nil, ErrNilObject
|
||||
}
|
||||
if ref, ok := obj.(*ObjectReference); ok {
|
||||
// Don't make a reference to a reference.
|
||||
return ref, nil
|
||||
}
|
||||
meta, err := meta.Accessor(obj)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -57,3 +61,7 @@ func GetReference(obj runtime.Object) (*ObjectReference, error) {
|
||||
ResourceVersion: meta.ResourceVersion(),
|
||||
}, nil
|
||||
}
|
||||
|
||||
// Allow clients to preemptively get a reference to an API object and pass it to places that
|
||||
// intend only to get a reference to that object. This simplifies the event recording interface.
|
||||
func (*ObjectReference) IsAnAPIObject() {}
|
||||
|
Loading…
Reference in New Issue
Block a user