mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-26 21:17:23 +00:00
fix volume failing test
This commit is contained in:
parent
3081fee0ef
commit
0b8dc56408
@ -173,29 +173,38 @@ func CreateTestClient() *fake.Clientset {
|
|||||||
obj.Items = append(obj.Items, nodes.Items...)
|
obj.Items = append(obj.Items, nodes.Items...)
|
||||||
return true, obj, nil
|
return true, obj, nil
|
||||||
})
|
})
|
||||||
|
var mu sync.Mutex
|
||||||
volumeAttachments = &storagev1.VolumeAttachmentList{}
|
volumeAttachments = &storagev1.VolumeAttachmentList{}
|
||||||
fakeClient.AddReactor("list", "volumeattachments", func(action core.Action) (handled bool, ret runtime.Object, err error) {
|
fakeClient.AddReactor("list", "volumeattachments", func(action core.Action) (handled bool, ret runtime.Object, err error) {
|
||||||
obj := &storagev1.VolumeAttachmentList{}
|
obj := &storagev1.VolumeAttachmentList{}
|
||||||
|
mu.Lock()
|
||||||
obj.Items = append(obj.Items, volumeAttachments.Items...)
|
obj.Items = append(obj.Items, volumeAttachments.Items...)
|
||||||
|
mu.Unlock()
|
||||||
return true, obj, nil
|
return true, obj, nil
|
||||||
})
|
})
|
||||||
fakeClient.AddReactor("create", "volumeattachments", func(action core.Action) (handled bool, ret runtime.Object, err error) {
|
fakeClient.AddReactor("create", "volumeattachments", func(action core.Action) (handled bool, ret runtime.Object, err error) {
|
||||||
createAction := action.(core.CreateAction)
|
createAction := action.(core.CreateAction)
|
||||||
va := createAction.GetObject().(*storagev1.VolumeAttachment)
|
va := createAction.GetObject().(*storagev1.VolumeAttachment)
|
||||||
|
mu.Lock()
|
||||||
volumeAttachments.Items = append(volumeAttachments.Items, *va)
|
volumeAttachments.Items = append(volumeAttachments.Items, *va)
|
||||||
|
mu.Unlock()
|
||||||
return true, createAction.GetObject(), nil
|
return true, createAction.GetObject(), nil
|
||||||
})
|
})
|
||||||
|
|
||||||
pvs = &v1.PersistentVolumeList{}
|
pvs = &v1.PersistentVolumeList{}
|
||||||
fakeClient.AddReactor("list", "persistentvolumes", func(action core.Action) (handled bool, ret runtime.Object, err error) {
|
fakeClient.AddReactor("list", "persistentvolumes", func(action core.Action) (handled bool, ret runtime.Object, err error) {
|
||||||
obj := &v1.PersistentVolumeList{}
|
obj := &v1.PersistentVolumeList{}
|
||||||
|
mu.Lock()
|
||||||
obj.Items = append(obj.Items, pvs.Items...)
|
obj.Items = append(obj.Items, pvs.Items...)
|
||||||
|
mu.Unlock()
|
||||||
return true, obj, nil
|
return true, obj, nil
|
||||||
})
|
})
|
||||||
fakeClient.AddReactor("create", "persistentvolumes", func(action core.Action) (handled bool, ret runtime.Object, err error) {
|
fakeClient.AddReactor("create", "persistentvolumes", func(action core.Action) (handled bool, ret runtime.Object, err error) {
|
||||||
createAction := action.(core.CreateAction)
|
createAction := action.(core.CreateAction)
|
||||||
pv := createAction.GetObject().(*v1.PersistentVolume)
|
pv := createAction.GetObject().(*v1.PersistentVolume)
|
||||||
|
mu.Lock()
|
||||||
pvs.Items = append(pvs.Items, *pv)
|
pvs.Items = append(pvs.Items, *pv)
|
||||||
|
mu.Unlock()
|
||||||
return true, createAction.GetObject(), nil
|
return true, createAction.GetObject(), nil
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user