Skip to content

Commit 90cf6f2

Browse files
authored
Merge pull request kubernetes#130413 from zhifei92/deprecated-pointer
chore(kubelet): Use ptr.To to replace the custom function unit64Ptr
2 parents ba71449 + 145bc8a commit 90cf6f2

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

pkg/kubelet/images/image_gc_manager_test.go

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import (
3838
stats "k8s.io/kubernetes/pkg/kubelet/server/stats"
3939
statstest "k8s.io/kubernetes/pkg/kubelet/server/stats/testing"
4040
testingclock "k8s.io/utils/clock/testing"
41+
"k8s.io/utils/ptr"
4142
)
4243

4344
var zero time.Time
@@ -626,8 +627,8 @@ func TestGarbageCollectBelowLowThreshold(t *testing.T) {
626627

627628
// Expect 40% usage.
628629
imageStats := &statsapi.FsStats{
629-
AvailableBytes: uint64Ptr(600),
630-
CapacityBytes: uint64Ptr(1000),
630+
AvailableBytes: ptr.To(uint64(600)),
631+
CapacityBytes: ptr.To(uint64(1000)),
631632
}
632633
mockStatsProvider.EXPECT().ImageFsStats(mock.Anything).Return(imageStats, imageStats, nil)
633634

@@ -659,8 +660,8 @@ func TestGarbageCollectBelowSuccess(t *testing.T) {
659660

660661
// Expect 95% usage and most of it gets freed.
661662
imageFs := &statsapi.FsStats{
662-
AvailableBytes: uint64Ptr(50),
663-
CapacityBytes: uint64Ptr(1000),
663+
AvailableBytes: ptr.To(uint64(50)),
664+
CapacityBytes: ptr.To(uint64(1000)),
664665
}
665666
mockStatsProvider.EXPECT().ImageFsStats(mock.Anything).Return(imageFs, imageFs, nil)
666667
fakeRuntime.ImageList = []container.Image{
@@ -681,8 +682,8 @@ func TestGarbageCollectNotEnoughFreed(t *testing.T) {
681682

682683
// Expect 95% usage and little of it gets freed.
683684
imageFs := &statsapi.FsStats{
684-
AvailableBytes: uint64Ptr(50),
685-
CapacityBytes: uint64Ptr(1000),
685+
AvailableBytes: ptr.To(uint64(50)),
686+
CapacityBytes: ptr.To(uint64(1000)),
686687
}
687688
mockStatsProvider.EXPECT().ImageFsStats(mock.Anything).Return(imageFs, imageFs, nil)
688689
fakeRuntime.ImageList = []container.Image{
@@ -916,7 +917,3 @@ func TestValidateImageGCPolicy(t *testing.T) {
916917
}
917918
}
918919
}
919-
920-
func uint64Ptr(i uint64) *uint64 {
921-
return &i
922-
}

0 commit comments

Comments
 (0)