mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-19 09:52:49 +00:00
test/integration: Replace deprecated pointer function
Signed-off-by: TommyStarK <thomasmilox@gmail.com>
This commit is contained in:
parent
7fd0ff5761
commit
9e885bce35
@ -325,8 +325,8 @@ func TestNodeAuthorizer(t *testing.T) {
|
||||
Name: "node1",
|
||||
},
|
||||
Spec: coordination.LeaseSpec{
|
||||
HolderIdentity: pointer.StringPtr("node1"),
|
||||
LeaseDurationSeconds: pointer.Int32Ptr(node1LeaseDurationSeconds),
|
||||
HolderIdentity: pointer.String("node1"),
|
||||
LeaseDurationSeconds: pointer.Int32(node1LeaseDurationSeconds),
|
||||
RenewTime: &metav1.MicroTime{Time: time.Now()},
|
||||
},
|
||||
}
|
||||
|
@ -196,8 +196,8 @@ func newTestLease(acquireTime time.Time, namespace string) *coordinationv1.Lease
|
||||
},
|
||||
},
|
||||
Spec: coordinationv1.LeaseSpec{
|
||||
HolderIdentity: pointer.StringPtr(testLeaseName),
|
||||
LeaseDurationSeconds: pointer.Int32Ptr(3600),
|
||||
HolderIdentity: pointer.String(testLeaseName),
|
||||
LeaseDurationSeconds: pointer.Int32(3600),
|
||||
AcquireTime: &metav1.MicroTime{Time: acquireTime},
|
||||
RenewTime: &metav1.MicroTime{Time: acquireTime},
|
||||
},
|
||||
|
@ -54,7 +54,7 @@ func Test_ServiceLoadBalancerDisableAllocateNodePorts(t *testing.T) {
|
||||
},
|
||||
Spec: corev1.ServiceSpec{
|
||||
Type: corev1.ServiceTypeLoadBalancer,
|
||||
AllocateLoadBalancerNodePorts: utilpointer.BoolPtr(false),
|
||||
AllocateLoadBalancerNodePorts: utilpointer.Bool(false),
|
||||
Ports: []corev1.ServicePort{{
|
||||
Port: int32(80),
|
||||
}},
|
||||
@ -113,7 +113,7 @@ func Test_ServiceUpdateLoadBalancerDisableAllocateNodePorts(t *testing.T) {
|
||||
}
|
||||
|
||||
service.Spec.Type = corev1.ServiceTypeLoadBalancer
|
||||
service.Spec.AllocateLoadBalancerNodePorts = utilpointer.BoolPtr(false)
|
||||
service.Spec.AllocateLoadBalancerNodePorts = utilpointer.Bool(false)
|
||||
service, err = client.CoreV1().Services(ns.Name).Update(context.TODO(), service, metav1.UpdateOptions{})
|
||||
if err != nil {
|
||||
t.Fatalf("Error updating test service: %v", err)
|
||||
@ -144,7 +144,7 @@ func Test_ServiceLoadBalancerEnableThenDisableAllocatedNodePorts(t *testing.T) {
|
||||
},
|
||||
Spec: corev1.ServiceSpec{
|
||||
Type: corev1.ServiceTypeLoadBalancer,
|
||||
AllocateLoadBalancerNodePorts: utilpointer.BoolPtr(true),
|
||||
AllocateLoadBalancerNodePorts: utilpointer.Bool(true),
|
||||
Ports: []corev1.ServicePort{{
|
||||
Port: int32(80),
|
||||
}},
|
||||
@ -163,7 +163,7 @@ func Test_ServiceLoadBalancerEnableThenDisableAllocatedNodePorts(t *testing.T) {
|
||||
t.Error("expected node ports but found none")
|
||||
}
|
||||
|
||||
service.Spec.AllocateLoadBalancerNodePorts = utilpointer.BoolPtr(false)
|
||||
service.Spec.AllocateLoadBalancerNodePorts = utilpointer.Bool(false)
|
||||
service, err = client.CoreV1().Services(ns.Name).Update(context.TODO(), service, metav1.UpdateOptions{})
|
||||
if err != nil {
|
||||
t.Fatalf("Error updating test service: %v", err)
|
||||
@ -194,7 +194,7 @@ func Test_ServiceLoadBalancerDisableThenEnableAllocatedNodePorts(t *testing.T) {
|
||||
},
|
||||
Spec: corev1.ServiceSpec{
|
||||
Type: corev1.ServiceTypeLoadBalancer,
|
||||
AllocateLoadBalancerNodePorts: utilpointer.BoolPtr(false),
|
||||
AllocateLoadBalancerNodePorts: utilpointer.Bool(false),
|
||||
Ports: []corev1.ServicePort{{
|
||||
Port: int32(80),
|
||||
}},
|
||||
@ -213,7 +213,7 @@ func Test_ServiceLoadBalancerDisableThenEnableAllocatedNodePorts(t *testing.T) {
|
||||
t.Error("not expected node ports but found one")
|
||||
}
|
||||
|
||||
service.Spec.AllocateLoadBalancerNodePorts = utilpointer.BoolPtr(true)
|
||||
service.Spec.AllocateLoadBalancerNodePorts = utilpointer.Bool(true)
|
||||
service, err = client.CoreV1().Services(ns.Name).Update(context.TODO(), service, metav1.UpdateOptions{})
|
||||
if err != nil {
|
||||
t.Fatalf("Error updating test service: %v", err)
|
||||
@ -264,7 +264,7 @@ func Test_ServiceLoadBalancerEnableLoadBalancerClass(t *testing.T) {
|
||||
Ports: []corev1.ServicePort{{
|
||||
Port: int32(80),
|
||||
}},
|
||||
LoadBalancerClass: utilpointer.StringPtr("test.com/test"),
|
||||
LoadBalancerClass: utilpointer.String("test.com/test"),
|
||||
},
|
||||
}
|
||||
|
||||
@ -310,7 +310,7 @@ func Test_SetLoadBalancerClassThenUpdateLoadBalancerClass(t *testing.T) {
|
||||
Ports: []corev1.ServicePort{{
|
||||
Port: int32(80),
|
||||
}},
|
||||
LoadBalancerClass: utilpointer.StringPtr("test.com/test"),
|
||||
LoadBalancerClass: utilpointer.String("test.com/test"),
|
||||
},
|
||||
}
|
||||
|
||||
@ -319,7 +319,7 @@ func Test_SetLoadBalancerClassThenUpdateLoadBalancerClass(t *testing.T) {
|
||||
t.Fatalf("Error creating test service: %v", err)
|
||||
}
|
||||
|
||||
service.Spec.LoadBalancerClass = utilpointer.StringPtr("test.com/update")
|
||||
service.Spec.LoadBalancerClass = utilpointer.String("test.com/update")
|
||||
_, err = client.CoreV1().Services(ns.Name).Update(ctx, service, metav1.UpdateOptions{})
|
||||
if err == nil {
|
||||
t.Fatal("Error: updating test service load balancer class should throw error, field is immutable")
|
||||
@ -369,7 +369,7 @@ func Test_UpdateLoadBalancerWithLoadBalancerClass(t *testing.T) {
|
||||
t.Fatalf("Error creating test service: %v", err)
|
||||
}
|
||||
|
||||
service.Spec.LoadBalancerClass = utilpointer.StringPtr("test.com/test")
|
||||
service.Spec.LoadBalancerClass = utilpointer.String("test.com/test")
|
||||
_, err = client.CoreV1().Services(ns.Name).Update(ctx, service, metav1.UpdateOptions{})
|
||||
if err == nil {
|
||||
t.Fatal("Error: updating test service load balancer class should throw error, field is immutable")
|
||||
|
@ -95,7 +95,7 @@ func TestStorageVersionGarbageCollection(t *testing.T) {
|
||||
t.Errorf("unexpected storage version entry id, expected %v, got: %v",
|
||||
expectedID, sv.Status.StorageVersions[0].APIServerID)
|
||||
}
|
||||
assertCommonEncodingVersion(t, kubeclient, pointer.StringPtr(idToVersion(t, idA)))
|
||||
assertCommonEncodingVersion(t, kubeclient, pointer.String(idToVersion(t, idA)))
|
||||
if err := kubeclient.InternalV1alpha1().StorageVersions().Delete(
|
||||
context.TODO(), svName, metav1.DeleteOptions{}); err != nil {
|
||||
t.Fatalf("failed to cleanup valid storage version: %v", err)
|
||||
@ -108,7 +108,7 @@ func TestStorageVersionGarbageCollection(t *testing.T) {
|
||||
assertCommonEncodingVersion(t, kubeclient, nil)
|
||||
deleteTestAPIServerIdentityLease(t, kubeclient, idA)
|
||||
assertStorageVersionEntries(t, kubeclient, 1, idB)
|
||||
assertCommonEncodingVersion(t, kubeclient, pointer.StringPtr(idToVersion(t, idB)))
|
||||
assertCommonEncodingVersion(t, kubeclient, pointer.String(idToVersion(t, idB)))
|
||||
})
|
||||
|
||||
t.Run("deleting an id should delete a storage version object that it owns entirely", func(t *testing.T) {
|
||||
@ -135,7 +135,7 @@ func createTestStorageVersion(t *testing.T, client kubernetes.Interface, ids ...
|
||||
// every id is unique and creates a different version. We know we have a common encoding
|
||||
// version when there is only one id. Pick it
|
||||
if len(ids) == 1 {
|
||||
sv.Status.CommonEncodingVersion = pointer.StringPtr(sv.Status.StorageVersions[0].EncodingVersion)
|
||||
sv.Status.CommonEncodingVersion = pointer.String(sv.Status.StorageVersions[0].EncodingVersion)
|
||||
}
|
||||
|
||||
createdSV, err := client.InternalV1alpha1().StorageVersions().Create(context.TODO(), sv, metav1.CreateOptions{})
|
||||
@ -176,8 +176,8 @@ func createTestAPIServerIdentityLease(t *testing.T, client kubernetes.Interface,
|
||||
},
|
||||
},
|
||||
Spec: coordinationv1.LeaseSpec{
|
||||
HolderIdentity: pointer.StringPtr(name),
|
||||
LeaseDurationSeconds: pointer.Int32Ptr(3600),
|
||||
HolderIdentity: pointer.String(name),
|
||||
LeaseDurationSeconds: pointer.Int32(3600),
|
||||
// create fresh leases
|
||||
AcquireTime: &metav1.MicroTime{Time: time.Now()},
|
||||
RenewTime: &metav1.MicroTime{Time: time.Now()},
|
||||
|
@ -505,7 +505,7 @@ func InitTestSchedulerWithNS(t *testing.T, nsPrefix string, opts ...scheduler.Op
|
||||
func InitTestDisablePreemption(t *testing.T, nsPrefix string) *TestContext {
|
||||
cfg := configtesting.V1beta3ToInternalWithDefaults(t, v1beta3.KubeSchedulerConfiguration{
|
||||
Profiles: []v1beta3.KubeSchedulerProfile{{
|
||||
SchedulerName: pointer.StringPtr(v1.DefaultSchedulerName),
|
||||
SchedulerName: pointer.String(v1.DefaultSchedulerName),
|
||||
Plugins: &v1beta3.Plugins{
|
||||
PostFilter: v1beta3.PluginSet{
|
||||
Disabled: []v1beta3.Plugin{
|
||||
|
Loading…
Reference in New Issue
Block a user