Merge pull request #51543 from sttts/sttts-deepcopy-admission

Automatic merge from submit-queue (batch tested with PRs 51228, 50185, 50940, 51544, 51543)

admission plugins: simplify deepcopy calls
pull/6/head
Kubernetes Submit Queue 2017-08-29 23:54:34 -07:00 committed by GitHub
commit 5030391c07
3 changed files with 7 additions and 23 deletions

View File

@ -729,12 +729,8 @@ func TestExclusionNoAdmit(t *testing.T) {
},
},
}
originalPod, err := api.Scheme.Copy(pod)
if err != nil {
t.Fatal(err)
}
err = admitPod(pod, pip)
originalPod := pod.DeepCopy()
err := admitPod(pod, pip)
if err != nil {
t.Fatal(err)
}
@ -797,12 +793,8 @@ func TestAdmitEmptyPodNamespace(t *testing.T) {
},
},
}
originalPod, err := api.Scheme.Copy(pod)
if err != nil {
t.Fatal(err)
}
err = admitPod(pod, pip)
originalPod := pod.DeepCopy()
err := admitPod(pod, pip)
if err != nil {
t.Fatal(err)
}

View File

@ -320,11 +320,7 @@ func (e *quotaEvaluator) checkQuotas(quotas []api.ResourceQuota, admissionAttrib
func copyQuotas(in []api.ResourceQuota) ([]api.ResourceQuota, error) {
out := make([]api.ResourceQuota, 0, len(in))
for _, quota := range in {
copied, err := api.Scheme.Copy(&quota)
if err != nil {
return nil, err
}
out = append(out, *copied.(*api.ResourceQuota))
out = append(out, *quota.DeepCopy())
}
return out, nil

View File

@ -191,11 +191,7 @@ func TestAdmission(t *testing.T) {
glog.V(4).Infof("starting test %q", test.name)
// clone the claim, it's going to be modified
clone, err := api.Scheme.DeepCopy(test.claim)
if err != nil {
t.Fatalf("Cannot clone claim: %v", err)
}
claim := clone.(*api.PersistentVolumeClaim)
claim := test.claim.DeepCopy()
ctrl := newPlugin()
informerFactory := informers.NewSharedInformerFactory(nil, controller.NoResyncPeriodFunc())
@ -214,7 +210,7 @@ func TestAdmission(t *testing.T) {
admission.Create,
nil, // userInfo
)
err = ctrl.Admit(attrs)
err := ctrl.Admit(attrs)
glog.Infof("Got %v", err)
if err != nil && !test.expectError {
t.Errorf("Test %q: unexpected error received: %v", test.name, err)