mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-17 15:50:10 +00:00
fix data race in test
Signed-off-by: lixd <xueduan.li@gmail.com>
This commit is contained in:
parent
9533cfe2ee
commit
12c0c08e65
@ -81,6 +81,12 @@ type FakeVersion struct {
|
|||||||
Version string
|
Version string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func snapshot(imageList []kubecontainer.Image) []kubecontainer.Image {
|
||||||
|
result := make([]kubecontainer.Image, len(imageList))
|
||||||
|
copy(result, imageList)
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
func (fv *FakeVersion) String() string {
|
func (fv *FakeVersion) String() string {
|
||||||
return fv.Version
|
return fv.Version
|
||||||
}
|
}
|
||||||
@ -362,7 +368,7 @@ func (f *FakeRuntime) ListImages(_ context.Context) ([]kubecontainer.Image, erro
|
|||||||
defer f.Unlock()
|
defer f.Unlock()
|
||||||
|
|
||||||
f.CalledFunctions = append(f.CalledFunctions, "ListImages")
|
f.CalledFunctions = append(f.CalledFunctions, "ListImages")
|
||||||
return f.ImageList, f.Err
|
return snapshot(f.ImageList), f.Err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *FakeRuntime) RemoveImage(_ context.Context, image kubecontainer.ImageSpec) error {
|
func (f *FakeRuntime) RemoveImage(_ context.Context, image kubecontainer.ImageSpec) error {
|
||||||
|
Loading…
Reference in New Issue
Block a user