Skip to content

Commit

Permalink
pkg/util: drop pointer wrapper functions.
Browse files Browse the repository at this point in the history
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 <gcslyp@gmail.com>
  • Loading branch information
liangyuanpeng committed Apr 15, 2024
1 parent cae35db commit 7c29869
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
8 changes: 4 additions & 4 deletions pkg/util/iptables/testing/parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
"github.com/lithammer/dedent"

"k8s.io/kubernetes/pkg/util/iptables"
utilpointer "k8s.io/utils/pointer"
ptr "k8s.io/utils/ptr"
)

func TestParseRule(t *testing.T) {
Expand Down Expand Up @@ -139,8 +139,8 @@ func TestParseRule(t *testing.T) {
Comment: &IPTablesValue{Value: "ns1/svc1:p80"},
AffinityName: &IPTablesValue{Value: "KUBE-SEP-SXIVWICOYRO3J4NJ"},
AffinitySeconds: &IPTablesValue{Value: "10800"},
AffinityCheck: utilpointer.Bool(true),
AffinityReap: utilpointer.Bool(true),
AffinityCheck: ptr.To(true),
AffinityReap: ptr.To(true),
Jump: &IPTablesValue{Value: "KUBE-SEP-SXIVWICOYRO3J4NJ"},
},
},
Expand Down Expand Up @@ -200,7 +200,7 @@ func TestParseRule(t *testing.T) {
parsed: &Rule{
Raw: `-A TEST -m recent ! --rcheck -j KUBE-SEP-SXIVWICOYRO3J4NJ`,
Chain: iptables.Chain("TEST"),
AffinityCheck: utilpointer.Bool(false),
AffinityCheck: ptr.To(false),
Jump: &IPTablesValue{Value: "KUBE-SEP-SXIVWICOYRO3J4NJ"},
},
},
Expand Down
10 changes: 5 additions & 5 deletions pkg/util/tolerations/tolerations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
"k8s.io/apimachinery/pkg/util/validation/field"
api "k8s.io/kubernetes/pkg/apis/core"
"k8s.io/kubernetes/pkg/apis/core/validation"
utilpointer "k8s.io/utils/pointer"
ptr "k8s.io/utils/ptr"
)

var (
Expand Down Expand Up @@ -99,20 +99,20 @@ var (
Key: "foo",
Operator: api.TolerationOpExists,
Effect: api.TaintEffectNoExecute,
TolerationSeconds: utilpointer.Int64Ptr(10),
TolerationSeconds: ptr.To[int64](10),
},
"foo-noexec-0": {
Key: "foo",
Operator: api.TolerationOpExists,
Effect: api.TaintEffectNoExecute,
TolerationSeconds: utilpointer.Int64Ptr(0),
TolerationSeconds: ptr.To[int64](0),
},
"foo-bar-noexec-10": {
Key: "foo",
Operator: api.TolerationOpEqual,
Value: "bar",
Effect: api.TaintEffectNoExecute,
TolerationSeconds: utilpointer.Int64Ptr(10),
TolerationSeconds: ptr.To[int64](10),
},
}
)
Expand Down Expand Up @@ -338,7 +338,7 @@ func TestFuzzed(t *testing.T) {
gen.Value = strings.Repeat("b", r.Intn(6)+1)
}
if gen.Effect == api.TaintEffectNoExecute && r.Float32() < tolerationSecondsProbability {
gen.TolerationSeconds = utilpointer.Int64Ptr(r.Int63n(10))
gen.TolerationSeconds = ptr.To[int64](r.Int63n(10))
}
// Ensure only valid tolerations are generated.
require.NoError(t, validation.ValidateTolerations([]api.Toleration{gen}, field.NewPath("")).ToAggregate(), "%#v", gen)
Expand Down

0 comments on commit 7c29869

Please sign in to comment.