Skip to content

Commit 7c29869

Browse files
committed
pkg/util: 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. See kubernetes/utils#283 for details. Signed-off-by: Lan Liang <[email protected]>
1 parent cae35db commit 7c29869

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

pkg/util/iptables/testing/parse_test.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import (
2828
"github.com/lithammer/dedent"
2929

3030
"k8s.io/kubernetes/pkg/util/iptables"
31-
utilpointer "k8s.io/utils/pointer"
31+
ptr "k8s.io/utils/ptr"
3232
)
3333

3434
func TestParseRule(t *testing.T) {
@@ -139,8 +139,8 @@ func TestParseRule(t *testing.T) {
139139
Comment: &IPTablesValue{Value: "ns1/svc1:p80"},
140140
AffinityName: &IPTablesValue{Value: "KUBE-SEP-SXIVWICOYRO3J4NJ"},
141141
AffinitySeconds: &IPTablesValue{Value: "10800"},
142-
AffinityCheck: utilpointer.Bool(true),
143-
AffinityReap: utilpointer.Bool(true),
142+
AffinityCheck: ptr.To(true),
143+
AffinityReap: ptr.To(true),
144144
Jump: &IPTablesValue{Value: "KUBE-SEP-SXIVWICOYRO3J4NJ"},
145145
},
146146
},
@@ -200,7 +200,7 @@ func TestParseRule(t *testing.T) {
200200
parsed: &Rule{
201201
Raw: `-A TEST -m recent ! --rcheck -j KUBE-SEP-SXIVWICOYRO3J4NJ`,
202202
Chain: iptables.Chain("TEST"),
203-
AffinityCheck: utilpointer.Bool(false),
203+
AffinityCheck: ptr.To(false),
204204
Jump: &IPTablesValue{Value: "KUBE-SEP-SXIVWICOYRO3J4NJ"},
205205
},
206206
},

pkg/util/tolerations/tolerations_test.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import (
2828
"k8s.io/apimachinery/pkg/util/validation/field"
2929
api "k8s.io/kubernetes/pkg/apis/core"
3030
"k8s.io/kubernetes/pkg/apis/core/validation"
31-
utilpointer "k8s.io/utils/pointer"
31+
ptr "k8s.io/utils/ptr"
3232
)
3333

3434
var (
@@ -99,20 +99,20 @@ var (
9999
Key: "foo",
100100
Operator: api.TolerationOpExists,
101101
Effect: api.TaintEffectNoExecute,
102-
TolerationSeconds: utilpointer.Int64Ptr(10),
102+
TolerationSeconds: ptr.To[int64](10),
103103
},
104104
"foo-noexec-0": {
105105
Key: "foo",
106106
Operator: api.TolerationOpExists,
107107
Effect: api.TaintEffectNoExecute,
108-
TolerationSeconds: utilpointer.Int64Ptr(0),
108+
TolerationSeconds: ptr.To[int64](0),
109109
},
110110
"foo-bar-noexec-10": {
111111
Key: "foo",
112112
Operator: api.TolerationOpEqual,
113113
Value: "bar",
114114
Effect: api.TaintEffectNoExecute,
115-
TolerationSeconds: utilpointer.Int64Ptr(10),
115+
TolerationSeconds: ptr.To[int64](10),
116116
},
117117
}
118118
)
@@ -338,7 +338,7 @@ func TestFuzzed(t *testing.T) {
338338
gen.Value = strings.Repeat("b", r.Intn(6)+1)
339339
}
340340
if gen.Effect == api.TaintEffectNoExecute && r.Float32() < tolerationSecondsProbability {
341-
gen.TolerationSeconds = utilpointer.Int64Ptr(r.Int63n(10))
341+
gen.TolerationSeconds = ptr.To[int64](r.Int63n(10))
342342
}
343343
// Ensure only valid tolerations are generated.
344344
require.NoError(t, validation.ValidateTolerations([]api.Toleration{gen}, field.NewPath("")).ToAggregate(), "%#v", gen)

0 commit comments

Comments
 (0)