diff --git a/api/v1alpha5/conversion.go b/api/v1alpha5/conversion.go index 79b282dfeb..b0e0d9eea6 100644 --- a/api/v1alpha5/conversion.go +++ b/api/v1alpha5/conversion.go @@ -21,7 +21,7 @@ import ( "strings" conversion "k8s.io/apimachinery/pkg/conversion" - "k8s.io/utils/pointer" + "k8s.io/utils/ptr" utilconversion "sigs.k8s.io/cluster-api/util/conversion" ctrlconversion "sigs.k8s.io/controller-runtime/pkg/conversion" @@ -301,7 +301,7 @@ func Convert_v1alpha5_OpenStackClusterSpec_To_v1beta1_OpenStackClusterSpec(in *O } if in.APIServerPort != 0 { - out.APIServerPort = pointer.Int(in.APIServerPort) + out.APIServerPort = ptr.To(in.APIServerPort) } return nil @@ -333,10 +333,10 @@ func Convert_v1beta1_PortOpts_To_v1alpha5_PortOpts(in *infrav1.PortOpts, out *Po if in.Profile != nil { out.Profile = make(map[string]string) - if pointer.BoolDeref(in.Profile.OVSHWOffload, false) { + if ptr.Deref(in.Profile.OVSHWOffload, false) { (out.Profile)["capabilities"] = "[\"switchdev\"]" } - if pointer.BoolDeref(in.Profile.TrustedVF, false) { + if ptr.Deref(in.Profile.TrustedVF, false) { (out.Profile)["trusted"] = trueString } } @@ -435,10 +435,10 @@ func Convert_v1alpha5_PortOpts_To_v1beta1_PortOpts(in *PortOpts, out *infrav1.Po // Profile is now a struct in v1beta1. if strings.Contains(in.Profile["capabilities"], "switchdev") { - out.Profile.OVSHWOffload = pointer.Bool(true) + out.Profile.OVSHWOffload = ptr.To(true) } if in.Profile["trusted"] == trueString { - out.Profile.TrustedVF = pointer.Bool(true) + out.Profile.TrustedVF = ptr.To(true) } return nil } @@ -608,21 +608,21 @@ func Convert_Map_string_To_Interface_To_v1beta1_BindingProfile(in map[string]str for k, v := range in { if k == "capabilities" { if strings.Contains(v, "switchdev") { - out.OVSHWOffload = pointer.Bool(true) + out.OVSHWOffload = ptr.To(true) } } if k == "trusted" && v == trueString { - out.TrustedVF = pointer.Bool(true) + out.TrustedVF = ptr.To(true) } } return nil } func Convert_v1beta1_BindingProfile_To_Map_string_To_Interface(in *infrav1.BindingProfile, out map[string]string, _ conversion.Scope) error { - if pointer.BoolDeref(in.OVSHWOffload, false) { + if ptr.Deref(in.OVSHWOffload, false) { (out)["capabilities"] = "[\"switchdev\"]" } - if pointer.BoolDeref(in.TrustedVF, false) { + if ptr.Deref(in.TrustedVF, false) { (out)["trusted"] = trueString } return nil diff --git a/api/v1alpha6/conversion_test.go b/api/v1alpha6/conversion_test.go index 67a394d801..d5f500e0b1 100644 --- a/api/v1alpha6/conversion_test.go +++ b/api/v1alpha6/conversion_test.go @@ -27,7 +27,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" runtimeserializer "k8s.io/apimachinery/pkg/runtime/serializer" - "k8s.io/utils/pointer" + "k8s.io/utils/ptr" utilconversion "sigs.k8s.io/cluster-api/util/conversion" "sigs.k8s.io/controller-runtime/pkg/conversion" @@ -221,7 +221,7 @@ func TestNetworksToPorts(t *testing.T) { Ports: []infrav1.PortOpts{ { Network: &infrav1.NetworkParam{ - ID: pointer.String(networkuuid), + ID: ptr.To(networkuuid), }, }, }, @@ -282,12 +282,12 @@ func TestNetworksToPorts(t *testing.T) { Ports: []infrav1.PortOpts{ { Network: &infrav1.NetworkParam{ - ID: pointer.String(networkuuid), + ID: ptr.To(networkuuid), }, FixedIPs: []infrav1.FixedIP{ { Subnet: &infrav1.SubnetParam{ - ID: pointer.String(subnetuuid), + ID: ptr.To(subnetuuid), }, }, }, @@ -326,7 +326,7 @@ func TestNetworksToPorts(t *testing.T) { Ports: []infrav1.PortOpts{ { Network: &infrav1.NetworkParam{ - ID: pointer.String(networkuuid), + ID: ptr.To(networkuuid), }, FixedIPs: []infrav1.FixedIP{ { @@ -388,19 +388,19 @@ func TestNetworksToPorts(t *testing.T) { Ports: []infrav1.PortOpts{ { Network: &infrav1.NetworkParam{ - ID: pointer.String(networkuuid), + ID: ptr.To(networkuuid), }, FixedIPs: []infrav1.FixedIP{ { Subnet: &infrav1.SubnetParam{ - ID: pointer.String(subnetuuid), + ID: ptr.To(subnetuuid), }, }, }, }, { Network: &infrav1.NetworkParam{ - ID: pointer.String(networkuuid), + ID: ptr.To(networkuuid), }, FixedIPs: []infrav1.FixedIP{ { @@ -465,7 +465,7 @@ func TestPortOptsConvertTo(t *testing.T) { } securityGroupFilterMerged := []infrav1.SecurityGroupParam{ {Filter: &infrav1.SecurityGroupFilter{Name: "one"}}, - {ID: pointer.String("654cba")}, + {ID: ptr.To("654cba")}, {ID: &uuids[0]}, {ID: &uuids[1]}, } @@ -474,8 +474,8 @@ func TestPortOptsConvertTo(t *testing.T) { "trusted": "true", } convertedPortProfile := infrav1.BindingProfile{ - OVSHWOffload: pointer.Bool(true), - TrustedVF: pointer.Bool(true), + OVSHWOffload: ptr.To(true), + TrustedVF: ptr.To(true), } tests := []struct { @@ -597,31 +597,31 @@ func TestMachineConversionControllerSpecFields(t *testing.T) { { name: "Set ProviderID", modifyUp: func(up *infrav1.OpenStackMachine) { - up.Spec.ProviderID = pointer.String("new-provider-id") + up.Spec.ProviderID = ptr.To("new-provider-id") }, testAfter: func(after *OpenStackMachine) { - g.Expect(after.Spec.ProviderID).To(gomega.Equal(pointer.String("new-provider-id"))) + g.Expect(after.Spec.ProviderID).To(gomega.Equal(ptr.To("new-provider-id"))) }, expectNetworkDiff: false, }, { name: "Set InstanceID", modifyUp: func(up *infrav1.OpenStackMachine) { - up.Status.InstanceID = pointer.String("new-instance-id") + up.Status.InstanceID = ptr.To("new-instance-id") }, testAfter: func(after *OpenStackMachine) { - g.Expect(after.Spec.InstanceID).To(gomega.Equal(pointer.String("new-instance-id"))) + g.Expect(after.Spec.InstanceID).To(gomega.Equal(ptr.To("new-instance-id"))) }, expectNetworkDiff: false, }, { name: "Set ProviderID and non-ignored change", modifyUp: func(up *infrav1.OpenStackMachine) { - up.Spec.ProviderID = pointer.String("new-provider-id") + up.Spec.ProviderID = ptr.To("new-provider-id") up.Spec.Flavor = "new-flavor" }, testAfter: func(after *OpenStackMachine) { - g.Expect(after.Spec.ProviderID).To(gomega.Equal(pointer.String("new-provider-id"))) + g.Expect(after.Spec.ProviderID).To(gomega.Equal(ptr.To("new-provider-id"))) g.Expect(after.Spec.Flavor).To(gomega.Equal("new-flavor")) }, expectNetworkDiff: true, diff --git a/api/v1alpha6/openstackmachine_types.go b/api/v1alpha6/openstackmachine_types.go index 9048c181ca..9f306cba1d 100644 --- a/api/v1alpha6/openstackmachine_types.go +++ b/api/v1alpha6/openstackmachine_types.go @@ -19,7 +19,7 @@ package v1alpha6 import ( corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/utils/pointer" + "k8s.io/utils/ptr" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" "sigs.k8s.io/cluster-api/errors" ) @@ -184,7 +184,7 @@ func (r *OpenStackMachine) SetConditions(conditions clusterv1.Conditions) { // SetFailure sets the OpenStackMachine status failure reason and failure message. func (r *OpenStackMachine) SetFailure(failureReason errors.MachineStatusError, failureMessage error) { r.Status.FailureReason = &failureReason - r.Status.FailureMessage = pointer.String(failureMessage.Error()) + r.Status.FailureMessage = ptr.To(failureMessage.Error()) } func init() { diff --git a/api/v1alpha6/types_conversion.go b/api/v1alpha6/types_conversion.go index b855b9e473..ce7d2030c9 100644 --- a/api/v1alpha6/types_conversion.go +++ b/api/v1alpha6/types_conversion.go @@ -21,7 +21,7 @@ import ( "strings" apiconversion "k8s.io/apimachinery/pkg/conversion" - "k8s.io/utils/pointer" + "k8s.io/utils/ptr" infrav1 "sigs.k8s.io/cluster-api-provider-openstack/api/v1beta1" optional "sigs.k8s.io/cluster-api-provider-openstack/pkg/utils/optional" @@ -387,10 +387,10 @@ func Convert_v1beta1_PortOpts_To_v1alpha6_PortOpts(in *infrav1.PortOpts, out *Po if in.Profile != nil { out.Profile = make(map[string]string) - if pointer.BoolDeref(in.Profile.OVSHWOffload, false) { + if ptr.Deref(in.Profile.OVSHWOffload, false) { (out.Profile)["capabilities"] = "[\"switchdev\"]" } - if pointer.BoolDeref(in.Profile.TrustedVF, false) { + if ptr.Deref(in.Profile.TrustedVF, false) { (out.Profile)["trusted"] = trueString } } @@ -402,21 +402,21 @@ func Convert_Map_string_To_Interface_To_v1beta1_BindingProfile(in map[string]str for k, v := range in { if k == "capabilities" { if strings.Contains(v, "switchdev") { - out.OVSHWOffload = pointer.Bool(true) + out.OVSHWOffload = ptr.To(true) } } if k == "trusted" && v == trueString { - out.TrustedVF = pointer.Bool(true) + out.TrustedVF = ptr.To(true) } } return nil } func Convert_v1beta1_BindingProfile_To_Map_string_To_Interface(in *infrav1.BindingProfile, out map[string]string, _ apiconversion.Scope) error { - if pointer.BoolDeref(in.OVSHWOffload, false) { + if ptr.Deref(in.OVSHWOffload, false) { (out)["capabilities"] = "[\"switchdev\"]" } - if pointer.BoolDeref(in.TrustedVF, false) { + if ptr.Deref(in.TrustedVF, false) { (out)["trusted"] = trueString } return nil diff --git a/api/v1alpha7/conversion_test.go b/api/v1alpha7/conversion_test.go index d44eabf604..cf3606ce5b 100644 --- a/api/v1alpha7/conversion_test.go +++ b/api/v1alpha7/conversion_test.go @@ -27,7 +27,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" runtimeserializer "k8s.io/apimachinery/pkg/runtime/serializer" - "k8s.io/utils/pointer" + "k8s.io/utils/ptr" utilconversion "sigs.k8s.io/cluster-api/util/conversion" "sigs.k8s.io/controller-runtime/pkg/conversion" @@ -201,31 +201,31 @@ func TestMachineConversionControllerSpecFields(t *testing.T) { { name: "Set ProviderID", modifyUp: func(up *infrav1.OpenStackMachine) { - up.Spec.ProviderID = pointer.String("new-provider-id") + up.Spec.ProviderID = ptr.To("new-provider-id") }, testAfter: func(g gomega.Gomega, after *OpenStackMachine) { - g.Expect(after.Spec.ProviderID).To(gomega.Equal(pointer.String("new-provider-id"))) + g.Expect(after.Spec.ProviderID).To(gomega.Equal(ptr.To("new-provider-id"))) }, expectIdentityRefDiff: false, }, { name: "Set InstanceID", modifyUp: func(up *infrav1.OpenStackMachine) { - up.Status.InstanceID = pointer.String("new-instance-id") + up.Status.InstanceID = ptr.To("new-instance-id") }, testAfter: func(g gomega.Gomega, after *OpenStackMachine) { - g.Expect(after.Spec.InstanceID).To(gomega.Equal(pointer.String("new-instance-id"))) + g.Expect(after.Spec.InstanceID).To(gomega.Equal(ptr.To("new-instance-id"))) }, expectIdentityRefDiff: false, }, { name: "Set ProviderID and non-ignored change", modifyUp: func(up *infrav1.OpenStackMachine) { - up.Spec.ProviderID = pointer.String("new-provider-id") + up.Spec.ProviderID = ptr.To("new-provider-id") up.Spec.Flavor = "new-flavor" }, testAfter: func(g gomega.Gomega, after *OpenStackMachine) { - g.Expect(after.Spec.ProviderID).To(gomega.Equal(pointer.String("new-provider-id"))) + g.Expect(after.Spec.ProviderID).To(gomega.Equal(ptr.To("new-provider-id"))) g.Expect(after.Spec.Flavor).To(gomega.Equal("new-flavor")) }, expectIdentityRefDiff: true, diff --git a/api/v1alpha7/openstackmachine_types.go b/api/v1alpha7/openstackmachine_types.go index 1cc5378573..043359db7a 100644 --- a/api/v1alpha7/openstackmachine_types.go +++ b/api/v1alpha7/openstackmachine_types.go @@ -19,7 +19,7 @@ package v1alpha7 import ( corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/utils/pointer" + "k8s.io/utils/ptr" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" "sigs.k8s.io/cluster-api/errors" ) @@ -179,7 +179,7 @@ func (r *OpenStackMachine) SetConditions(conditions clusterv1.Conditions) { // SetFailure sets the OpenStackMachine status failure reason and failure message. func (r *OpenStackMachine) SetFailure(failureReason errors.MachineStatusError, failureMessage error) { r.Status.FailureReason = &failureReason - r.Status.FailureMessage = pointer.String(failureMessage.Error()) + r.Status.FailureMessage = ptr.To(failureMessage.Error()) } func init() { diff --git a/api/v1beta1/conversion.go b/api/v1beta1/conversion.go index 250483a0f0..d442dc0f1d 100644 --- a/api/v1beta1/conversion.go +++ b/api/v1beta1/conversion.go @@ -19,7 +19,7 @@ package v1beta1 import ( "strings" - "k8s.io/utils/pointer" + "k8s.io/utils/ptr" ) // Hub marks OpenStackCluster as a conversion hub. @@ -53,20 +53,20 @@ func LegacyCalicoSecurityGroupRules() []SecurityGroupRuleSpec { return []SecurityGroupRuleSpec{ { Name: "BGP (calico)", - Description: pointer.String("Created by cluster-api-provider-openstack API conversion - BGP (calico)"), + Description: ptr.To("Created by cluster-api-provider-openstack API conversion - BGP (calico)"), Direction: "ingress", - EtherType: pointer.String("IPv4"), - PortRangeMin: pointer.Int(179), - PortRangeMax: pointer.Int(179), - Protocol: pointer.String("tcp"), + EtherType: ptr.To("IPv4"), + PortRangeMin: ptr.To(179), + PortRangeMax: ptr.To(179), + Protocol: ptr.To("tcp"), RemoteManagedGroups: []ManagedSecurityGroupName{"controlplane", "worker"}, }, { Name: "IP-in-IP (calico)", - Description: pointer.String("Created by cluster-api-provider-openstack API conversion - IP-in-IP (calico)"), + Description: ptr.To("Created by cluster-api-provider-openstack API conversion - IP-in-IP (calico)"), Direction: "ingress", - EtherType: pointer.String("IPv4"), - Protocol: pointer.String("4"), + EtherType: ptr.To("IPv4"), + Protocol: ptr.To("4"), RemoteManagedGroups: []ManagedSecurityGroupName{"controlplane", "worker"}, }, } diff --git a/api/v1beta1/openstackmachine_types.go b/api/v1beta1/openstackmachine_types.go index 2dc57b4312..4a6e798426 100644 --- a/api/v1beta1/openstackmachine_types.go +++ b/api/v1beta1/openstackmachine_types.go @@ -19,7 +19,7 @@ package v1beta1 import ( corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/utils/pointer" + "k8s.io/utils/ptr" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" "sigs.k8s.io/cluster-api/errors" @@ -206,7 +206,7 @@ func (r *OpenStackMachine) SetConditions(conditions clusterv1.Conditions) { // SetFailure sets the OpenStackMachine status failure reason and failure message. func (r *OpenStackMachine) SetFailure(failureReason errors.MachineStatusError, failureMessage error) { r.Status.FailureReason = &failureReason - r.Status.FailureMessage = pointer.String(failureMessage.Error()) + r.Status.FailureMessage = ptr.To(failureMessage.Error()) } func init() { diff --git a/api/v1beta1/types.go b/api/v1beta1/types.go index b141d2731b..46dba26406 100644 --- a/api/v1beta1/types.go +++ b/api/v1beta1/types.go @@ -17,7 +17,7 @@ limitations under the License. package v1beta1 import ( - "k8s.io/utils/pointer" + "k8s.io/utils/ptr" "sigs.k8s.io/cluster-api-provider-openstack/pkg/utils/optional" ) @@ -822,7 +822,7 @@ type APIServerLoadBalancer struct { } func (s *APIServerLoadBalancer) IsZero() bool { - return s == nil || ((s.Enabled == nil || !*s.Enabled) && len(s.AdditionalPorts) == 0 && len(s.AllowedCIDRs) == 0 && pointer.StringDeref(s.Provider, "") == "") + return s == nil || ((s.Enabled == nil || !*s.Enabled) && len(s.AdditionalPorts) == 0 && len(s.AllowedCIDRs) == 0 && ptr.Deref(s.Provider, "") == "") } func (s *APIServerLoadBalancer) IsEnabled() bool { diff --git a/controllers/openstackcluster_controller.go b/controllers/openstackcluster_controller.go index 58ab0d00d4..7ba565cb90 100644 --- a/controllers/openstackcluster_controller.go +++ b/controllers/openstackcluster_controller.go @@ -29,7 +29,7 @@ import ( apierrors "k8s.io/apimachinery/pkg/api/errors" kerrors "k8s.io/apimachinery/pkg/util/errors" "k8s.io/client-go/tools/record" - "k8s.io/utils/pointer" + "k8s.io/utils/ptr" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" capierrors "sigs.k8s.io/cluster-api/errors" "sigs.k8s.io/cluster-api/util" @@ -382,7 +382,7 @@ func reconcileNormal(scope *scope.WithLogger, cluster *clusterv1.Cluster, openSt openStackCluster.Status.FailureDomains = make(clusterv1.FailureDomains) for _, az := range availabilityZones { // By default, the AZ is used or not used for control plane nodes depending on the flag - found := !pointer.BoolDeref(openStackCluster.Spec.ControlPlaneOmitAvailabilityZone, false) + found := !ptr.Deref(openStackCluster.Spec.ControlPlaneOmitAvailabilityZone, false) // If explicit AZs for control plane nodes are given, they override the value if len(openStackCluster.Spec.ControlPlaneAvailabilityZones) > 0 { found = contains(openStackCluster.Spec.ControlPlaneAvailabilityZones, az.ZoneName) @@ -838,7 +838,7 @@ func reconcileControlPlaneEndpoint(scope *scope.WithLogger, networkingService *n // API server load balancer is disabled, but floating IP is not. Create // a floating IP to be attached directly to a control plane host. - case !pointer.BoolDeref(openStackCluster.Spec.DisableAPIServerFloatingIP, false): + case !ptr.Deref(openStackCluster.Spec.DisableAPIServerFloatingIP, false): fp, err := networkingService.GetOrCreateFloatingIP(openStackCluster, openStackCluster, clusterResourceName, openStackCluster.Spec.APIServerFloatingIP) if err != nil { handleUpdateOSCError(openStackCluster, fmt.Errorf("floating IP cannot be got or created: %w", err)) @@ -916,7 +916,7 @@ func (r *OpenStackClusterReconciler) SetupWithManager(ctx context.Context, mgr c func handleUpdateOSCError(openstackCluster *infrav1.OpenStackCluster, message error) { err := capierrors.UpdateClusterError openstackCluster.Status.FailureReason = &err - openstackCluster.Status.FailureMessage = pointer.String(message.Error()) + openstackCluster.Status.FailureMessage = ptr.To(message.Error()) } // getClusterSubnets retrieves the subnets based on the Subnet filters specified on OpenstackCluster. diff --git a/controllers/openstackcluster_controller_test.go b/controllers/openstackcluster_controller_test.go index 62a7f6fcfa..21dc0dbe3d 100644 --- a/controllers/openstackcluster_controller_test.go +++ b/controllers/openstackcluster_controller_test.go @@ -34,7 +34,7 @@ import ( . "github.com/onsi/gomega" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" - "k8s.io/utils/pointer" + "k8s.io/utils/ptr" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" "sigs.k8s.io/cluster-api/test/framework" "sigs.k8s.io/cluster-api/util/annotations" @@ -64,7 +64,7 @@ var _ = Describe("OpenStackCluster controller", func() { bastionSpec := infrav1.OpenStackMachineSpec{ Image: infrav1.ImageParam{ Filter: &infrav1.ImageFilter{ - Name: pointer.String("fake-name"), + Name: ptr.To("fake-name"), }, }, } @@ -199,7 +199,7 @@ var _ = Describe("OpenStackCluster controller", func() { It("should be able to reconcile when bastion is explicitly disabled and does not exist", func() { testCluster.SetName("no-bastion-explicit") testCluster.Spec = infrav1.OpenStackClusterSpec{ - Bastion: &infrav1.Bastion{Enabled: pointer.Bool(false)}, + Bastion: &infrav1.Bastion{Enabled: ptr.To(false)}, } err := k8sClient.Create(ctx, testCluster) Expect(err).To(BeNil()) @@ -231,7 +231,7 @@ var _ = Describe("OpenStackCluster controller", func() { testCluster.SetName("adopt-existing-bastion") testCluster.Spec = infrav1.OpenStackClusterSpec{ Bastion: &infrav1.Bastion{ - Enabled: pointer.Bool(true), + Enabled: ptr.To(true), Spec: &bastionSpec, }, } @@ -314,7 +314,7 @@ var _ = Describe("OpenStackCluster controller", func() { testCluster.SetName("requeue-bastion") testCluster.Spec = infrav1.OpenStackClusterSpec{ Bastion: &infrav1.Bastion{ - Enabled: pointer.Bool(true), + Enabled: ptr.To(true), Spec: &bastionSpec, }, } @@ -396,7 +396,7 @@ var _ = Describe("OpenStackCluster controller", func() { testCluster.SetName("requeue-bastion") testCluster.Spec = infrav1.OpenStackClusterSpec{ Bastion: &infrav1.Bastion{ - Enabled: pointer.Bool(true), + Enabled: ptr.To(true), Spec: &bastionSpec, }, } @@ -517,16 +517,16 @@ var _ = Describe("OpenStackCluster controller", func() { testCluster.SetName("subnet-filtering") testCluster.Spec = infrav1.OpenStackClusterSpec{ Bastion: &infrav1.Bastion{ - Enabled: pointer.Bool(true), + Enabled: ptr.To(true), Spec: &bastionSpec, }, - DisableAPIServerFloatingIP: pointer.Bool(true), - APIServerFixedIP: pointer.String("10.0.0.1"), + DisableAPIServerFloatingIP: ptr.To(true), + APIServerFixedIP: ptr.To("10.0.0.1"), ExternalNetwork: &infrav1.NetworkParam{ - ID: pointer.String(externalNetworkID), + ID: ptr.To(externalNetworkID), }, Network: &infrav1.NetworkParam{ - ID: pointer.String(clusterNetworkID), + ID: ptr.To(clusterNetworkID), }, } testCluster.Status = infrav1.OpenStackClusterStatus{ @@ -587,16 +587,16 @@ var _ = Describe("OpenStackCluster controller", func() { testCluster.SetName("subnet-filtering") testCluster.Spec = infrav1.OpenStackClusterSpec{ Bastion: &infrav1.Bastion{ - Enabled: pointer.Bool(true), + Enabled: ptr.To(true), Spec: &bastionSpec, }, - DisableAPIServerFloatingIP: pointer.Bool(true), - APIServerFixedIP: pointer.String("10.0.0.1"), + DisableAPIServerFloatingIP: ptr.To(true), + APIServerFixedIP: ptr.To("10.0.0.1"), ExternalNetwork: &infrav1.NetworkParam{ - ID: pointer.String(externalNetworkID), + ID: ptr.To(externalNetworkID), }, Network: &infrav1.NetworkParam{ - ID: pointer.String(clusterNetworkID), + ID: ptr.To(clusterNetworkID), }, Subnets: []infrav1.SubnetParam{ {ID: &clusterSubnets[0]}, @@ -663,11 +663,11 @@ var _ = Describe("OpenStackCluster controller", func() { testCluster.SetName("subnet-filtering") testCluster.Spec = infrav1.OpenStackClusterSpec{ - DisableAPIServerFloatingIP: pointer.Bool(true), - APIServerFixedIP: pointer.String("10.0.0.1"), - DisableExternalNetwork: pointer.Bool(true), + DisableAPIServerFloatingIP: ptr.To(true), + APIServerFixedIP: ptr.To("10.0.0.1"), + DisableExternalNetwork: ptr.To(true), Subnets: []infrav1.SubnetParam{ - {ID: pointer.String(clusterSubnetID)}, + {ID: ptr.To(clusterSubnetID)}, }, } err := k8sClient.Create(ctx, testCluster) @@ -758,7 +758,7 @@ func Test_getAPIServerPort(t *testing.T) { name: "with API server port", openStackCluster: &infrav1.OpenStackCluster{ Spec: infrav1.OpenStackClusterSpec{ - APIServerPort: pointer.Int(6445), + APIServerPort: ptr.To(6445), }, }, want: 6445, diff --git a/controllers/openstackfloatingippool_controller.go b/controllers/openstackfloatingippool_controller.go index 209c9338b9..b739fb25e7 100644 --- a/controllers/openstackfloatingippool_controller.go +++ b/controllers/openstackfloatingippool_controller.go @@ -28,7 +28,7 @@ import ( "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/util/wait" "k8s.io/client-go/tools/record" - "k8s.io/utils/pointer" + "k8s.io/utils/ptr" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" ipamv1 "sigs.k8s.io/cluster-api/exp/ipam/api/v1beta1" "sigs.k8s.io/cluster-api/util/conditions" @@ -168,7 +168,7 @@ func (r *OpenStackFloatingIPPoolReconciler) Reconcile(ctx context.Context, req c Name: claim.Name, }, PoolRef: corev1.TypedLocalObjectReference{ - APIGroup: pointer.String(infrav1alpha1.GroupVersion.Group), + APIGroup: ptr.To(infrav1alpha1.GroupVersion.Group), Kind: pool.Kind, Name: pool.Name, }, @@ -352,7 +352,7 @@ func (r *OpenStackFloatingIPPoolReconciler) getIP(ctx context.Context, scope *sc } pool.Status.FailedIPs = append(pool.Status.FailedIPs, ip) } - maxIPs := pointer.IntDeref(pool.Spec.MaxIPs, -1) + maxIPs := ptr.Deref(pool.Spec.MaxIPs, -1) // If we have reached the maximum number of IPs, we should not create more IPs if maxIPs != -1 && len(pool.Status.ClaimedIPs) >= maxIPs { scope.Logger().Info("MaxIPs reached", "pool", pool.Name) diff --git a/controllers/openstackmachine_controller.go b/controllers/openstackmachine_controller.go index 12eb53d465..a1869e3b51 100644 --- a/controllers/openstackmachine_controller.go +++ b/controllers/openstackmachine_controller.go @@ -30,7 +30,7 @@ import ( "k8s.io/apimachinery/pkg/types" kerrors "k8s.io/apimachinery/pkg/util/errors" "k8s.io/client-go/tools/record" - "k8s.io/utils/pointer" + "k8s.io/utils/ptr" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" capierrors "sigs.k8s.io/cluster-api/errors" ipamv1 "sigs.k8s.io/cluster-api/exp/ipam/api/v1beta1" @@ -619,7 +619,7 @@ func (r *OpenStackMachineReconciler) reconcileNormal(ctx context.Context, scope } state := instanceStatus.State() - openStackMachine.Status.InstanceID = pointer.String(instanceStatus.ID()) + openStackMachine.Status.InstanceID = ptr.To(instanceStatus.ID()) openStackMachine.Status.InstanceState = &state instanceNS, err := instanceStatus.NetworkStatus() @@ -652,7 +652,7 @@ func (r *OpenStackMachineReconciler) reconcileNormal(ctx context.Context, scope conditions.MarkTrue(openStackMachine, infrav1.InstanceReadyCondition) // Set properties required by CAPI machine controller - openStackMachine.Spec.ProviderID = pointer.String(fmt.Sprintf("openstack:///%s", instanceStatus.ID())) + openStackMachine.Spec.ProviderID = ptr.To(fmt.Sprintf("openstack:///%s", instanceStatus.ID())) openStackMachine.Status.Ready = true case infrav1.InstanceStateError: // If the machine has a NodeRef then it must have been working at some point, @@ -715,7 +715,7 @@ func (r *OpenStackMachineReconciler) reconcileAPIServerLoadBalancer(scope *scope conditions.MarkFalse(openStackMachine, infrav1.APIServerIngressReadyCondition, infrav1.LoadBalancerMemberErrorReason, clusterv1.ConditionSeverityError, "Reconciling load balancer member failed: %v", err) return fmt.Errorf("reconcile load balancer member: %w", err) } - } else if !pointer.BoolDeref(openStackCluster.Spec.DisableAPIServerFloatingIP, false) { + } else if !ptr.Deref(openStackCluster.Spec.DisableAPIServerFloatingIP, false) { var floatingIPAddress *string switch { case openStackCluster.Spec.ControlPlaneEndpoint != nil && openStackCluster.Spec.ControlPlaneEndpoint.IsValid(): diff --git a/controllers/openstackmachine_controller_test.go b/controllers/openstackmachine_controller_test.go index c77220bc4c..6197dca779 100644 --- a/controllers/openstackmachine_controller_test.go +++ b/controllers/openstackmachine_controller_test.go @@ -33,7 +33,7 @@ import ( "github.com/gophercloud/gophercloud/openstack/networking/v2/ports" . "github.com/onsi/gomega" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/utils/pointer" + "k8s.io/utils/ptr" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" infrav1 "sigs.k8s.io/cluster-api-provider-openstack/api/v1beta1" @@ -80,7 +80,7 @@ func getDefaultOpenStackCluster() *infrav1.OpenStackCluster { func getDefaultMachine() *clusterv1.Machine { return &clusterv1.Machine{ Spec: clusterv1.MachineSpec{ - FailureDomain: pointer.String(failureDomain), + FailureDomain: ptr.To(failureDomain), }, } } @@ -97,15 +97,15 @@ func getDefaultOpenStackMachine() *infrav1.OpenStackMachine { // FloatingIP is only used by the cluster controller for the Bastion // TODO: Test Networks, Ports, Subnet, and Trunk separately Flavor: flavorName, - Image: infrav1.ImageParam{ID: pointer.String(imageUUID)}, + Image: infrav1.ImageParam{ID: ptr.To(imageUUID)}, SSHKeyName: sshKeyName, Tags: []string{"test-tag"}, ServerMetadata: []infrav1.ServerMetadata{ {Key: "test-metadata", Value: "test-value"}, }, - ConfigDrive: pointer.Bool(true), + ConfigDrive: ptr.To(true), SecurityGroups: []infrav1.SecurityGroupParam{}, - ServerGroup: &infrav1.ServerGroupParam{ID: pointer.String(serverGroupUUID)}, + ServerGroup: &infrav1.ServerGroupParam{ID: ptr.To(serverGroupUUID)}, }, Status: infrav1.OpenStackMachineStatus{ Resolved: &infrav1.ResolvedMachineSpec{ @@ -126,8 +126,8 @@ func getDefaultInstanceSpec() *compute.InstanceSpec { Metadata: map[string]string{ "test-metadata": "test-value", }, - ConfigDrive: *pointer.Bool(true), - FailureDomain: *pointer.String(failureDomain), + ConfigDrive: *ptr.To(true), + FailureDomain: *ptr.To(failureDomain), ServerGroupID: serverGroupUUID, Tags: []string{"test-tag"}, } @@ -243,7 +243,7 @@ func Test_reconcileDelete(t *testing.T) { defaultImage := infrav1.ImageParam{ Filter: &infrav1.ImageFilter{ - Name: pointer.String(imageName), + Name: ptr.To(imageName), }, } @@ -344,7 +344,7 @@ func Test_reconcileDelete(t *testing.T) { Image: defaultImage, }, Status: infrav1.OpenStackMachineStatus{ - InstanceID: pointer.String(instanceUUID), + InstanceID: ptr.To(instanceUUID), Resolved: &infrav1.ResolvedMachineSpec{ ImageID: imageUUID, Ports: defaultResolvedPorts, @@ -370,7 +370,7 @@ func Test_reconcileDelete(t *testing.T) { }, }, Status: infrav1.OpenStackMachineStatus{ - InstanceID: pointer.String(instanceUUID), + InstanceID: ptr.To(instanceUUID), Resolved: &infrav1.ResolvedMachineSpec{ ImageID: imageUUID, Ports: defaultResolvedPorts, @@ -426,7 +426,7 @@ func Test_reconcileDelete(t *testing.T) { // Unlike resolved and resources, // instanceID will have been converted // from the previous API version. - InstanceID: pointer.String(instanceUUID), + InstanceID: ptr.To(instanceUUID), }, }, expect: func(r *recorders) { diff --git a/controllers/suite_test.go b/controllers/suite_test.go index 81727efa24..d4497275b7 100644 --- a/controllers/suite_test.go +++ b/controllers/suite_test.go @@ -31,7 +31,7 @@ import ( "k8s.io/apimachinery/pkg/types" "k8s.io/client-go/kubernetes/scheme" "k8s.io/client-go/rest" - "k8s.io/utils/pointer" + "k8s.io/utils/ptr" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" "sigs.k8s.io/cluster-api/test/framework" "sigs.k8s.io/controller-runtime/pkg/client" @@ -150,7 +150,7 @@ var _ = Describe("When calling getOrCreate", func() { machine := &clusterv1.Machine{} openStackMachine := &infrav1.OpenStackMachine{ Status: infrav1.OpenStackMachineStatus{ - InstanceID: pointer.String("machine-uuid"), + InstanceID: ptr.To("machine-uuid"), }, } diff --git a/go.mod b/go.mod index c2bfc1a442..917ee16d17 100644 --- a/go.mod +++ b/go.mod @@ -19,14 +19,14 @@ require ( golang.org/x/crypto v0.16.0 golang.org/x/text v0.14.0 gopkg.in/ini.v1 v1.67.0 - k8s.io/api v0.28.4 - k8s.io/apiextensions-apiserver v0.28.4 - k8s.io/apimachinery v0.28.4 - k8s.io/client-go v0.28.4 - k8s.io/component-base v0.28.4 - k8s.io/klog/v2 v2.100.1 + k8s.io/api v0.29.3 + k8s.io/apiextensions-apiserver v0.29.3 + k8s.io/apimachinery v0.29.3 + k8s.io/client-go v0.29.3 + k8s.io/component-base v0.29.3 + k8s.io/klog/v2 v2.110.1 k8s.io/kubernetes v1.28.3 - k8s.io/utils v0.0.0-20230406110748-d93618cff8a2 + k8s.io/utils v0.0.0-20230726121419-3b25d923346b sigs.k8s.io/cluster-api v1.6.0 sigs.k8s.io/cluster-api/test v1.6.0 sigs.k8s.io/controller-runtime v0.16.3 @@ -64,7 +64,7 @@ require ( github.com/evanphx/json-patch v5.6.0+incompatible // indirect github.com/evanphx/json-patch/v5 v5.7.0 // indirect github.com/felixge/httpsnoop v1.0.4 // indirect - github.com/fsnotify/fsnotify v1.6.0 // indirect + github.com/fsnotify/fsnotify v1.7.0 // indirect github.com/go-logr/stdr v1.2.2 // indirect github.com/go-logr/zapr v1.2.4 // indirect github.com/go-openapi/jsonpointer v0.19.6 // indirect @@ -74,8 +74,8 @@ require ( github.com/gobuffalo/flect v1.0.2 // indirect github.com/gogo/protobuf v1.3.2 // indirect github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect - github.com/golang/protobuf v1.5.3 // indirect - github.com/google/cel-go v0.16.1 // indirect + github.com/golang/protobuf v1.5.4 // indirect + github.com/google/cel-go v0.17.7 // indirect github.com/google/gnostic-models v0.6.8 // indirect github.com/google/go-github/v53 v53.2.0 // indirect github.com/google/go-querystring v1.1.0 // indirect @@ -149,17 +149,17 @@ require ( google.golang.org/genproto/googleapis/api v0.0.0-20230913181813-007df8e322eb // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20230920204549-e6e6cdab5c13 // indirect google.golang.org/grpc v1.59.0 // indirect - google.golang.org/protobuf v1.31.0 // indirect + google.golang.org/protobuf v1.33.0 // indirect gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect - k8s.io/apiserver v0.28.4 // indirect - k8s.io/cluster-bootstrap v0.28.4 // indirect - k8s.io/kms v0.28.4 // indirect - k8s.io/kube-openapi v0.0.0-20230717233707-2695361300d9 // indirect - sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.1.2 // indirect + k8s.io/apiserver v0.29.3 // indirect + k8s.io/cluster-bootstrap v0.29.3 // indirect + k8s.io/kms v0.29.3 // indirect + k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00 // indirect + sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.28.0 // indirect sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect sigs.k8s.io/kind v0.20.0 // indirect - sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect + sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect ) diff --git a/go.sum b/go.sum index 3da2fa64fd..ef8fbd603c 100644 --- a/go.sum +++ b/go.sum @@ -142,12 +142,11 @@ github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2 github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= github.com/frankban/quicktest v1.14.4 h1:g2rn0vABPOOXmZUj+vbmUp0lPoXEMuhTpIluN0XL9UY= github.com/frankban/quicktest v1.14.4/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0= -github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY= -github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw= +github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA= +github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= -github.com/go-logr/logr v1.2.0/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-logr/logr v1.2.4/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-logr/logr v1.3.0 h1:2y3SDp0ZXuc6/cjLSZ+Q3ir+QB9T/iG5yYRXqsagWSY= @@ -202,15 +201,14 @@ github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvq github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= -github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= -github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= -github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= +github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/btree v1.0.1 h1:gK4Kx5IaGY9CD5sPJ36FHiBJ6ZXl0kilRiiCj+jdYp4= github.com/google/btree v1.0.1/go.mod h1:xXMiIv4Fb/0kKde4SpL7qlzvu5cMJDRkFDxJfI9uaxA= -github.com/google/cel-go v0.16.1 h1:3hZfSNiAU3KOiNtxuFXVp5WFy4hf/Ly3Sa4/7F8SXNo= -github.com/google/cel-go v0.16.1/go.mod h1:HXZKzB0LXqer5lHHgfWAnlYwJaQBDKMjxjulNQzhwhY= +github.com/google/cel-go v0.17.7 h1:6ebJFzu1xO2n7TLtN+UBqShGBhlD85bhvglh5DpcfqQ= +github.com/google/cel-go v0.17.7/go.mod h1:HXZKzB0LXqer5lHHgfWAnlYwJaQBDKMjxjulNQzhwhY= github.com/google/gnostic-models v0.6.8 h1:yo/ABAfM5IMRsS1VnXjTBvUb61tFIHozhlYvRgGre9I= github.com/google/gnostic-models v0.6.8/go.mod h1:5n7qKqH0f5wFt+aWF8CW6pZLLNOfYuF5OpfBSENuI8U= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= @@ -222,7 +220,6 @@ github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= @@ -263,8 +260,8 @@ github.com/gophercloud/gophercloud v1.7.0 h1:fyJGKh0LBvIZKLvBWvQdIgkaV5yTM3Jh9EY github.com/gophercloud/gophercloud v1.7.0/go.mod h1:aAVqcocTSXh2vYFZ1JTvx4EQmfgzxRcNupUfxZbBNDM= github.com/gophercloud/utils v0.0.0-20231010081019-80377eca5d56 h1:sH7xkTfYzxIEgzq1tDHIMKRh1vThOEOGNsettdEeLbE= github.com/gophercloud/utils v0.0.0-20231010081019-80377eca5d56/go.mod h1:VSalo4adEk+3sNkmVJLnhHoOyOYYS8sTWLG4mv5BKto= -github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc= -github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= +github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc= +github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 h1:+9834+KizmvFV7pXQGSXQTsaWhq2GjuNUt0aUU0YBYw= github.com/grpc-ecosystem/go-grpc-middleware v1.3.0/go.mod h1:z0ButlSOZa5vEBq9m2m2hlwIgKw+rp3sdCBRoJY+30Y= github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 h1:Ovs26xHkKqVztRpIrF/92BcuyuQ/YW4NSIpoGtfXNho= @@ -431,22 +428,22 @@ github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9de github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= -go.etcd.io/bbolt v1.3.7 h1:j+zJOnnEjF/kyHlDDgGnVL/AIqIJPq8UoB2GSNfkUfQ= -go.etcd.io/bbolt v1.3.7/go.mod h1:N9Mkw9X8x5fupy0IKsmuqVtoGDyxsaDlbk4Rd05IAQw= +go.etcd.io/bbolt v1.3.8 h1:xs88BrvEv273UsB79e0hcVrlUWmS0a8upikMFhSyAtA= +go.etcd.io/bbolt v1.3.8/go.mod h1:N9Mkw9X8x5fupy0IKsmuqVtoGDyxsaDlbk4Rd05IAQw= go.etcd.io/etcd/api/v3 v3.5.10 h1:szRajuUUbLyppkhs9K6BRtjY37l66XQQmw7oZRANE4k= go.etcd.io/etcd/api/v3 v3.5.10/go.mod h1:TidfmT4Uycad3NM/o25fG3J07odo4GBB9hoxaodFCtI= go.etcd.io/etcd/client/pkg/v3 v3.5.10 h1:kfYIdQftBnbAq8pUWFXfpuuxFSKzlmM5cSn76JByiT0= go.etcd.io/etcd/client/pkg/v3 v3.5.10/go.mod h1:DYivfIviIuQ8+/lCq4vcxuseg2P2XbHygkKwFo9fc8U= -go.etcd.io/etcd/client/v2 v2.305.9 h1:YZ2OLi0OvR0H75AcgSUajjd5uqKDKocQUqROTG11jIo= -go.etcd.io/etcd/client/v2 v2.305.9/go.mod h1:0NBdNx9wbxtEQLwAQtrDHwx58m02vXpDcgSYI2seohQ= +go.etcd.io/etcd/client/v2 v2.305.10 h1:MrmRktzv/XF8CvtQt+P6wLUlURaNpSDJHFZhe//2QE4= +go.etcd.io/etcd/client/v2 v2.305.10/go.mod h1:m3CKZi69HzilhVqtPDcjhSGp+kA1OmbNn0qamH80xjA= go.etcd.io/etcd/client/v3 v3.5.10 h1:W9TXNZ+oB3MCd/8UjxHTWK5J9Nquw9fQBLJd5ne5/Ao= go.etcd.io/etcd/client/v3 v3.5.10/go.mod h1:RVeBnDz2PUEZqTpgqwAtUd8nAPf5kjyFyND7P1VkOKc= -go.etcd.io/etcd/pkg/v3 v3.5.9 h1:6R2jg/aWd/zB9+9JxmijDKStGJAPFsX3e6BeJkMi6eQ= -go.etcd.io/etcd/pkg/v3 v3.5.9/go.mod h1:BZl0SAShQFk0IpLWR78T/+pyt8AruMHhTNNX73hkNVY= -go.etcd.io/etcd/raft/v3 v3.5.9 h1:ZZ1GIHoUlHsn0QVqiRysAm3/81Xx7+i2d7nSdWxlOiI= -go.etcd.io/etcd/raft/v3 v3.5.9/go.mod h1:WnFkqzFdZua4LVlVXQEGhmooLeyS7mqzS4Pf4BCVqXg= -go.etcd.io/etcd/server/v3 v3.5.9 h1:vomEmmxeztLtS5OEH7d0hBAg4cjVIu9wXuNzUZx2ZA0= -go.etcd.io/etcd/server/v3 v3.5.9/go.mod h1:GgI1fQClQCFIzuVjlvdbMxNbnISt90gdfYyqiAIt65g= +go.etcd.io/etcd/pkg/v3 v3.5.10 h1:WPR8K0e9kWl1gAhB5A7gEa5ZBTNkT9NdNWrR8Qpo1CM= +go.etcd.io/etcd/pkg/v3 v3.5.10/go.mod h1:TKTuCKKcF1zxmfKWDkfz5qqYaE3JncKKZPFf8c1nFUs= +go.etcd.io/etcd/raft/v3 v3.5.10 h1:cgNAYe7xrsrn/5kXMSaH8kM/Ky8mAdMqGOxyYwpP0LA= +go.etcd.io/etcd/raft/v3 v3.5.10/go.mod h1:odD6kr8XQXTy9oQnyMPBOr0TVe+gT0neQhElQ6jbGRc= +go.etcd.io/etcd/server/v3 v3.5.10 h1:4NOGyOwD5sUZ22PiWYKmfxqoeh72z6EhYjNosKGLmZg= +go.etcd.io/etcd/server/v3 v3.5.10/go.mod h1:gBplPHfs6YI0L+RpGkTQO7buDbHv5HJGG/Bst0/zIPo= go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= @@ -637,7 +634,6 @@ golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20211025201205-69cdffdb9359/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc= @@ -820,10 +816,8 @@ google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2 google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4= google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= -google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= -google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= -google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= +google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20200902074654-038fdea0a05b/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= @@ -853,35 +847,35 @@ honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWh honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= -k8s.io/api v0.28.4 h1:8ZBrLjwosLl/NYgv1P7EQLqoO8MGQApnbgH8tu3BMzY= -k8s.io/api v0.28.4/go.mod h1:axWTGrY88s/5YE+JSt4uUi6NMM+gur1en2REMR7IRj0= -k8s.io/apiextensions-apiserver v0.28.4 h1:AZpKY/7wQ8n+ZYDtNHbAJBb+N4AXXJvyZx6ww6yAJvU= -k8s.io/apiextensions-apiserver v0.28.4/go.mod h1:pgQIZ1U8eJSMQcENew/0ShUTlePcSGFq6dxSxf2mwPM= -k8s.io/apimachinery v0.28.4 h1:zOSJe1mc+GxuMnFzD4Z/U1wst50X28ZNsn5bhgIIao8= -k8s.io/apimachinery v0.28.4/go.mod h1:wI37ncBvfAoswfq626yPTe6Bz1c22L7uaJ8dho83mgg= -k8s.io/apiserver v0.28.4 h1:BJXlaQbAU/RXYX2lRz+E1oPe3G3TKlozMMCZWu5GMgg= -k8s.io/apiserver v0.28.4/go.mod h1:Idq71oXugKZoVGUUL2wgBCTHbUR+FYTWa4rq9j4n23w= -k8s.io/client-go v0.28.4 h1:Np5ocjlZcTrkyRJ3+T3PkXDpe4UpatQxj85+xjaD2wY= -k8s.io/client-go v0.28.4/go.mod h1:0VDZFpgoZfelyP5Wqu0/r/TRYcLYuJ2U1KEeoaPa1N4= -k8s.io/cluster-bootstrap v0.28.4 h1:4MKNy1Qd9QY7pl47rSMGIORF+tm3CUaqC1M8U9bjn4Q= -k8s.io/cluster-bootstrap v0.28.4/go.mod h1:/c4ro/R4yf4EtJgFgFtvnHkbDOHwubeKJXh5R1c89Bc= -k8s.io/component-base v0.28.4 h1:c/iQLWPdUgI90O+T9TeECg8o7N3YJTiuz2sKxILYcYo= -k8s.io/component-base v0.28.4/go.mod h1:m9hR0uvqXDybiGL2nf/3Lf0MerAfQXzkfWhUY58JUbU= -k8s.io/klog/v2 v2.100.1 h1:7WCHKK6K8fNhTqfBhISHQ97KrnJNFZMcQvKp7gP/tmg= -k8s.io/klog/v2 v2.100.1/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0= -k8s.io/kms v0.28.4 h1:PMgY/3CQTWP9eIKmNQiTgjLIZ0ns6O+voagzD2/4mSg= -k8s.io/kms v0.28.4/go.mod h1:HL4/lR/bhjAJPbqycKtfhWiKh1Sp21cpHOL8P4oo87w= -k8s.io/kube-openapi v0.0.0-20230717233707-2695361300d9 h1:LyMgNKD2P8Wn1iAwQU5OhxCKlKJy0sHc+PcDwFB24dQ= -k8s.io/kube-openapi v0.0.0-20230717233707-2695361300d9/go.mod h1:wZK2AVp1uHCp4VamDVgBP2COHZjqD1T68Rf0CM3YjSM= +k8s.io/api v0.29.3 h1:2ORfZ7+bGC3YJqGpV0KSDDEVf8hdGQ6A03/50vj8pmw= +k8s.io/api v0.29.3/go.mod h1:y2yg2NTyHUUkIoTC+phinTnEa3KFM6RZ3szxt014a80= +k8s.io/apiextensions-apiserver v0.29.3 h1:9HF+EtZaVpFjStakF4yVufnXGPRppWFEQ87qnO91YeI= +k8s.io/apiextensions-apiserver v0.29.3/go.mod h1:po0XiY5scnpJfFizNGo6puNU6Fq6D70UJY2Cb2KwAVc= +k8s.io/apimachinery v0.29.3 h1:2tbx+5L7RNvqJjn7RIuIKu9XTsIZ9Z5wX2G22XAa5EU= +k8s.io/apimachinery v0.29.3/go.mod h1:hx/S4V2PNW4OMg3WizRrHutyB5la0iCUbZym+W0EQIU= +k8s.io/apiserver v0.29.3 h1:xR7ELlJ/BZSr2n4CnD3lfA4gzFivh0wwfNfz9L0WZcE= +k8s.io/apiserver v0.29.3/go.mod h1:hrvXlwfRulbMbBgmWRQlFru2b/JySDpmzvQwwk4GUOs= +k8s.io/client-go v0.29.3 h1:R/zaZbEAxqComZ9FHeQwOh3Y1ZUs7FaHKZdQtIc2WZg= +k8s.io/client-go v0.29.3/go.mod h1:tkDisCvgPfiRpxGnOORfkljmS+UrW+WtXAy2fTvXJB0= +k8s.io/cluster-bootstrap v0.29.3 h1:DIMDZSN8gbFMy9CS2mAS2Iqq/fIUG783WN/1lqi5TF8= +k8s.io/cluster-bootstrap v0.29.3/go.mod h1:aPAg1VtXx3uRrx5qU2jTzR7p1rf18zLXWS+pGhiqPto= +k8s.io/component-base v0.29.3 h1:Oq9/nddUxlnrCuuR2K/jp6aflVvc0uDvxMzAWxnGzAo= +k8s.io/component-base v0.29.3/go.mod h1:Yuj33XXjuOk2BAaHsIGHhCKZQAgYKhqIxIjIr2UXYio= +k8s.io/klog/v2 v2.110.1 h1:U/Af64HJf7FcwMcXyKm2RPM22WZzyR7OSpYj5tg3cL0= +k8s.io/klog/v2 v2.110.1/go.mod h1:YGtd1984u+GgbuZ7e08/yBuAfKLSO0+uR1Fhi6ExXjo= +k8s.io/kms v0.29.3 h1:ReljsAUhYlm2spdT4yXmY+9a8x8dc/OT4mXvwQPPteQ= +k8s.io/kms v0.29.3/go.mod h1:TBGbJKpRUMk59neTMDMddjIDL+D4HuFUbpuiuzmOPg0= +k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00 h1:aVUu9fTY98ivBPKR9Y5w/AuzbMm96cd3YHRTU83I780= +k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00/go.mod h1:AsvuZPBlUDVuCdzJ87iajxtXuR9oktsTctW/R9wwouA= k8s.io/kubernetes v1.28.3 h1:XTci6gzk+JR51UZuZQCFJ4CsyUkfivSjLI4O1P9z6LY= k8s.io/kubernetes v1.28.3/go.mod h1:NhAysZWvHtNcJFFHic87ofxQN7loylCQwg3ZvXVDbag= -k8s.io/utils v0.0.0-20230406110748-d93618cff8a2 h1:qY1Ad8PODbnymg2pRbkyMT/ylpTrCM8P2RJ0yroCyIk= -k8s.io/utils v0.0.0-20230406110748-d93618cff8a2/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= +k8s.io/utils v0.0.0-20230726121419-3b25d923346b h1:sgn3ZU783SCgtaSJjpcVVlRqd6GSnlTLKgpAAttJvpI= +k8s.io/utils v0.0.0-20230726121419-3b25d923346b/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= -sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.1.2 h1:trsWhjU5jZrx6UvFu4WzQDrN7Pga4a7Qg+zcfcj64PA= -sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.1.2/go.mod h1:+qG7ISXqCDVVcyO8hLn12AKVYYUjM7ftlqsqmrhMZE0= +sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.28.0 h1:TgtAeesdhpm2SGwkQasmbeqDo8th5wOBA5h/AjTKA4I= +sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.28.0/go.mod h1:VHVDI/KrK4fjnV61bE2g3sA7tiETLn8sooImelsCx3Y= sigs.k8s.io/cluster-api v1.6.0 h1:2bhVSnUbtWI8taCjd9lGiHExsRUpKf7Z1fXqi/IwYx4= sigs.k8s.io/cluster-api v1.6.0/go.mod h1:LB7u/WxiWj4/bbpHNOa1oQ8nq0MQ5iYlD0pGfRSBGLI= sigs.k8s.io/cluster-api/test v1.6.0 h1:hvqUpSYxXCvs4FiEfsDpFZAfZ7i4kkP/59mVdFHlzSI= @@ -892,8 +886,8 @@ sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd h1:EDPBXCAspyGV4jQlpZSudPeMm sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd/go.mod h1:B8JuhiUyNFVKdsE8h686QcCxMaH6HrOAZj4vswFpcB0= sigs.k8s.io/kind v0.20.0 h1:f0sc3v9mQbGnjBUaqSFST1dwIuiikKVGgoTwpoP33a8= sigs.k8s.io/kind v0.20.0/go.mod h1:aBlbxg08cauDgZ612shr017/rZwqd7AS563FvpWKPVs= -sigs.k8s.io/structured-merge-diff/v4 v4.2.3 h1:PRbqxJClWWYMNV1dhaG4NsibJbArud9kFxnAMREiWFE= -sigs.k8s.io/structured-merge-diff/v4 v4.2.3/go.mod h1:qjx8mGObPmV2aSZepjQjbmb2ihdVs8cGKBraizNC69E= +sigs.k8s.io/structured-merge-diff/v4 v4.4.1 h1:150L+0vs/8DA78h1u02ooW1/fFq/Lwr+sGiqlzvrtq4= +sigs.k8s.io/structured-merge-diff/v4 v4.4.1/go.mod h1:N8hJocpFajUSSeSJ9bOZ77VzejKZaXsTtZo4/u7Io08= sigs.k8s.io/yaml v1.3.0/go.mod h1:GeOyir5tyXNByN85N/dRIT9es5UQNerPYEKK56eTBm8= sigs.k8s.io/yaml v1.4.0 h1:Mk1wCc2gy/F0THH0TAp1QYyJNzRm2KCLy3o5ASXVI5E= sigs.k8s.io/yaml v1.4.0/go.mod h1:Ejl7/uTz7PSA4eKMyQCUTnhZYNmLIl+5c2lQPGR2BPY= diff --git a/pkg/cloud/services/compute/instance_test.go b/pkg/cloud/services/compute/instance_test.go index 54677279aa..74a2773efe 100644 --- a/pkg/cloud/services/compute/instance_test.go +++ b/pkg/cloud/services/compute/instance_test.go @@ -30,7 +30,7 @@ import ( "github.com/gophercloud/gophercloud/openstack/compute/v2/servers" "github.com/gophercloud/gophercloud/openstack/imageservice/v2/images" . "github.com/onsi/gomega" - "k8s.io/utils/pointer" + "k8s.io/utils/ptr" infrav1 "sigs.k8s.io/cluster-api-provider-openstack/api/v1beta1" "sigs.k8s.io/cluster-api-provider-openstack/pkg/clients" @@ -193,8 +193,8 @@ func getDefaultInstanceSpec() *InstanceSpec { Metadata: map[string]string{ "test-metadata": "test-value", }, - ConfigDrive: *pointer.Bool(true), - FailureDomain: *pointer.String(failureDomain), + ConfigDrive: *ptr.To(true), + FailureDomain: *ptr.To(failureDomain), ServerGroupID: serverGroupUUID, Tags: []string{"test-tag"}, } diff --git a/pkg/cloud/services/compute/referenced_resources_test.go b/pkg/cloud/services/compute/referenced_resources_test.go index eca7468d9d..4d9ae11ec7 100644 --- a/pkg/cloud/services/compute/referenced_resources_test.go +++ b/pkg/cloud/services/compute/referenced_resources_test.go @@ -26,7 +26,7 @@ import ( "github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/servergroups" "github.com/gophercloud/gophercloud/openstack/imageservice/v2/images" . "github.com/onsi/gomega" - "k8s.io/utils/pointer" + "k8s.io/utils/ptr" infrav1 "sigs.k8s.io/cluster-api-provider-openstack/api/v1beta1" "sigs.k8s.io/cluster-api-provider-openstack/pkg/clients/mock" @@ -48,7 +48,7 @@ func Test_ResolveMachineSpec(t *testing.T) { Description: "Created by cluster-api-provider-openstack cluster test-cluster", NetworkID: networkID1, FixedIPs: []infrav1.ResolvedFixedIP{ - {SubnetID: pointer.String(subnetID)}, + {SubnetID: ptr.To(subnetID)}, }, }, } @@ -67,8 +67,8 @@ func Test_ResolveMachineSpec(t *testing.T) { { testName: "Resources ID passed", spec: infrav1.OpenStackMachineSpec{ - ServerGroup: &infrav1.ServerGroupParam{ID: pointer.String(serverGroupID1)}, - Image: infrav1.ImageParam{ID: pointer.String(imageID1)}, + ServerGroup: &infrav1.ServerGroupParam{ID: ptr.To(serverGroupID1)}, + Image: infrav1.ImageParam{ID: ptr.To(imageID1)}, }, want: &infrav1.ResolvedMachineSpec{ ImageID: imageID1, @@ -79,7 +79,7 @@ func Test_ResolveMachineSpec(t *testing.T) { { testName: "Only image ID passed: want image id and default ports", spec: infrav1.OpenStackMachineSpec{ - Image: infrav1.ImageParam{ID: pointer.String(imageID1)}, + Image: infrav1.ImageParam{ID: ptr.To(imageID1)}, }, want: &infrav1.ResolvedMachineSpec{ ImageID: imageID1, @@ -89,7 +89,7 @@ func Test_ResolveMachineSpec(t *testing.T) { { testName: "Server group empty", spec: infrav1.OpenStackMachineSpec{ - Image: infrav1.ImageParam{ID: pointer.String(imageID1)}, + Image: infrav1.ImageParam{ID: ptr.To(imageID1)}, ServerGroup: nil, }, want: &infrav1.ResolvedMachineSpec{ @@ -100,8 +100,8 @@ func Test_ResolveMachineSpec(t *testing.T) { { testName: "Server group by Name not found", spec: infrav1.OpenStackMachineSpec{ - Image: infrav1.ImageParam{ID: pointer.String(imageID1)}, - ServerGroup: &infrav1.ServerGroupParam{Filter: &infrav1.ServerGroupFilter{Name: pointer.String("test-server-group")}}, + Image: infrav1.ImageParam{ID: ptr.To(imageID1)}, + ServerGroup: &infrav1.ServerGroupParam{Filter: &infrav1.ServerGroupFilter{Name: ptr.To("test-server-group")}}, }, expectComputeMock: func(m *mock.MockComputeClientMockRecorder) { m.ListServerGroups().Return( @@ -116,7 +116,7 @@ func Test_ResolveMachineSpec(t *testing.T) { spec: infrav1.OpenStackMachineSpec{ Image: infrav1.ImageParam{ Filter: &infrav1.ImageFilter{ - Name: pointer.String("test-image"), + Name: ptr.To("test-image"), }, }, }, @@ -129,11 +129,11 @@ func Test_ResolveMachineSpec(t *testing.T) { { testName: "Ports set", spec: infrav1.OpenStackMachineSpec{ - Image: infrav1.ImageParam{ID: pointer.String(imageID1)}, + Image: infrav1.ImageParam{ID: ptr.To(imageID1)}, Ports: []infrav1.PortOpts{ { Network: &infrav1.NetworkParam{ - ID: pointer.String(networkID2), + ID: ptr.To(networkID2), }, }, }, diff --git a/pkg/cloud/services/compute/servergroup_test.go b/pkg/cloud/services/compute/servergroup_test.go index b73b496dcf..5a8e757075 100644 --- a/pkg/cloud/services/compute/servergroup_test.go +++ b/pkg/cloud/services/compute/servergroup_test.go @@ -23,7 +23,7 @@ import ( "github.com/go-logr/logr/testr" "github.com/golang/mock/gomock" "github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/servergroups" - "k8s.io/utils/pointer" + "k8s.io/utils/ptr" infrav1 "sigs.k8s.io/cluster-api-provider-openstack/api/v1beta1" "sigs.k8s.io/cluster-api-provider-openstack/pkg/clients/mock" @@ -43,7 +43,7 @@ func TestService_GetServerGroupID(t *testing.T) { }{ { testName: "Return server group ID from filter if only filter (with ID) given", - serverGroupParam: &infrav1.ServerGroupParam{ID: pointer.String(serverGroupID1)}, + serverGroupParam: &infrav1.ServerGroupParam{ID: ptr.To(serverGroupID1)}, expect: func(m *mock.MockComputeClientMockRecorder) { }, want: serverGroupID1, @@ -59,7 +59,7 @@ func TestService_GetServerGroupID(t *testing.T) { }, { testName: "Return server group ID from filter if only filter (with name) given", - serverGroupParam: &infrav1.ServerGroupParam{Filter: &infrav1.ServerGroupFilter{Name: pointer.String("test-server-group")}}, + serverGroupParam: &infrav1.ServerGroupParam{Filter: &infrav1.ServerGroupFilter{Name: ptr.To("test-server-group")}}, expect: func(m *mock.MockComputeClientMockRecorder) { m.ListServerGroups().Return( []servergroups.ServerGroup{{ID: serverGroupID1, Name: "test-server-group"}}, @@ -70,7 +70,7 @@ func TestService_GetServerGroupID(t *testing.T) { }, { testName: "Return no results", - serverGroupParam: &infrav1.ServerGroupParam{Filter: &infrav1.ServerGroupFilter{Name: pointer.String("test-server-group")}}, + serverGroupParam: &infrav1.ServerGroupParam{Filter: &infrav1.ServerGroupFilter{Name: ptr.To("test-server-group")}}, expect: func(m *mock.MockComputeClientMockRecorder) { m.ListServerGroups().Return( []servergroups.ServerGroup{}, @@ -81,7 +81,7 @@ func TestService_GetServerGroupID(t *testing.T) { }, { testName: "Return multiple results", - serverGroupParam: &infrav1.ServerGroupParam{Filter: &infrav1.ServerGroupFilter{Name: pointer.String("test-server-group")}}, + serverGroupParam: &infrav1.ServerGroupParam{Filter: &infrav1.ServerGroupFilter{Name: ptr.To("test-server-group")}}, expect: func(m *mock.MockComputeClientMockRecorder) { m.ListServerGroups().Return( []servergroups.ServerGroup{ @@ -95,7 +95,7 @@ func TestService_GetServerGroupID(t *testing.T) { }, { testName: "OpenStack returns error", - serverGroupParam: &infrav1.ServerGroupParam{Filter: &infrav1.ServerGroupFilter{Name: pointer.String("test-server-group")}}, + serverGroupParam: &infrav1.ServerGroupParam{Filter: &infrav1.ServerGroupFilter{Name: ptr.To("test-server-group")}}, expect: func(m *mock.MockComputeClientMockRecorder) { m.ListServerGroups().Return( nil, diff --git a/pkg/cloud/services/loadbalancer/loadbalancer.go b/pkg/cloud/services/loadbalancer/loadbalancer.go index 8fdea9fefb..97f7fe81fa 100644 --- a/pkg/cloud/services/loadbalancer/loadbalancer.go +++ b/pkg/cloud/services/loadbalancer/loadbalancer.go @@ -30,7 +30,7 @@ import ( "github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/pools" "k8s.io/apimachinery/pkg/util/wait" utilsnet "k8s.io/utils/net" - "k8s.io/utils/pointer" + "k8s.io/utils/ptr" infrav1 "sigs.k8s.io/cluster-api-provider-openstack/api/v1beta1" "sigs.k8s.io/cluster-api-provider-openstack/pkg/record" @@ -98,7 +98,7 @@ func (s *Service) ReconcileLoadBalancer(openStackCluster *infrav1.OpenStackClust } } - if !pointer.BoolDeref(openStackCluster.Spec.DisableAPIServerFloatingIP, false) { + if !ptr.Deref(openStackCluster.Spec.DisableAPIServerFloatingIP, false) { floatingIPAddress, err := getAPIServerFloatingIP(openStackCluster) if err != nil { return false, err @@ -155,7 +155,7 @@ func getAPIServerVIPAddress(openStackCluster *infrav1.OpenStackCluster) (*string return openStackCluster.Spec.APIServerFixedIP, nil // If we are using the VIP as the control plane endpoint, use any value explicitly set on the control plane endpoint - case pointer.BoolDeref(openStackCluster.Spec.DisableAPIServerFloatingIP, false) && openStackCluster.Spec.ControlPlaneEndpoint != nil && openStackCluster.Spec.ControlPlaneEndpoint.IsValid(): + case ptr.Deref(openStackCluster.Spec.DisableAPIServerFloatingIP, false) && openStackCluster.Spec.ControlPlaneEndpoint != nil && openStackCluster.Spec.ControlPlaneEndpoint.IsValid(): fixedIPAddress, err := lookupHost(openStackCluster.Spec.ControlPlaneEndpoint.Host) if err != nil { return nil, fmt.Errorf("lookup host: %w", err) diff --git a/pkg/cloud/services/loadbalancer/loadbalancer_test.go b/pkg/cloud/services/loadbalancer/loadbalancer_test.go index 3768884adb..bc8317e61e 100644 --- a/pkg/cloud/services/loadbalancer/loadbalancer_test.go +++ b/pkg/cloud/services/loadbalancer/loadbalancer_test.go @@ -31,7 +31,7 @@ import ( "github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/pools" "github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/providers" . "github.com/onsi/gomega" - "k8s.io/utils/pointer" + "k8s.io/utils/ptr" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" infrav1 "sigs.k8s.io/cluster-api-provider-openstack/api/v1beta1" @@ -59,9 +59,9 @@ func Test_ReconcileLoadBalancer(t *testing.T) { openStackCluster := &infrav1.OpenStackCluster{ Spec: infrav1.OpenStackClusterSpec{ APIServerLoadBalancer: &infrav1.APIServerLoadBalancer{ - Enabled: pointer.Bool(true), + Enabled: ptr.To(true), }, - DisableAPIServerFloatingIP: pointer.Bool(true), + DisableAPIServerFloatingIP: ptr.To(true), ControlPlaneEndpoint: &clusterv1.APIEndpoint{ Host: apiHostname, Port: 6443, @@ -193,38 +193,38 @@ func Test_getAPIServerVIPAddress(t *testing.T) { }, }, }, - want: pointer.String("1.2.3.4"), + want: ptr.To("1.2.3.4"), wantError: false, }, { name: "API server VIP is API Server Fixed IP", openStackCluster: &infrav1.OpenStackCluster{ Spec: infrav1.OpenStackClusterSpec{ - APIServerFixedIP: pointer.String("1.2.3.4"), + APIServerFixedIP: ptr.To("1.2.3.4"), }, }, - want: pointer.String("1.2.3.4"), + want: ptr.To("1.2.3.4"), wantError: false, }, { name: "API server VIP with valid control plane endpoint", openStackCluster: &infrav1.OpenStackCluster{ Spec: infrav1.OpenStackClusterSpec{ - DisableAPIServerFloatingIP: pointer.Bool(true), + DisableAPIServerFloatingIP: ptr.To(true), ControlPlaneEndpoint: &clusterv1.APIEndpoint{ Host: apiHostname, Port: 6443, }, }, }, - want: pointer.String("192.168.100.10"), + want: ptr.To("192.168.100.10"), wantError: false, }, { name: "API server VIP with invalid control plane endpoint", openStackCluster: &infrav1.OpenStackCluster{ Spec: infrav1.OpenStackClusterSpec{ - DisableAPIServerFloatingIP: pointer.Bool(true), + DisableAPIServerFloatingIP: ptr.To(true), ControlPlaneEndpoint: &clusterv1.APIEndpoint{ Host: "invalid-api.test-cluster.test", Port: 6443, @@ -282,17 +282,17 @@ func Test_getAPIServerFloatingIP(t *testing.T) { }, }, }, - want: pointer.String("1.2.3.4"), + want: ptr.To("1.2.3.4"), wantError: false, }, { name: "API server FIP is API Server Floating IP", openStackCluster: &infrav1.OpenStackCluster{ Spec: infrav1.OpenStackClusterSpec{ - APIServerFloatingIP: pointer.String("1.2.3.4"), + APIServerFloatingIP: ptr.To("1.2.3.4"), }, }, - want: pointer.String("1.2.3.4"), + want: ptr.To("1.2.3.4"), wantError: false, }, { @@ -305,7 +305,7 @@ func Test_getAPIServerFloatingIP(t *testing.T) { }, }, }, - want: pointer.String("192.168.100.10"), + want: ptr.To("192.168.100.10"), wantError: false, }, { diff --git a/pkg/cloud/services/networking/floatingip.go b/pkg/cloud/services/networking/floatingip.go index 3e495e77d0..4e611f7fe0 100644 --- a/pkg/cloud/services/networking/floatingip.go +++ b/pkg/cloud/services/networking/floatingip.go @@ -24,7 +24,7 @@ import ( "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/layer3/floatingips" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/util/wait" - "k8s.io/utils/pointer" + "k8s.io/utils/ptr" "sigs.k8s.io/cluster-api-provider-openstack/api/v1alpha1" infrav1 "sigs.k8s.io/cluster-api-provider-openstack/api/v1beta1" @@ -38,7 +38,7 @@ func (s *Service) GetOrCreateFloatingIP(eventObject runtime.Object, openStackClu var err error var fpCreateOpts floatingips.CreateOpts - if pointer.StringDeref(ip, "") != "" { + if ptr.Deref(ip, "") != "" { fp, err = s.GetFloatingIP(*ip) if err != nil { return nil, err diff --git a/pkg/cloud/services/networking/floatingip_test.go b/pkg/cloud/services/networking/floatingip_test.go index 60a9db4300..11148e88e4 100644 --- a/pkg/cloud/services/networking/floatingip_test.go +++ b/pkg/cloud/services/networking/floatingip_test.go @@ -23,7 +23,7 @@ import ( "github.com/golang/mock/gomock" "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/layer3/floatingips" . "github.com/onsi/gomega" - "k8s.io/utils/pointer" + "k8s.io/utils/ptr" infrav1 "sigs.k8s.io/cluster-api-provider-openstack/api/v1beta1" "sigs.k8s.io/cluster-api-provider-openstack/pkg/clients/mock" @@ -86,7 +86,7 @@ func Test_GetOrCreateFloatingIP(t *testing.T) { client: mockClient, } eventObject := infrav1.OpenStackMachine{} - got, err := s.GetOrCreateFloatingIP(&eventObject, openStackCluster, "test-cluster", pointer.String(tt.ip)) + got, err := s.GetOrCreateFloatingIP(&eventObject, openStackCluster, "test-cluster", ptr.To(tt.ip)) g.Expect(err).ShouldNot(HaveOccurred()) g.Expect(got).To(Equal(tt.want)) }) diff --git a/pkg/cloud/services/networking/network.go b/pkg/cloud/services/networking/network.go index 716750e026..f5602a2436 100644 --- a/pkg/cloud/services/networking/network.go +++ b/pkg/cloud/services/networking/network.go @@ -25,7 +25,7 @@ import ( "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/external" "github.com/gophercloud/gophercloud/openstack/networking/v2/networks" "github.com/gophercloud/gophercloud/openstack/networking/v2/subnets" - "k8s.io/utils/pointer" + "k8s.io/utils/ptr" infrav1 "sigs.k8s.io/cluster-api-provider-openstack/api/v1beta1" "sigs.k8s.io/cluster-api-provider-openstack/pkg/metrics" @@ -79,7 +79,7 @@ func (c createOpts) ToNetworkCreateMap() (map[string]interface{}, error) { // - no external network was given in the cluster spec and no external network was found // - the user has set OpenStackCluster.Spec.DisableExternalNetwork to true. func (s *Service) ReconcileExternalNetwork(openStackCluster *infrav1.OpenStackCluster) error { - if pointer.BoolDeref(openStackCluster.Spec.DisableExternalNetwork, false) { + if ptr.Deref(openStackCluster.Spec.DisableExternalNetwork, false) { s.scope.Logger().Info("External network is disabled - proceeding with internal network only") openStackCluster.Status.ExternalNetwork = nil return nil @@ -144,7 +144,7 @@ func (s *Service) ReconcileNetwork(openStackCluster *infrav1.OpenStackCluster, c Name: networkName, } - if pointer.BoolDeref(openStackCluster.Spec.DisablePortSecurity, false) { + if ptr.Deref(openStackCluster.Spec.DisablePortSecurity, false) { opts.PortSecurityEnabled = gophercloud.Disabled } @@ -299,7 +299,7 @@ type GetNetworkOpts func(networks.ListOptsBuilder) networks.ListOptsBuilder func ExternalNetworksOnly(opts networks.ListOptsBuilder) networks.ListOptsBuilder { return &external.ListOptsExt{ ListOptsBuilder: opts, - External: pointer.Bool(true), + External: ptr.To(true), } } diff --git a/pkg/cloud/services/networking/network_test.go b/pkg/cloud/services/networking/network_test.go index 41fa452838..3a3c519743 100644 --- a/pkg/cloud/services/networking/network_test.go +++ b/pkg/cloud/services/networking/network_test.go @@ -27,7 +27,7 @@ import ( "github.com/gophercloud/gophercloud/openstack/networking/v2/networks" "github.com/gophercloud/gophercloud/openstack/networking/v2/subnets" . "github.com/onsi/gomega" - "k8s.io/utils/pointer" + "k8s.io/utils/ptr" infrav1 "sigs.k8s.io/cluster-api-provider-openstack/api/v1beta1" "sigs.k8s.io/cluster-api-provider-openstack/pkg/clients/mock" @@ -117,7 +117,7 @@ func Test_ReconcileNetwork(t *testing.T) { name: "creation with disabled port security", openStackCluster: &infrav1.OpenStackCluster{ Spec: infrav1.OpenStackClusterSpec{ - DisablePortSecurity: pointer.Bool(true), + DisablePortSecurity: ptr.To(true), }, }, expect: func(m *mock.MockNetworkClientMockRecorder) { @@ -153,7 +153,7 @@ func Test_ReconcileNetwork(t *testing.T) { name: "creation with mtu set", openStackCluster: &infrav1.OpenStackCluster{ Spec: infrav1.OpenStackClusterSpec{ - NetworkMTU: pointer.Int(1500), + NetworkMTU: ptr.To(1500), }, }, expect: func(m *mock.MockNetworkClientMockRecorder) { @@ -165,7 +165,7 @@ func Test_ReconcileNetwork(t *testing.T) { CreateNetwork(createOpts{ AdminStateUp: gophercloud.Enabled, Name: expectedNetworkName, - MTU: pointer.Int(1500), + MTU: ptr.To(1500), }). Return(&networks.Network{ ID: fakeNetworkID, @@ -214,7 +214,7 @@ func Test_ReconcileExternalNetwork(t *testing.T) { return func(opts networks.ListOptsBuilder) ([]networks.Network, error) { expected := &external.ListOptsExt{ ListOptsBuilder: listOpts, - External: pointer.Bool(true), + External: ptr.To(true), } g.Expect(opts).To(Equal(expected), cmp.Diff(opts, expected)) @@ -234,7 +234,7 @@ func Test_ReconcileExternalNetwork(t *testing.T) { openStackCluster: &infrav1.OpenStackCluster{ Spec: infrav1.OpenStackClusterSpec{ ExternalNetwork: &infrav1.NetworkParam{ - ID: pointer.String(fakeNetworkID), + ID: ptr.To(fakeNetworkID), }, }, }, @@ -247,7 +247,7 @@ func Test_ReconcileExternalNetwork(t *testing.T) { want: &infrav1.OpenStackCluster{ Spec: infrav1.OpenStackClusterSpec{ ExternalNetwork: &infrav1.NetworkParam{ - ID: pointer.String(fakeNetworkID), + ID: ptr.To(fakeNetworkID), }, }, Status: infrav1.OpenStackClusterStatus{ @@ -297,7 +297,7 @@ func Test_ReconcileExternalNetwork(t *testing.T) { openStackCluster: &infrav1.OpenStackCluster{ Spec: infrav1.OpenStackClusterSpec{ ExternalNetwork: &infrav1.NetworkParam{ - ID: pointer.String(fakeNetworkID), + ID: ptr.To(fakeNetworkID), }, }, }, @@ -307,7 +307,7 @@ func Test_ReconcileExternalNetwork(t *testing.T) { want: &infrav1.OpenStackCluster{ Spec: infrav1.OpenStackClusterSpec{ ExternalNetwork: &infrav1.NetworkParam{ - ID: pointer.String(fakeNetworkID), + ID: ptr.To(fakeNetworkID), }, }, }, @@ -339,13 +339,13 @@ func Test_ReconcileExternalNetwork(t *testing.T) { name: "not reconcile external network when external network disabled", openStackCluster: &infrav1.OpenStackCluster{ Spec: infrav1.OpenStackClusterSpec{ - DisableExternalNetwork: pointer.Bool(true), + DisableExternalNetwork: ptr.To(true), }, }, expect: func(_ Gomega, m *mock.MockNetworkClientMockRecorder) {}, want: &infrav1.OpenStackCluster{ Spec: infrav1.OpenStackClusterSpec{ - DisableExternalNetwork: pointer.Bool(true), + DisableExternalNetwork: ptr.To(true), }, Status: infrav1.OpenStackClusterStatus{ ExternalNetwork: nil, @@ -406,7 +406,7 @@ func Test_ReconcileExternalNetwork(t *testing.T) { DoAndReturn(func(opts networks.ListOptsBuilder) ([]networks.Network, error) { expected := &external.ListOptsExt{ ListOptsBuilder: networks.ListOpts{}, - External: pointer.Bool(true), + External: ptr.To(true), } g.Expect(opts).To(Equal(expected), cmp.Diff(opts, expected)) diff --git a/pkg/cloud/services/networking/port.go b/pkg/cloud/services/networking/port.go index 9b736cd4d4..9d740ae3ff 100644 --- a/pkg/cloud/services/networking/port.go +++ b/pkg/cloud/services/networking/port.go @@ -30,7 +30,7 @@ import ( "github.com/gophercloud/gophercloud/openstack/networking/v2/ports" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/util/wait" - "k8s.io/utils/pointer" + "k8s.io/utils/ptr" infrav1 "sigs.k8s.io/cluster-api-provider-openstack/api/v1beta1" "sigs.k8s.io/cluster-api-provider-openstack/pkg/record" @@ -125,11 +125,11 @@ func (s *Service) GetPortForExternalNetwork(instanceID string, externalNetworkID func (s *Service) CreatePort(eventObject runtime.Object, portSpec *infrav1.ResolvedPortSpec) (*ports.Port, error) { var addressPairs []ports.AddressPair - if !pointer.BoolDeref(portSpec.DisablePortSecurity, false) { + if !ptr.Deref(portSpec.DisablePortSecurity, false) { for _, ap := range portSpec.AllowedAddressPairs { addressPairs = append(addressPairs, ports.AddressPair{ IPAddress: ap.IPAddress, - MACAddress: pointer.StringDeref(ap.MACAddress, ""), + MACAddress: ptr.Deref(ap.MACAddress, ""), }) } } @@ -139,8 +139,8 @@ func (s *Service) CreatePort(eventObject runtime.Object, portSpec *infrav1.Resol fixedIPs = make([]ports.IP, len(portSpec.FixedIPs)) for i, fixedIP := range portSpec.FixedIPs { fixedIPs[i] = ports.IP{ - SubnetID: pointer.StringDeref(fixedIP.SubnetID, ""), - IPAddress: pointer.StringDeref(fixedIP.IPAddress, ""), + SubnetID: ptr.Deref(fixedIP.SubnetID, ""), + IPAddress: ptr.Deref(fixedIP.IPAddress, ""), } } } @@ -160,7 +160,7 @@ func (s *Service) CreatePort(eventObject runtime.Object, portSpec *infrav1.Resol NetworkID: portSpec.NetworkID, Description: portSpec.Description, AdminStateUp: portSpec.AdminStateUp, - MACAddress: pointer.StringDeref(portSpec.MACAddress, ""), + MACAddress: ptr.Deref(portSpec.MACAddress, ""), AllowedAddressPairs: addressPairs, ValueSpecs: valueSpecs, PropagateUplinkStatus: portSpec.PropagateUplinkStatus, @@ -184,8 +184,8 @@ func (s *Service) CreatePort(eventObject runtime.Object, portSpec *infrav1.Resol portsBindingOpts := portsbinding.CreateOptsExt{ CreateOptsBuilder: builder, - HostID: pointer.StringDeref(portSpec.HostID, ""), - VNICType: pointer.StringDeref(portSpec.VNICType, ""), + HostID: ptr.Deref(portSpec.HostID, ""), + VNICType: ptr.Deref(portSpec.VNICType, ""), Profile: getPortProfile(portSpec.Profile), } builder = portsBindingOpts @@ -203,7 +203,7 @@ func (s *Service) CreatePort(eventObject runtime.Object, portSpec *infrav1.Resol } } record.Eventf(eventObject, "SuccessfulCreatePort", "Created port %s with id %s", port.Name, port.ID) - if pointer.BoolDeref(portSpec.Trunk, false) { + if ptr.Deref(portSpec.Trunk, false) { trunk, err := s.getOrCreateTrunkForPort(eventObject, port) if err != nil { record.Warnf(eventObject, "FailedCreateTrunk", "Failed to create trunk for port %s: %v", port.Name, err) @@ -227,10 +227,10 @@ func getPortProfile(p *infrav1.BindingProfile) map[string]interface{} { // if p.OVSHWOffload is true, we need to set the profile // to enable hardware offload for the port - if pointer.BoolDeref(p.OVSHWOffload, false) { + if ptr.Deref(p.OVSHWOffload, false) { portProfile["capabilities"] = []string{"switchdev"} } - if pointer.BoolDeref(p.TrustedVF, false) { + if ptr.Deref(p.TrustedVF, false) { portProfile["trusted"] = true } @@ -384,7 +384,7 @@ func (s *Service) ConstructPorts(spec *infrav1.OpenStackMachineSpec, clusterReso // trunk support is required if any port has trunk enabled portUsesTrunk := func() bool { for _, port := range resolvedPorts { - if pointer.BoolDeref(port.Trunk, false) { + if ptr.Deref(port.Trunk, false) { return true } } diff --git a/pkg/cloud/services/networking/port_test.go b/pkg/cloud/services/networking/port_test.go index 501f5f39cc..bbdc1cd018 100644 --- a/pkg/cloud/services/networking/port_test.go +++ b/pkg/cloud/services/networking/port_test.go @@ -33,7 +33,7 @@ import ( "github.com/gophercloud/gophercloud/openstack/networking/v2/subnets" . "github.com/onsi/gomega" "github.com/onsi/gomega/types" - "k8s.io/utils/pointer" + "k8s.io/utils/ptr" infrav1 "sigs.k8s.io/cluster-api-provider-openstack/api/v1beta1" "sigs.k8s.io/cluster-api-provider-openstack/pkg/clients/mock" @@ -72,36 +72,36 @@ func Test_CreatePort(t *testing.T) { NetworkID: netID, FixedIPs: []infrav1.ResolvedFixedIP{ { - SubnetID: pointer.String(subnetID1), - IPAddress: pointer.String(ipAddress1), + SubnetID: ptr.To(subnetID1), + IPAddress: ptr.To(ipAddress1), }, { - IPAddress: pointer.String(ipAddress2), + IPAddress: ptr.To(ipAddress2), }, { - SubnetID: pointer.String(subnetID2), + SubnetID: ptr.To(subnetID2), }, }, SecurityGroups: []string{portSecurityGroupID}, ResolvedPortSpecFields: infrav1.ResolvedPortSpecFields{ - AdminStateUp: pointer.Bool(true), - MACAddress: pointer.String(macAddress), + AdminStateUp: ptr.To(true), + MACAddress: ptr.To(macAddress), AllowedAddressPairs: []infrav1.AddressPair{ { IPAddress: ipAddress1, - MACAddress: pointer.String(macAddress), + MACAddress: ptr.To(macAddress), }, { IPAddress: ipAddress2, }, }, - HostID: pointer.String(hostID), - VNICType: pointer.String("normal"), + HostID: ptr.To(hostID), + VNICType: ptr.To("normal"), Profile: &infrav1.BindingProfile{ - OVSHWOffload: pointer.Bool(true), - TrustedVF: pointer.Bool(true), + OVSHWOffload: ptr.To(true), + TrustedVF: ptr.To(true), }, - PropagateUplinkStatus: pointer.Bool(true), + PropagateUplinkStatus: ptr.To(true), ValueSpecs: []infrav1.ValueSpec{ { Name: "test-valuespec", @@ -117,7 +117,7 @@ func Test_CreatePort(t *testing.T) { Name: "foo-port-1", Description: "Created by cluster-api-provider-openstack cluster test-cluster", NetworkID: netID, - AdminStateUp: pointer.Bool(true), + AdminStateUp: ptr.To(true), MACAddress: macAddress, FixedIPs: []ports.IP{ { @@ -141,7 +141,7 @@ func Test_CreatePort(t *testing.T) { IPAddress: ipAddress2, }, }, - PropagateUplinkStatus: pointer.Bool(true), + PropagateUplinkStatus: ptr.To(true), ValueSpecs: &map[string]string{ "test-key": "test-value", }, @@ -197,11 +197,11 @@ func Test_CreatePort(t *testing.T) { Name: "test-port", NetworkID: netID, ResolvedPortSpecFields: infrav1.ResolvedPortSpecFields{ - DisablePortSecurity: pointer.Bool(true), + DisablePortSecurity: ptr.To(true), AllowedAddressPairs: []infrav1.AddressPair{ { IPAddress: ipAddress1, - MACAddress: pointer.String(macAddress), + MACAddress: ptr.To(macAddress), }, }, }, @@ -214,7 +214,7 @@ func Test_CreatePort(t *testing.T) { } expectedCreateOpts = portsecurity.PortCreateOptsExt{ CreateOptsBuilder: expectedCreateOpts, - PortSecurityEnabled: pointer.Bool(false), + PortSecurityEnabled: ptr.To(false), } expectedCreateOpts = portsbinding.CreateOptsExt{ CreateOptsBuilder: expectedCreateOpts, @@ -233,11 +233,11 @@ func Test_CreatePort(t *testing.T) { Name: "test-port", NetworkID: netID, ResolvedPortSpecFields: infrav1.ResolvedPortSpecFields{ - DisablePortSecurity: pointer.Bool(false), + DisablePortSecurity: ptr.To(false), AllowedAddressPairs: []infrav1.AddressPair{ { IPAddress: ipAddress1, - MACAddress: pointer.String(macAddress), + MACAddress: ptr.To(macAddress), }, }, }, @@ -256,7 +256,7 @@ func Test_CreatePort(t *testing.T) { } expectedCreateOpts = portsecurity.PortCreateOptsExt{ CreateOptsBuilder: expectedCreateOpts, - PortSecurityEnabled: pointer.Bool(true), + PortSecurityEnabled: ptr.To(true), } expectedCreateOpts = portsbinding.CreateOptsExt{ CreateOptsBuilder: expectedCreateOpts, @@ -275,7 +275,7 @@ func Test_CreatePort(t *testing.T) { Name: "test-port", NetworkID: netID, Tags: []string{"tag1", "tag2"}, - Trunk: pointer.Bool(true), + Trunk: ptr.To(true), }, expect: func(m *mock.MockNetworkClientMockRecorder, g types.Gomega) { var expectedCreateOpts ports.CreateOptsBuilder @@ -385,7 +385,7 @@ func TestService_ConstructPorts(t *testing.T) { Tags: []string{"test-tag"}, NetworkID: defaultNetworkID, FixedIPs: []infrav1.ResolvedFixedIP{ - {SubnetID: pointer.String(defaultSubnetID)}, + {SubnetID: ptr.To(defaultSubnetID)}, }, }, }, @@ -395,7 +395,7 @@ func TestService_ConstructPorts(t *testing.T) { spec: infrav1.OpenStackMachineSpec{ Ports: []infrav1.PortOpts{ { - NameSuffix: pointer.String("custom"), + NameSuffix: ptr.To("custom"), Network: nil, FixedIPs: nil, }, @@ -408,7 +408,7 @@ func TestService_ConstructPorts(t *testing.T) { NetworkID: defaultNetworkID, FixedIPs: []infrav1.ResolvedFixedIP{ { - SubnetID: pointer.String(defaultSubnetID), + SubnetID: ptr.To(defaultSubnetID), }, }, Tags: []string{"test-tag"}, @@ -420,7 +420,7 @@ func TestService_ConstructPorts(t *testing.T) { spec: infrav1.OpenStackMachineSpec{ Ports: []infrav1.PortOpts{ { - NameSuffix: pointer.String("custom"), + NameSuffix: ptr.To("custom"), Network: nil, FixedIPs: nil, }, @@ -436,10 +436,10 @@ func TestService_ConstructPorts(t *testing.T) { Description: defaultDescription, NetworkID: defaultNetworkID, FixedIPs: []infrav1.ResolvedFixedIP{ - {SubnetID: pointer.String(defaultSubnetID)}, + {SubnetID: ptr.To(defaultSubnetID)}, }, Tags: []string{"test-tag"}, - Trunk: pointer.Bool(true), + Trunk: ptr.To(true), }, }, wantErr: false, @@ -449,7 +449,7 @@ func TestService_ConstructPorts(t *testing.T) { spec: infrav1.OpenStackMachineSpec{ Ports: []infrav1.PortOpts{ { - Trunk: pointer.Bool(true), + Trunk: ptr.To(true), }, }, Trunk: false, @@ -463,10 +463,10 @@ func TestService_ConstructPorts(t *testing.T) { Description: defaultDescription, NetworkID: defaultNetworkID, FixedIPs: []infrav1.ResolvedFixedIP{ - {SubnetID: pointer.String(defaultSubnetID)}, + {SubnetID: ptr.To(defaultSubnetID)}, }, Tags: []string{"test-tag"}, - Trunk: pointer.Bool(true), + Trunk: ptr.To(true), }, }, }, @@ -476,7 +476,7 @@ func TestService_ConstructPorts(t *testing.T) { Ports: []infrav1.PortOpts{ { Network: &infrav1.NetworkParam{ - ID: pointer.String(networkID), + ID: ptr.To(networkID), }, }, }, @@ -527,7 +527,7 @@ func TestService_ConstructPorts(t *testing.T) { FixedIPs: []infrav1.FixedIP{ { Subnet: &infrav1.SubnetParam{ - ID: pointer.String(subnetID1), + ID: ptr.To(subnetID1), }, }, }, @@ -541,7 +541,7 @@ func TestService_ConstructPorts(t *testing.T) { { NetworkID: networkID, FixedIPs: []infrav1.ResolvedFixedIP{ - {SubnetID: pointer.String(subnetID1)}, + {SubnetID: ptr.To(subnetID1)}, }, // Defaults @@ -576,7 +576,7 @@ func TestService_ConstructPorts(t *testing.T) { NetworkID: networkID, FixedIPs: []infrav1.ResolvedFixedIP{ { - SubnetID: pointer.String(subnetID1), + SubnetID: ptr.To(subnetID1), }, }, @@ -668,10 +668,10 @@ func TestService_ConstructPorts(t *testing.T) { NetworkID: networkID, FixedIPs: []infrav1.ResolvedFixedIP{ { - SubnetID: pointer.String(subnetID1), + SubnetID: ptr.To(subnetID1), }, { - SubnetID: pointer.String(subnetID2), + SubnetID: ptr.To(subnetID2), }, }, @@ -699,7 +699,7 @@ func TestService_ConstructPorts(t *testing.T) { Name: "test-instance-0", NetworkID: defaultNetworkID, FixedIPs: []infrav1.ResolvedFixedIP{ - {SubnetID: pointer.String(defaultSubnetID)}, + {SubnetID: ptr.To(defaultSubnetID)}, }, Description: defaultDescription, Tags: []string{"test-tag"}, @@ -730,7 +730,7 @@ func TestService_ConstructPorts(t *testing.T) { Name: "test-instance-0", NetworkID: defaultNetworkID, FixedIPs: []infrav1.ResolvedFixedIP{ - {SubnetID: pointer.String(defaultSubnetID)}, + {SubnetID: ptr.To(defaultSubnetID)}, }, Description: defaultDescription, Tags: []string{"test-tag"}, @@ -741,13 +741,13 @@ func TestService_ConstructPorts(t *testing.T) { { name: "managed security group added to port", spec: infrav1.OpenStackMachineSpec{}, - managedSecurityGroup: pointer.String(securityGroupID1), + managedSecurityGroup: ptr.To(securityGroupID1), want: []infrav1.ResolvedPortSpec{ { Name: "test-instance-0", NetworkID: defaultNetworkID, FixedIPs: []infrav1.ResolvedFixedIP{ - {SubnetID: pointer.String(defaultSubnetID)}, + {SubnetID: ptr.To(defaultSubnetID)}, }, Description: defaultDescription, Tags: []string{"test-tag"}, @@ -760,7 +760,7 @@ func TestService_ConstructPorts(t *testing.T) { spec: infrav1.OpenStackMachineSpec{ SecurityGroups: []infrav1.SecurityGroupParam{{Filter: &infrav1.SecurityGroupFilter{Name: "machine-security-group"}}}, }, - managedSecurityGroup: pointer.String(securityGroupID1), + managedSecurityGroup: ptr.To(securityGroupID1), expectNetwork: func(m *mock.MockNetworkClientMockRecorder) { m.ListSecGroup(groups.ListOpts{Name: "machine-security-group"}).Return([]groups.SecGroup{ {ID: securityGroupID2}, @@ -771,7 +771,7 @@ func TestService_ConstructPorts(t *testing.T) { Name: "test-instance-0", NetworkID: defaultNetworkID, FixedIPs: []infrav1.ResolvedFixedIP{ - {SubnetID: pointer.String(defaultSubnetID)}, + {SubnetID: ptr.To(defaultSubnetID)}, }, Description: defaultDescription, Tags: []string{"test-tag"}, @@ -841,7 +841,7 @@ func Test_getPortName(t *testing.T) { name: "with PortOpts name suffix", instanceName: "test-1-instance", spec: &infrav1.PortOpts{ - NameSuffix: pointer.String("foo"), + NameSuffix: ptr.To("foo"), }, netIndex: 4, want: "test-1-instance-foo", @@ -857,10 +857,10 @@ func Test_getPortName(t *testing.T) { name: "with PortOpts name suffix", instanceName: "test-1-instance", spec: &infrav1.PortOpts{ - NameSuffix: pointer.String("foo2"), - Network: &infrav1.NetworkParam{ID: pointer.String("bar")}, + NameSuffix: ptr.To("foo2"), + Network: &infrav1.NetworkParam{ID: ptr.To("bar")}, ResolvedPortSpecFields: infrav1.ResolvedPortSpecFields{ - DisablePortSecurity: pointer.Bool(true), + DisablePortSecurity: ptr.To(true), }, }, netIndex: 4, diff --git a/pkg/cloud/services/networking/securitygroups_test.go b/pkg/cloud/services/networking/securitygroups_test.go index 487fa9bd87..a9f0ca3163 100644 --- a/pkg/cloud/services/networking/securitygroups_test.go +++ b/pkg/cloud/services/networking/securitygroups_test.go @@ -27,7 +27,7 @@ import ( "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/security/groups" "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/security/rules" . "github.com/onsi/gomega" - "k8s.io/utils/pointer" + "k8s.io/utils/ptr" infrav1 "sigs.k8s.io/cluster-api-provider-openstack/api/v1beta1" "sigs.k8s.io/cluster-api-provider-openstack/pkg/clients/mock" @@ -51,9 +51,9 @@ func TestValidateRemoteManagedGroups(t *testing.T) { { name: "Valid rule with missing remoteManagedGroups", rule: infrav1.SecurityGroupRuleSpec{ - PortRangeMin: pointer.Int(22), - PortRangeMax: pointer.Int(22), - Protocol: pointer.String("tcp"), + PortRangeMin: ptr.To(22), + PortRangeMax: ptr.To(22), + Protocol: ptr.To("tcp"), }, remoteManagedGroups: map[string]string{ "self": "self", @@ -123,9 +123,9 @@ func TestGetAllNodesRules(t *testing.T) { }, allNodesSecurityGroupRules: []infrav1.SecurityGroupRuleSpec{ { - Protocol: pointer.String("tcp"), - PortRangeMin: pointer.Int(22), - PortRangeMax: pointer.Int(22), + Protocol: ptr.To("tcp"), + PortRangeMin: ptr.To(22), + PortRangeMax: ptr.To(22), RemoteManagedGroups: []infrav1.ManagedSecurityGroupName{ "controlplane", "worker", @@ -156,9 +156,9 @@ func TestGetAllNodesRules(t *testing.T) { }, allNodesSecurityGroupRules: []infrav1.SecurityGroupRuleSpec{ { - Protocol: pointer.String("tcp"), - PortRangeMin: pointer.Int(22), - PortRangeMax: pointer.Int(22), + Protocol: ptr.To("tcp"), + PortRangeMin: ptr.To(22), + PortRangeMax: ptr.To(22), RemoteManagedGroups: []infrav1.ManagedSecurityGroupName{"controlplane"}, }, }, @@ -179,9 +179,9 @@ func TestGetAllNodesRules(t *testing.T) { }, allNodesSecurityGroupRules: []infrav1.SecurityGroupRuleSpec{ { - Protocol: pointer.String("tcp"), - PortRangeMin: pointer.Int(22), - PortRangeMax: pointer.Int(22), + Protocol: ptr.To("tcp"), + PortRangeMin: ptr.To(22), + PortRangeMax: ptr.To(22), RemoteManagedGroups: []infrav1.ManagedSecurityGroupName{ "controlplanezzz", "worker", @@ -199,9 +199,9 @@ func TestGetAllNodesRules(t *testing.T) { }, allNodesSecurityGroupRules: []infrav1.SecurityGroupRuleSpec{ { - Protocol: pointer.String("tcp"), - PortRangeMin: pointer.Int(22), - PortRangeMax: pointer.Int(22), + Protocol: ptr.To("tcp"), + PortRangeMin: ptr.To(22), + PortRangeMax: ptr.To(22), RemoteManagedGroups: []infrav1.ManagedSecurityGroupName{ "bastion", }, @@ -274,9 +274,9 @@ func TestGenerateDesiredSecGroups(t *testing.T) { ManagedSecurityGroups: &infrav1.ManagedSecurityGroups{ AllNodesSecurityGroupRules: []infrav1.SecurityGroupRuleSpec{ { - Protocol: pointer.String("tcp"), - PortRangeMin: pointer.Int(22), - PortRangeMax: pointer.Int(22), + Protocol: ptr.To("tcp"), + PortRangeMin: ptr.To(22), + PortRangeMax: ptr.To(22), RemoteManagedGroups: []infrav1.ManagedSecurityGroupName{"controlplane", "worker"}, }, }, @@ -293,9 +293,9 @@ func TestGenerateDesiredSecGroups(t *testing.T) { ManagedSecurityGroups: &infrav1.ManagedSecurityGroups{ AllNodesSecurityGroupRules: []infrav1.SecurityGroupRuleSpec{ { - Protocol: pointer.String("tcp"), - PortRangeMin: pointer.Int(22), - PortRangeMax: pointer.Int(22), + Protocol: ptr.To("tcp"), + PortRangeMin: ptr.To(22), + PortRangeMax: ptr.To(22), RemoteManagedGroups: []infrav1.ManagedSecurityGroupName{"controlplane", "worker", "unknownGroup"}, }, }, @@ -533,7 +533,7 @@ func TestService_ReconcileSecurityGroups(t *testing.T) { name: "Default control plane, worker, and bastion security groups", openStackClusterSpec: infrav1.OpenStackClusterSpec{ Bastion: &infrav1.Bastion{ - Enabled: pointer.Bool(true), + Enabled: ptr.To(true), }, ManagedSecurityGroups: &infrav1.ManagedSecurityGroups{}, }, diff --git a/pkg/webhooks/openstackcluster_webhook.go b/pkg/webhooks/openstackcluster_webhook.go index d5a68c6ae5..194933c3d6 100644 --- a/pkg/webhooks/openstackcluster_webhook.go +++ b/pkg/webhooks/openstackcluster_webhook.go @@ -23,7 +23,7 @@ import ( "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/util/validation/field" - "k8s.io/utils/pointer" + "k8s.io/utils/ptr" "sigs.k8s.io/controller-runtime/pkg/builder" "sigs.k8s.io/controller-runtime/pkg/manager" "sigs.k8s.io/controller-runtime/pkg/webhook" @@ -98,13 +98,13 @@ func (*openStackClusterWebhook) ValidateUpdate(_ context.Context, oldObjRaw, new } // Allow change only for the first time. - if pointer.BoolDeref(oldObj.Spec.DisableAPIServerFloatingIP, false) && pointer.StringDeref(oldObj.Spec.APIServerFixedIP, "") == "" { + if ptr.Deref(oldObj.Spec.DisableAPIServerFloatingIP, false) && ptr.Deref(oldObj.Spec.APIServerFixedIP, "") == "" { oldObj.Spec.APIServerFixedIP = nil newObj.Spec.APIServerFixedIP = nil } // If API Server floating IP is disabled, allow the change of the API Server port only for the first time. - if pointer.BoolDeref(oldObj.Spec.DisableAPIServerFloatingIP, false) && oldObj.Spec.APIServerPort == nil && newObj.Spec.APIServerPort != nil { + if ptr.Deref(oldObj.Spec.DisableAPIServerFloatingIP, false) && oldObj.Spec.APIServerPort == nil && newObj.Spec.APIServerPort != nil { newObj.Spec.APIServerPort = nil } @@ -145,7 +145,7 @@ func (*openStackClusterWebhook) ValidateUpdate(_ context.Context, oldObjRaw, new newObj.Spec.ControlPlaneOmitAvailabilityZone = nil // Allow change on the spec.APIServerFloatingIP only if it matches the current api server loadbalancer IP. - if oldObj.Status.APIServerLoadBalancer != nil && pointer.StringDeref(newObj.Spec.APIServerFloatingIP, "") == oldObj.Status.APIServerLoadBalancer.IP { + if oldObj.Status.APIServerLoadBalancer != nil && ptr.Deref(newObj.Spec.APIServerFloatingIP, "") == oldObj.Status.APIServerLoadBalancer.IP { newObj.Spec.APIServerFloatingIP = nil oldObj.Spec.APIServerFloatingIP = nil } diff --git a/pkg/webhooks/openstackcluster_webhook_test.go b/pkg/webhooks/openstackcluster_webhook_test.go index d42b6eb1ce..edd60296a3 100644 --- a/pkg/webhooks/openstackcluster_webhook_test.go +++ b/pkg/webhooks/openstackcluster_webhook_test.go @@ -21,7 +21,7 @@ import ( "testing" . "github.com/onsi/gomega" - "k8s.io/utils/pointer" + "k8s.io/utils/ptr" infrav1 "sigs.k8s.io/cluster-api-provider-openstack/api/v1beta1" ) @@ -87,12 +87,12 @@ func TestOpenStackCluster_ValidateUpdate(t *testing.T) { Spec: &infrav1.OpenStackMachineSpec{ Image: infrav1.ImageParam{ Filter: &infrav1.ImageFilter{ - Name: pointer.String("foobar"), + Name: ptr.To("foobar"), }, }, Flavor: "minimal", }, - Enabled: pointer.Bool(true), + Enabled: ptr.To(true), }, }, Status: infrav1.OpenStackClusterStatus{ @@ -111,12 +111,12 @@ func TestOpenStackCluster_ValidateUpdate(t *testing.T) { Spec: &infrav1.OpenStackMachineSpec{ Image: infrav1.ImageParam{ Filter: &infrav1.ImageFilter{ - Name: pointer.String("foobarbaz"), + Name: ptr.To("foobarbaz"), }, }, Flavor: "medium", }, - Enabled: pointer.Bool(true), + Enabled: ptr.To(true), }, }, }, @@ -134,10 +134,10 @@ func TestOpenStackCluster_ValidateUpdate(t *testing.T) { AllNodesSecurityGroupRules: []infrav1.SecurityGroupRuleSpec{ { Name: "foobar", - Description: pointer.String("foobar"), - PortRangeMin: pointer.Int(80), - PortRangeMax: pointer.Int(80), - Protocol: pointer.String("tcp"), + Description: ptr.To("foobar"), + PortRangeMin: ptr.To(80), + PortRangeMax: ptr.To(80), + Protocol: ptr.To("tcp"), RemoteManagedGroups: []infrav1.ManagedSecurityGroupName{"controlplane"}, }, }, @@ -154,10 +154,10 @@ func TestOpenStackCluster_ValidateUpdate(t *testing.T) { AllNodesSecurityGroupRules: []infrav1.SecurityGroupRuleSpec{ { Name: "foobar", - Description: pointer.String("foobar"), - PortRangeMin: pointer.Int(80), - PortRangeMax: pointer.Int(80), - Protocol: pointer.String("tcp"), + Description: ptr.To("foobar"), + PortRangeMin: ptr.To(80), + PortRangeMax: ptr.To(80), + Protocol: ptr.To("tcp"), RemoteManagedGroups: []infrav1.ManagedSecurityGroupName{"controlplane", "worker"}, }, }, @@ -175,7 +175,7 @@ func TestOpenStackCluster_ValidateUpdate(t *testing.T) { CloudName: "foobar", }, APIServerLoadBalancer: &infrav1.APIServerLoadBalancer{ - Enabled: pointer.Bool(true), + Enabled: ptr.To(true), AllowedCIDRs: []string{ "0.0.0.0/0", "192.168.10.0/24", @@ -190,7 +190,7 @@ func TestOpenStackCluster_ValidateUpdate(t *testing.T) { CloudName: "foobar", }, APIServerLoadBalancer: &infrav1.APIServerLoadBalancer{ - Enabled: pointer.Bool(true), + Enabled: ptr.To(true), AllowedCIDRs: []string{ "0.0.0.0/0", "192.168.10.0/24", @@ -294,7 +294,7 @@ func TestOpenStackCluster_ValidateUpdate(t *testing.T) { Name: "foobar", CloudName: "foobar", }, - ControlPlaneOmitAvailabilityZone: pointer.Bool(true), + ControlPlaneOmitAvailabilityZone: ptr.To(true), }, }, wantErr: false, @@ -307,7 +307,7 @@ func TestOpenStackCluster_ValidateUpdate(t *testing.T) { Name: "foobar", CloudName: "foobar", }, - DisableAPIServerFloatingIP: pointer.Bool(true), + DisableAPIServerFloatingIP: ptr.To(true), }, }, newTemplate: &infrav1.OpenStackCluster{ @@ -316,8 +316,8 @@ func TestOpenStackCluster_ValidateUpdate(t *testing.T) { Name: "foobar", CloudName: "foobar", }, - DisableAPIServerFloatingIP: pointer.Bool(true), - APIServerFixedIP: pointer.String("20.1.56.1"), + DisableAPIServerFloatingIP: ptr.To(true), + APIServerFixedIP: ptr.To("20.1.56.1"), }, }, wantErr: false, @@ -330,7 +330,7 @@ func TestOpenStackCluster_ValidateUpdate(t *testing.T) { Name: "foobar", CloudName: "foobar", }, - DisableAPIServerFloatingIP: pointer.Bool(false), + DisableAPIServerFloatingIP: ptr.To(false), }, }, newTemplate: &infrav1.OpenStackCluster{ @@ -339,8 +339,8 @@ func TestOpenStackCluster_ValidateUpdate(t *testing.T) { Name: "foobar", CloudName: "foobar", }, - DisableAPIServerFloatingIP: pointer.Bool(false), - APIServerFixedIP: pointer.String("20.1.56.1"), + DisableAPIServerFloatingIP: ptr.To(false), + APIServerFixedIP: ptr.To("20.1.56.1"), }, }, wantErr: true, @@ -354,13 +354,13 @@ func TestOpenStackCluster_ValidateUpdate(t *testing.T) { Name: "foobar", CloudName: "foobar", }, - DisableAPIServerFloatingIP: pointer.Bool(true), + DisableAPIServerFloatingIP: ptr.To(true), }, }, newTemplate: &infrav1.OpenStackCluster{ Spec: infrav1.OpenStackClusterSpec{ - DisableAPIServerFloatingIP: pointer.Bool(true), - APIServerPort: pointer.Int(8443), + DisableAPIServerFloatingIP: ptr.To(true), + APIServerPort: ptr.To(8443), }, }, wantErr: false, @@ -373,7 +373,7 @@ func TestOpenStackCluster_ValidateUpdate(t *testing.T) { Name: "foobar", CloudName: "foobar", }, - DisableAPIServerFloatingIP: pointer.Bool(false), + DisableAPIServerFloatingIP: ptr.To(false), }, }, newTemplate: &infrav1.OpenStackCluster{ @@ -382,8 +382,8 @@ func TestOpenStackCluster_ValidateUpdate(t *testing.T) { Name: "foobar", CloudName: "foobar", }, - DisableAPIServerFloatingIP: pointer.Bool(false), - APIServerPort: pointer.Int(8443), + DisableAPIServerFloatingIP: ptr.To(false), + APIServerPort: ptr.To(8443), }, }, wantErr: true, @@ -409,7 +409,7 @@ func TestOpenStackCluster_ValidateUpdate(t *testing.T) { Name: "foobar", CloudName: "foobar", }, - APIServerFloatingIP: pointer.String("1.2.3.4"), + APIServerFloatingIP: ptr.To("1.2.3.4"), }, Status: infrav1.OpenStackClusterStatus{ APIServerLoadBalancer: &infrav1.LoadBalancer{ @@ -440,7 +440,7 @@ func TestOpenStackCluster_ValidateUpdate(t *testing.T) { Name: "foobar", CloudName: "foobar", }, - APIServerFloatingIP: pointer.String("5.6.7.8"), + APIServerFloatingIP: ptr.To("5.6.7.8"), }, Status: infrav1.OpenStackClusterStatus{ APIServerLoadBalancer: &infrav1.LoadBalancer{ @@ -459,12 +459,12 @@ func TestOpenStackCluster_ValidateUpdate(t *testing.T) { CloudName: "foobar", }, Bastion: &infrav1.Bastion{ - Enabled: pointer.Bool(true), + Enabled: ptr.To(true), Spec: &infrav1.OpenStackMachineSpec{ Flavor: "m1.small", Image: infrav1.ImageParam{ Filter: &infrav1.ImageFilter{ - Name: pointer.String("ubuntu"), + Name: ptr.To("ubuntu"), }, }, }, @@ -490,12 +490,12 @@ func TestOpenStackCluster_ValidateUpdate(t *testing.T) { CloudName: "foobar", }, Bastion: &infrav1.Bastion{ - Enabled: pointer.Bool(false), + Enabled: ptr.To(false), Spec: &infrav1.OpenStackMachineSpec{ Flavor: "m1.small", Image: infrav1.ImageParam{ Filter: &infrav1.ImageFilter{ - Name: pointer.String("ubuntu"), + Name: ptr.To("ubuntu"), }, }, }, @@ -561,10 +561,10 @@ func TestOpenStackCluster_ValidateCreate(t *testing.T) { AllNodesSecurityGroupRules: []infrav1.SecurityGroupRuleSpec{ { Name: "foobar", - Description: pointer.String("foobar"), - PortRangeMin: pointer.Int(80), - PortRangeMax: pointer.Int(80), - Protocol: pointer.String("tcp"), + Description: ptr.To("foobar"), + PortRangeMin: ptr.To(80), + PortRangeMax: ptr.To(80), + Protocol: ptr.To("tcp"), }, }, }, @@ -584,12 +584,12 @@ func TestOpenStackCluster_ValidateCreate(t *testing.T) { AllNodesSecurityGroupRules: []infrav1.SecurityGroupRuleSpec{ { Name: "foobar", - Description: pointer.String("foobar"), - PortRangeMin: pointer.Int(80), - PortRangeMax: pointer.Int(80), - Protocol: pointer.String("tcp"), + Description: ptr.To("foobar"), + PortRangeMin: ptr.To(80), + PortRangeMax: ptr.To(80), + Protocol: ptr.To("tcp"), RemoteManagedGroups: []infrav1.ManagedSecurityGroupName{"controlplane"}, - RemoteGroupID: pointer.String("foobar"), + RemoteGroupID: ptr.To("foobar"), }, }, }, diff --git a/pkg/webhooks/openstackmachinetemplate_webhook_test.go b/pkg/webhooks/openstackmachinetemplate_webhook_test.go index 6b148f3bfa..1d767c1142 100644 --- a/pkg/webhooks/openstackmachinetemplate_webhook_test.go +++ b/pkg/webhooks/openstackmachinetemplate_webhook_test.go @@ -23,7 +23,7 @@ import ( . "github.com/onsi/gomega" admissionv1 "k8s.io/api/admission/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/utils/pointer" + "k8s.io/utils/ptr" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" "sigs.k8s.io/controller-runtime/pkg/webhook/admission" @@ -49,7 +49,7 @@ func TestOpenStackMachineTemplate_ValidateUpdate(t *testing.T) { Flavor: "foo", Image: infrav1.ImageParam{ Filter: &infrav1.ImageFilter{ - Name: pointer.String("bar"), + Name: ptr.To("bar"), }, }, }, @@ -63,7 +63,7 @@ func TestOpenStackMachineTemplate_ValidateUpdate(t *testing.T) { Flavor: "foo", Image: infrav1.ImageParam{ Filter: &infrav1.ImageFilter{ - Name: pointer.String("NewImage"), + Name: ptr.To("NewImage"), }, }, }, @@ -82,7 +82,7 @@ func TestOpenStackMachineTemplate_ValidateUpdate(t *testing.T) { Flavor: "foo", Image: infrav1.ImageParam{ Filter: &infrav1.ImageFilter{ - Name: pointer.String("bar"), + Name: ptr.To("bar"), }, }, }, @@ -99,7 +99,7 @@ func TestOpenStackMachineTemplate_ValidateUpdate(t *testing.T) { Flavor: "foo", Image: infrav1.ImageParam{ Filter: &infrav1.ImageFilter{ - Name: pointer.String("bar"), + Name: ptr.To("bar"), }, }, }, @@ -120,7 +120,7 @@ func TestOpenStackMachineTemplate_ValidateUpdate(t *testing.T) { Flavor: "foo", Image: infrav1.ImageParam{ Filter: &infrav1.ImageFilter{ - Name: pointer.String("bar"), + Name: ptr.To("bar"), }, }, }, @@ -134,14 +134,14 @@ func TestOpenStackMachineTemplate_ValidateUpdate(t *testing.T) { Flavor: "foo", Image: infrav1.ImageParam{ Filter: &infrav1.ImageFilter{ - Name: pointer.String("NewImage"), + Name: ptr.To("NewImage"), }, }, }, }, }, }, - req: &admission.Request{AdmissionRequest: admissionv1.AdmissionRequest{DryRun: pointer.Bool(true)}}, + req: &admission.Request{AdmissionRequest: admissionv1.AdmissionRequest{DryRun: ptr.To(true)}}, wantErr: true, }, { @@ -153,7 +153,7 @@ func TestOpenStackMachineTemplate_ValidateUpdate(t *testing.T) { Flavor: "foo", Image: infrav1.ImageParam{ Filter: &infrav1.ImageFilter{ - Name: pointer.String("bar"), + Name: ptr.To("bar"), }, }, }, @@ -172,14 +172,14 @@ func TestOpenStackMachineTemplate_ValidateUpdate(t *testing.T) { Flavor: "foo", Image: infrav1.ImageParam{ Filter: &infrav1.ImageFilter{ - Name: pointer.String("NewImage"), + Name: ptr.To("NewImage"), }, }, }, }, }, }, - req: &admission.Request{AdmissionRequest: admissionv1.AdmissionRequest{DryRun: pointer.Bool(true)}}, + req: &admission.Request{AdmissionRequest: admissionv1.AdmissionRequest{DryRun: ptr.To(true)}}, }, } diff --git a/test/e2e/suites/apivalidations/filters_test.go b/test/e2e/suites/apivalidations/filters_test.go index 08b8cdfccd..d51bb924bb 100644 --- a/test/e2e/suites/apivalidations/filters_test.go +++ b/test/e2e/suites/apivalidations/filters_test.go @@ -20,7 +20,7 @@ import ( . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" corev1 "k8s.io/api/core/v1" - "k8s.io/utils/pointer" + "k8s.io/utils/ptr" infrav1 "sigs.k8s.io/cluster-api-provider-openstack/api/v1beta1" ) @@ -38,7 +38,7 @@ var _ = Describe("Filter API validations", func() { // Initialise a basic machine object in the correct namespace machine = &infrav1.OpenStackMachine{ Spec: infrav1.OpenStackMachineSpec{ - Image: infrav1.ImageParam{Filter: &infrav1.ImageFilter{Name: pointer.String("test-image")}}, + Image: infrav1.ImageParam{Filter: &infrav1.ImageFilter{Name: ptr.To("test-image")}}, }, } machine.Namespace = namespace.Name @@ -188,9 +188,9 @@ var _ = Describe("Filter API validations", func() { It("should not allow both ID and Filter to be set", func() { machine.Spec.Image = infrav1.ImageParam{ - ID: pointer.String(imageUUID), + ID: ptr.To(imageUUID), Filter: &infrav1.ImageFilter{ - Name: pointer.String("bar"), + Name: ptr.To("bar"), }, } Expect(k8sClient.Create(ctx, machine)).NotTo(Succeed(), "OpenStackMachine creation should fail") @@ -198,7 +198,7 @@ var _ = Describe("Filter API validations", func() { It("should not allow both ID and Tags of ImageFilter to be set", func() { machine.Spec.Image = infrav1.ImageParam{ - ID: pointer.String(imageUUID), + ID: ptr.To(imageUUID), Filter: &infrav1.ImageFilter{ Tags: []string{"bar", "baz"}, }, @@ -208,14 +208,14 @@ var _ = Describe("Filter API validations", func() { It("should allow UUID ID of ImageFilter to be set", func() { machine.Spec.Image = infrav1.ImageParam{ - ID: pointer.String(imageUUID), + ID: ptr.To(imageUUID), } Expect(k8sClient.Create(ctx, machine)).To(Succeed(), "OpenStackMachine creation should succeed") }) It("should not allow non-UUID ID of ImageFilter to be set", func() { machine.Spec.Image = infrav1.ImageParam{ - ID: pointer.String("foo"), + ID: ptr.To("foo"), } Expect(k8sClient.Create(ctx, machine)).NotTo(Succeed(), "OpenStackMachine creation should fail") }) @@ -223,7 +223,7 @@ var _ = Describe("Filter API validations", func() { It("should allow Name and Tags of ImageFilter to be set", func() { machine.Spec.Image = infrav1.ImageParam{ Filter: &infrav1.ImageFilter{ - Name: pointer.String("bar"), + Name: ptr.To("bar"), Tags: []string{"bar", "baz"}, }, } @@ -241,7 +241,7 @@ var _ = Describe("Filter API validations", func() { Context("NetworkParam", func() { It("should allow setting ID", func() { cluster.Spec.Network = &infrav1.NetworkParam{ - ID: pointer.String("06c32c52-f207-4f6a-a769-bbcbe5a43f5c"), + ID: ptr.To("06c32c52-f207-4f6a-a769-bbcbe5a43f5c"), } Expect(k8sClient.Create(ctx, cluster)).To(Succeed(), "OpenStackCluster creation should succeed") }) @@ -260,7 +260,7 @@ var _ = Describe("Filter API validations", func() { It("should not allow setting invalid id", func() { cluster.Spec.Network = &infrav1.NetworkParam{ - ID: pointer.String("foo"), + ID: ptr.To("foo"), } Expect(k8sClient.Create(ctx, cluster)).NotTo(Succeed(), "OpenStackCluster creation should fail") }) @@ -274,7 +274,7 @@ var _ = Describe("Filter API validations", func() { It("should not allow setting both ID and Filter", func() { cluster.Spec.Network = &infrav1.NetworkParam{ - ID: pointer.String("06c32c52-f207-4f6a-a769-bbcbe5a43f5c"), Filter: &infrav1.NetworkFilter{Name: "foo"}, + ID: ptr.To("06c32c52-f207-4f6a-a769-bbcbe5a43f5c"), Filter: &infrav1.NetworkFilter{Name: "foo"}, } Expect(k8sClient.Create(ctx, cluster)).NotTo(Succeed(), "OpenStackCluster creation should fail") }) @@ -283,7 +283,7 @@ var _ = Describe("Filter API validations", func() { Context("SubnetParam", func() { It("should allow setting ID", func() { cluster.Spec.Subnets = []infrav1.SubnetParam{ - {ID: pointer.String("06c32c52-f207-4f6a-a769-bbcbe5a43f5c")}, + {ID: ptr.To("06c32c52-f207-4f6a-a769-bbcbe5a43f5c")}, } Expect(k8sClient.Create(ctx, cluster)).To(Succeed(), "OpenStackCluster creation should succeed") }) @@ -302,7 +302,7 @@ var _ = Describe("Filter API validations", func() { It("should not allow setting invalid id", func() { cluster.Spec.Subnets = []infrav1.SubnetParam{ - {ID: pointer.String("foo")}, + {ID: ptr.To("foo")}, } Expect(k8sClient.Create(ctx, cluster)).NotTo(Succeed(), "OpenStackCluster creation should fail") }) @@ -316,7 +316,7 @@ var _ = Describe("Filter API validations", func() { It("should not allow setting both ID and Filter", func() { cluster.Spec.Subnets = []infrav1.SubnetParam{ - {ID: pointer.String("06c32c52-f207-4f6a-a769-bbcbe5a43f5c"), Filter: &infrav1.SubnetFilter{Name: "foo"}}, + {ID: ptr.To("06c32c52-f207-4f6a-a769-bbcbe5a43f5c"), Filter: &infrav1.SubnetFilter{Name: "foo"}}, } Expect(k8sClient.Create(ctx, cluster)).NotTo(Succeed(), "OpenStackCluster creation should fail") }) @@ -325,7 +325,7 @@ var _ = Describe("Filter API validations", func() { Context("SecurityGroupParam", func() { It("should allow setting ID", func() { machine.Spec.SecurityGroups = []infrav1.SecurityGroupParam{ - {ID: pointer.String("06c32c52-f207-4f6a-a769-bbcbe5a43f5c")}, + {ID: ptr.To("06c32c52-f207-4f6a-a769-bbcbe5a43f5c")}, } Expect(k8sClient.Create(ctx, machine)).To(Succeed(), "OpenStackMachine creation should succeed") }) @@ -344,7 +344,7 @@ var _ = Describe("Filter API validations", func() { It("should not allow setting invalid id", func() { machine.Spec.SecurityGroups = []infrav1.SecurityGroupParam{ - {ID: pointer.String("foo")}, + {ID: ptr.To("foo")}, } Expect(k8sClient.Create(ctx, machine)).NotTo(Succeed(), "OpenStackMachine creation should fail") }) @@ -358,7 +358,7 @@ var _ = Describe("Filter API validations", func() { It("should not allow setting both ID and Filter", func() { machine.Spec.SecurityGroups = []infrav1.SecurityGroupParam{ - {ID: pointer.String("06c32c52-f207-4f6a-a769-bbcbe5a43f5c"), Filter: &infrav1.SecurityGroupFilter{Name: "foo"}}, + {ID: ptr.To("06c32c52-f207-4f6a-a769-bbcbe5a43f5c"), Filter: &infrav1.SecurityGroupFilter{Name: "foo"}}, } Expect(k8sClient.Create(ctx, machine)).NotTo(Succeed(), "OpenStackMachine creation should fail") }) @@ -367,7 +367,7 @@ var _ = Describe("Filter API validations", func() { Context("RouterParam", func() { It("should allow setting ID", func() { cluster.Spec.Router = &infrav1.RouterParam{ - ID: pointer.String("06c32c52-f207-4f6a-a769-bbcbe5a43f5c"), + ID: ptr.To("06c32c52-f207-4f6a-a769-bbcbe5a43f5c"), } Expect(k8sClient.Create(ctx, cluster)).To(Succeed(), "OpenStackCluster creation should succeed") }) @@ -386,7 +386,7 @@ var _ = Describe("Filter API validations", func() { It("should not allow setting invalid id", func() { cluster.Spec.Router = &infrav1.RouterParam{ - ID: pointer.String("foo"), + ID: ptr.To("foo"), } Expect(k8sClient.Create(ctx, cluster)).NotTo(Succeed(), "OpenStackCluster creation should fail") }) @@ -400,7 +400,7 @@ var _ = Describe("Filter API validations", func() { It("should not allow setting both ID and Filter", func() { cluster.Spec.Router = &infrav1.RouterParam{ - ID: pointer.String("06c32c52-f207-4f6a-a769-bbcbe5a43f5c"), + ID: ptr.To("06c32c52-f207-4f6a-a769-bbcbe5a43f5c"), Filter: &infrav1.RouterFilter{Name: "foo"}, } Expect(k8sClient.Create(ctx, cluster)).NotTo(Succeed(), "OpenStackCluster creation should fail") @@ -409,12 +409,12 @@ var _ = Describe("Filter API validations", func() { Context("ServerGroupParam", func() { It("should allow setting ID", func() { - machine.Spec.ServerGroup = &infrav1.ServerGroupParam{ID: pointer.String("06c32c52-f207-4f6a-a769-bbcbe5a43f5c")} + machine.Spec.ServerGroup = &infrav1.ServerGroupParam{ID: ptr.To("06c32c52-f207-4f6a-a769-bbcbe5a43f5c")} Expect(k8sClient.Create(ctx, machine)).To(Succeed(), "OpenStackMachine creation should succeed") }) It("should allow setting non-empty Filter", func() { - machine.Spec.ServerGroup = &infrav1.ServerGroupParam{Filter: &infrav1.ServerGroupFilter{Name: pointer.String("foo")}} + machine.Spec.ServerGroup = &infrav1.ServerGroupParam{Filter: &infrav1.ServerGroupFilter{Name: ptr.To("foo")}} Expect(k8sClient.Create(ctx, machine)).To(Succeed(), "OpenStackMachine creation should succeed") }) @@ -424,7 +424,7 @@ var _ = Describe("Filter API validations", func() { }) It("should not allow setting invalid id", func() { - machine.Spec.ServerGroup = &infrav1.ServerGroupParam{ID: pointer.String("foo")} + machine.Spec.ServerGroup = &infrav1.ServerGroupParam{ID: ptr.To("foo")} Expect(k8sClient.Create(ctx, machine)).NotTo(Succeed(), "OpenStackMachine creation should fail") }) @@ -435,8 +435,8 @@ var _ = Describe("Filter API validations", func() { It("should not allow setting both ID and Filter", func() { machine.Spec.ServerGroup = &infrav1.ServerGroupParam{ - ID: pointer.String("06c32c52-f207-4f6a-a769-bbcbe5a43f5c"), - Filter: &infrav1.ServerGroupFilter{Name: pointer.String("foo")}, + ID: ptr.To("06c32c52-f207-4f6a-a769-bbcbe5a43f5c"), + Filter: &infrav1.ServerGroupFilter{Name: ptr.To("foo")}, } Expect(k8sClient.Create(ctx, machine)).NotTo(Succeed(), "OpenStackMachine creation should fail") }) diff --git a/test/e2e/suites/apivalidations/openstackcluster_test.go b/test/e2e/suites/apivalidations/openstackcluster_test.go index d05a21c732..33657eb00d 100644 --- a/test/e2e/suites/apivalidations/openstackcluster_test.go +++ b/test/e2e/suites/apivalidations/openstackcluster_test.go @@ -21,7 +21,7 @@ import ( . "github.com/onsi/gomega" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/types" - "k8s.io/utils/pointer" + "k8s.io/utils/ptr" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" "sigs.k8s.io/controller-runtime/pkg/client" @@ -105,11 +105,11 @@ var _ = Describe("OpenStackCluster API validations", func() { It("should allow bastion.enabled=true with a spec", func() { cluster.Spec.Bastion = &infrav1.Bastion{ - Enabled: pointer.Bool(true), + Enabled: ptr.To(true), Spec: &infrav1.OpenStackMachineSpec{ Image: infrav1.ImageParam{ Filter: &infrav1.ImageFilter{ - Name: pointer.String("fake-image"), + Name: ptr.To("fake-image"), }, }, }, @@ -119,7 +119,7 @@ var _ = Describe("OpenStackCluster API validations", func() { It("should not allow bastion.enabled=true without a spec", func() { cluster.Spec.Bastion = &infrav1.Bastion{ - Enabled: pointer.Bool(true), + Enabled: ptr.To(true), } Expect(create(cluster)).NotTo(Succeed(), "OpenStackCluster creation should not succeed") }) @@ -134,7 +134,7 @@ var _ = Describe("OpenStackCluster API validations", func() { Spec: &infrav1.OpenStackMachineSpec{ Image: infrav1.ImageParam{ Filter: &infrav1.ImageFilter{ - Name: pointer.String("fake-image"), + Name: ptr.To("fake-image"), }, }, }, @@ -150,15 +150,15 @@ var _ = Describe("OpenStackCluster API validations", func() { It("should allow IPv4 as bastion floatingIP", func() { cluster.Spec.Bastion = &infrav1.Bastion{ - Enabled: pointer.Bool(true), + Enabled: ptr.To(true), Spec: &infrav1.OpenStackMachineSpec{ Image: infrav1.ImageParam{ Filter: &infrav1.ImageFilter{ - Name: pointer.String("fake-image"), + Name: ptr.To("fake-image"), }, }, }, - FloatingIP: pointer.String("10.0.0.0"), + FloatingIP: ptr.To("10.0.0.0"), } Expect(create(cluster)).To(Succeed(), "OpenStackCluster creation should succeed") }) @@ -168,11 +168,11 @@ var _ = Describe("OpenStackCluster API validations", func() { Spec: &infrav1.OpenStackMachineSpec{ Image: infrav1.ImageParam{ Filter: &infrav1.ImageFilter{ - Name: pointer.String("fake-image"), + Name: ptr.To("fake-image"), }, }, }, - FloatingIP: pointer.String("foobar"), + FloatingIP: ptr.To("foobar"), } Expect(create(cluster)).NotTo(Succeed(), "OpenStackCluster creation should not succeed") }) diff --git a/test/e2e/suites/apivalidations/openstackmachine_test.go b/test/e2e/suites/apivalidations/openstackmachine_test.go index 4e888a3a41..f8ad67970a 100644 --- a/test/e2e/suites/apivalidations/openstackmachine_test.go +++ b/test/e2e/suites/apivalidations/openstackmachine_test.go @@ -22,7 +22,7 @@ import ( . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" corev1 "k8s.io/api/core/v1" - "k8s.io/utils/pointer" + "k8s.io/utils/ptr" infrav1 "sigs.k8s.io/cluster-api-provider-openstack/api/v1beta1" ) @@ -37,7 +37,7 @@ var _ = Describe("OpenStackMachine API validations", func() { // Initialise a basic machine object in the correct namespace machine = &infrav1.OpenStackMachine{ Spec: infrav1.OpenStackMachineSpec{ - Image: infrav1.ImageParam{Filter: &infrav1.ImageFilter{Name: pointer.String("test-image")}}, + Image: infrav1.ImageParam{Filter: &infrav1.ImageFilter{Name: ptr.To("test-image")}}, }, } machine.Namespace = namespace.Name @@ -53,11 +53,11 @@ var _ = Describe("OpenStackMachine API validations", func() { Expect(k8sClient.Create(ctx, machine)).To(Succeed(), "OpenStackMachine creation should succeed") By("Setting the providerID") - machine.Spec.ProviderID = pointer.String("foo") + machine.Spec.ProviderID = ptr.To("foo") Expect(k8sClient.Update(ctx, machine)).To(Succeed(), "Setting providerID should succeed") By("Modifying the providerID") - machine.Spec.ProviderID = pointer.String("bar") + machine.Spec.ProviderID = ptr.To("bar") Expect(k8sClient.Update(ctx, machine)).NotTo(Succeed(), "Updating providerID should fail") }) diff --git a/test/e2e/suites/conformance/conformance_test.go b/test/e2e/suites/conformance/conformance_test.go index 02019422fc..25a5cc2f22 100644 --- a/test/e2e/suites/conformance/conformance_test.go +++ b/test/e2e/suites/conformance/conformance_test.go @@ -28,7 +28,7 @@ import ( . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" corev1 "k8s.io/api/core/v1" - "k8s.io/utils/pointer" + "k8s.io/utils/ptr" "sigs.k8s.io/cluster-api/test/framework/clusterctl" "sigs.k8s.io/cluster-api/test/framework/kubernetesversions" "sigs.k8s.io/cluster-api/test/framework/kubetest" @@ -81,8 +81,8 @@ var _ = Describe("conformance tests", func() { Namespace: namespace.Name, ClusterName: name, KubernetesVersion: kubernetesVersion, - ControlPlaneMachineCount: pointer.Int64(controlPlaneMachineCount), - WorkerMachineCount: pointer.Int64(workerMachineCount), + ControlPlaneMachineCount: ptr.To(controlPlaneMachineCount), + WorkerMachineCount: ptr.To(workerMachineCount), }, WaitForClusterIntervals: e2eCtx.E2EConfig.GetIntervals(specName, "wait-cluster"), WaitForControlPlaneIntervals: e2eCtx.E2EConfig.GetIntervals(specName, "wait-control-plane"), diff --git a/test/e2e/suites/e2e/e2e_test.go b/test/e2e/suites/e2e/e2e_test.go index 78ddf8b55a..09ee609346 100644 --- a/test/e2e/suites/e2e/e2e_test.go +++ b/test/e2e/suites/e2e/e2e_test.go @@ -45,7 +45,7 @@ import ( apimachinerytypes "k8s.io/apimachinery/pkg/types" utilrand "k8s.io/apimachinery/pkg/util/rand" "k8s.io/apimachinery/pkg/util/sets" - "k8s.io/utils/pointer" + "k8s.io/utils/ptr" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" bootstrapv1 "sigs.k8s.io/cluster-api/bootstrap/kubeadm/api/v1beta1" "sigs.k8s.io/cluster-api/controllers/noderefutil" @@ -85,8 +85,8 @@ var _ = Describe("e2e tests [PR-Blocking]", func() { shared.Logf("Creating a cluster") clusterName := fmt.Sprintf("cluster-%s", namespace.Name) configCluster := defaultConfigCluster(clusterName, namespace.Name) - configCluster.ControlPlaneMachineCount = pointer.Int64(1) - configCluster.WorkerMachineCount = pointer.Int64(1) + configCluster.ControlPlaneMachineCount = ptr.To(int64(1)) + configCluster.WorkerMachineCount = ptr.To(int64(1)) configCluster.Flavor = shared.FlavorDefault createCluster(ctx, configCluster, clusterResources) md := clusterResources.MachineDeployments @@ -176,7 +176,7 @@ var _ = Describe("e2e tests [PR-Blocking]", func() { openStackCluster, err = shared.ClusterForSpec(ctx, e2eCtx, namespace) Expect(err).NotTo(HaveOccurred()) openStackClusterDisabledBastion := openStackCluster.DeepCopy() - openStackClusterDisabledBastion.Spec.Bastion.Enabled = pointer.Bool(false) + openStackClusterDisabledBastion.Spec.Bastion.Enabled = ptr.To(false) Expect(e2eCtx.Environment.BootstrapClusterProxy.GetClient().Update(ctx, openStackClusterDisabledBastion)).To(Succeed()) Eventually( func() (bool, error) { @@ -253,8 +253,8 @@ var _ = Describe("e2e tests [PR-Blocking]", func() { shared.Logf("Creating a cluster") clusterName := fmt.Sprintf("cluster-%s", namespace.Name) configCluster := defaultConfigCluster(clusterName, namespace.Name) - configCluster.ControlPlaneMachineCount = pointer.Int64(1) - configCluster.WorkerMachineCount = pointer.Int64(1) + configCluster.ControlPlaneMachineCount = ptr.To(int64(1)) + configCluster.WorkerMachineCount = ptr.To(int64(1)) configCluster.Flavor = shared.FlavorFlatcar createCluster(ctx, configCluster, clusterResources) md := clusterResources.MachineDeployments @@ -298,8 +298,8 @@ var _ = Describe("e2e tests [PR-Blocking]", func() { shared.Logf("Creating a cluster") clusterName := fmt.Sprintf("cluster-%s", namespace.Name) configCluster := defaultConfigCluster(clusterName, namespace.Name) - configCluster.ControlPlaneMachineCount = pointer.Int64(1) - configCluster.WorkerMachineCount = pointer.Int64(1) + configCluster.ControlPlaneMachineCount = ptr.To(int64(1)) + configCluster.WorkerMachineCount = ptr.To(int64(1)) configCluster.Flavor = shared.FlavorFlatcarSysext createCluster(ctx, configCluster, clusterResources) md := clusterResources.MachineDeployments @@ -340,8 +340,8 @@ var _ = Describe("e2e tests [PR-Blocking]", func() { shared.Logf("Creating a cluster") clusterName := fmt.Sprintf("cluster-%s", namespace.Name) configCluster := defaultConfigCluster(clusterName, namespace.Name) - configCluster.ControlPlaneMachineCount = pointer.Int64(1) - configCluster.WorkerMachineCount = pointer.Int64(1) + configCluster.ControlPlaneMachineCount = ptr.To(int64(1)) + configCluster.WorkerMachineCount = ptr.To(int64(1)) configCluster.Flavor = shared.FlavorWithoutLB createCluster(ctx, configCluster, clusterResources) md := clusterResources.MachineDeployments @@ -372,11 +372,11 @@ var _ = Describe("e2e tests [PR-Blocking]", func() { customPortOptions := &[]infrav1.PortOpts{ { - Description: pointer.String("primary"), + Description: ptr.To("primary"), }, { - Description: pointer.String("trunked"), - Trunk: pointer.Bool(true), + Description: ptr.To("trunked"), + Trunk: ptr.To(true), }, { SecurityGroups: []infrav1.SecurityGroupParam{{Filter: &infrav1.SecurityGroupFilter{Name: testSecurityGroupName}}}, @@ -474,8 +474,8 @@ var _ = Describe("e2e tests [PR-Blocking]", func() { shared.Logf("Creating a cluster") clusterName = fmt.Sprintf("cluster-%s", namespace.Name) configCluster = defaultConfigCluster(clusterName, namespace.Name) - configCluster.ControlPlaneMachineCount = pointer.Int64(1) - configCluster.WorkerMachineCount = pointer.Int64(1) + configCluster.ControlPlaneMachineCount = ptr.To(int64(1)) + configCluster.WorkerMachineCount = ptr.To(int64(1)) configCluster.Flavor = shared.FlavorMultiNetwork createCluster(ctx, configCluster, clusterResources) md = clusterResources.MachineDeployments @@ -559,8 +559,8 @@ var _ = Describe("e2e tests [PR-Blocking]", func() { shared.Logf("Creating a cluster") clusterName := fmt.Sprintf("cluster-%s", namespace.Name) configCluster := defaultConfigCluster(clusterName, namespace.Name) - configCluster.ControlPlaneMachineCount = pointer.Int64(1) - configCluster.WorkerMachineCount = pointer.Int64(0) + configCluster.ControlPlaneMachineCount = ptr.To(int64(1)) + configCluster.WorkerMachineCount = ptr.To(int64(0)) configCluster.Flavor = shared.FlavorWithoutLB createCluster(ctx, configCluster, clusterResources) @@ -612,8 +612,8 @@ var _ = Describe("e2e tests [PR-Blocking]", func() { shared.Logf("Creating a cluster") clusterName = fmt.Sprintf("cluster-%s", namespace.Name) configCluster := defaultConfigCluster(clusterName, namespace.Name) - configCluster.ControlPlaneMachineCount = pointer.Int64(3) - configCluster.WorkerMachineCount = pointer.Int64(2) + configCluster.ControlPlaneMachineCount = ptr.To(int64(3)) + configCluster.WorkerMachineCount = ptr.To(int64(2)) configCluster.Flavor = shared.FlavorMultiAZ createCluster(ctx, configCluster, clusterResources) md = clusterResources.MachineDeployments @@ -861,7 +861,7 @@ func makeOpenStackMachineTemplate(namespace, clusterName, name string) *infrav1. Flavor: e2eCtx.E2EConfig.GetVariable(shared.OpenStackNodeMachineFlavor), Image: infrav1.ImageParam{ Filter: &infrav1.ImageFilter{ - Name: pointer.String(e2eCtx.E2EConfig.GetVariable(shared.OpenStackImageName)), + Name: ptr.To(e2eCtx.E2EConfig.GetVariable(shared.OpenStackImageName)), }, }, SSHKeyName: shared.DefaultSSHKeyPairName, @@ -887,7 +887,7 @@ func makeOpenStackMachineTemplateWithPortOptions(namespace, clusterName, name st Flavor: e2eCtx.E2EConfig.GetVariable(shared.OpenStackNodeMachineFlavor), Image: infrav1.ImageParam{ Filter: &infrav1.ImageFilter{ - Name: pointer.String(e2eCtx.E2EConfig.GetVariable(shared.OpenStackImageName)), + Name: ptr.To(e2eCtx.E2EConfig.GetVariable(shared.OpenStackImageName)), }, }, SSHKeyName: shared.DefaultSSHKeyPairName, @@ -976,7 +976,7 @@ func makeMachineDeployment(namespace, mdName, clusterName string, failureDomain Name: mdName, Namespace: namespace, }, - Version: pointer.String(e2eCtx.E2EConfig.GetVariable(shared.KubernetesVersion)), + Version: ptr.To(e2eCtx.E2EConfig.GetVariable(shared.KubernetesVersion)), }, }, }, diff --git a/test/e2e/suites/e2e/remediations_test.go b/test/e2e/suites/e2e/remediations_test.go index e047dd498f..c4a4e0d1f8 100644 --- a/test/e2e/suites/e2e/remediations_test.go +++ b/test/e2e/suites/e2e/remediations_test.go @@ -23,7 +23,7 @@ import ( "context" . "github.com/onsi/ginkgo/v2" - "k8s.io/utils/pointer" + "k8s.io/utils/ptr" capi_e2e "sigs.k8s.io/cluster-api/test/e2e" "sigs.k8s.io/cluster-api-provider-openstack/test/e2e/shared" @@ -39,7 +39,7 @@ var _ = Describe("When testing unhealthy machines remediation", func() { BootstrapClusterProxy: e2eCtx.Environment.BootstrapClusterProxy, ArtifactFolder: e2eCtx.Settings.ArtifactFolder, SkipCleanup: false, - Flavor: pointer.String(shared.FlavorMDRemediation), + Flavor: ptr.To(shared.FlavorMDRemediation), } }) }) diff --git a/test/helpers/external/cluster.go b/test/helpers/external/cluster.go index 6a697f0d17..25e8f9bebd 100644 --- a/test/helpers/external/cluster.go +++ b/test/helpers/external/cluster.go @@ -21,7 +21,7 @@ import ( "golang.org/x/text/language" apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/utils/pointer" + "k8s.io/utils/ptr" ) const ( @@ -67,11 +67,11 @@ func generateTestClusterAPICRD(kind, pluralKind string) *apiextensionsv1.CustomR Properties: map[string]apiextensionsv1.JSONSchemaProps{ "spec": { Type: "object", - XPreserveUnknownFields: pointer.Bool(true), + XPreserveUnknownFields: ptr.To(true), }, "status": { Type: "object", - XPreserveUnknownFields: pointer.Bool(true), + XPreserveUnknownFields: ptr.To(true), }, }, }, diff --git a/test/helpers/fuzzerfuncs.go b/test/helpers/fuzzerfuncs.go index 063bfe9b58..b5648eae6d 100644 --- a/test/helpers/fuzzerfuncs.go +++ b/test/helpers/fuzzerfuncs.go @@ -20,7 +20,7 @@ import ( "strings" fuzz "github.com/google/gofuzz" - "k8s.io/utils/pointer" + "k8s.io/utils/ptr" infrav1 "sigs.k8s.io/cluster-api-provider-openstack/api/v1beta1" "sigs.k8s.io/cluster-api-provider-openstack/pkg/utils/optional" @@ -52,7 +52,7 @@ type isZeroer[T any] interface { func fuzzFilterParam[Z isZeroer[T], T any](id *optional.String, filter *Z, c fuzz.Continue) { if c.RandBool() { - *id = pointer.String(nonEmptyString(c)) + *id = ptr.To(nonEmptyString(c)) *filter = nil } else { *filter = new(T)