Repository navigation
fix(kube): use non global Scheme to convert - #7401
Merged
Merged
Conversation
hiddeco
commented
Jan 14, 2020
thomastaylor312
suggested changes
Feb 11, 2020
thomastaylor312
left a comment
Contributor
There was a problem hiding this comment.
Good fix on this. Just one point of feedback around constructing the scheme
| // combination with e.g. a versioned kube client. If we would not do this, the client | ||
| // may attempt to perform e.g. a 3-way-merge strategy patch for custom resources. | ||
| func kubernetesNativeScheme() *runtime.Scheme { | ||
| s := runtime.NewScheme() |
Contributor
There was a problem hiding this comment.
We should probably use sync.Once to set this up and then only generate it once instead of every time. convertWithMapper is used a lot (basically for every resource), so it might be good to do this once. It could be stored in a non-exported global variable local to this package
hiddeco
force-pushed
the
non-global-scheme-convert
branch
from
February 11, 2020 23:23
7c2c346 to
3a7132b
Compare
But instead use a newly initialized Scheme with only Kubernetes native resources added. This ensures the 3-way-merge patch strategy is not accidentally chosen for custom resources due to them being added to the global Scheme by e.g. versioned clients while using Helm as a package, and not a self-contained binary. Signed-off-by: Hidde Beydals <[email protected]>
Signed-off-by: Hidde Beydals <[email protected]>
hiddeco
force-pushed
the
non-global-scheme-convert
branch
from
February 12, 2020 00:43
3a7132b to
e41184a
Compare
thomastaylor312
approved these changes
Feb 18, 2020
thomastaylor312
left a comment
Contributor
There was a problem hiding this comment.
LGTM. Thanks for this fix!
1 of 2 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
But instead use a newly initialized Scheme with only Kubernetes native
resources added. This ensures the 3-way-merge patch strategy is not
accidentally chosen for custom resources due to them being added
to the global Scheme by e.g. versioned clients while using Helm as a
package, and not a self-contained binary.
Signed-off-by: Hidde Beydals [email protected]
Closes #7400