diff --git a/go.mod b/go.mod index 974db2419..2909c72db 100644 --- a/go.mod +++ b/go.mod @@ -44,8 +44,8 @@ require ( google.golang.org/grpc v1.38.0 gopkg.in/natefinch/lumberjack.v2 v2.0.0 gopkg.in/square/go-jose.v2 v2.2.2 - k8s.io/api v0.0.0-20210820160405-5403b8c7f696 - k8s.io/apimachinery v0.0.0-20210820200223-19d98351410f + k8s.io/api v0.0.0-20210823160431-2e3872a4612f + k8s.io/apimachinery v0.0.0-20210823160225-43d8bfe8f725 k8s.io/client-go v0.0.0-20210820200723-590eaed90a85 k8s.io/component-base v0.0.0-20210820041117-a191e9fae528 k8s.io/klog/v2 v2.9.0 @@ -57,8 +57,8 @@ require ( ) replace ( - k8s.io/api => k8s.io/api v0.0.0-20210820160405-5403b8c7f696 - k8s.io/apimachinery => k8s.io/apimachinery v0.0.0-20210820200223-19d98351410f + k8s.io/api => k8s.io/api v0.0.0-20210823160431-2e3872a4612f + k8s.io/apimachinery => k8s.io/apimachinery v0.0.0-20210823160225-43d8bfe8f725 k8s.io/client-go => k8s.io/client-go v0.0.0-20210820200723-590eaed90a85 k8s.io/component-base => k8s.io/component-base v0.0.0-20210820041117-a191e9fae528 ) diff --git a/go.sum b/go.sum index 39d874fca..df22abd5f 100644 --- a/go.sum +++ b/go.sum @@ -932,10 +932,10 @@ honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWh honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= -k8s.io/api v0.0.0-20210820160405-5403b8c7f696 h1:VeDLDi3k0cH4LwrHrza1S5RfNTS5Ke9a4cjDxwl0tes= -k8s.io/api v0.0.0-20210820160405-5403b8c7f696/go.mod h1:4L/pB8yzulD3folKSl90IBVQTkp2WH+Lc5oN9GGFyOg= -k8s.io/apimachinery v0.0.0-20210820200223-19d98351410f h1:/jTdlnzadZ/keFPHUc/agLHDhPCDBHYsl7Yj2tUDM4g= -k8s.io/apimachinery v0.0.0-20210820200223-19d98351410f/go.mod h1:9bsqX1kl7oIEzpNzAVhpZQ9E/AcXq62F+TCC81jicxo= +k8s.io/api v0.0.0-20210823160431-2e3872a4612f h1:2yD9i6wR5BmlzqVamiBG56pgB96NWEKI374nJoThCao= +k8s.io/api v0.0.0-20210823160431-2e3872a4612f/go.mod h1:9NII8izUMCcs10XIYvYhVPgZoYR8Svcxaj4ROCKZE5w= +k8s.io/apimachinery v0.0.0-20210823160225-43d8bfe8f725 h1:fkTd5iY1R9JSSTs2M1mwmzX6Cmepwnd/uj6vawk1+cg= +k8s.io/apimachinery v0.0.0-20210823160225-43d8bfe8f725/go.mod h1:9bsqX1kl7oIEzpNzAVhpZQ9E/AcXq62F+TCC81jicxo= k8s.io/client-go v0.0.0-20210820200723-590eaed90a85 h1:l1bg5TOnjmD7AZcjimvppPVIJhgqWW77cnDGniuzKi4= k8s.io/client-go v0.0.0-20210820200723-590eaed90a85/go.mod h1:b7BeUxg/uN2Me9ddwSuzQa2+asz8h3+840bxjk5v4ZI= k8s.io/component-base v0.0.0-20210820041117-a191e9fae528 h1:rjkrYH4ht8L9NgoeMS6pHJ/PcCAnPatFz4tfR/Jotx4= diff --git a/pkg/registry/generic/registry/store.go b/pkg/registry/generic/registry/store.go index ec9870a03..d94627834 100644 --- a/pkg/registry/generic/registry/store.go +++ b/pkg/registry/generic/registry/store.go @@ -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 diff --git a/pkg/registry/rest/resttest/resttest.go b/pkg/registry/rest/resttest/resttest.go index b394da620..c271c66ed 100644 --- a/pkg/registry/rest/resttest/resttest.go +++ b/pkg/registry/rest/resttest/resttest.go @@ -381,7 +381,8 @@ func (t *Tester) testCreateGeneratesName(valid runtime.Object) { t.Fatalf("Unexpected error: %v", err) } defer t.delete(t.TestContext(), created) - if objectMeta.GetName() == "test-" || !strings.HasPrefix(objectMeta.GetName(), "test-") { + createdMeta := t.getObjectMetaOrFail(created) + if createdMeta.GetName() == "test-" || !strings.HasPrefix(createdMeta.GetName(), "test-") { t.Errorf("unexpected name: %#v", valid) } } @@ -399,7 +400,8 @@ func (t *Tester) testCreateHasMetadata(valid runtime.Object) { t.Fatalf("Unexpected object from result: %#v", obj) } defer t.delete(t.TestContext(), obj) - if !metav1.HasObjectMetaSystemFieldValues(objectMeta) { + createdMeta := t.getObjectMetaOrFail(obj) + if !metav1.HasObjectMetaSystemFieldValues(createdMeta) { t.Errorf("storage did not populate object meta field values") } } @@ -501,7 +503,8 @@ func (t *Tester) testCreateResetsUserData(valid runtime.Object, opts metav1.Crea t.Fatalf("Unexpected object from result: %#v", obj) } defer t.delete(t.TestContext(), obj) - if objectMeta.GetUID() == "bad-uid" || objectMeta.GetCreationTimestamp() == now { + createdMeta := t.getObjectMetaOrFail(obj) + if createdMeta.GetUID() == "bad-uid" || createdMeta.GetCreationTimestamp() == now { t.Errorf("ObjectMeta did not reset basic fields: %#v", objectMeta) } }