pkg/controller: Replace deprecated func usage from the k8s.io/utils/pointer
pkg
This commit is contained in:
@@ -43,7 +43,7 @@ import (
|
||||
"k8s.io/kubernetes/pkg/controller/endpointslice/topologycache"
|
||||
endpointutil "k8s.io/kubernetes/pkg/controller/util/endpoint"
|
||||
endpointsliceutil "k8s.io/kubernetes/pkg/controller/util/endpointslice"
|
||||
utilpointer "k8s.io/utils/pointer"
|
||||
"k8s.io/utils/pointer"
|
||||
)
|
||||
|
||||
// Most of the tests related to EndpointSlice allocation can be found in reconciler_test.go
|
||||
@@ -500,41 +500,41 @@ func TestSyncService(t *testing.T) {
|
||||
},
|
||||
expectedEndpointPorts: []discovery.EndpointPort{
|
||||
{
|
||||
Name: utilpointer.StringPtr("sctp-example"),
|
||||
Name: pointer.String("sctp-example"),
|
||||
Protocol: protoPtr(v1.ProtocolSCTP),
|
||||
Port: utilpointer.Int32Ptr(int32(3456)),
|
||||
Port: pointer.Int32(3456),
|
||||
},
|
||||
{
|
||||
Name: utilpointer.StringPtr("udp-example"),
|
||||
Name: pointer.String("udp-example"),
|
||||
Protocol: protoPtr(v1.ProtocolUDP),
|
||||
Port: utilpointer.Int32Ptr(int32(161)),
|
||||
Port: pointer.Int32(161),
|
||||
},
|
||||
{
|
||||
Name: utilpointer.StringPtr("tcp-example"),
|
||||
Name: pointer.String("tcp-example"),
|
||||
Protocol: protoPtr(v1.ProtocolTCP),
|
||||
Port: utilpointer.Int32Ptr(int32(80)),
|
||||
Port: pointer.Int32(80),
|
||||
},
|
||||
},
|
||||
expectedEndpoints: []discovery.Endpoint{
|
||||
{
|
||||
Conditions: discovery.EndpointConditions{
|
||||
Ready: utilpointer.BoolPtr(true),
|
||||
Serving: utilpointer.BoolPtr(true),
|
||||
Terminating: utilpointer.BoolPtr(false),
|
||||
Ready: pointer.Bool(true),
|
||||
Serving: pointer.Bool(true),
|
||||
Terminating: pointer.Bool(false),
|
||||
},
|
||||
Addresses: []string{"10.0.0.1"},
|
||||
TargetRef: &v1.ObjectReference{Kind: "Pod", Namespace: "default", Name: "pod0"},
|
||||
NodeName: utilpointer.StringPtr("node-1"),
|
||||
NodeName: pointer.String("node-1"),
|
||||
},
|
||||
{
|
||||
Conditions: discovery.EndpointConditions{
|
||||
Ready: utilpointer.BoolPtr(true),
|
||||
Serving: utilpointer.BoolPtr(true),
|
||||
Terminating: utilpointer.BoolPtr(false),
|
||||
Ready: pointer.Bool(true),
|
||||
Serving: pointer.Bool(true),
|
||||
Terminating: pointer.Bool(false),
|
||||
},
|
||||
Addresses: []string{"10.0.0.2"},
|
||||
TargetRef: &v1.ObjectReference{Kind: "Pod", Namespace: "default", Name: "pod1"},
|
||||
NodeName: utilpointer.StringPtr("node-1"),
|
||||
NodeName: pointer.String("node-1"),
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -617,31 +617,31 @@ func TestSyncService(t *testing.T) {
|
||||
},
|
||||
expectedEndpointPorts: []discovery.EndpointPort{
|
||||
{
|
||||
Name: utilpointer.StringPtr("sctp-example"),
|
||||
Name: pointer.String("sctp-example"),
|
||||
Protocol: protoPtr(v1.ProtocolSCTP),
|
||||
Port: utilpointer.Int32Ptr(int32(3456)),
|
||||
Port: pointer.Int32(3456),
|
||||
},
|
||||
{
|
||||
Name: utilpointer.StringPtr("udp-example"),
|
||||
Name: pointer.String("udp-example"),
|
||||
Protocol: protoPtr(v1.ProtocolUDP),
|
||||
Port: utilpointer.Int32Ptr(int32(161)),
|
||||
Port: pointer.Int32(161),
|
||||
},
|
||||
{
|
||||
Name: utilpointer.StringPtr("tcp-example"),
|
||||
Name: pointer.String("tcp-example"),
|
||||
Protocol: protoPtr(v1.ProtocolTCP),
|
||||
Port: utilpointer.Int32Ptr(int32(80)),
|
||||
Port: pointer.Int32(80),
|
||||
},
|
||||
},
|
||||
expectedEndpoints: []discovery.Endpoint{
|
||||
{
|
||||
Conditions: discovery.EndpointConditions{
|
||||
Ready: utilpointer.BoolPtr(true),
|
||||
Serving: utilpointer.BoolPtr(true),
|
||||
Terminating: utilpointer.BoolPtr(false),
|
||||
Ready: pointer.Bool(true),
|
||||
Serving: pointer.Bool(true),
|
||||
Terminating: pointer.Bool(false),
|
||||
},
|
||||
Addresses: []string{"fd08::5678:0000:0000:9abc:def0"},
|
||||
TargetRef: &v1.ObjectReference{Kind: "Pod", Namespace: "default", Name: "pod1"},
|
||||
NodeName: utilpointer.StringPtr("node-1"),
|
||||
NodeName: pointer.String("node-1"),
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -722,41 +722,41 @@ func TestSyncService(t *testing.T) {
|
||||
},
|
||||
expectedEndpointPorts: []discovery.EndpointPort{
|
||||
{
|
||||
Name: utilpointer.StringPtr("sctp-example"),
|
||||
Name: pointer.String("sctp-example"),
|
||||
Protocol: protoPtr(v1.ProtocolSCTP),
|
||||
Port: utilpointer.Int32Ptr(int32(3456)),
|
||||
Port: pointer.Int32(3456),
|
||||
},
|
||||
{
|
||||
Name: utilpointer.StringPtr("udp-example"),
|
||||
Name: pointer.String("udp-example"),
|
||||
Protocol: protoPtr(v1.ProtocolUDP),
|
||||
Port: utilpointer.Int32Ptr(int32(161)),
|
||||
Port: pointer.Int32(161),
|
||||
},
|
||||
{
|
||||
Name: utilpointer.StringPtr("tcp-example"),
|
||||
Name: pointer.String("tcp-example"),
|
||||
Protocol: protoPtr(v1.ProtocolTCP),
|
||||
Port: utilpointer.Int32Ptr(int32(80)),
|
||||
Port: pointer.Int32(80),
|
||||
},
|
||||
},
|
||||
expectedEndpoints: []discovery.Endpoint{
|
||||
{
|
||||
Conditions: discovery.EndpointConditions{
|
||||
Ready: utilpointer.BoolPtr(true),
|
||||
Serving: utilpointer.BoolPtr(true),
|
||||
Terminating: utilpointer.BoolPtr(false),
|
||||
Ready: pointer.Bool(true),
|
||||
Serving: pointer.Bool(true),
|
||||
Terminating: pointer.Bool(false),
|
||||
},
|
||||
Addresses: []string{"10.0.0.1"},
|
||||
TargetRef: &v1.ObjectReference{Kind: "Pod", Namespace: "default", Name: "pod0"},
|
||||
NodeName: utilpointer.StringPtr("node-1"),
|
||||
NodeName: pointer.String("node-1"),
|
||||
},
|
||||
{
|
||||
Conditions: discovery.EndpointConditions{
|
||||
Ready: utilpointer.BoolPtr(false),
|
||||
Serving: utilpointer.BoolPtr(true),
|
||||
Terminating: utilpointer.BoolPtr(true),
|
||||
Ready: pointer.Bool(false),
|
||||
Serving: pointer.Bool(true),
|
||||
Terminating: pointer.Bool(true),
|
||||
},
|
||||
Addresses: []string{"10.0.0.2"},
|
||||
TargetRef: &v1.ObjectReference{Kind: "Pod", Namespace: "default", Name: "pod1"},
|
||||
NodeName: utilpointer.StringPtr("node-1"),
|
||||
NodeName: pointer.String("node-1"),
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -837,41 +837,41 @@ func TestSyncService(t *testing.T) {
|
||||
},
|
||||
expectedEndpointPorts: []discovery.EndpointPort{
|
||||
{
|
||||
Name: utilpointer.StringPtr("sctp-example"),
|
||||
Name: pointer.String("sctp-example"),
|
||||
Protocol: protoPtr(v1.ProtocolSCTP),
|
||||
Port: utilpointer.Int32Ptr(int32(3456)),
|
||||
Port: pointer.Int32(3456),
|
||||
},
|
||||
{
|
||||
Name: utilpointer.StringPtr("udp-example"),
|
||||
Name: pointer.String("udp-example"),
|
||||
Protocol: protoPtr(v1.ProtocolUDP),
|
||||
Port: utilpointer.Int32Ptr(int32(161)),
|
||||
Port: pointer.Int32(161),
|
||||
},
|
||||
{
|
||||
Name: utilpointer.StringPtr("tcp-example"),
|
||||
Name: pointer.String("tcp-example"),
|
||||
Protocol: protoPtr(v1.ProtocolTCP),
|
||||
Port: utilpointer.Int32Ptr(int32(80)),
|
||||
Port: pointer.Int32(80),
|
||||
},
|
||||
},
|
||||
expectedEndpoints: []discovery.Endpoint{
|
||||
{
|
||||
Conditions: discovery.EndpointConditions{
|
||||
Ready: utilpointer.BoolPtr(true),
|
||||
Serving: utilpointer.BoolPtr(true),
|
||||
Terminating: utilpointer.BoolPtr(false),
|
||||
Ready: pointer.Bool(true),
|
||||
Serving: pointer.Bool(true),
|
||||
Terminating: pointer.Bool(false),
|
||||
},
|
||||
Addresses: []string{"10.0.0.1"},
|
||||
TargetRef: &v1.ObjectReference{Kind: "Pod", Namespace: "default", Name: "pod0"},
|
||||
NodeName: utilpointer.StringPtr("node-1"),
|
||||
NodeName: pointer.String("node-1"),
|
||||
},
|
||||
{
|
||||
Conditions: discovery.EndpointConditions{
|
||||
Ready: utilpointer.BoolPtr(false),
|
||||
Serving: utilpointer.BoolPtr(false),
|
||||
Terminating: utilpointer.BoolPtr(true),
|
||||
Ready: pointer.Bool(false),
|
||||
Serving: pointer.Bool(false),
|
||||
Terminating: pointer.Bool(true),
|
||||
},
|
||||
Addresses: []string{"10.0.0.2"},
|
||||
TargetRef: &v1.ObjectReference{Kind: "Pod", Namespace: "default", Name: "pod1"},
|
||||
NodeName: utilpointer.StringPtr("node-1"),
|
||||
NodeName: pointer.String("node-1"),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@@ -23,7 +23,7 @@ import (
|
||||
discovery "k8s.io/api/discovery/v1"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
"k8s.io/kubernetes/pkg/controller/util/endpoint"
|
||||
utilpointer "k8s.io/utils/pointer"
|
||||
"k8s.io/utils/pointer"
|
||||
)
|
||||
|
||||
func TestNumEndpointsAndSlices(t *testing.T) {
|
||||
@@ -92,8 +92,8 @@ func expectNumEndpointsAndSlices(t *testing.T, c *Cache, desired int, actual int
|
||||
func benchmarkUpdateServicePortCache(b *testing.B, num int) {
|
||||
c := NewCache(int32(100))
|
||||
ns := "benchmark"
|
||||
httpKey := endpoint.NewPortMapKey([]discovery.EndpointPort{{Port: utilpointer.Int32Ptr(80)}})
|
||||
httpsKey := endpoint.NewPortMapKey([]discovery.EndpointPort{{Port: utilpointer.Int32Ptr(443)}})
|
||||
httpKey := endpoint.NewPortMapKey([]discovery.EndpointPort{{Port: pointer.Int32(80)}})
|
||||
httpsKey := endpoint.NewPortMapKey([]discovery.EndpointPort{{Port: pointer.Int32(443)}})
|
||||
spCache := &ServicePortCache{items: map[endpoint.PortMapKey]EfficiencyInfo{
|
||||
httpKey: {
|
||||
Endpoints: 182,
|
||||
|
@@ -42,7 +42,7 @@ import (
|
||||
"k8s.io/kubernetes/pkg/controller/endpointslice/metrics"
|
||||
"k8s.io/kubernetes/pkg/controller/endpointslice/topologycache"
|
||||
endpointsliceutil "k8s.io/kubernetes/pkg/controller/util/endpointslice"
|
||||
utilpointer "k8s.io/utils/pointer"
|
||||
"k8s.io/utils/pointer"
|
||||
)
|
||||
|
||||
var defaultMaxEndpointsPerSlice = int32(100)
|
||||
@@ -125,12 +125,12 @@ func TestReconcile1Pod(t *testing.T) {
|
||||
{
|
||||
Addresses: []string{"1.2.3.4"},
|
||||
Conditions: discovery.EndpointConditions{
|
||||
Ready: utilpointer.BoolPtr(true),
|
||||
Serving: utilpointer.BoolPtr(true),
|
||||
Terminating: utilpointer.BoolPtr(false),
|
||||
Ready: pointer.Bool(true),
|
||||
Serving: pointer.Bool(true),
|
||||
Terminating: pointer.Bool(false),
|
||||
},
|
||||
Zone: utilpointer.StringPtr("us-central1-a"),
|
||||
NodeName: utilpointer.StringPtr("node-1"),
|
||||
Zone: pointer.String("us-central1-a"),
|
||||
NodeName: pointer.String("node-1"),
|
||||
TargetRef: &corev1.ObjectReference{
|
||||
Kind: "Pod",
|
||||
Namespace: namespace,
|
||||
@@ -151,12 +151,12 @@ func TestReconcile1Pod(t *testing.T) {
|
||||
{
|
||||
Addresses: []string{"1.2.3.4"},
|
||||
Conditions: discovery.EndpointConditions{
|
||||
Ready: utilpointer.BoolPtr(true),
|
||||
Serving: utilpointer.BoolPtr(true),
|
||||
Terminating: utilpointer.BoolPtr(false),
|
||||
Ready: pointer.Bool(true),
|
||||
Serving: pointer.Bool(true),
|
||||
Terminating: pointer.Bool(false),
|
||||
},
|
||||
Zone: utilpointer.StringPtr("us-central1-a"),
|
||||
NodeName: utilpointer.StringPtr("node-1"),
|
||||
Zone: pointer.String("us-central1-a"),
|
||||
NodeName: pointer.String("node-1"),
|
||||
TargetRef: &corev1.ObjectReference{
|
||||
Kind: "Pod",
|
||||
Namespace: namespace,
|
||||
@@ -178,12 +178,12 @@ func TestReconcile1Pod(t *testing.T) {
|
||||
{
|
||||
Addresses: []string{"1.2.3.4"},
|
||||
Conditions: discovery.EndpointConditions{
|
||||
Ready: utilpointer.BoolPtr(true),
|
||||
Serving: utilpointer.BoolPtr(true),
|
||||
Terminating: utilpointer.BoolPtr(false),
|
||||
Ready: pointer.Bool(true),
|
||||
Serving: pointer.Bool(true),
|
||||
Terminating: pointer.Bool(false),
|
||||
},
|
||||
Zone: utilpointer.StringPtr("us-central1-a"),
|
||||
NodeName: utilpointer.StringPtr("node-1"),
|
||||
Zone: pointer.String("us-central1-a"),
|
||||
NodeName: pointer.String("node-1"),
|
||||
TargetRef: &corev1.ObjectReference{
|
||||
Kind: "Pod",
|
||||
Namespace: namespace,
|
||||
@@ -196,12 +196,12 @@ func TestReconcile1Pod(t *testing.T) {
|
||||
expectedEndpoint: discovery.Endpoint{
|
||||
Addresses: []string{"1.2.3.4"},
|
||||
Conditions: discovery.EndpointConditions{
|
||||
Ready: utilpointer.BoolPtr(true),
|
||||
Serving: utilpointer.BoolPtr(true),
|
||||
Terminating: utilpointer.BoolPtr(false),
|
||||
Ready: pointer.Bool(true),
|
||||
Serving: pointer.Bool(true),
|
||||
Terminating: pointer.Bool(false),
|
||||
},
|
||||
Zone: utilpointer.StringPtr("us-central1-a"),
|
||||
NodeName: utilpointer.StringPtr("node-1"),
|
||||
Zone: pointer.String("us-central1-a"),
|
||||
NodeName: pointer.String("node-1"),
|
||||
TargetRef: &corev1.ObjectReference{
|
||||
Kind: "Pod",
|
||||
Namespace: namespace,
|
||||
@@ -220,12 +220,12 @@ func TestReconcile1Pod(t *testing.T) {
|
||||
{
|
||||
Addresses: []string{"1.2.3.4"},
|
||||
Conditions: discovery.EndpointConditions{
|
||||
Ready: utilpointer.BoolPtr(true),
|
||||
Serving: utilpointer.BoolPtr(true),
|
||||
Terminating: utilpointer.BoolPtr(false),
|
||||
Ready: pointer.Bool(true),
|
||||
Serving: pointer.Bool(true),
|
||||
Terminating: pointer.Bool(false),
|
||||
},
|
||||
Zone: utilpointer.StringPtr("us-central1-a"),
|
||||
NodeName: utilpointer.StringPtr("node-1"),
|
||||
Zone: pointer.String("us-central1-a"),
|
||||
NodeName: pointer.String("node-1"),
|
||||
TargetRef: &corev1.ObjectReference{
|
||||
Kind: "Pod",
|
||||
Namespace: namespace,
|
||||
@@ -238,12 +238,12 @@ func TestReconcile1Pod(t *testing.T) {
|
||||
expectedEndpoint: discovery.Endpoint{
|
||||
Addresses: []string{"1.2.3.4"},
|
||||
Conditions: discovery.EndpointConditions{
|
||||
Ready: utilpointer.BoolPtr(true),
|
||||
Serving: utilpointer.BoolPtr(true),
|
||||
Terminating: utilpointer.BoolPtr(false),
|
||||
Ready: pointer.Bool(true),
|
||||
Serving: pointer.Bool(true),
|
||||
Terminating: pointer.Bool(false),
|
||||
},
|
||||
Zone: utilpointer.StringPtr("us-central1-a"),
|
||||
NodeName: utilpointer.StringPtr("node-1"),
|
||||
Zone: pointer.String("us-central1-a"),
|
||||
NodeName: pointer.String("node-1"),
|
||||
TargetRef: &corev1.ObjectReference{
|
||||
Kind: "Pod",
|
||||
Namespace: namespace,
|
||||
@@ -264,12 +264,12 @@ func TestReconcile1Pod(t *testing.T) {
|
||||
{
|
||||
Addresses: []string{"1.2.3.4"},
|
||||
Conditions: discovery.EndpointConditions{
|
||||
Ready: utilpointer.BoolPtr(true),
|
||||
Serving: utilpointer.BoolPtr(true),
|
||||
Terminating: utilpointer.BoolPtr(false),
|
||||
Ready: pointer.Bool(true),
|
||||
Serving: pointer.Bool(true),
|
||||
Terminating: pointer.Bool(false),
|
||||
},
|
||||
Zone: utilpointer.StringPtr("us-central1-a"),
|
||||
NodeName: utilpointer.StringPtr("node-1"),
|
||||
Zone: pointer.String("us-central1-a"),
|
||||
NodeName: pointer.String("node-1"),
|
||||
TargetRef: &corev1.ObjectReference{
|
||||
Kind: "Pod",
|
||||
Namespace: namespace,
|
||||
@@ -282,12 +282,12 @@ func TestReconcile1Pod(t *testing.T) {
|
||||
expectedEndpoint: discovery.Endpoint{
|
||||
Addresses: []string{"1.2.3.4"},
|
||||
Conditions: discovery.EndpointConditions{
|
||||
Ready: utilpointer.BoolPtr(true),
|
||||
Serving: utilpointer.BoolPtr(true),
|
||||
Terminating: utilpointer.BoolPtr(false),
|
||||
Ready: pointer.Bool(true),
|
||||
Serving: pointer.Bool(true),
|
||||
Terminating: pointer.Bool(false),
|
||||
},
|
||||
Zone: utilpointer.StringPtr("us-central1-a"),
|
||||
NodeName: utilpointer.StringPtr("node-1"),
|
||||
Zone: pointer.String("us-central1-a"),
|
||||
NodeName: pointer.String("node-1"),
|
||||
TargetRef: &corev1.ObjectReference{
|
||||
Kind: "Pod",
|
||||
Namespace: namespace,
|
||||
@@ -308,12 +308,12 @@ func TestReconcile1Pod(t *testing.T) {
|
||||
{
|
||||
Addresses: []string{"1234::5678:0000:0000:9abc:def0"},
|
||||
Conditions: discovery.EndpointConditions{
|
||||
Ready: utilpointer.BoolPtr(true),
|
||||
Serving: utilpointer.BoolPtr(true),
|
||||
Terminating: utilpointer.BoolPtr(false),
|
||||
Ready: pointer.Bool(true),
|
||||
Serving: pointer.Bool(true),
|
||||
Terminating: pointer.Bool(false),
|
||||
},
|
||||
Zone: utilpointer.StringPtr("us-central1-a"),
|
||||
NodeName: utilpointer.StringPtr("node-1"),
|
||||
Zone: pointer.String("us-central1-a"),
|
||||
NodeName: pointer.String("node-1"),
|
||||
TargetRef: &corev1.ObjectReference{
|
||||
Kind: "Pod",
|
||||
Namespace: namespace,
|
||||
@@ -336,12 +336,12 @@ func TestReconcile1Pod(t *testing.T) {
|
||||
{
|
||||
Addresses: []string{"1234::5678:0000:0000:9abc:def0"},
|
||||
Conditions: discovery.EndpointConditions{
|
||||
Ready: utilpointer.BoolPtr(true),
|
||||
Serving: utilpointer.BoolPtr(true),
|
||||
Terminating: utilpointer.BoolPtr(false),
|
||||
Ready: pointer.Bool(true),
|
||||
Serving: pointer.Bool(true),
|
||||
Terminating: pointer.Bool(false),
|
||||
},
|
||||
Zone: utilpointer.StringPtr("us-central1-a"),
|
||||
NodeName: utilpointer.StringPtr("node-1"),
|
||||
Zone: pointer.String("us-central1-a"),
|
||||
NodeName: pointer.String("node-1"),
|
||||
TargetRef: &corev1.ObjectReference{
|
||||
Kind: "Pod",
|
||||
Namespace: namespace,
|
||||
@@ -363,12 +363,12 @@ func TestReconcile1Pod(t *testing.T) {
|
||||
{
|
||||
Addresses: []string{"1234::5678:0000:0000:9abc:def0"},
|
||||
Conditions: discovery.EndpointConditions{
|
||||
Ready: utilpointer.BoolPtr(true),
|
||||
Serving: utilpointer.BoolPtr(true),
|
||||
Terminating: utilpointer.BoolPtr(false),
|
||||
Ready: pointer.Bool(true),
|
||||
Serving: pointer.Bool(true),
|
||||
Terminating: pointer.Bool(false),
|
||||
},
|
||||
Zone: utilpointer.StringPtr("us-central1-a"),
|
||||
NodeName: utilpointer.StringPtr("node-1"),
|
||||
Zone: pointer.String("us-central1-a"),
|
||||
NodeName: pointer.String("node-1"),
|
||||
TargetRef: &corev1.ObjectReference{
|
||||
Kind: "Pod",
|
||||
Namespace: namespace,
|
||||
@@ -380,12 +380,12 @@ func TestReconcile1Pod(t *testing.T) {
|
||||
{
|
||||
Addresses: []string{"1.2.3.4"},
|
||||
Conditions: discovery.EndpointConditions{
|
||||
Ready: utilpointer.BoolPtr(true),
|
||||
Serving: utilpointer.BoolPtr(true),
|
||||
Terminating: utilpointer.BoolPtr(false),
|
||||
Ready: pointer.Bool(true),
|
||||
Serving: pointer.Bool(true),
|
||||
Terminating: pointer.Bool(false),
|
||||
},
|
||||
Zone: utilpointer.StringPtr("us-central1-a"),
|
||||
NodeName: utilpointer.StringPtr("node-1"),
|
||||
Zone: pointer.String("us-central1-a"),
|
||||
NodeName: pointer.String("node-1"),
|
||||
TargetRef: &corev1.ObjectReference{
|
||||
Kind: "Pod",
|
||||
Namespace: namespace,
|
||||
@@ -1192,9 +1192,9 @@ func TestReconcileEndpointSlicesNamedPorts(t *testing.T) {
|
||||
for i := range fetchedSlices {
|
||||
expectedSlices = append(expectedSlices, discovery.EndpointSlice{
|
||||
Ports: []discovery.EndpointPort{{
|
||||
Name: utilpointer.StringPtr(""),
|
||||
Name: pointer.String(""),
|
||||
Protocol: &protoTCP,
|
||||
Port: utilpointer.Int32Ptr(int32(8080 + i)),
|
||||
Port: pointer.Int32(int32(8080 + i)),
|
||||
}},
|
||||
AddressType: discovery.AddressTypeIPv4,
|
||||
})
|
||||
|
@@ -21,7 +21,7 @@ import (
|
||||
"testing"
|
||||
|
||||
discovery "k8s.io/api/discovery/v1"
|
||||
utilpointer "k8s.io/utils/pointer"
|
||||
"k8s.io/utils/pointer"
|
||||
)
|
||||
|
||||
func Test_getTotalReadyEndpoints(t *testing.T) {
|
||||
@@ -93,14 +93,14 @@ func sliceWithNEndpoints(ready, unready int) *discovery.EndpointSlice {
|
||||
for i := 0; i < ready; i++ {
|
||||
endpoints[i] = discovery.Endpoint{
|
||||
Addresses: []string{fmt.Sprintf("10.1.2.%d", i)},
|
||||
Conditions: discovery.EndpointConditions{Ready: utilpointer.BoolPtr(true)},
|
||||
Conditions: discovery.EndpointConditions{Ready: pointer.Bool(true)},
|
||||
}
|
||||
}
|
||||
|
||||
for i := 0; i < unready; i++ {
|
||||
endpoints[ready+i] = discovery.Endpoint{
|
||||
Addresses: []string{fmt.Sprintf("10.1.2.%d", ready+i)},
|
||||
Conditions: discovery.EndpointConditions{Ready: utilpointer.BoolPtr(false)},
|
||||
Conditions: discovery.EndpointConditions{Ready: pointer.Bool(false)},
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -27,7 +27,7 @@ import (
|
||||
discovery "k8s.io/api/discovery/v1"
|
||||
"k8s.io/apimachinery/pkg/api/resource"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
utilpointer "k8s.io/utils/pointer"
|
||||
"k8s.io/utils/pointer"
|
||||
)
|
||||
|
||||
func TestAddHints(t *testing.T) {
|
||||
@@ -65,8 +65,8 @@ func TestAddHints(t *testing.T) {
|
||||
ToCreate: []*discovery.EndpointSlice{{
|
||||
Endpoints: []discovery.Endpoint{{
|
||||
Addresses: []string{"10.1.2.3"},
|
||||
Zone: utilpointer.StringPtr("zone-a"),
|
||||
Conditions: discovery.EndpointConditions{Ready: utilpointer.BoolPtr(true)},
|
||||
Zone: pointer.String("zone-a"),
|
||||
Conditions: discovery.EndpointConditions{Ready: pointer.Bool(true)},
|
||||
}},
|
||||
}},
|
||||
},
|
||||
@@ -74,8 +74,8 @@ func TestAddHints(t *testing.T) {
|
||||
expectedSlicesToCreate: []*discovery.EndpointSlice{{
|
||||
Endpoints: []discovery.Endpoint{{
|
||||
Addresses: []string{"10.1.2.3"},
|
||||
Zone: utilpointer.StringPtr("zone-a"),
|
||||
Conditions: discovery.EndpointConditions{Ready: utilpointer.BoolPtr(true)},
|
||||
Zone: pointer.String("zone-a"),
|
||||
Conditions: discovery.EndpointConditions{Ready: pointer.Bool(true)},
|
||||
}},
|
||||
}},
|
||||
expectedSlicesToUpdate: []*discovery.EndpointSlice{},
|
||||
@@ -99,12 +99,12 @@ func TestAddHints(t *testing.T) {
|
||||
ToCreate: []*discovery.EndpointSlice{{
|
||||
Endpoints: []discovery.Endpoint{{
|
||||
Addresses: []string{"10.1.2.3"},
|
||||
Zone: utilpointer.StringPtr("zone-a"),
|
||||
Conditions: discovery.EndpointConditions{Ready: utilpointer.BoolPtr(true)},
|
||||
Zone: pointer.String("zone-a"),
|
||||
Conditions: discovery.EndpointConditions{Ready: pointer.Bool(true)},
|
||||
}, {
|
||||
Addresses: []string{"10.1.2.4"},
|
||||
Zone: utilpointer.StringPtr("zone-b"),
|
||||
Conditions: discovery.EndpointConditions{Ready: utilpointer.BoolPtr(true)},
|
||||
Zone: pointer.String("zone-b"),
|
||||
Conditions: discovery.EndpointConditions{Ready: pointer.Bool(true)},
|
||||
}},
|
||||
}},
|
||||
},
|
||||
@@ -112,12 +112,12 @@ func TestAddHints(t *testing.T) {
|
||||
expectedSlicesToCreate: []*discovery.EndpointSlice{{
|
||||
Endpoints: []discovery.Endpoint{{
|
||||
Addresses: []string{"10.1.2.3"},
|
||||
Zone: utilpointer.StringPtr("zone-a"),
|
||||
Conditions: discovery.EndpointConditions{Ready: utilpointer.BoolPtr(true)},
|
||||
Zone: pointer.String("zone-a"),
|
||||
Conditions: discovery.EndpointConditions{Ready: pointer.Bool(true)},
|
||||
}, {
|
||||
Addresses: []string{"10.1.2.4"},
|
||||
Zone: utilpointer.StringPtr("zone-b"),
|
||||
Conditions: discovery.EndpointConditions{Ready: utilpointer.BoolPtr(true)},
|
||||
Zone: pointer.String("zone-b"),
|
||||
Conditions: discovery.EndpointConditions{Ready: pointer.Bool(true)},
|
||||
}},
|
||||
}},
|
||||
expectedSlicesToUpdate: []*discovery.EndpointSlice{},
|
||||
@@ -140,12 +140,12 @@ func TestAddHints(t *testing.T) {
|
||||
ToCreate: []*discovery.EndpointSlice{{
|
||||
Endpoints: []discovery.Endpoint{{
|
||||
Addresses: []string{"10.1.2.3"},
|
||||
Zone: utilpointer.StringPtr("zone-a"),
|
||||
Conditions: discovery.EndpointConditions{Ready: utilpointer.BoolPtr(true)},
|
||||
Zone: pointer.String("zone-a"),
|
||||
Conditions: discovery.EndpointConditions{Ready: pointer.Bool(true)},
|
||||
}, {
|
||||
Addresses: []string{"10.1.2.4"},
|
||||
Zone: utilpointer.StringPtr("zone-b"),
|
||||
Conditions: discovery.EndpointConditions{Ready: utilpointer.BoolPtr(true)},
|
||||
Zone: pointer.String("zone-b"),
|
||||
Conditions: discovery.EndpointConditions{Ready: pointer.Bool(true)},
|
||||
}},
|
||||
}},
|
||||
},
|
||||
@@ -158,14 +158,14 @@ func TestAddHints(t *testing.T) {
|
||||
expectedSlicesToCreate: []*discovery.EndpointSlice{{
|
||||
Endpoints: []discovery.Endpoint{{
|
||||
Addresses: []string{"10.1.2.3"},
|
||||
Zone: utilpointer.StringPtr("zone-a"),
|
||||
Zone: pointer.String("zone-a"),
|
||||
Hints: &discovery.EndpointHints{ForZones: []discovery.ForZone{{Name: "zone-a"}}},
|
||||
Conditions: discovery.EndpointConditions{Ready: utilpointer.BoolPtr(true)},
|
||||
Conditions: discovery.EndpointConditions{Ready: pointer.Bool(true)},
|
||||
}, {
|
||||
Addresses: []string{"10.1.2.4"},
|
||||
Zone: utilpointer.StringPtr("zone-b"),
|
||||
Zone: pointer.String("zone-b"),
|
||||
Hints: &discovery.EndpointHints{ForZones: []discovery.ForZone{{Name: "zone-b"}}},
|
||||
Conditions: discovery.EndpointConditions{Ready: utilpointer.BoolPtr(true)},
|
||||
Conditions: discovery.EndpointConditions{Ready: pointer.Bool(true)},
|
||||
}},
|
||||
}},
|
||||
expectedSlicesToUpdate: []*discovery.EndpointSlice{},
|
||||
@@ -188,19 +188,19 @@ func TestAddHints(t *testing.T) {
|
||||
ToCreate: []*discovery.EndpointSlice{{
|
||||
Endpoints: []discovery.Endpoint{{
|
||||
Addresses: []string{"10.1.2.3"},
|
||||
Zone: utilpointer.StringPtr("zone-a"),
|
||||
Conditions: discovery.EndpointConditions{Ready: utilpointer.BoolPtr(true)},
|
||||
Zone: pointer.String("zone-a"),
|
||||
Conditions: discovery.EndpointConditions{Ready: pointer.Bool(true)},
|
||||
}, {
|
||||
Addresses: []string{"10.1.2.4"},
|
||||
Zone: utilpointer.StringPtr("zone-b"),
|
||||
Conditions: discovery.EndpointConditions{Ready: utilpointer.BoolPtr(true)},
|
||||
Zone: pointer.String("zone-b"),
|
||||
Conditions: discovery.EndpointConditions{Ready: pointer.Bool(true)},
|
||||
}, {
|
||||
Addresses: []string{"10.1.2.5"},
|
||||
Zone: utilpointer.StringPtr("zone-b"),
|
||||
Conditions: discovery.EndpointConditions{Ready: utilpointer.BoolPtr(false)},
|
||||
Zone: pointer.String("zone-b"),
|
||||
Conditions: discovery.EndpointConditions{Ready: pointer.Bool(false)},
|
||||
}, {
|
||||
Addresses: []string{"10.1.2.6"},
|
||||
Zone: utilpointer.StringPtr("zone-b"),
|
||||
Zone: pointer.String("zone-b"),
|
||||
}},
|
||||
}},
|
||||
},
|
||||
@@ -213,22 +213,22 @@ func TestAddHints(t *testing.T) {
|
||||
expectedSlicesToCreate: []*discovery.EndpointSlice{{
|
||||
Endpoints: []discovery.Endpoint{{
|
||||
Addresses: []string{"10.1.2.3"},
|
||||
Zone: utilpointer.StringPtr("zone-a"),
|
||||
Zone: pointer.String("zone-a"),
|
||||
Hints: &discovery.EndpointHints{ForZones: []discovery.ForZone{{Name: "zone-a"}}},
|
||||
Conditions: discovery.EndpointConditions{Ready: utilpointer.BoolPtr(true)},
|
||||
Conditions: discovery.EndpointConditions{Ready: pointer.Bool(true)},
|
||||
}, {
|
||||
Addresses: []string{"10.1.2.4"},
|
||||
Zone: utilpointer.StringPtr("zone-b"),
|
||||
Zone: pointer.String("zone-b"),
|
||||
Hints: &discovery.EndpointHints{ForZones: []discovery.ForZone{{Name: "zone-b"}}},
|
||||
Conditions: discovery.EndpointConditions{Ready: utilpointer.BoolPtr(true)},
|
||||
Conditions: discovery.EndpointConditions{Ready: pointer.Bool(true)},
|
||||
}, {
|
||||
Addresses: []string{"10.1.2.5"},
|
||||
Zone: utilpointer.StringPtr("zone-b"),
|
||||
Zone: pointer.String("zone-b"),
|
||||
Hints: nil,
|
||||
Conditions: discovery.EndpointConditions{Ready: utilpointer.BoolPtr(false)},
|
||||
Conditions: discovery.EndpointConditions{Ready: pointer.Bool(false)},
|
||||
}, {
|
||||
Addresses: []string{"10.1.2.6"},
|
||||
Zone: utilpointer.StringPtr("zone-b"),
|
||||
Zone: pointer.String("zone-b"),
|
||||
Hints: nil,
|
||||
}},
|
||||
}},
|
||||
@@ -253,51 +253,51 @@ func TestAddHints(t *testing.T) {
|
||||
ToCreate: []*discovery.EndpointSlice{{
|
||||
Endpoints: []discovery.Endpoint{{
|
||||
Addresses: []string{"10.1.2.3"},
|
||||
Zone: utilpointer.StringPtr("zone-a"),
|
||||
Conditions: discovery.EndpointConditions{Ready: utilpointer.BoolPtr(true)},
|
||||
Zone: pointer.String("zone-a"),
|
||||
Conditions: discovery.EndpointConditions{Ready: pointer.Bool(true)},
|
||||
}, {
|
||||
Addresses: []string{"10.1.2.4"},
|
||||
Zone: utilpointer.StringPtr("zone-b"),
|
||||
Conditions: discovery.EndpointConditions{Ready: utilpointer.BoolPtr(true)},
|
||||
Zone: pointer.String("zone-b"),
|
||||
Conditions: discovery.EndpointConditions{Ready: pointer.Bool(true)},
|
||||
}},
|
||||
}, {
|
||||
Endpoints: []discovery.Endpoint{{
|
||||
Addresses: []string{"10.1.3.3"},
|
||||
Zone: utilpointer.StringPtr("zone-c"),
|
||||
Conditions: discovery.EndpointConditions{Ready: utilpointer.BoolPtr(true)},
|
||||
Zone: pointer.String("zone-c"),
|
||||
Conditions: discovery.EndpointConditions{Ready: pointer.Bool(true)},
|
||||
}, {
|
||||
Addresses: []string{"10.1.3.4"},
|
||||
Zone: utilpointer.StringPtr("zone-c"),
|
||||
Conditions: discovery.EndpointConditions{Ready: utilpointer.BoolPtr(true)},
|
||||
Zone: pointer.String("zone-c"),
|
||||
Conditions: discovery.EndpointConditions{Ready: pointer.Bool(true)},
|
||||
}, {
|
||||
Addresses: []string{"10.1.3.4"},
|
||||
Zone: utilpointer.StringPtr("zone-a"),
|
||||
Conditions: discovery.EndpointConditions{Ready: utilpointer.BoolPtr(true)},
|
||||
Zone: pointer.String("zone-a"),
|
||||
Conditions: discovery.EndpointConditions{Ready: pointer.Bool(true)},
|
||||
}},
|
||||
}},
|
||||
ToUpdate: []*discovery.EndpointSlice{{
|
||||
Endpoints: []discovery.Endpoint{{
|
||||
Addresses: []string{"10.2.2.3"},
|
||||
Zone: utilpointer.StringPtr("zone-a"),
|
||||
Conditions: discovery.EndpointConditions{Ready: utilpointer.BoolPtr(true)},
|
||||
Zone: pointer.String("zone-a"),
|
||||
Conditions: discovery.EndpointConditions{Ready: pointer.Bool(true)},
|
||||
}, {
|
||||
Addresses: []string{"10.2.2.4"},
|
||||
Zone: utilpointer.StringPtr("zone-a"),
|
||||
Conditions: discovery.EndpointConditions{Ready: utilpointer.BoolPtr(true)},
|
||||
Zone: pointer.String("zone-a"),
|
||||
Conditions: discovery.EndpointConditions{Ready: pointer.Bool(true)},
|
||||
}},
|
||||
}, {
|
||||
Endpoints: []discovery.Endpoint{{
|
||||
Addresses: []string{"10.2.3.3"},
|
||||
Zone: utilpointer.StringPtr("zone-b"),
|
||||
Conditions: discovery.EndpointConditions{Ready: utilpointer.BoolPtr(true)},
|
||||
Zone: pointer.String("zone-b"),
|
||||
Conditions: discovery.EndpointConditions{Ready: pointer.Bool(true)},
|
||||
}, {
|
||||
Addresses: []string{"10.2.3.4"},
|
||||
Zone: utilpointer.StringPtr("zone-c"),
|
||||
Conditions: discovery.EndpointConditions{Ready: utilpointer.BoolPtr(true)},
|
||||
Zone: pointer.String("zone-c"),
|
||||
Conditions: discovery.EndpointConditions{Ready: pointer.Bool(true)},
|
||||
}, {
|
||||
Addresses: []string{"10.2.3.4"},
|
||||
Zone: utilpointer.StringPtr("zone-a"),
|
||||
Conditions: discovery.EndpointConditions{Ready: utilpointer.BoolPtr(true)},
|
||||
Zone: pointer.String("zone-a"),
|
||||
Conditions: discovery.EndpointConditions{Ready: pointer.Bool(true)},
|
||||
}},
|
||||
}},
|
||||
},
|
||||
@@ -311,61 +311,61 @@ func TestAddHints(t *testing.T) {
|
||||
expectedSlicesToCreate: []*discovery.EndpointSlice{{
|
||||
Endpoints: []discovery.Endpoint{{
|
||||
Addresses: []string{"10.1.2.3"},
|
||||
Zone: utilpointer.StringPtr("zone-a"),
|
||||
Zone: pointer.String("zone-a"),
|
||||
Hints: &discovery.EndpointHints{ForZones: []discovery.ForZone{{Name: "zone-b"}}},
|
||||
Conditions: discovery.EndpointConditions{Ready: utilpointer.BoolPtr(true)},
|
||||
Conditions: discovery.EndpointConditions{Ready: pointer.Bool(true)},
|
||||
}, {
|
||||
Addresses: []string{"10.1.2.4"},
|
||||
Zone: utilpointer.StringPtr("zone-b"),
|
||||
Zone: pointer.String("zone-b"),
|
||||
Hints: &discovery.EndpointHints{ForZones: []discovery.ForZone{{Name: "zone-b"}}},
|
||||
Conditions: discovery.EndpointConditions{Ready: utilpointer.BoolPtr(true)},
|
||||
Conditions: discovery.EndpointConditions{Ready: pointer.Bool(true)},
|
||||
}},
|
||||
}, {
|
||||
Endpoints: []discovery.Endpoint{{
|
||||
Addresses: []string{"10.1.3.3"},
|
||||
Zone: utilpointer.StringPtr("zone-c"),
|
||||
Zone: pointer.String("zone-c"),
|
||||
Hints: &discovery.EndpointHints{ForZones: []discovery.ForZone{{Name: "zone-c"}}},
|
||||
Conditions: discovery.EndpointConditions{Ready: utilpointer.BoolPtr(true)},
|
||||
Conditions: discovery.EndpointConditions{Ready: pointer.Bool(true)},
|
||||
}, {
|
||||
Addresses: []string{"10.1.3.4"},
|
||||
Zone: utilpointer.StringPtr("zone-c"),
|
||||
Zone: pointer.String("zone-c"),
|
||||
Hints: &discovery.EndpointHints{ForZones: []discovery.ForZone{{Name: "zone-c"}}},
|
||||
Conditions: discovery.EndpointConditions{Ready: utilpointer.BoolPtr(true)},
|
||||
Conditions: discovery.EndpointConditions{Ready: pointer.Bool(true)},
|
||||
}, {
|
||||
Addresses: []string{"10.1.3.4"},
|
||||
Zone: utilpointer.StringPtr("zone-a"),
|
||||
Zone: pointer.String("zone-a"),
|
||||
Hints: &discovery.EndpointHints{ForZones: []discovery.ForZone{{Name: "zone-a"}}},
|
||||
Conditions: discovery.EndpointConditions{Ready: utilpointer.BoolPtr(true)},
|
||||
Conditions: discovery.EndpointConditions{Ready: pointer.Bool(true)},
|
||||
}},
|
||||
}},
|
||||
expectedSlicesToUpdate: []*discovery.EndpointSlice{{
|
||||
Endpoints: []discovery.Endpoint{{
|
||||
Addresses: []string{"10.2.2.3"},
|
||||
Zone: utilpointer.StringPtr("zone-a"),
|
||||
Zone: pointer.String("zone-a"),
|
||||
Hints: &discovery.EndpointHints{ForZones: []discovery.ForZone{{Name: "zone-a"}}},
|
||||
Conditions: discovery.EndpointConditions{Ready: utilpointer.BoolPtr(true)},
|
||||
Conditions: discovery.EndpointConditions{Ready: pointer.Bool(true)},
|
||||
}, {
|
||||
Addresses: []string{"10.2.2.4"},
|
||||
Zone: utilpointer.StringPtr("zone-a"),
|
||||
Zone: pointer.String("zone-a"),
|
||||
Hints: &discovery.EndpointHints{ForZones: []discovery.ForZone{{Name: "zone-a"}}},
|
||||
Conditions: discovery.EndpointConditions{Ready: utilpointer.BoolPtr(true)},
|
||||
Conditions: discovery.EndpointConditions{Ready: pointer.Bool(true)},
|
||||
}},
|
||||
}, {
|
||||
Endpoints: []discovery.Endpoint{{
|
||||
Addresses: []string{"10.2.3.3"},
|
||||
Zone: utilpointer.StringPtr("zone-b"),
|
||||
Zone: pointer.String("zone-b"),
|
||||
Hints: &discovery.EndpointHints{ForZones: []discovery.ForZone{{Name: "zone-b"}}},
|
||||
Conditions: discovery.EndpointConditions{Ready: utilpointer.BoolPtr(true)},
|
||||
Conditions: discovery.EndpointConditions{Ready: pointer.Bool(true)},
|
||||
}, {
|
||||
Addresses: []string{"10.2.3.4"},
|
||||
Zone: utilpointer.StringPtr("zone-c"),
|
||||
Zone: pointer.String("zone-c"),
|
||||
Hints: &discovery.EndpointHints{ForZones: []discovery.ForZone{{Name: "zone-c"}}},
|
||||
Conditions: discovery.EndpointConditions{Ready: utilpointer.BoolPtr(true)},
|
||||
Conditions: discovery.EndpointConditions{Ready: pointer.Bool(true)},
|
||||
}, {
|
||||
Addresses: []string{"10.2.3.4"},
|
||||
Zone: utilpointer.StringPtr("zone-a"),
|
||||
Zone: pointer.String("zone-a"),
|
||||
Hints: &discovery.EndpointHints{ForZones: []discovery.ForZone{{Name: "zone-a"}}},
|
||||
Conditions: discovery.EndpointConditions{Ready: utilpointer.BoolPtr(true)},
|
||||
Conditions: discovery.EndpointConditions{Ready: pointer.Bool(true)},
|
||||
}},
|
||||
}},
|
||||
expectedEvents: []*EventBuilder{
|
||||
|
@@ -21,7 +21,7 @@ import (
|
||||
"testing"
|
||||
|
||||
discovery "k8s.io/api/discovery/v1"
|
||||
utilpointer "k8s.io/utils/pointer"
|
||||
"k8s.io/utils/pointer"
|
||||
)
|
||||
|
||||
func Test_redistributeHints(t *testing.T) {
|
||||
@@ -41,9 +41,9 @@ func Test_redistributeHints(t *testing.T) {
|
||||
name: "single endpoint",
|
||||
slices: []*discovery.EndpointSlice{{
|
||||
Endpoints: []discovery.Endpoint{{
|
||||
Zone: utilpointer.StringPtr("zone-a"),
|
||||
Zone: pointer.String("zone-a"),
|
||||
Hints: &discovery.EndpointHints{ForZones: []discovery.ForZone{{Name: "zone-a"}}},
|
||||
Conditions: discovery.EndpointConditions{Ready: utilpointer.BoolPtr(true)},
|
||||
Conditions: discovery.EndpointConditions{Ready: pointer.Bool(true)},
|
||||
}},
|
||||
}},
|
||||
givingZones: map[string]int{"zone-a": 1},
|
||||
@@ -53,17 +53,17 @@ func Test_redistributeHints(t *testing.T) {
|
||||
name: "endpoints from 1 zone redistributed to 2 other zones",
|
||||
slices: []*discovery.EndpointSlice{{
|
||||
Endpoints: []discovery.Endpoint{{
|
||||
Zone: utilpointer.StringPtr("zone-a"),
|
||||
Zone: pointer.String("zone-a"),
|
||||
Hints: &discovery.EndpointHints{ForZones: []discovery.ForZone{{Name: "zone-a"}}},
|
||||
Conditions: discovery.EndpointConditions{Ready: utilpointer.BoolPtr(true)},
|
||||
Conditions: discovery.EndpointConditions{Ready: pointer.Bool(true)},
|
||||
}, {
|
||||
Zone: utilpointer.StringPtr("zone-a"),
|
||||
Zone: pointer.String("zone-a"),
|
||||
Hints: &discovery.EndpointHints{ForZones: []discovery.ForZone{{Name: "zone-a"}}},
|
||||
Conditions: discovery.EndpointConditions{Ready: utilpointer.BoolPtr(true)},
|
||||
Conditions: discovery.EndpointConditions{Ready: pointer.Bool(true)},
|
||||
}, {
|
||||
Zone: utilpointer.StringPtr("zone-a"),
|
||||
Zone: pointer.String("zone-a"),
|
||||
Hints: &discovery.EndpointHints{ForZones: []discovery.ForZone{{Name: "zone-a"}}},
|
||||
Conditions: discovery.EndpointConditions{Ready: utilpointer.BoolPtr(true)},
|
||||
Conditions: discovery.EndpointConditions{Ready: pointer.Bool(true)},
|
||||
}},
|
||||
}},
|
||||
givingZones: map[string]int{"zone-a": 2},
|
||||
@@ -215,9 +215,9 @@ func Test_getHintsByZone(t *testing.T) {
|
||||
name: "single zone hint",
|
||||
slice: discovery.EndpointSlice{
|
||||
Endpoints: []discovery.Endpoint{{
|
||||
Zone: utilpointer.StringPtr("zone-a"),
|
||||
Zone: pointer.String("zone-a"),
|
||||
Hints: &discovery.EndpointHints{ForZones: []discovery.ForZone{{Name: "zone-a"}}},
|
||||
Conditions: discovery.EndpointConditions{Ready: utilpointer.BoolPtr(true)},
|
||||
Conditions: discovery.EndpointConditions{Ready: pointer.Bool(true)},
|
||||
}},
|
||||
},
|
||||
allocations: map[string]Allocation{
|
||||
@@ -231,15 +231,15 @@ func Test_getHintsByZone(t *testing.T) {
|
||||
name: "single zone hint with 1 unready endpoint and 1 unknown endpoint",
|
||||
slice: discovery.EndpointSlice{
|
||||
Endpoints: []discovery.Endpoint{{
|
||||
Zone: utilpointer.StringPtr("zone-a"),
|
||||
Zone: pointer.String("zone-a"),
|
||||
Hints: &discovery.EndpointHints{ForZones: []discovery.ForZone{{Name: "zone-a"}}},
|
||||
Conditions: discovery.EndpointConditions{Ready: utilpointer.BoolPtr(true)},
|
||||
Conditions: discovery.EndpointConditions{Ready: pointer.Bool(true)},
|
||||
}, {
|
||||
Zone: utilpointer.StringPtr("zone-a"),
|
||||
Zone: pointer.String("zone-a"),
|
||||
Hints: &discovery.EndpointHints{ForZones: []discovery.ForZone{{Name: "zone-a"}}},
|
||||
Conditions: discovery.EndpointConditions{Ready: utilpointer.BoolPtr(false)},
|
||||
Conditions: discovery.EndpointConditions{Ready: pointer.Bool(false)},
|
||||
}, {
|
||||
Zone: utilpointer.StringPtr("zone-a"),
|
||||
Zone: pointer.String("zone-a"),
|
||||
Hints: &discovery.EndpointHints{ForZones: []discovery.ForZone{{Name: "zone-a"}}},
|
||||
}},
|
||||
},
|
||||
@@ -255,19 +255,19 @@ func Test_getHintsByZone(t *testing.T) {
|
||||
slice: discovery.EndpointSlice{
|
||||
Endpoints: []discovery.Endpoint{
|
||||
{
|
||||
Zone: utilpointer.StringPtr("zone-a"),
|
||||
Zone: pointer.String("zone-a"),
|
||||
Hints: &discovery.EndpointHints{ForZones: []discovery.ForZone{{Name: "zone-a"}}},
|
||||
Conditions: discovery.EndpointConditions{Ready: utilpointer.BoolPtr(true)},
|
||||
Conditions: discovery.EndpointConditions{Ready: pointer.Bool(true)},
|
||||
},
|
||||
{
|
||||
Zone: utilpointer.StringPtr("zone-a"),
|
||||
Zone: pointer.String("zone-a"),
|
||||
Hints: &discovery.EndpointHints{ForZones: []discovery.ForZone{{Name: "zone-b"}}},
|
||||
Conditions: discovery.EndpointConditions{Ready: utilpointer.BoolPtr(true)},
|
||||
Conditions: discovery.EndpointConditions{Ready: pointer.Bool(true)},
|
||||
},
|
||||
{
|
||||
Zone: utilpointer.StringPtr("zone-b"),
|
||||
Zone: pointer.String("zone-b"),
|
||||
Hints: &discovery.EndpointHints{ForZones: []discovery.ForZone{{Name: "zone-b"}}},
|
||||
Conditions: discovery.EndpointConditions{Ready: utilpointer.BoolPtr(true)},
|
||||
Conditions: discovery.EndpointConditions{Ready: pointer.Bool(true)},
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -286,9 +286,9 @@ func Test_getHintsByZone(t *testing.T) {
|
||||
slice: discovery.EndpointSlice{
|
||||
Endpoints: []discovery.Endpoint{
|
||||
{
|
||||
Zone: utilpointer.StringPtr("zone-a"),
|
||||
Zone: pointer.String("zone-a"),
|
||||
Hints: &discovery.EndpointHints{ForZones: []discovery.ForZone{{Name: "zone-non-existent"}}},
|
||||
Conditions: discovery.EndpointConditions{Ready: utilpointer.BoolPtr(true)},
|
||||
Conditions: discovery.EndpointConditions{Ready: pointer.Bool(true)},
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -302,9 +302,9 @@ func Test_getHintsByZone(t *testing.T) {
|
||||
slice: discovery.EndpointSlice{
|
||||
Endpoints: []discovery.Endpoint{
|
||||
{
|
||||
Zone: utilpointer.StringPtr("zone-a"),
|
||||
Zone: pointer.String("zone-a"),
|
||||
Hints: nil,
|
||||
Conditions: discovery.EndpointConditions{Ready: utilpointer.BoolPtr(true)},
|
||||
Conditions: discovery.EndpointConditions{Ready: pointer.Bool(true)},
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -318,9 +318,9 @@ func Test_getHintsByZone(t *testing.T) {
|
||||
slice: discovery.EndpointSlice{
|
||||
Endpoints: []discovery.Endpoint{
|
||||
{
|
||||
Zone: utilpointer.StringPtr("zone-a"),
|
||||
Zone: pointer.String("zone-a"),
|
||||
Hints: &discovery.EndpointHints{ForZones: []discovery.ForZone{}},
|
||||
Conditions: discovery.EndpointConditions{Ready: utilpointer.BoolPtr(true)},
|
||||
Conditions: discovery.EndpointConditions{Ready: pointer.Bool(true)},
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -334,14 +334,14 @@ func Test_getHintsByZone(t *testing.T) {
|
||||
slice: discovery.EndpointSlice{
|
||||
Endpoints: []discovery.Endpoint{
|
||||
{
|
||||
Zone: utilpointer.StringPtr("zone-a"),
|
||||
Zone: pointer.String("zone-a"),
|
||||
Hints: &discovery.EndpointHints{ForZones: []discovery.ForZone{{Name: "zone-a"}}},
|
||||
Conditions: discovery.EndpointConditions{Ready: utilpointer.BoolPtr(true)},
|
||||
Conditions: discovery.EndpointConditions{Ready: pointer.Bool(true)},
|
||||
},
|
||||
{
|
||||
Zone: utilpointer.StringPtr("zone-a"),
|
||||
Zone: pointer.String("zone-a"),
|
||||
Hints: &discovery.EndpointHints{ForZones: []discovery.ForZone{{Name: "zone-a"}}},
|
||||
Conditions: discovery.EndpointConditions{Ready: utilpointer.BoolPtr(true)},
|
||||
Conditions: discovery.EndpointConditions{Ready: pointer.Bool(true)},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@@ -33,7 +33,7 @@ import (
|
||||
"k8s.io/apimachinery/pkg/util/rand"
|
||||
"k8s.io/client-go/kubernetes/fake"
|
||||
k8stesting "k8s.io/client-go/testing"
|
||||
utilpointer "k8s.io/utils/pointer"
|
||||
"k8s.io/utils/pointer"
|
||||
)
|
||||
|
||||
func TestNewEndpointSlice(t *testing.T) {
|
||||
@@ -256,11 +256,11 @@ func TestPodToEndpoint(t *testing.T) {
|
||||
expectedEndpoint: discovery.Endpoint{
|
||||
Addresses: []string{"1.2.3.5"},
|
||||
Conditions: discovery.EndpointConditions{
|
||||
Ready: utilpointer.BoolPtr(true),
|
||||
Serving: utilpointer.BoolPtr(true),
|
||||
Terminating: utilpointer.BoolPtr(false),
|
||||
Ready: pointer.Bool(true),
|
||||
Serving: pointer.Bool(true),
|
||||
Terminating: pointer.Bool(false),
|
||||
},
|
||||
NodeName: utilpointer.StringPtr("node-1"),
|
||||
NodeName: pointer.String("node-1"),
|
||||
TargetRef: &v1.ObjectReference{
|
||||
Kind: "Pod",
|
||||
Namespace: ns,
|
||||
@@ -276,11 +276,11 @@ func TestPodToEndpoint(t *testing.T) {
|
||||
expectedEndpoint: discovery.Endpoint{
|
||||
Addresses: []string{"1.2.3.5"},
|
||||
Conditions: discovery.EndpointConditions{
|
||||
Ready: utilpointer.BoolPtr(true),
|
||||
Serving: utilpointer.BoolPtr(true),
|
||||
Terminating: utilpointer.BoolPtr(false),
|
||||
Ready: pointer.Bool(true),
|
||||
Serving: pointer.Bool(true),
|
||||
Terminating: pointer.Bool(false),
|
||||
},
|
||||
NodeName: utilpointer.StringPtr("node-1"),
|
||||
NodeName: pointer.String("node-1"),
|
||||
TargetRef: &v1.ObjectReference{
|
||||
Kind: "Pod",
|
||||
Namespace: ns,
|
||||
@@ -296,11 +296,11 @@ func TestPodToEndpoint(t *testing.T) {
|
||||
expectedEndpoint: discovery.Endpoint{
|
||||
Addresses: []string{"1.2.3.5"},
|
||||
Conditions: discovery.EndpointConditions{
|
||||
Ready: utilpointer.BoolPtr(false),
|
||||
Serving: utilpointer.BoolPtr(false),
|
||||
Terminating: utilpointer.BoolPtr(false),
|
||||
Ready: pointer.Bool(false),
|
||||
Serving: pointer.Bool(false),
|
||||
Terminating: pointer.Bool(false),
|
||||
},
|
||||
NodeName: utilpointer.StringPtr("node-1"),
|
||||
NodeName: pointer.String("node-1"),
|
||||
TargetRef: &v1.ObjectReference{
|
||||
Kind: "Pod",
|
||||
Namespace: ns,
|
||||
@@ -316,11 +316,11 @@ func TestPodToEndpoint(t *testing.T) {
|
||||
expectedEndpoint: discovery.Endpoint{
|
||||
Addresses: []string{"1.2.3.5"},
|
||||
Conditions: discovery.EndpointConditions{
|
||||
Ready: utilpointer.BoolPtr(true),
|
||||
Serving: utilpointer.BoolPtr(false),
|
||||
Terminating: utilpointer.BoolPtr(false),
|
||||
Ready: pointer.Bool(true),
|
||||
Serving: pointer.Bool(false),
|
||||
Terminating: pointer.Bool(false),
|
||||
},
|
||||
NodeName: utilpointer.StringPtr("node-1"),
|
||||
NodeName: pointer.String("node-1"),
|
||||
TargetRef: &v1.ObjectReference{
|
||||
Kind: "Pod",
|
||||
Namespace: ns,
|
||||
@@ -337,12 +337,12 @@ func TestPodToEndpoint(t *testing.T) {
|
||||
expectedEndpoint: discovery.Endpoint{
|
||||
Addresses: []string{"1.2.3.5"},
|
||||
Conditions: discovery.EndpointConditions{
|
||||
Ready: utilpointer.BoolPtr(true),
|
||||
Serving: utilpointer.BoolPtr(true),
|
||||
Terminating: utilpointer.BoolPtr(false),
|
||||
Ready: pointer.Bool(true),
|
||||
Serving: pointer.Bool(true),
|
||||
Terminating: pointer.Bool(false),
|
||||
},
|
||||
Zone: utilpointer.StringPtr("us-central1-a"),
|
||||
NodeName: utilpointer.StringPtr("node-1"),
|
||||
Zone: pointer.String("us-central1-a"),
|
||||
NodeName: pointer.String("node-1"),
|
||||
TargetRef: &v1.ObjectReference{
|
||||
Kind: "Pod",
|
||||
Namespace: ns,
|
||||
@@ -359,12 +359,12 @@ func TestPodToEndpoint(t *testing.T) {
|
||||
expectedEndpoint: discovery.Endpoint{
|
||||
Addresses: []string{"1.2.3.4"},
|
||||
Conditions: discovery.EndpointConditions{
|
||||
Ready: utilpointer.BoolPtr(true),
|
||||
Serving: utilpointer.BoolPtr(true),
|
||||
Terminating: utilpointer.BoolPtr(false),
|
||||
Ready: pointer.Bool(true),
|
||||
Serving: pointer.Bool(true),
|
||||
Terminating: pointer.Bool(false),
|
||||
},
|
||||
Zone: utilpointer.StringPtr("us-central1-a"),
|
||||
NodeName: utilpointer.StringPtr("node-1"),
|
||||
Zone: pointer.String("us-central1-a"),
|
||||
NodeName: pointer.String("node-1"),
|
||||
TargetRef: &v1.ObjectReference{
|
||||
Kind: "Pod",
|
||||
Namespace: ns,
|
||||
@@ -381,13 +381,13 @@ func TestPodToEndpoint(t *testing.T) {
|
||||
expectedEndpoint: discovery.Endpoint{
|
||||
Addresses: []string{"1.2.3.5"},
|
||||
Conditions: discovery.EndpointConditions{
|
||||
Ready: utilpointer.BoolPtr(true),
|
||||
Serving: utilpointer.BoolPtr(true),
|
||||
Terminating: utilpointer.BoolPtr(false),
|
||||
Ready: pointer.Bool(true),
|
||||
Serving: pointer.Bool(true),
|
||||
Terminating: pointer.Bool(false),
|
||||
},
|
||||
Hostname: &readyPodHostname.Spec.Hostname,
|
||||
Zone: utilpointer.StringPtr("us-central1-a"),
|
||||
NodeName: utilpointer.StringPtr("node-1"),
|
||||
Zone: pointer.String("us-central1-a"),
|
||||
NodeName: pointer.String("node-1"),
|
||||
TargetRef: &v1.ObjectReference{
|
||||
Kind: "Pod",
|
||||
Namespace: ns,
|
||||
@@ -403,11 +403,11 @@ func TestPodToEndpoint(t *testing.T) {
|
||||
expectedEndpoint: discovery.Endpoint{
|
||||
Addresses: []string{"1.2.3.5"},
|
||||
Conditions: discovery.EndpointConditions{
|
||||
Ready: utilpointer.BoolPtr(true),
|
||||
Serving: utilpointer.BoolPtr(true),
|
||||
Terminating: utilpointer.BoolPtr(false),
|
||||
Ready: pointer.Bool(true),
|
||||
Serving: pointer.Bool(true),
|
||||
Terminating: pointer.Bool(false),
|
||||
},
|
||||
NodeName: utilpointer.StringPtr("node-1"),
|
||||
NodeName: pointer.String("node-1"),
|
||||
TargetRef: &v1.ObjectReference{
|
||||
Kind: "Pod",
|
||||
Namespace: ns,
|
||||
@@ -423,11 +423,11 @@ func TestPodToEndpoint(t *testing.T) {
|
||||
expectedEndpoint: discovery.Endpoint{
|
||||
Addresses: []string{"1.2.3.5"},
|
||||
Conditions: discovery.EndpointConditions{
|
||||
Ready: utilpointer.BoolPtr(false),
|
||||
Serving: utilpointer.BoolPtr(true),
|
||||
Terminating: utilpointer.BoolPtr(true),
|
||||
Ready: pointer.Bool(false),
|
||||
Serving: pointer.Bool(true),
|
||||
Terminating: pointer.Bool(true),
|
||||
},
|
||||
NodeName: utilpointer.StringPtr("node-1"),
|
||||
NodeName: pointer.String("node-1"),
|
||||
TargetRef: &v1.ObjectReference{
|
||||
Kind: "Pod",
|
||||
Namespace: ns,
|
||||
@@ -443,11 +443,11 @@ func TestPodToEndpoint(t *testing.T) {
|
||||
expectedEndpoint: discovery.Endpoint{
|
||||
Addresses: []string{"1.2.3.5"},
|
||||
Conditions: discovery.EndpointConditions{
|
||||
Ready: utilpointer.BoolPtr(false),
|
||||
Serving: utilpointer.BoolPtr(false),
|
||||
Terminating: utilpointer.BoolPtr(true),
|
||||
Ready: pointer.Bool(false),
|
||||
Serving: pointer.Bool(false),
|
||||
Terminating: pointer.Bool(true),
|
||||
},
|
||||
NodeName: utilpointer.StringPtr("node-1"),
|
||||
NodeName: pointer.String("node-1"),
|
||||
TargetRef: &v1.ObjectReference{
|
||||
Kind: "Pod",
|
||||
Namespace: ns,
|
||||
@@ -527,7 +527,7 @@ func TestGetEndpointPorts(t *testing.T) {
|
||||
Port: 80,
|
||||
TargetPort: intstr.FromInt(80),
|
||||
Protocol: protoTCP,
|
||||
AppProtocol: utilpointer.StringPtr("example.com/custom-protocol"),
|
||||
AppProtocol: pointer.String("example.com/custom-protocol"),
|
||||
}},
|
||||
},
|
||||
},
|
||||
@@ -539,10 +539,10 @@ func TestGetEndpointPorts(t *testing.T) {
|
||||
},
|
||||
},
|
||||
expectedPorts: []*discovery.EndpointPort{{
|
||||
Name: utilpointer.StringPtr("http"),
|
||||
Port: utilpointer.Int32Ptr(80),
|
||||
Name: pointer.String("http"),
|
||||
Port: pointer.Int32(80),
|
||||
Protocol: &protoTCP,
|
||||
AppProtocol: utilpointer.StringPtr("example.com/custom-protocol"),
|
||||
AppProtocol: pointer.String("example.com/custom-protocol"),
|
||||
}},
|
||||
},
|
||||
"service with named port and AppProtocol on one port": {
|
||||
@@ -557,7 +557,7 @@ func TestGetEndpointPorts(t *testing.T) {
|
||||
Name: "https",
|
||||
Protocol: protoTCP,
|
||||
TargetPort: intstr.FromString("https"),
|
||||
AppProtocol: utilpointer.StringPtr("https"),
|
||||
AppProtocol: pointer.String("https"),
|
||||
}},
|
||||
},
|
||||
},
|
||||
@@ -573,14 +573,14 @@ func TestGetEndpointPorts(t *testing.T) {
|
||||
},
|
||||
},
|
||||
expectedPorts: []*discovery.EndpointPort{{
|
||||
Name: utilpointer.StringPtr("http"),
|
||||
Port: utilpointer.Int32Ptr(80),
|
||||
Name: pointer.String("http"),
|
||||
Port: pointer.Int32(80),
|
||||
Protocol: &protoTCP,
|
||||
}, {
|
||||
Name: utilpointer.StringPtr("https"),
|
||||
Port: utilpointer.Int32Ptr(443),
|
||||
Name: pointer.String("https"),
|
||||
Port: pointer.Int32(443),
|
||||
Protocol: &protoTCP,
|
||||
AppProtocol: utilpointer.StringPtr("https"),
|
||||
AppProtocol: pointer.String("https"),
|
||||
}},
|
||||
},
|
||||
}
|
||||
|
Reference in New Issue
Block a user