diff --git a/federation/pkg/federation-controller/util/eventsink/eventsink.go b/federation/pkg/federation-controller/util/eventsink/eventsink.go index c9dbd7b201..da51767ecf 100644 --- a/federation/pkg/federation-controller/util/eventsink/eventsink.go +++ b/federation/pkg/federation-controller/util/eventsink/eventsink.go @@ -61,7 +61,10 @@ func init() { } if err := scheme.AddGeneratedDeepCopyFuncs( conversion.GeneratedDeepCopyFunc{ - Fn: metav1.DeepCopy_v1_Time, + Fn: func(in, out interface{}, c *conversion.Cloner) error { + in.(*metav1.Time).DeepCopyInto(out.(*metav1.Time)) + return nil + }, InType: reflect.TypeOf(&metav1.Time{}), }, ); err != nil { diff --git a/staging/src/k8s.io/apiextensions-apiserver/pkg/controller/finalizer/crd_finalizer.go b/staging/src/k8s.io/apiextensions-apiserver/pkg/controller/finalizer/crd_finalizer.go index 5974f7e5cd..f73c7db37e 100644 --- a/staging/src/k8s.io/apiextensions-apiserver/pkg/controller/finalizer/crd_finalizer.go +++ b/staging/src/k8s.io/apiextensions-apiserver/pkg/controller/finalizer/crd_finalizer.go @@ -109,10 +109,7 @@ func (c *CRDFinalizer) sync(key string) error { return nil } - crd := &apiextensions.CustomResourceDefinition{} - if err := apiextensions.DeepCopy_apiextensions_CustomResourceDefinition(cachedCRD, crd, cloner); err != nil { - return err - } + crd := cachedCRD.DeepCopy() // update the status condition. This cleanup could take a while. apiextensions.SetCRDCondition(crd, apiextensions.CustomResourceDefinitionCondition{ @@ -320,18 +317,8 @@ func (c *CRDFinalizer) updateCustomResourceDefinition(oldObj, newObj interface{} // is likely to be the originator, so requeuing would hot-loop us. Failures are requeued by the workqueue directly. // This is a low traffic and scale resource, so the copy is terrible. It's not good, so better ideas // are welcome. - oldCopy := &apiextensions.CustomResourceDefinition{} - if err := apiextensions.DeepCopy_apiextensions_CustomResourceDefinition(oldCRD, oldCopy, cloner); err != nil { - utilruntime.HandleError(err) - c.enqueue(newCRD) - return - } - newCopy := &apiextensions.CustomResourceDefinition{} - if err := apiextensions.DeepCopy_apiextensions_CustomResourceDefinition(newCRD, newCopy, cloner); err != nil { - utilruntime.HandleError(err) - c.enqueue(newCRD) - return - } + oldCopy := oldCRD.DeepCopy() + newCopy := newCRD.DeepCopy() oldCopy.ResourceVersion = "" newCopy.ResourceVersion = "" apiextensions.RemoveCRDCondition(oldCopy, apiextensions.Terminating) diff --git a/staging/src/k8s.io/apiextensions-apiserver/pkg/controller/status/naming_controller.go b/staging/src/k8s.io/apiextensions-apiserver/pkg/controller/status/naming_controller.go index 7dbb10307d..4789f0acaf 100644 --- a/staging/src/k8s.io/apiextensions-apiserver/pkg/controller/status/naming_controller.go +++ b/staging/src/k8s.io/apiextensions-apiserver/pkg/controller/status/naming_controller.go @@ -251,11 +251,7 @@ func (c *NamingConditionController) sync(key string) error { return nil } - crd := &apiextensions.CustomResourceDefinition{} - if err := apiextensions.DeepCopy_apiextensions_CustomResourceDefinition(inCustomResourceDefinition, crd, cloner); err != nil { - return err - } - + crd := inCustomResourceDefinition.DeepCopy() crd.Status.AcceptedNames = acceptedNames apiextensions.SetCRDCondition(crd, namingCondition) apiextensions.SetCRDCondition(crd, establishedCondition) diff --git a/staging/src/k8s.io/apimachinery/pkg/conversion/unstructured/converter_test.go b/staging/src/k8s.io/apimachinery/pkg/conversion/unstructured/converter_test.go index 68ca9e203f..e05679f900 100644 --- a/staging/src/k8s.io/apimachinery/pkg/conversion/unstructured/converter_test.go +++ b/staging/src/k8s.io/apimachinery/pkg/conversion/unstructured/converter_test.go @@ -21,8 +21,6 @@ import ( "reflect" "testing" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/util/diff" "k8s.io/apimachinery/pkg/util/json" ) @@ -73,25 +71,7 @@ type F struct { I []float32 `json:"fi"` } -// Implement runtime.Object to make types usable for tests. - -func (c *C) GetObjectKind() schema.ObjectKind { - return schema.EmptyObjectKind -} - -func (d *D) GetObjectKind() schema.ObjectKind { - return schema.EmptyObjectKind -} - -func (e *E) GetObjectKind() schema.ObjectKind { - return schema.EmptyObjectKind -} - -func (f *F) GetObjectKind() schema.ObjectKind { - return schema.EmptyObjectKind -} - -func doRoundTrip(t *testing.T, item runtime.Object) { +func doRoundTrip(t *testing.T, item interface{}) { data, err := json.Marshal(item) if err != nil { t.Errorf("Error when marshaling object: %v", err) @@ -127,7 +107,7 @@ func doRoundTrip(t *testing.T, item runtime.Object) { return } - newObj := reflect.New(reflect.TypeOf(item).Elem()).Interface().(runtime.Object) + newObj := reflect.New(reflect.TypeOf(item).Elem()).Interface() err = DefaultConverter.FromUnstructured(newUnstr, newObj) if err != nil { t.Errorf("FromUnstructured failed: %v", err) @@ -142,7 +122,7 @@ func doRoundTrip(t *testing.T, item runtime.Object) { func TestRoundTrip(t *testing.T) { intVal := int64(42) testCases := []struct { - obj runtime.Object + obj interface{} }{ { // This (among others) tests nil map, slice and pointer. @@ -223,7 +203,7 @@ func TestRoundTrip(t *testing.T) { // 1) serialized json -> object // 2) serialized json -> map[string]interface{} -> object // produces the same object. -func doUnrecognized(t *testing.T, jsonData string, item runtime.Object, expectedErr error) { +func doUnrecognized(t *testing.T, jsonData string, item interface{}, expectedErr error) { unmarshalledObj := reflect.New(reflect.TypeOf(item).Elem()).Interface() err := json.Unmarshal([]byte(jsonData), &unmarshalledObj) if (err != nil) != (expectedErr != nil) { @@ -237,7 +217,7 @@ func doUnrecognized(t *testing.T, jsonData string, item runtime.Object, expected t.Errorf("Error when unmarshaling to unstructured: %v", err) return } - newObj := reflect.New(reflect.TypeOf(item).Elem()).Interface().(runtime.Object) + newObj := reflect.New(reflect.TypeOf(item).Elem()).Interface() err = DefaultConverter.FromUnstructured(unstr, newObj) if (err != nil) != (expectedErr != nil) { t.Errorf("Unexpected error in FromUnstructured: %v, expected: %v", err, expectedErr) @@ -251,7 +231,7 @@ func doUnrecognized(t *testing.T, jsonData string, item runtime.Object, expected func TestUnrecognized(t *testing.T) { testCases := []struct { data string - obj runtime.Object + obj interface{} err error }{ { diff --git a/staging/src/k8s.io/apiserver/plugin/pkg/audit/webhook/webhook.go b/staging/src/k8s.io/apiserver/plugin/pkg/audit/webhook/webhook.go index 1e1b7e59ae..e20afd2e02 100644 --- a/staging/src/k8s.io/apiserver/plugin/pkg/audit/webhook/webhook.go +++ b/staging/src/k8s.io/apiserver/plugin/pkg/audit/webhook/webhook.go @@ -22,8 +22,6 @@ import ( "strings" "time" - "github.com/golang/glog" - "k8s.io/apimachinery/pkg/apimachinery/announced" "k8s.io/apimachinery/pkg/apimachinery/registered" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -260,11 +258,7 @@ func (b *batchBackend) ProcessEvents(ev ...*auditinternal.Event) { for i, e := range ev { // Per the audit.Backend interface these events are reused after being // sent to the Sink. Deep copy and send the copy to the queue. - event := new(auditinternal.Event) - if err := auditinternal.DeepCopy_audit_Event(e, event, b.cloner); err != nil { - glog.Errorf("failed to clone audit event: %v: %#v", err, e) - return - } + event := e.DeepCopy() select { case b.buffer <- event: diff --git a/staging/src/k8s.io/kube-aggregator/pkg/controllers/autoregister/autoregister_controller.go b/staging/src/k8s.io/kube-aggregator/pkg/controllers/autoregister/autoregister_controller.go index f606d51c24..7c723c499a 100644 --- a/staging/src/k8s.io/kube-aggregator/pkg/controllers/autoregister/autoregister_controller.go +++ b/staging/src/k8s.io/kube-aggregator/pkg/controllers/autoregister/autoregister_controller.go @@ -206,10 +206,7 @@ func (c *autoRegisterController) checkAPIService(name string) error { } // we have an entry and we have a desired, now we deconflict. Only a few fields matter. - apiService := &apiregistration.APIService{} - if err := apiregistration.DeepCopy_apiregistration_APIService(curr, apiService, cloner); err != nil { - return err - } + apiService := curr.DeepCopy() apiService.Spec = desired.Spec _, err = c.apiServiceClient.APIServices().Update(apiService) return err @@ -226,12 +223,7 @@ func (c *autoRegisterController) AddAPIServiceToSync(in *apiregistration.APIServ c.apiServicesToSyncLock.Lock() defer c.apiServicesToSyncLock.Unlock() - apiService := &apiregistration.APIService{} - if err := apiregistration.DeepCopy_apiregistration_APIService(in, apiService, cloner); err != nil { - // this shouldn't happen - utilruntime.HandleError(err) - return - } + apiService := in.DeepCopy() if apiService.Labels == nil { apiService.Labels = map[string]string{} } diff --git a/staging/src/k8s.io/kube-aggregator/pkg/controllers/status/available_controller.go b/staging/src/k8s.io/kube-aggregator/pkg/controllers/status/available_controller.go index 19e28d17a1..7517b40f6b 100644 --- a/staging/src/k8s.io/kube-aggregator/pkg/controllers/status/available_controller.go +++ b/staging/src/k8s.io/kube-aggregator/pkg/controllers/status/available_controller.go @@ -113,10 +113,7 @@ func (c *AvailableConditionController) sync(key string) error { return err } - apiService := &apiregistration.APIService{} - if err := apiregistration.DeepCopy_apiregistration_APIService(inAPIService, apiService, cloner); err != nil { - return err - } + apiService := inAPIService.DeepCopy() availableCondition := apiregistration.APIServiceCondition{ Type: apiregistration.Available,