mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-27 21:47:07 +00:00
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
This commit is contained in:
commit
5030391c07
@ -729,12 +729,8 @@ func TestExclusionNoAdmit(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
originalPod, err := api.Scheme.Copy(pod)
|
originalPod := pod.DeepCopy()
|
||||||
if err != nil {
|
err := admitPod(pod, pip)
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
err = admitPod(pod, pip)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@ -797,12 +793,8 @@ func TestAdmitEmptyPodNamespace(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
originalPod, err := api.Scheme.Copy(pod)
|
originalPod := pod.DeepCopy()
|
||||||
if err != nil {
|
err := admitPod(pod, pip)
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
err = admitPod(pod, pip)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
@ -320,11 +320,7 @@ func (e *quotaEvaluator) checkQuotas(quotas []api.ResourceQuota, admissionAttrib
|
|||||||
func copyQuotas(in []api.ResourceQuota) ([]api.ResourceQuota, error) {
|
func copyQuotas(in []api.ResourceQuota) ([]api.ResourceQuota, error) {
|
||||||
out := make([]api.ResourceQuota, 0, len(in))
|
out := make([]api.ResourceQuota, 0, len(in))
|
||||||
for _, quota := range in {
|
for _, quota := range in {
|
||||||
copied, err := api.Scheme.Copy("a)
|
out = append(out, *quota.DeepCopy())
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
out = append(out, *copied.(*api.ResourceQuota))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return out, nil
|
return out, nil
|
||||||
|
@ -191,11 +191,7 @@ func TestAdmission(t *testing.T) {
|
|||||||
glog.V(4).Infof("starting test %q", test.name)
|
glog.V(4).Infof("starting test %q", test.name)
|
||||||
|
|
||||||
// clone the claim, it's going to be modified
|
// clone the claim, it's going to be modified
|
||||||
clone, err := api.Scheme.DeepCopy(test.claim)
|
claim := test.claim.DeepCopy()
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("Cannot clone claim: %v", err)
|
|
||||||
}
|
|
||||||
claim := clone.(*api.PersistentVolumeClaim)
|
|
||||||
|
|
||||||
ctrl := newPlugin()
|
ctrl := newPlugin()
|
||||||
informerFactory := informers.NewSharedInformerFactory(nil, controller.NoResyncPeriodFunc())
|
informerFactory := informers.NewSharedInformerFactory(nil, controller.NoResyncPeriodFunc())
|
||||||
@ -214,7 +210,7 @@ func TestAdmission(t *testing.T) {
|
|||||||
admission.Create,
|
admission.Create,
|
||||||
nil, // userInfo
|
nil, // userInfo
|
||||||
)
|
)
|
||||||
err = ctrl.Admit(attrs)
|
err := ctrl.Admit(attrs)
|
||||||
glog.Infof("Got %v", err)
|
glog.Infof("Got %v", err)
|
||||||
if err != nil && !test.expectError {
|
if err != nil && !test.expectError {
|
||||||
t.Errorf("Test %q: unexpected error received: %v", test.name, err)
|
t.Errorf("Test %q: unexpected error received: %v", test.name, err)
|
||||||
|
Loading…
Reference in New Issue
Block a user