client-go: simplify deepcopy calls

Kubernetes-commit: ed423054ba0089a6d58fb0e048fe1acfd966f0d7
This commit is contained in:
Dr. Stefan Schimanski
2017-08-15 14:15:58 +02:00
committed by Kubernetes Publisher
parent 7be903ab67
commit 7cdaec7d07
6 changed files with 11 additions and 44 deletions

View File

@@ -27,7 +27,6 @@ go_library(
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/types:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/watch:go_default_library",
"//vendor/k8s.io/client-go/kubernetes/scheme:go_default_library",
],
)

View File

@@ -28,7 +28,6 @@ import (
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/watch"
"k8s.io/client-go/kubernetes/scheme"
)
func NewFakeControllerSource() *FakeControllerSource {
@@ -153,11 +152,7 @@ func (f *FakeControllerSource) getListItemsLocked() ([]runtime.Object, error) {
// Otherwise, if they make a change and write it back, they
// will inadvertently change our canonical copy (in
// addition to racing with other clients).
objCopy, err := scheme.Scheme.DeepCopy(obj)
if err != nil {
return nil, err
}
list = append(list, objCopy.(runtime.Object))
list = append(list, obj.DeepCopyObject())
}
return list, nil
}
@@ -242,11 +237,7 @@ func (f *FakeControllerSource) Watch(options metav1.ListOptions) (watch.Interfac
// it back, they will inadvertently change the our
// canonical copy (in addition to racing with other
// clients).
objCopy, err := scheme.Scheme.DeepCopy(c.Object)
if err != nil {
return nil, err
}
changes = append(changes, watch.Event{Type: c.Type, Object: objCopy.(runtime.Object)})
changes = append(changes, watch.Event{Type: c.Type, Object: c.Object.DeepCopyObject()})
}
return f.Broadcaster.WatchWithPrefix(changes), nil
} else if rc > len(f.changes) {