Skip to content

Commit 36d84ae

Browse files
author
qiankunli
committed
feat: supprot disable deepcopy on list funcion
Signed-off-by: qiankunli <[email protected]>
1 parent d991225 commit 36d84ae

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

pkg/cache/internal/cache_reader.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ func (c *CacheReader) List(_ context.Context, out client.ObjectList, opts ...cli
161161
}
162162

163163
var outObj runtime.Object
164-
if c.disableDeepCopy {
164+
if c.disableDeepCopy || listOpts.DisableDeepCopy {
165165
// skip deep copy which might be unsafe
166166
// you must DeepCopy any object before mutating it outside
167167
outObj = obj

pkg/client/options.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,11 @@ type ListOptions struct {
417417
// it has expired. This field is not supported if watch is true in the Raw ListOptions.
418418
Continue string
419419

420+
// disableDeepCopy indicates not to deep copy objects during list objects.
421+
// Be very careful with this, when enabled you must DeepCopy any object before mutating it,
422+
// otherwise you will mutate the object in the cache.
423+
DisableDeepCopy bool
424+
420425
// Raw represents raw ListOptions, as passed to the API server. Note
421426
// that these may not be respected by all implementations of interface,
422427
// and the LabelSelector, FieldSelector, Limit and Continue fields are ignored.

0 commit comments

Comments
 (0)