@@ -54,7 +54,10 @@ type CacheReader struct {
54
54
}
55
55
56
56
// Get checks the indexer for the object and writes a copy of it if found.
57
- func (c * CacheReader ) Get (_ context.Context , key client.ObjectKey , out client.Object , _ ... client.GetOption ) error {
57
+ func (c * CacheReader ) Get (_ context.Context , key client.ObjectKey , out client.Object , opts ... client.GetOption ) error {
58
+ getOpts := client.GetOptions {}
59
+ getOpts .ApplyOptions (opts )
60
+
58
61
if c .scopeName == apimeta .RESTScopeNameRoot {
59
62
key .Namespace = ""
60
63
}
@@ -81,7 +84,7 @@ func (c *CacheReader) Get(_ context.Context, key client.ObjectKey, out client.Ob
81
84
return fmt .Errorf ("cache contained %T, which is not an Object" , obj )
82
85
}
83
86
84
- if c .disableDeepCopy {
87
+ if c .disableDeepCopy || ( getOpts . UnsafeDisableDeepCopy != nil && * getOpts . UnsafeDisableDeepCopy ) {
85
88
// skip deep copy which might be unsafe
86
89
// you must DeepCopy any object before mutating it outside
87
90
} else {
@@ -97,7 +100,7 @@ func (c *CacheReader) Get(_ context.Context, key client.ObjectKey, out client.Ob
97
100
return fmt .Errorf ("cache had type %s, but %s was asked for" , objVal .Type (), outVal .Type ())
98
101
}
99
102
reflect .Indirect (outVal ).Set (reflect .Indirect (objVal ))
100
- if ! c .disableDeepCopy {
103
+ if ! c .disableDeepCopy && ( getOpts . UnsafeDisableDeepCopy == nil || ! * getOpts . UnsafeDisableDeepCopy ) {
101
104
out .GetObjectKind ().SetGroupVersionKind (c .groupVersionKind )
102
105
}
103
106
0 commit comments