-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Deep copy by default #19
Conversation
The options passed to `NewObjectCache` were not actually being copied into the returned object cache. Signed-off-by: Justin Kulikauskas <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor comment on description wording
Not DeepCopying can save some resources in some situations, but is also a common way to introduce hard-to-find bugs, since items in the cache can then mutate unexpectedly. This library now follows the pattern from controller-runtime, which does a DeepCopy by default, which can be disabled with an option when creating the client. Signed-off-by: Justin Kulikauskas <[email protected]>
dfc2b14
to
2d95c84
Compare
Quality Gate passedIssues Measures |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
@@ -87,6 +90,7 @@ func NewObjectCache(discoveryClient *discovery.DiscoveryClient, options ObjectCa | |||
cache: &sync.Map{}, | |||
gvkToGVRCache: &sync.Map{}, | |||
discoveryClient: discoveryClient, | |||
options: options, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question: Was this just missed (or unnecessary) previously?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it was just missed. The other options aren't tested (and I think that's ok; they'd be annoying to test for a low payoff).
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: dhaiducek, JustinKuli The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Not DeepCopying can save some resources in some situations, but is also a common way to introduce hard-to-find bugs, since items in the cache can then mutate unexpectedly. This library now follows the pattern from controller-runtime, which does a DeepCopy by default, which can be disabled with an option when creating the client.