mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 03:41:45 +00:00
REST: Document mutable inputs on Create()
If one doesn't DeepCopy() on the way into Create, we can end up writing into the original object. This is by design, and should not be a problem EXCEPT for tests. If a test compares the input to this function with the result, but the input was mutated in-situ, it may hide errors, resulting in tests that pass, but shouldn't.
This commit is contained in:
parent
42c7e62180
commit
6dfae64d9b
@ -360,6 +360,9 @@ func (e *Store) ListPredicate(ctx context.Context, p storage.SelectionPredicate,
|
||||
func finishNothing(context.Context, bool) {}
|
||||
|
||||
// Create inserts a new item according to the unique key from the object.
|
||||
// Note that registries may mutate the input object (e.g. in the strategy
|
||||
// hooks). Tests which call this might want to call DeepCopy if they expect to
|
||||
// be able to examine the input and output objects for differences.
|
||||
func (e *Store) Create(ctx context.Context, obj runtime.Object, createValidation rest.ValidateObjectFunc, options *metav1.CreateOptions) (runtime.Object, error) {
|
||||
var finishCreate FinishFunc = finishNothing
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user