Skip to content

Commit ff3e9ea

Browse files
committed
pkg/api(s): drop pointer wrapper functions
The new k8s.io/utils/ptr package provides generic wrapper functions, which can be used instead of type-specific pointer wrapper functions. This replaces the latter with the former, and migrates other uses of the deprecated pointer package to ptr in affacted files. Signed-off-by: Stephen Kitt <[email protected]>
1 parent 851cf43 commit ff3e9ea

File tree

6 files changed

+517
-547
lines changed

6 files changed

+517
-547
lines changed

pkg/api/job/warnings_test.go

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import (
2323
"k8s.io/kubernetes/pkg/apis/batch"
2424
"k8s.io/kubernetes/pkg/apis/core"
2525
"k8s.io/kubernetes/test/utils/ktesting"
26-
"k8s.io/utils/pointer"
26+
"k8s.io/utils/ptr"
2727
)
2828

2929
var (
@@ -50,21 +50,21 @@ func TestWarningsForJobSpec(t *testing.T) {
5050
}{
5151
"valid NonIndexed": {
5252
spec: &batch.JobSpec{
53-
CompletionMode: completionModePtr(batch.NonIndexedCompletion),
53+
CompletionMode: ptr.To(batch.NonIndexedCompletion),
5454
Template: validPodTemplate,
5555
},
5656
},
5757
"NondIndexed with high completions and parallelism": {
5858
spec: &batch.JobSpec{
59-
CompletionMode: completionModePtr(batch.NonIndexedCompletion),
59+
CompletionMode: ptr.To(batch.NonIndexedCompletion),
6060
Template: validPodTemplate,
61-
Parallelism: pointer.Int32(1_000_000_000),
62-
Completions: pointer.Int32(1_000_000_000),
61+
Parallelism: ptr.To[int32](1_000_000_000),
62+
Completions: ptr.To[int32](1_000_000_000),
6363
},
6464
},
6565
"invalid PodTemplate": {
6666
spec: &batch.JobSpec{
67-
CompletionMode: completionModePtr(batch.NonIndexedCompletion),
67+
CompletionMode: ptr.To(batch.NonIndexedCompletion),
6868
Template: core.PodTemplateSpec{
6969
Spec: core.PodSpec{ImagePullSecrets: []core.LocalObjectReference{{Name: ""}}},
7070
},
@@ -73,33 +73,33 @@ func TestWarningsForJobSpec(t *testing.T) {
7373
},
7474
"valid Indexed low completions low parallelism": {
7575
spec: &batch.JobSpec{
76-
CompletionMode: completionModePtr(batch.IndexedCompletion),
77-
Completions: pointer.Int32(10_000),
78-
Parallelism: pointer.Int32(10_000),
76+
CompletionMode: ptr.To(batch.IndexedCompletion),
77+
Completions: ptr.To[int32](10_000),
78+
Parallelism: ptr.To[int32](10_000),
7979
Template: validPodTemplate,
8080
},
8181
},
8282
"valid Indexed high completions low parallelism": {
8383
spec: &batch.JobSpec{
84-
CompletionMode: completionModePtr(batch.IndexedCompletion),
85-
Completions: pointer.Int32(1000_000_000),
86-
Parallelism: pointer.Int32(10_000),
84+
CompletionMode: ptr.To(batch.IndexedCompletion),
85+
Completions: ptr.To[int32](1000_000_000),
86+
Parallelism: ptr.To[int32](10_000),
8787
Template: validPodTemplate,
8888
},
8989
},
9090
"valid Indexed medium completions medium parallelism": {
9191
spec: &batch.JobSpec{
92-
CompletionMode: completionModePtr(batch.IndexedCompletion),
93-
Completions: pointer.Int32(100_000),
94-
Parallelism: pointer.Int32(100_000),
92+
CompletionMode: ptr.To(batch.IndexedCompletion),
93+
Completions: ptr.To[int32](100_000),
94+
Parallelism: ptr.To[int32](100_000),
9595
Template: validPodTemplate,
9696
},
9797
},
9898
"invalid Indexed high completions high parallelism": {
9999
spec: &batch.JobSpec{
100-
CompletionMode: completionModePtr(batch.IndexedCompletion),
101-
Completions: pointer.Int32(100_001),
102-
Parallelism: pointer.Int32(10_001),
100+
CompletionMode: ptr.To(batch.IndexedCompletion),
101+
Completions: ptr.To[int32](100_001),
102+
Parallelism: ptr.To[int32](10_001),
103103
Template: validPodTemplate,
104104
},
105105
wantWarningsCount: 1,
@@ -115,7 +115,3 @@ func TestWarningsForJobSpec(t *testing.T) {
115115
})
116116
}
117117
}
118-
119-
func completionModePtr(m batch.CompletionMode) *batch.CompletionMode {
120-
return &m
121-
}

0 commit comments

Comments
 (0)