From 87b50e13f120e3f969527c0783d85b58e9bcc91b Mon Sep 17 00:00:00 2001 From: Matt Boersma Date: Fri, 30 May 2025 11:23:10 -0600 Subject: [PATCH 1/2] Bump Go toolchain to v1.24.4 --- Dockerfile | 2 +- Tiltfile | 2 +- api/v1beta1/azurecluster_webhook_test.go | 5 +- .../azureclusteridentity_webhook_test.go | 5 +- .../azureclustertemplate_webhook_test.go | 3 +- api/v1beta1/azuremachine_webhook_test.go | 10 ++-- .../azuremachinetemplate_webhook_test.go | 7 +-- .../azuremanagedcluster_webhook_test.go | 7 +-- .../azuremanagedcontrolplane_webhook_test.go | 21 ++++--- ...anagedcontrolplanetemplate_webhook_test.go | 7 +-- .../azuremanagedmachinepool_webhook_test.go | 15 +++-- ...managedmachinepooltemplate_webhook_test.go | 7 +-- azure/converters/resourcehealth.go | 2 +- azure/defaults_test.go | 4 +- azure/errors_test.go | 4 +- azure/scope/cluster_test.go | 15 +++-- azure/scope/identity_test.go | 8 +-- azure/scope/machine.go | 2 +- azure/scope/machine_test.go | 13 ++--- azure/scope/machinepool_test.go | 8 +-- azure/scope/machinepoolmachine_test.go | 3 +- azure/scope/managedcontrolplane_test.go | 3 +- azure/scope/managedmachinepool_test.go | 3 +- .../machinepool_deployment_strategy_test.go | 3 +- azure/services/agentpools/agentpools_test.go | 9 ++- azure/services/agentpools/spec_test.go | 9 ++- azure/services/aksextensions/spec_test.go | 3 +- azure/services/aso/aso_test.go | 56 +++++++++--------- azure/services/aso/service_test.go | 30 +++++----- azure/services/async/async_test.go | 4 +- .../availabilitysets/availabilitysets_test.go | 5 +- azure/services/availabilitysets/spec_test.go | 3 +- azure/services/bastionhosts/spec_test.go | 3 +- azure/services/disks/disks_test.go | 3 +- azure/services/fleetsmembers/spec_test.go | 3 +- azure/services/groups/groups_test.go | 3 +- azure/services/groups/spec_test.go | 3 +- .../inboundnatrules/inboundnatrules_test.go | 5 +- azure/services/inboundnatrules/spec_test.go | 3 +- .../loadbalancers/loadbalancers_test.go | 5 +- azure/services/loadbalancers/spec_test.go | 3 +- .../managedclusters/managedclusters_test.go | 9 ++- azure/services/managedclusters/spec_test.go | 9 ++- .../services/natgateways/natgateways_test.go | 5 +- azure/services/natgateways/spec_test.go | 3 +- .../networkinterfaces_test.go | 5 +- azure/services/networkinterfaces/spec_test.go | 3 +- azure/services/privatedns/link_spec_test.go | 3 +- azure/services/privatedns/privatedns_test.go | 5 +- azure/services/privatedns/record_spec_test.go | 3 +- azure/services/privatedns/zone_spec_test.go | 3 +- azure/services/privateendpoints/spec_test.go | 3 +- azure/services/publicips/publicips_test.go | 5 +- azure/services/publicips/spec_test.go | 3 +- .../resourcehealth/resourcehealth_test.go | 3 +- azure/services/resourceskus/cache_test.go | 7 +-- .../roleassignments/roleassignments_test.go | 5 +- azure/services/roleassignments/spec_test.go | 3 +- .../services/routetables/routetables_test.go | 5 +- azure/services/routetables/spec_test.go | 3 +- azure/services/scalesets/scalesets_test.go | 5 +- azure/services/scalesets/spec_test.go | 3 +- .../scalesets/vmssextension_spec_test.go | 3 +- .../services/scalesetvms/scalesetvms_test.go | 5 +- .../securitygroups/securitygroups_test.go | 5 +- azure/services/securitygroups/spec_test.go | 3 +- azure/services/subnets/spec_test.go | 3 +- azure/services/subnets/subnets_test.go | 9 ++- azure/services/tags/tags_test.go | 3 +- .../virtualmachineimages/images_test.go | 5 +- azure/services/virtualmachines/spec_test.go | 3 +- .../virtualmachines/virtualmachines_test.go | 7 +-- azure/services/virtualnetworks/spec_test.go | 3 +- .../virtualnetworks/virtualnetworks_test.go | 7 +-- azure/services/vmextensions/spec_test.go | 3 +- .../vmextensions/vmextensions_test.go | 3 +- azure/services/vnetpeerings/spec_test.go | 3 +- .../vnetpeerings/vnetpeerings_test.go | 5 +- controllers/agentpooladopt_controller_test.go | 3 +- controllers/aso_credential_cache_test.go | 3 +- controllers/asosecret_controller_test.go | 5 +- .../azureasomanagedcluster_controller_test.go | 2 +- ...easomanagedcontrolplane_controller_test.go | 2 +- ...reasomanagedmachinepool_controller_test.go | 2 +- controllers/azurecluster_controller.go | 8 +-- controllers/azurecluster_controller_test.go | 10 ++-- controllers/azurecluster_reconciler_test.go | 7 +-- .../azurejson_machine_controller_test.go | 3 +- .../azurejson_machinepool_controller_test.go | 5 +- ...urejson_machinetemplate_controller_test.go | 3 +- controllers/azuremachine_controller_test.go | 16 +++--- controllers/azuremachine_reconciler_test.go | 7 +-- .../azuremanagedcluster_controller_test.go | 3 +- ...zuremanagedcontrolplane_controller_test.go | 9 ++- ...zuremanagedcontrolplane_reconciler_test.go | 3 +- .../azuremanagedmachinepool_controller.go | 2 +- ...azuremanagedmachinepool_controller_test.go | 3 +- ...azuremanagedmachinepool_reconciler_test.go | 3 +- controllers/helpers_test.go | 57 +++++++++---------- .../managedclusteradopt_controller_test.go | 3 +- controllers/resource_reconciler_test.go | 8 +-- .../v1beta1/azuremachinepool_webhook_test.go | 16 +++--- .../azuremachinepool_controller_test.go | 4 +- .../azuremachinepool_reconciler_test.go | 7 +-- ...azuremachinepoolmachine_controller_test.go | 7 +-- exp/controllers/helpers_test.go | 10 ++-- go.mod | 4 +- hack/tools/go.mod | 4 +- pkg/coalescing/reconciler_test.go | 3 +- .../azureasomanagedcontrolplane_test.go | 11 ++-- .../azureasomanagedmachinepool_test.go | 7 +-- pkg/mutators/mutator_test.go | 4 +- 112 files changed, 315 insertions(+), 401 deletions(-) diff --git a/Dockerfile b/Dockerfile index 524b93cc1fe..e1684c9d1d7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -18,7 +18,7 @@ ARG ARCH # Build the manager binary -FROM golang:1.23 AS builder +FROM golang:1.24 AS builder WORKDIR /workspace # Run this with docker build --build_arg $(go env GOPROXY) to override the goproxy diff --git a/Tiltfile b/Tiltfile index 4f3326e65d4..6b8641ea1a5 100644 --- a/Tiltfile +++ b/Tiltfile @@ -173,7 +173,7 @@ def validate_auth(): tilt_helper_dockerfile_header = """ # Tilt image -FROM golang:1.23 AS tilt-helper +FROM golang:1.24 AS tilt-helper # Support live reloading with Tilt RUN wget --output-document /restart.sh --quiet https://raw.githubusercontent.com/windmilleng/rerun-process-wrapper/master/restart.sh && \ wget --output-document /start.sh --quiet https://raw.githubusercontent.com/windmilleng/rerun-process-wrapper/master/start.sh && \ diff --git a/api/v1beta1/azurecluster_webhook_test.go b/api/v1beta1/azurecluster_webhook_test.go index 79449a29ed8..a7848e7db00 100644 --- a/api/v1beta1/azurecluster_webhook_test.go +++ b/api/v1beta1/azurecluster_webhook_test.go @@ -17,7 +17,6 @@ limitations under the License. package v1beta1 import ( - "context" "testing" . "github.com/onsi/gomega" @@ -109,7 +108,7 @@ func TestAzureCluster_ValidateCreate(t *testing.T) { for _, tc := range tests { t.Run(tc.name, func(t *testing.T) { g := NewWithT(t) - _, err := (&AzureClusterWebhook{}).ValidateCreate(context.Background(), tc.cluster) + _, err := (&AzureClusterWebhook{}).ValidateCreate(t.Context(), tc.cluster) if tc.wantErr { g.Expect(err).To(HaveOccurred()) } else { @@ -345,7 +344,7 @@ func TestAzureCluster_ValidateUpdate(t *testing.T) { t.Run(tc.name, func(t *testing.T) { t.Parallel() g := NewWithT(t) - _, err := (&AzureClusterWebhook{}).ValidateUpdate(context.Background(), tc.oldCluster, tc.cluster) + _, err := (&AzureClusterWebhook{}).ValidateUpdate(t.Context(), tc.oldCluster, tc.cluster) if tc.wantErr { g.Expect(err).To(HaveOccurred()) } else { diff --git a/api/v1beta1/azureclusteridentity_webhook_test.go b/api/v1beta1/azureclusteridentity_webhook_test.go index 9205338b2f9..33f6044bb66 100644 --- a/api/v1beta1/azureclusteridentity_webhook_test.go +++ b/api/v1beta1/azureclusteridentity_webhook_test.go @@ -17,7 +17,6 @@ limitations under the License. package v1beta1 import ( - "context" "testing" . "github.com/onsi/gomega" @@ -84,7 +83,7 @@ func TestAzureClusterIdentity_ValidateCreate(t *testing.T) { for _, tc := range tests { t.Run(tc.name, func(t *testing.T) { g := NewWithT(t) - _, err := (&azureClusterIdentityWebhook{}).ValidateCreate(context.Background(), tc.clusterIdentity) + _, err := (&azureClusterIdentityWebhook{}).ValidateCreate(t.Context(), tc.clusterIdentity) if tc.wantErr { g.Expect(err).To(HaveOccurred()) } else { @@ -164,7 +163,7 @@ func TestAzureClusterIdentity_ValidateUpdate(t *testing.T) { for _, tc := range tests { t.Run(tc.name, func(t *testing.T) { g := NewWithT(t) - _, err := (&azureClusterIdentityWebhook{}).ValidateUpdate(context.Background(), tc.oldClusterIdentity, tc.clusterIdentity) + _, err := (&azureClusterIdentityWebhook{}).ValidateUpdate(t.Context(), tc.oldClusterIdentity, tc.clusterIdentity) if tc.wantErr { g.Expect(err).To(HaveOccurred()) } else { diff --git a/api/v1beta1/azureclustertemplate_webhook_test.go b/api/v1beta1/azureclustertemplate_webhook_test.go index d7d870dbaa6..5672a64107c 100644 --- a/api/v1beta1/azureclustertemplate_webhook_test.go +++ b/api/v1beta1/azureclustertemplate_webhook_test.go @@ -17,7 +17,6 @@ limitations under the License. package v1beta1 import ( - "context" "testing" . "github.com/onsi/gomega" @@ -58,7 +57,7 @@ func TestValidateUpdate(t *testing.T) { t.Run("template is immutable", func(t *testing.T) { g := NewWithT(t) - _, err := (&azureClusterTemplateWebhook{}).ValidateUpdate(context.Background(), oldClusterTemplate, newClusterTemplate) + _, err := (&azureClusterTemplateWebhook{}).ValidateUpdate(t.Context(), oldClusterTemplate, newClusterTemplate) g.Expect(err).To(HaveOccurred()) }) } diff --git a/api/v1beta1/azuremachine_webhook_test.go b/api/v1beta1/azuremachine_webhook_test.go index 7612c7cd916..fe0d1c13808 100644 --- a/api/v1beta1/azuremachine_webhook_test.go +++ b/api/v1beta1/azuremachine_webhook_test.go @@ -253,7 +253,7 @@ func TestAzureMachine_ValidateCreate(t *testing.T) { t.Run(tc.name, func(t *testing.T) { g := NewWithT(t) mw := &azureMachineWebhook{} - _, err := mw.ValidateCreate(context.Background(), tc.machine) + _, err := mw.ValidateCreate(t.Context(), tc.machine) if tc.wantErr { g.Expect(err).To(HaveOccurred()) } else { @@ -928,7 +928,7 @@ func TestAzureMachine_ValidateUpdate(t *testing.T) { t.Run(tc.name, func(t *testing.T) { g := NewWithT(t) mw := &azureMachineWebhook{} - _, err := mw.ValidateUpdate(context.Background(), tc.oldMachine, tc.newMachine) + _, err := mw.ValidateUpdate(t.Context(), tc.oldMachine, tc.newMachine) if tc.wantErr { g.Expect(err).To(HaveOccurred()) } else { @@ -980,17 +980,17 @@ func TestAzureMachine_Default(t *testing.T) { Client: mockClient, } - err := mw.Default(context.Background(), publicKeyExistTest.machine) + err := mw.Default(t.Context(), publicKeyExistTest.machine) g.Expect(err).NotTo(HaveOccurred()) g.Expect(publicKeyExistTest.machine.Spec.SSHPublicKey).To(Equal(existingPublicKey)) - err = mw.Default(context.Background(), publicKeyNotExistTest.machine) + err = mw.Default(t.Context(), publicKeyNotExistTest.machine) g.Expect(err).NotTo(HaveOccurred()) g.Expect(publicKeyNotExistTest.machine.Spec.SSHPublicKey).To(Not(BeEmpty())) for _, possibleCachingType := range armcompute.PossibleCachingTypesValues() { cacheTypeSpecifiedTest := test{machine: &AzureMachine{ObjectMeta: testObjectMeta, Spec: AzureMachineSpec{OSDisk: OSDisk{CachingType: string(possibleCachingType)}}}} - err = mw.Default(context.Background(), cacheTypeSpecifiedTest.machine) + err = mw.Default(t.Context(), cacheTypeSpecifiedTest.machine) g.Expect(err).NotTo(HaveOccurred()) g.Expect(cacheTypeSpecifiedTest.machine.Spec.OSDisk.CachingType).To(Equal(string(possibleCachingType))) } diff --git a/api/v1beta1/azuremachinetemplate_webhook_test.go b/api/v1beta1/azuremachinetemplate_webhook_test.go index d9aa7a4420c..6659f0688f7 100644 --- a/api/v1beta1/azuremachinetemplate_webhook_test.go +++ b/api/v1beta1/azuremachinetemplate_webhook_test.go @@ -17,7 +17,6 @@ limitations under the License. package v1beta1 import ( - "context" "testing" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v5" @@ -248,7 +247,7 @@ func TestAzureMachineTemplate_ValidateCreate(t *testing.T) { t.Run(test.name, func(t *testing.T) { t.Parallel() g := NewWithT(t) - ctx := context.Background() + ctx := t.Context() _, err := (&azureMachineTemplateWebhook{}).ValidateCreate(ctx, test.machineTemplate) if test.wantErr { g.Expect(err).To(HaveOccurred()) @@ -547,7 +546,7 @@ func TestAzureMachineTemplate_ValidateUpdate(t *testing.T) { for _, amt := range tests { t.Run(amt.name, func(t *testing.T) { g := NewWithT(t) - ctx := admission.NewContextWithRequest(context.Background(), admission.Request{AdmissionRequest: admissionv1.AdmissionRequest{DryRun: ptr.To(true)}}) + ctx := admission.NewContextWithRequest(t.Context(), admission.Request{AdmissionRequest: admissionv1.AdmissionRequest{DryRun: ptr.To(true)}}) _, err := (&azureMachineTemplateWebhook{}).ValidateUpdate(ctx, amt.oldTemplate, amt.template) if amt.wantErr { g.Expect(err).To(HaveOccurred()) @@ -561,7 +560,7 @@ func TestAzureMachineTemplate_ValidateUpdate(t *testing.T) { t.Run(amt.name, func(t *testing.T) { t.Parallel() g := NewWithT(t) - ctx := admission.NewContextWithRequest(context.Background(), admission.Request{AdmissionRequest: admissionv1.AdmissionRequest{DryRun: ptr.To(false)}}) + ctx := admission.NewContextWithRequest(t.Context(), admission.Request{AdmissionRequest: admissionv1.AdmissionRequest{DryRun: ptr.To(false)}}) _, err := (&azureMachineTemplateWebhook{}).ValidateUpdate(ctx, amt.oldTemplate, amt.template) if amt.wantErr { g.Expect(err).To(HaveOccurred()) diff --git a/api/v1beta1/azuremanagedcluster_webhook_test.go b/api/v1beta1/azuremanagedcluster_webhook_test.go index 37929d4a24d..ec4cc4b919d 100644 --- a/api/v1beta1/azuremanagedcluster_webhook_test.go +++ b/api/v1beta1/azuremanagedcluster_webhook_test.go @@ -17,7 +17,6 @@ limitations under the License. package v1beta1 import ( - "context" "testing" . "github.com/onsi/gomega" @@ -82,7 +81,7 @@ func TestAzureManagedCluster_ValidateUpdate(t *testing.T) { for _, tc := range tests { t.Run(tc.name, func(t *testing.T) { g := NewWithT(t) - _, err := (&azureManagedClusterWebhook{}).ValidateUpdate(context.Background(), tc.oldAMC, tc.amc) + _, err := (&azureManagedClusterWebhook{}).ValidateUpdate(t.Context(), tc.oldAMC, tc.amc) if tc.wantErr { g.Expect(err).To(HaveOccurred()) } else { @@ -125,7 +124,7 @@ func TestAzureManagedCluster_ValidateCreate(t *testing.T) { for _, tc := range tests { t.Run(tc.name, func(t *testing.T) { g := NewWithT(t) - _, err := (&azureManagedClusterWebhook{}).ValidateCreate(context.Background(), tc.amc) + _, err := (&azureManagedClusterWebhook{}).ValidateCreate(t.Context(), tc.amc) if tc.wantErr { g.Expect(err).To(HaveOccurred()) } else { @@ -155,7 +154,7 @@ func TestAzureManagedCluster_ValidateCreateFailure(t *testing.T) { utilfeature.SetFeatureGateDuringTest(t, feature.Gates, capifeature.MachinePool, *tc.featureGateEnabled) } g := NewWithT(t) - _, err := (&azureManagedClusterWebhook{}).ValidateCreate(context.Background(), tc.amc) + _, err := (&azureManagedClusterWebhook{}).ValidateCreate(t.Context(), tc.amc) if tc.expectError { g.Expect(err).To(HaveOccurred()) } else { diff --git a/api/v1beta1/azuremanagedcontrolplane_webhook_test.go b/api/v1beta1/azuremanagedcontrolplane_webhook_test.go index 45db1012a0e..3b25e3bc7fb 100644 --- a/api/v1beta1/azuremanagedcontrolplane_webhook_test.go +++ b/api/v1beta1/azuremanagedcontrolplane_webhook_test.go @@ -17,7 +17,6 @@ limitations under the License. package v1beta1 import ( - "context" "testing" . "github.com/onsi/gomega" @@ -61,7 +60,7 @@ func TestDefaultingWebhook(t *testing.T) { }, } mcpw := &azureManagedControlPlaneWebhook{} - err := mcpw.Default(context.Background(), amcp) + err := mcpw.Default(t.Context(), amcp) g.Expect(err).NotTo(HaveOccurred()) g.Expect(amcp.Spec.ResourceGroupName).To(Equal("fooCluster")) g.Expect(amcp.Spec.Version).To(Equal("v1.17.5")) @@ -104,7 +103,7 @@ func TestDefaultingWebhook(t *testing.T) { } amcp.Spec.EnablePreviewFeatures = ptr.To(true) - err = mcpw.Default(context.Background(), amcp) + err = mcpw.Default(t.Context(), amcp) g.Expect(err).NotTo(HaveOccurred()) g.Expect(*amcp.Spec.NetworkPlugin).To(Equal(netPlug)) g.Expect(*amcp.Spec.NetworkPolicy).To(Equal(netPol)) @@ -160,7 +159,7 @@ func TestDefaultingWebhook(t *testing.T) { SSHPublicKey: ptr.To(""), }, } - err = mcpw.Default(context.Background(), amcp) + err = mcpw.Default(t.Context(), amcp) g.Expect(err).NotTo(HaveOccurred()) g.Expect(amcp.Spec.VirtualNetwork.CIDRBlock).To(Equal(defaultAKSVnetCIDRForOverlay)) g.Expect(amcp.Spec.VirtualNetwork.Subnet.CIDRBlock).To(Equal(defaultAKSNodeSubnetCIDRForOverlay)) @@ -1387,7 +1386,7 @@ func TestValidatingWebhook(t *testing.T) { mcpw := &azureManagedControlPlaneWebhook{ Client: client, } - _, err := mcpw.ValidateCreate(context.Background(), &tt.amcp) + _, err := mcpw.ValidateCreate(t.Context(), &tt.amcp) if tt.expectErr { g.Expect(err).To(HaveOccurred()) } else { @@ -1637,7 +1636,7 @@ func TestAzureManagedControlPlane_ValidateCreate(t *testing.T) { mcpw := &azureManagedControlPlaneWebhook{ Client: client, } - _, err := mcpw.ValidateCreate(context.Background(), tc.amcp) + _, err := mcpw.ValidateCreate(t.Context(), tc.amcp) if tc.wantErr { g.Expect(err).To(HaveOccurred()) if tc.errorLen > 0 { @@ -1674,7 +1673,7 @@ func TestAzureManagedControlPlane_ValidateCreateFailure(t *testing.T) { mcpw := &azureManagedControlPlaneWebhook{ Client: client, } - _, err := mcpw.ValidateCreate(context.Background(), tc.amcp) + _, err := mcpw.ValidateCreate(t.Context(), tc.amcp) if tc.expectError { g.Expect(err).To(HaveOccurred()) } else { @@ -3184,7 +3183,7 @@ func TestAzureManagedControlPlane_ValidateUpdate(t *testing.T) { mcpw := &azureManagedControlPlaneWebhook{ Client: client, } - _, err := mcpw.ValidateUpdate(context.Background(), tc.oldAMCP, tc.amcp) + _, err := mcpw.ValidateUpdate(t.Context(), tc.oldAMCP, tc.amcp) if tc.wantErr { g.Expect(err).To(HaveOccurred()) } else { @@ -3365,7 +3364,7 @@ func TestAzureManagedClusterSecurityProfileValidateCreate(t *testing.T) { mcpw := &azureManagedControlPlaneWebhook{ Client: client, } - _, err := mcpw.ValidateCreate(context.Background(), tc.amcp) + _, err := mcpw.ValidateCreate(t.Context(), tc.amcp) if tc.wantErr != "" { g.Expect(err).To(HaveOccurred()) g.Expect(err.Error()).To(Equal(tc.wantErr)) @@ -3866,7 +3865,7 @@ func TestAzureClusterSecurityProfileValidateUpdate(t *testing.T) { mcpw := &azureManagedControlPlaneWebhook{ Client: client, } - _, err := mcpw.ValidateUpdate(context.Background(), tc.oldAMCP, tc.amcp) + _, err := mcpw.ValidateUpdate(t.Context(), tc.oldAMCP, tc.amcp) if tc.wantErr != "" { g.Expect(err).To(HaveOccurred()) g.Expect(err.Error()).To(Equal(tc.wantErr)) @@ -4154,7 +4153,7 @@ func TestValidateAMCPVirtualNetwork(t *testing.T) { t.Run(tc.name, func(t *testing.T) { g := NewWithT(t) mcpw := &azureManagedControlPlaneWebhook{} - err := mcpw.Default(context.Background(), tc.amcp) + err := mcpw.Default(t.Context(), tc.amcp) g.Expect(err).NotTo(HaveOccurred()) errs := validateAMCPVirtualNetwork(tc.amcp.Spec.VirtualNetwork, field.NewPath("spec", "virtualNetwork")) diff --git a/api/v1beta1/azuremanagedcontrolplanetemplate_webhook_test.go b/api/v1beta1/azuremanagedcontrolplanetemplate_webhook_test.go index 3955ab39251..00886a8c7f6 100644 --- a/api/v1beta1/azuremanagedcontrolplanetemplate_webhook_test.go +++ b/api/v1beta1/azuremanagedcontrolplanetemplate_webhook_test.go @@ -17,7 +17,6 @@ limitations under the License. package v1beta1 import ( - "context" "testing" . "github.com/onsi/gomega" @@ -31,7 +30,7 @@ func TestControlPlaneTemplateDefaultingWebhook(t *testing.T) { t.Logf("Testing amcp defaulting webhook with no baseline") amcpt := getAzureManagedControlPlaneTemplate() mcptw := &azureManagedControlPlaneTemplateWebhook{} - err := mcptw.Default(context.Background(), amcpt) + err := mcptw.Default(t.Context(), amcpt) g.Expect(err).NotTo(HaveOccurred()) g.Expect(*amcpt.Spec.Template.Spec.NetworkPlugin).To(Equal("azure")) g.Expect(*amcpt.Spec.Template.Spec.LoadBalancerSKU).To(Equal("Standard")) @@ -54,7 +53,7 @@ func TestControlPlaneTemplateDefaultingWebhook(t *testing.T) { amcpt.Spec.Template.Spec.SKU.Tier = PaidManagedControlPlaneTier amcpt.Spec.Template.Spec.EnablePreviewFeatures = ptr.To(true) - err = mcptw.Default(context.Background(), amcpt) + err = mcptw.Default(t.Context(), amcpt) g.Expect(err).NotTo(HaveOccurred()) g.Expect(*amcpt.Spec.Template.Spec.NetworkPlugin).To(Equal(netPlug)) g.Expect(*amcpt.Spec.Template.Spec.LoadBalancerSKU).To(Equal(lbSKU)) @@ -274,7 +273,7 @@ func TestControlPlaneTemplateUpdateWebhook(t *testing.T) { t.Run(tc.name, func(t *testing.T) { g := NewWithT(t) cpw := &azureManagedControlPlaneTemplateWebhook{} - _, err := cpw.ValidateUpdate(context.Background(), tc.oldControlPlaneTemplate, tc.controlPlaneTemplate) + _, err := cpw.ValidateUpdate(t.Context(), tc.oldControlPlaneTemplate, tc.controlPlaneTemplate) if tc.wantErr { g.Expect(err).To(HaveOccurred()) } else { diff --git a/api/v1beta1/azuremanagedmachinepool_webhook_test.go b/api/v1beta1/azuremanagedmachinepool_webhook_test.go index 0c0756468a7..eb41e4b0d6e 100644 --- a/api/v1beta1/azuremanagedmachinepool_webhook_test.go +++ b/api/v1beta1/azuremanagedmachinepool_webhook_test.go @@ -17,7 +17,6 @@ limitations under the License. package v1beta1 import ( - "context" "testing" asocontainerservicev1 "github.com/Azure/azure-service-operator/v2/api/containerservice/v1api20231001" @@ -55,7 +54,7 @@ func TestAzureManagedMachinePoolDefaultingWebhook(t *testing.T) { mw := &azureManagedMachinePoolWebhook{ Client: client, } - err := mw.Default(context.Background(), ammp) + err := mw.Default(t.Context(), ammp) g.Expect(err).NotTo(HaveOccurred()) g.Expect(ammp.Labels).NotTo(BeNil()) val, ok := ammp.Labels[LabelAgentPoolMode] @@ -66,21 +65,21 @@ func TestAzureManagedMachinePoolDefaultingWebhook(t *testing.T) { t.Logf("Testing ammp defaulting webhook with empty string name specified in Spec") emptyName := "" ammp.Spec.Name = &emptyName - err = mw.Default(context.Background(), ammp) + err = mw.Default(t.Context(), ammp) g.Expect(err).NotTo(HaveOccurred()) g.Expect(*ammp.Spec.Name).To(Equal("fooname")) t.Logf("Testing ammp defaulting webhook with normal name specified in Spec") normalName := "barname" ammp.Spec.Name = &normalName - err = mw.Default(context.Background(), ammp) + err = mw.Default(t.Context(), ammp) g.Expect(err).NotTo(HaveOccurred()) g.Expect(*ammp.Spec.Name).To(Equal("barname")) t.Logf("Testing ammp defaulting webhook with normal OsDiskType specified in Spec") normalOsDiskType := "Ephemeral" ammp.Spec.OsDiskType = &normalOsDiskType - err = mw.Default(context.Background(), ammp) + err = mw.Default(t.Context(), ammp) g.Expect(err).NotTo(HaveOccurred()) g.Expect(*ammp.Spec.OsDiskType).To(Equal("Ephemeral")) } @@ -642,7 +641,7 @@ func TestAzureManagedMachinePoolUpdatingWebhook(t *testing.T) { mw := &azureManagedMachinePoolWebhook{ Client: client, } - _, err := mw.ValidateUpdate(context.Background(), tc.old, tc.new) + _, err := mw.ValidateUpdate(t.Context(), tc.old, tc.new) if tc.wantErr { g.Expect(err).To(HaveOccurred()) } else { @@ -1293,7 +1292,7 @@ func TestAzureManagedMachinePool_ValidateCreate(t *testing.T) { mw := &azureManagedMachinePoolWebhook{ Client: client, } - _, err := mw.ValidateCreate(context.Background(), tc.ammp) + _, err := mw.ValidateCreate(t.Context(), tc.ammp) if tc.wantErr { g.Expect(err).To(HaveOccurred()) g.Expect(err).To(HaveLen(tc.errorLen)) @@ -1325,7 +1324,7 @@ func TestAzureManagedMachinePool_ValidateCreateFailure(t *testing.T) { } g := NewWithT(t) mw := &azureManagedMachinePoolWebhook{} - _, err := mw.ValidateCreate(context.Background(), tc.ammp) + _, err := mw.ValidateCreate(t.Context(), tc.ammp) if tc.expectError { g.Expect(err).To(HaveOccurred()) } else { diff --git a/api/v1beta1/azuremanagedmachinepooltemplate_webhook_test.go b/api/v1beta1/azuremanagedmachinepooltemplate_webhook_test.go index 0b572a01e74..ff698e63364 100644 --- a/api/v1beta1/azuremanagedmachinepooltemplate_webhook_test.go +++ b/api/v1beta1/azuremanagedmachinepooltemplate_webhook_test.go @@ -17,7 +17,6 @@ limitations under the License. package v1beta1 import ( - "context" "testing" . "github.com/onsi/gomega" @@ -33,7 +32,7 @@ func TestManagedMachinePoolTemplateDefaultingWebhook(t *testing.T) { t.Logf("Testing ammpt defaulting webhook with no baseline") ammpt := getAzureManagedMachinePoolTemplate() mmptw := &azureManagedMachinePoolTemplateWebhook{} - err := mmptw.Default(context.Background(), ammpt) + err := mmptw.Default(t.Context(), ammpt) g.Expect(err).NotTo(HaveOccurred()) g.Expect(ammpt.Labels).To(Equal(map[string]string{ LabelAgentPoolMode: "System", @@ -47,7 +46,7 @@ func TestManagedMachinePoolTemplateDefaultingWebhook(t *testing.T) { ammpt.Spec.Template.Spec.Name = ptr.To("barName") ammpt.Spec.Template.Spec.OSType = ptr.To("Windows") }) - err = mmptw.Default(context.Background(), ammpt) + err = mmptw.Default(t.Context(), ammpt) g.Expect(err).NotTo(HaveOccurred()) g.Expect(ammpt.Labels).To(Equal(map[string]string{ LabelAgentPoolMode: "User", @@ -236,7 +235,7 @@ func TestManagedMachinePoolTemplateUpdateWebhook(t *testing.T) { t.Run(tc.name, func(t *testing.T) { g := NewWithT(t) mpw := &azureManagedMachinePoolTemplateWebhook{} - _, err := mpw.ValidateUpdate(context.Background(), tc.oldMachinePoolTemplate, tc.machinePoolTemplate) + _, err := mpw.ValidateUpdate(t.Context(), tc.oldMachinePoolTemplate, tc.machinePoolTemplate) if tc.wantErr { g.Expect(err).To(HaveOccurred()) } else { diff --git a/azure/converters/resourcehealth.go b/azure/converters/resourcehealth.go index 5497dd53043..c6aae20fe20 100644 --- a/azure/converters/resourcehealth.go +++ b/azure/converters/resourcehealth.go @@ -67,5 +67,5 @@ func SDKAvailabilityStatusToCondition(availStatus armresourcehealth.Availability message = *availStatus.Properties.Summary } - return conditions.FalseCondition(infrav1.AzureResourceAvailableCondition, reason.String(), severity, message) + return conditions.FalseCondition(infrav1.AzureResourceAvailableCondition, reason.String(), severity, "%s", message) } diff --git a/azure/defaults_test.go b/azure/defaults_test.go index 88708df72cf..4c6f19d195d 100644 --- a/azure/defaults_test.go +++ b/azure/defaults_test.go @@ -106,7 +106,7 @@ func TestPerCallPolicies(t *testing.T) { g.Expect(opts.PerCallPolicies).To(ContainElement(BeAssignableToTypeOf(userAgentPolicy{}))) // Create a request with a correlation ID. - ctx := context.WithValue(context.Background(), tele.CorrIDKeyVal, tele.CorrID(corrID)) + ctx := context.WithValue(t.Context(), tele.CorrIDKeyVal, tele.CorrID(corrID)) req, err := runtime.NewRequest(ctx, http.MethodGet, server.URL) g.Expect(err).NotTo(HaveOccurred()) @@ -188,7 +188,7 @@ func TestCustomPutPatchHeaderPolicy(t *testing.T) { g.Expect(err).NotTo(HaveOccurred()) // Create a request - req, err := runtime.NewRequest(context.Background(), tc.method, server.URL) + req, err := runtime.NewRequest(t.Context(), tc.method, server.URL) g.Expect(err).NotTo(HaveOccurred()) // Create a pipeline and send the request to the test server for validation. diff --git a/azure/errors_test.go b/azure/errors_test.go index bb0b5befcf0..b8a33a6f3a7 100644 --- a/azure/errors_test.go +++ b/azure/errors_test.go @@ -35,7 +35,7 @@ func TestIsContextDeadlineExceededOrCanceled(t *testing.T) { { name: "Context deadline exceeded error", err: func() error { - ctx, cancel := context.WithDeadline(context.Background(), time.Now().Add(-7*time.Hour)) + ctx, cancel := context.WithDeadline(t.Context(), time.Now().Add(-7*time.Hour)) defer cancel() return ctx.Err() }(), @@ -44,7 +44,7 @@ func TestIsContextDeadlineExceededOrCanceled(t *testing.T) { { name: "Context canceled exceeded error", err: func() error { - ctx, cancel := context.WithDeadline(context.Background(), time.Now().Add(1*time.Hour)) + ctx, cancel := context.WithDeadline(t.Context(), time.Now().Add(1*time.Hour)) cancel() return ctx.Err() }(), diff --git a/azure/scope/cluster_test.go b/azure/scope/cluster_test.go index 6bb5c6ba9e7..bc340d1d9ed 100644 --- a/azure/scope/cluster_test.go +++ b/azure/scope/cluster_test.go @@ -17,7 +17,6 @@ limitations under the License. package scope import ( - "context" "fmt" "reflect" "strings" @@ -103,7 +102,7 @@ func TestNewClusterScope(t *testing.T) { }, }, } - err := (&infrav1.AzureClusterWebhook{}).Default(context.Background(), azureCluster) + err := (&infrav1.AzureClusterWebhook{}).Default(t.Context(), azureCluster) g.Expect(err).NotTo(HaveOccurred()) fakeIdentity := &infrav1.AzureClusterIdentity{ @@ -118,7 +117,7 @@ func TestNewClusterScope(t *testing.T) { initObjects := []runtime.Object{cluster, azureCluster, fakeIdentity, fakeSecret} fakeClient := fake.NewClientBuilder().WithScheme(scheme).WithRuntimeObjects(initObjects...).Build() - _, err = NewClusterScope(context.TODO(), ClusterScopeParams{ + _, err = NewClusterScope(t.Context(), ClusterScopeParams{ Cluster: cluster, AzureCluster: azureCluster, Client: fakeClient, @@ -231,7 +230,7 @@ func TestAPIServerHost(t *testing.T) { tc.azureCluster.ObjectMeta = metav1.ObjectMeta{ Name: cluster.Name, } - err := (&infrav1.AzureClusterWebhook{}).Default(context.Background(), &tc.azureCluster) + err := (&infrav1.AzureClusterWebhook{}).Default(t.Context(), &tc.azureCluster) g.Expect(err).NotTo(HaveOccurred()) clusterScope := &ClusterScope{ @@ -390,7 +389,7 @@ func TestGettingSecurityRules(t *testing.T) { t.Run(tt.name, func(t *testing.T) { g := NewWithT(t) - err := (&infrav1.AzureClusterWebhook{}).Default(context.Background(), tt.azureCluster) + err := (&infrav1.AzureClusterWebhook{}).Default(t.Context(), tt.azureCluster) g.Expect(err).NotTo(HaveOccurred()) clusterScope := &ClusterScope{ @@ -2279,7 +2278,7 @@ func TestOutboundLBName(t *testing.T) { azureCluster.Spec.NetworkSpec.NodeOutboundLB = tc.nodeOutboundLB } - err := (&infrav1.AzureClusterWebhook{}).Default(context.Background(), azureCluster) + err := (&infrav1.AzureClusterWebhook{}).Default(t.Context(), azureCluster) g.Expect(err).NotTo(HaveOccurred()) clusterScope := &ClusterScope{ @@ -2394,7 +2393,7 @@ func TestBackendPoolName(t *testing.T) { }, } - err := (&infrav1.AzureClusterWebhook{}).Default(context.Background(), azureCluster) + err := (&infrav1.AzureClusterWebhook{}).Default(t.Context(), azureCluster) g.Expect(err).NotTo(HaveOccurred()) if tc.customAPIServerBackendPoolName != "" { @@ -2508,7 +2507,7 @@ func TestOutboundPoolName(t *testing.T) { } } - err := (&infrav1.AzureClusterWebhook{}).Default(context.Background(), azureCluster) + err := (&infrav1.AzureClusterWebhook{}).Default(t.Context(), azureCluster) g.Expect(err).NotTo(HaveOccurred()) clusterScope := &ClusterScope{ diff --git a/azure/scope/identity_test.go b/azure/scope/identity_test.go index 4d125f4b07d..669fe204e82 100644 --- a/azure/scope/identity_test.go +++ b/azure/scope/identity_test.go @@ -134,7 +134,7 @@ func TestAllowedNamespaces(t *testing.T) { initObjects := []runtime.Object{tc.identity, fakeNamespace} fakeClient := fake.NewClientBuilder().WithScheme(scheme).WithRuntimeObjects(initObjects...).Build() - actual := IsClusterNamespaceAllowed(context.TODO(), fakeClient, tc.identity.Spec.AllowedNamespaces, tc.clusterNamespace) + actual := IsClusterNamespaceAllowed(t.Context(), fakeClient, tc.identity.Spec.AllowedNamespaces, tc.clusterNamespace) g.Expect(actual).To(Equal(tc.expected)) }) } @@ -439,7 +439,7 @@ func TestGetTokenCredential(t *testing.T) { }, }, cacheExpect: func(cache *mock_azure.MockCredentialCache) { - ctx := context.Background() + ctx := context.Background() //nolint:usetesting credsPath := "../../test/setup/credentials.json" //nolint:gosec clientOptions := azcore.ClientOptions{ Cloud: cloud.Configuration{ @@ -481,9 +481,9 @@ func TestGetTokenCredential(t *testing.T) { cache := mock_azure.NewMockCredentialCache(mockCtrl) tt.cacheExpect(cache) - provider, err := NewAzureCredentialsProvider(context.Background(), cache, fakeClient, tt.cluster.Spec.IdentityRef, "") + provider, err := NewAzureCredentialsProvider(t.Context(), cache, fakeClient, tt.cluster.Spec.IdentityRef, "") g.Expect(err).NotTo(HaveOccurred()) - _, err = provider.GetTokenCredential(context.Background(), "", tt.ActiveDirectoryAuthorityHost, "") + _, err = provider.GetTokenCredential(t.Context(), "", tt.ActiveDirectoryAuthorityHost, "") g.Expect(err).NotTo(HaveOccurred()) }) } diff --git a/azure/scope/machine.go b/azure/scope/machine.go index 67635826d8b..141a4084770 100644 --- a/azure/scope/machine.go +++ b/azure/scope/machine.go @@ -611,7 +611,7 @@ func (m *MachineScope) SetFailureReason(v string) { // SetConditionFalse sets the specified AzureMachine condition to false. func (m *MachineScope) SetConditionFalse(conditionType clusterv1.ConditionType, reason string, severity clusterv1.ConditionSeverity, message string) { - conditions.MarkFalse(m.AzureMachine, conditionType, reason, severity, message) + conditions.MarkFalse(m.AzureMachine, conditionType, reason, severity, "%s", message) } // SetAnnotation sets a key value annotation on the AzureMachine. diff --git a/azure/scope/machine_test.go b/azure/scope/machine_test.go index 30c4127ca1b..9c37de5956f 100644 --- a/azure/scope/machine_test.go +++ b/azure/scope/machine_test.go @@ -17,7 +17,6 @@ limitations under the License. package scope import ( - "context" "reflect" "testing" @@ -1659,7 +1658,7 @@ func TestMachineScope_GetVMImage(t *testing.T) { ClusterScoper: clusterMock, }, want: func() *infrav1.Image { - image, _ := svc.GetDefaultWindowsImage(context.TODO(), "", "1.20.1", "containerd", "") + image, _ := svc.GetDefaultWindowsImage(t.Context(), "", "1.20.1", "containerd", "") return image }(), expectedErr: "", @@ -1691,7 +1690,7 @@ func TestMachineScope_GetVMImage(t *testing.T) { ClusterScoper: clusterMock, }, want: func() *infrav1.Image { - image, _ := svc.GetDefaultWindowsImage(context.TODO(), "", "1.22.1", "dockershim", "") + image, _ := svc.GetDefaultWindowsImage(t.Context(), "", "1.22.1", "dockershim", "") return image }(), expectedErr: "unsupported runtime dockershim", @@ -1723,7 +1722,7 @@ func TestMachineScope_GetVMImage(t *testing.T) { ClusterScoper: clusterMock, }, want: func() *infrav1.Image { - image, _ := svc.GetDefaultWindowsImage(context.TODO(), "", "1.23.3", "", "windows-2019") + image, _ := svc.GetDefaultWindowsImage(t.Context(), "", "1.23.3", "", "windows-2019") return image }(), expectedErr: "", @@ -1755,7 +1754,7 @@ func TestMachineScope_GetVMImage(t *testing.T) { ClusterScoper: clusterMock, }, want: func() *infrav1.Image { - image, _ := svc.GetDefaultWindowsImage(context.TODO(), "", "1.23.3", "", "windows-2022") + image, _ := svc.GetDefaultWindowsImage(t.Context(), "", "1.23.3", "", "windows-2022") return image }(), expectedErr: "", @@ -1779,7 +1778,7 @@ func TestMachineScope_GetVMImage(t *testing.T) { ClusterScoper: clusterMock, }, want: func() *infrav1.Image { - image, _ := svc.GetDefaultLinuxImage(context.TODO(), "", "1.20.1") + image, _ := svc.GetDefaultLinuxImage(t.Context(), "", "1.20.1") return image }(), expectedErr: "", @@ -1787,7 +1786,7 @@ func TestMachineScope_GetVMImage(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - gotImage, err := tt.machineScope.GetVMImage(context.TODO()) + gotImage, err := tt.machineScope.GetVMImage(t.Context()) if (err == nil && tt.expectedErr != "") || (err != nil && tt.expectedErr != err.Error()) { t.Errorf("expected error %v, got %v", tt.expectedErr, err) } diff --git a/azure/scope/machinepool_test.go b/azure/scope/machinepool_test.go index 40c4cbf22f3..939e72399ef 100644 --- a/azure/scope/machinepool_test.go +++ b/azure/scope/machinepool_test.go @@ -507,7 +507,7 @@ func TestMachinePoolScope_GetVMImage(t *testing.T) { AzureMachinePool: amp, ClusterScoper: clusterMock, } - image, err := s.GetVMImage(context.TODO()) + image, err := s.GetVMImage(t.Context()) c.Verify(g, amp, image, err) }) } @@ -741,7 +741,7 @@ func TestMachinePoolScope_updateReplicasAndProviderIDs(t *testing.T) { AzureMachinePool: amp, MachinePool: mp, } - err := s.updateReplicasAndProviderIDs(context.TODO()) + err := s.updateReplicasAndProviderIDs(t.Context()) c.Verify(g, s.AzureMachinePool, err) }) } @@ -1347,7 +1347,7 @@ func TestMachinePoolScope_SetInfrastructureMachineKind(t *testing.T) { } func TestMachinePoolScope_applyAzureMachinePoolMachines(t *testing.T) { - ctx, cancel := context.WithCancel(context.Background()) + ctx, cancel := context.WithCancel(t.Context()) defer cancel() scheme := runtime.NewScheme() _ = clusterv1.AddToScheme(scheme) @@ -1752,7 +1752,7 @@ func TestMachinePoolScope_setProvisioningStateAndConditions(t *testing.T) { } func TestBootstrapDataChanges(t *testing.T) { - ctx, cancel := context.WithCancel(context.Background()) + ctx, cancel := context.WithCancel(t.Context()) defer cancel() scheme := runtime.NewScheme() _ = clusterv1.AddToScheme(scheme) diff --git a/azure/scope/machinepoolmachine_test.go b/azure/scope/machinepoolmachine_test.go index 5d9186cd55c..2be064caceb 100644 --- a/azure/scope/machinepoolmachine_test.go +++ b/azure/scope/machinepoolmachine_test.go @@ -17,7 +17,6 @@ limitations under the License. package scope import ( - "context" "reflect" "testing" @@ -449,7 +448,7 @@ func TestMachineScope_UpdateNodeStatus(t *testing.T) { s.instance = instance s.workloadNodeGetter = mockClient - err = s.UpdateNodeStatus(context.TODO()) + err = s.UpdateNodeStatus(t.Context()) if c.Err == "" { g.Expect(err).To(Succeed()) } else { diff --git a/azure/scope/managedcontrolplane_test.go b/azure/scope/managedcontrolplane_test.go index c5158edc248..d4ec2b5a4cc 100644 --- a/azure/scope/managedcontrolplane_test.go +++ b/azure/scope/managedcontrolplane_test.go @@ -17,7 +17,6 @@ limitations under the License. package scope import ( - "context" "reflect" "testing" @@ -88,7 +87,7 @@ func TestNewManagedControlPlaneScope(t *testing.T) { fakeClient := fake.NewClientBuilder().WithScheme(scheme).WithRuntimeObjects(initObjects...).Build() input.Client = fakeClient - _, err := NewManagedControlPlaneScope(context.TODO(), input) + _, err := NewManagedControlPlaneScope(t.Context(), input) g.Expect(err).NotTo(HaveOccurred()) } diff --git a/azure/scope/managedmachinepool_test.go b/azure/scope/managedmachinepool_test.go index 9b6154b585c..bfbba40de62 100644 --- a/azure/scope/managedmachinepool_test.go +++ b/azure/scope/managedmachinepool_test.go @@ -17,7 +17,6 @@ limitations under the License. package scope import ( - "context" "reflect" "testing" @@ -69,7 +68,7 @@ func TestNewManagedMachinePoolScope(t *testing.T) { g := NewWithT(t) fakeClient := fake.NewClientBuilder().WithScheme(scheme).WithObjects(input.MachinePool, input.InfraMachinePool, input.ControlPlane).Build() input.Client = fakeClient - _, err := NewManagedMachinePoolScope(context.TODO(), input) + _, err := NewManagedMachinePoolScope(t.Context(), input) g.Expect(err).To(Succeed()) } diff --git a/azure/scope/strategies/machinepool_deployments/machinepool_deployment_strategy_test.go b/azure/scope/strategies/machinepool_deployments/machinepool_deployment_strategy_test.go index 066acaf0c06..e741c866a66 100644 --- a/azure/scope/strategies/machinepool_deployments/machinepool_deployment_strategy_test.go +++ b/azure/scope/strategies/machinepool_deployments/machinepool_deployment_strategy_test.go @@ -17,7 +17,6 @@ limitations under the License. package machinepool import ( - "context" "testing" "time" @@ -401,7 +400,7 @@ func TestMachinePoolRollingUpdateStrategy_SelectMachinesToDelete(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { g := NewWithT(t) - got, err := tt.strategy.SelectMachinesToDelete(context.Background(), tt.desiredReplicas, tt.input) + got, err := tt.strategy.SelectMachinesToDelete(t.Context(), tt.desiredReplicas, tt.input) if tt.errStr == "" { g.Expect(err).To(Succeed()) g.Expect(got).To(tt.want) diff --git a/azure/services/agentpools/agentpools_test.go b/azure/services/agentpools/agentpools_test.go index 6d1a7c55eb3..bcd82437422 100644 --- a/azure/services/agentpools/agentpools_test.go +++ b/azure/services/agentpools/agentpools_test.go @@ -17,7 +17,6 @@ limitations under the License. package agentpools import ( - "context" "testing" asocontainerservicev1 "github.com/Azure/azure-service-operator/v2/api/containerservice/v1api20231001" @@ -37,7 +36,7 @@ func TestPostCreateOrUpdateResourceHook(t *testing.T) { mockCtrl := gomock.NewController(t) scope := mock_agentpools.NewMockAgentPoolScope(mockCtrl) - err := postCreateOrUpdateResourceHook(context.Background(), scope, nil, errors.New("an error")) + err := postCreateOrUpdateResourceHook(t.Context(), scope, nil, errors.New("an error")) g.Expect(err).To(HaveOccurred()) }) @@ -54,7 +53,7 @@ func TestPostCreateOrUpdateResourceHook(t *testing.T) { }, } - err := postCreateOrUpdateResourceHook(context.Background(), scope, managedCluster, nil) + err := postCreateOrUpdateResourceHook(t.Context(), scope, managedCluster, nil) g.Expect(err).NotTo(HaveOccurred()) }) @@ -73,7 +72,7 @@ func TestPostCreateOrUpdateResourceHook(t *testing.T) { }, } - err := postCreateOrUpdateResourceHook(context.Background(), scope, managedCluster, nil) + err := postCreateOrUpdateResourceHook(t.Context(), scope, managedCluster, nil) g.Expect(err).NotTo(HaveOccurred()) }) @@ -92,6 +91,6 @@ func TestPostCreateOrUpdateResourceHook(t *testing.T) { }, } - g.Expect(postCreateOrUpdateResourceHook(context.Background(), scope, agentPool, nil)).To(Succeed()) + g.Expect(postCreateOrUpdateResourceHook(t.Context(), scope, agentPool, nil)).To(Succeed()) }) } diff --git a/azure/services/agentpools/spec_test.go b/azure/services/agentpools/spec_test.go index b5635d5aff6..7784d5ad0d6 100644 --- a/azure/services/agentpools/spec_test.go +++ b/azure/services/agentpools/spec_test.go @@ -17,7 +17,6 @@ limitations under the License. package agentpools import ( - "context" "testing" asocontainerservicev1 "github.com/Azure/azure-service-operator/v2/api/containerservice/v1api20231001" @@ -121,7 +120,7 @@ func TestParameters(t *testing.T) { }, } - actual, err := spec.Parameters(context.Background(), nil) + actual, err := spec.Parameters(t.Context(), nil) g.Expect(err).NotTo(HaveOccurred()) g.Expect(cmp.Diff(actual, expected)).To(BeEmpty()) @@ -217,7 +216,7 @@ func TestParameters(t *testing.T) { }, } - actual, err := spec.Parameters(context.Background(), nil) + actual, err := spec.Parameters(t.Context(), nil) g.Expect(err).NotTo(HaveOccurred()) g.Expect(cmp.Diff(actual, expected)).To(BeEmpty()) @@ -245,7 +244,7 @@ func TestParameters(t *testing.T) { }, } - actual, err := spec.Parameters(context.Background(), existing) + actual, err := spec.Parameters(t.Context(), existing) actualTyped, ok := actual.(*asocontainerservicev1.ManagedClustersAgentPool) g.Expect(ok).To(BeTrue()) @@ -280,7 +279,7 @@ func TestParameters(t *testing.T) { }, } - actual, err := spec.Parameters(context.Background(), existing) + actual, err := spec.Parameters(t.Context(), existing) actualTyped, ok := actual.(*asocontainerservicev1preview.ManagedClustersAgentPool) g.Expect(ok).To(BeTrue()) diff --git a/azure/services/aksextensions/spec_test.go b/azure/services/aksextensions/spec_test.go index 309e1d7e83e..b83d198b25a 100644 --- a/azure/services/aksextensions/spec_test.go +++ b/azure/services/aksextensions/spec_test.go @@ -17,7 +17,6 @@ limitations under the License. package aksextensions import ( - "context" "testing" asokubernetesconfigurationv1 "github.com/Azure/azure-service-operator/v2/api/kubernetesconfiguration/v1api20230501" @@ -142,7 +141,7 @@ func TestAzureAKSExtensionSpec_Parameters(t *testing.T) { g := NewWithT(t) t.Parallel() - result, err := tc.spec.Parameters(context.TODO(), tc.existing) + result, err := tc.spec.Parameters(t.Context(), tc.existing) if tc.expectedError != "" { g.Expect(err).To(HaveOccurred()) g.Expect(err).To(MatchError(tc.expectedError)) diff --git a/azure/services/aso/aso_test.go b/azure/services/aso/aso_test.go index d519396671b..81f364549b7 100644 --- a/azure/services/aso/aso_test.go +++ b/azure/services/aso/aso_test.go @@ -118,7 +118,7 @@ func TestCreateOrUpdateResource(t *testing.T) { }, }) - ctx := context.Background() + ctx := t.Context() g.Expect(c.Create(ctx, &asoresourcesv1.ResourceGroup{ ObjectMeta: metav1.ObjectMeta{ Name: "name", @@ -160,7 +160,7 @@ func TestCreateOrUpdateResource(t *testing.T) { }, }, nil) - ctx := context.Background() + ctx := t.Context() result, err := s.CreateOrUpdateResource(ctx, specMock, "service") g.Expect(result).To(BeNil()) g.Expect(err).To(HaveOccurred()) @@ -205,7 +205,7 @@ func TestCreateOrUpdateResource(t *testing.T) { }) specMock.EXPECT().WasManaged(gomock.Any()).Return(false) - ctx := context.Background() + ctx := t.Context() g.Expect(c.Create(ctx, &asoresourcesv1.ResourceGroup{ ObjectMeta: metav1.ObjectMeta{ Name: "name", @@ -261,7 +261,7 @@ func TestCreateOrUpdateResource(t *testing.T) { }) specMock.EXPECT().WasManaged(gomock.Any()).Return(false) - ctx := context.Background() + ctx := t.Context() g.Expect(c.Create(ctx, &asoresourcesv1.ResourceGroup{ ObjectMeta: metav1.ObjectMeta{ Name: "name", @@ -313,7 +313,7 @@ func TestCreateOrUpdateResource(t *testing.T) { }) specMock.EXPECT().WasManaged(gomock.Any()).Return(false) - ctx := context.Background() + ctx := t.Context() g.Expect(c.Create(ctx, &asoresourcesv1.ResourceGroup{ ObjectMeta: metav1.ObjectMeta{ Name: "name", @@ -365,7 +365,7 @@ func TestCreateOrUpdateResource(t *testing.T) { }, }) - ctx := context.Background() + ctx := t.Context() result, err := s.CreateOrUpdateResource(ctx, specMock, "service") g.Expect(result).To(BeNil()) g.Expect(err).To(HaveOccurred()) @@ -395,7 +395,7 @@ func TestCreateOrUpdateResource(t *testing.T) { }) specMock.EXPECT().WasManaged(gomock.Any()).Return(false) - ctx := context.Background() + ctx := t.Context() g.Expect(c.Create(ctx, &asoresourcesv1.ResourceGroup{ ObjectMeta: metav1.ObjectMeta{ Name: "name", @@ -442,7 +442,7 @@ func TestCreateOrUpdateResource(t *testing.T) { return group, nil }) - ctx := context.Background() + ctx := t.Context() g.Expect(c.Create(ctx, &asoresourcesv1.ResourceGroup{ ObjectMeta: metav1.ObjectMeta{ Name: "name", @@ -501,7 +501,7 @@ func TestCreateOrUpdateResource(t *testing.T) { }) specMock.EXPECT().WasManaged(gomock.Any()).Return(true) - ctx := context.Background() + ctx := t.Context() g.Expect(c.Create(ctx, &asoresourcesv1.ResourceGroup{ ObjectMeta: metav1.ObjectMeta{ Name: "name", @@ -559,7 +559,7 @@ func TestCreateOrUpdateResource(t *testing.T) { }) specMock.EXPECT().WasManaged(gomock.Any()).Return(true) - ctx := context.Background() + ctx := t.Context() g.Expect(c.Create(ctx, &asoresourcesv1.ResourceGroup{ ObjectMeta: metav1.ObjectMeta{ Name: "name", @@ -614,7 +614,7 @@ func TestCreateOrUpdateResource(t *testing.T) { }) specMock.EXPECT().Parameters(gomockinternal.AContext(), gomock.Not(gomock.Nil())).Return(nil, errors.New("parameters error")) - ctx := context.Background() + ctx := t.Context() g.Expect(c.Create(ctx, &asoresourcesv1.ResourceGroup{ ObjectMeta: metav1.ObjectMeta{ Name: "name", @@ -658,7 +658,7 @@ func TestCreateOrUpdateResource(t *testing.T) { }, }) - ctx := context.Background() + ctx := t.Context() g.Expect(c.Create(ctx, &asoresourcesv1.ResourceGroup{ ObjectMeta: metav1.ObjectMeta{ Name: "name", @@ -704,7 +704,7 @@ func TestCreateOrUpdateResource(t *testing.T) { }) specMock.EXPECT().WasManaged(gomock.Any()).Return(false) - ctx := context.Background() + ctx := t.Context() g.Expect(c.Create(ctx, &asoresourcesv1.ResourceGroup{ ObjectMeta: metav1.ObjectMeta{ Name: "name", @@ -763,7 +763,7 @@ func TestCreateOrUpdateResource(t *testing.T) { }) specMock.EXPECT().WasManaged(gomock.Any()).Return(false) - ctx := context.Background() + ctx := t.Context() g.Expect(c.Create(ctx, &asoresourcesv1.ResourceGroup{ ObjectMeta: metav1.ObjectMeta{ Name: "name", @@ -821,7 +821,7 @@ func TestCreateOrUpdateResource(t *testing.T) { specMock.MockTagsGetterSetter.EXPECT().GetDesiredTags(gomock.Any()).Return(nil).Times(2) specMock.MockTagsGetterSetter.EXPECT().SetTags(gomock.Any(), gomock.Any()) - ctx := context.Background() + ctx := t.Context() g.Expect(c.Create(ctx, &asoresourcesv1.ResourceGroup{ ObjectMeta: metav1.ObjectMeta{ Name: "name", @@ -880,7 +880,7 @@ func TestCreateOrUpdateResource(t *testing.T) { return group, nil }) - ctx := context.Background() + ctx := t.Context() g.Expect(c.Create(ctx, &asoresourcesv1.ResourceGroup{ ObjectMeta: metav1.ObjectMeta{ Name: "name", @@ -931,7 +931,7 @@ func TestCreateOrUpdateResource(t *testing.T) { }) specMock.EXPECT().WasManaged(gomock.Any()).Return(false) - ctx := context.Background() + ctx := t.Context() g.Expect(c.Create(ctx, &asoresourcesv1.ResourceGroup{ ObjectMeta: metav1.ObjectMeta{ Name: "name", @@ -1005,7 +1005,7 @@ func TestCreateOrUpdateResource(t *testing.T) { `{"metadata": {"labels": {"another": "label"}}}`, }) - ctx := context.Background() + ctx := t.Context() result, err := s.CreateOrUpdateResource(ctx, specMock, "service") g.Expect(result).To(BeNil()) @@ -1053,7 +1053,7 @@ func TestCreateOrUpdateResource(t *testing.T) { `{"metadata": {"labels": {"another": "label"}}}`, }) - ctx := context.Background() + ctx := t.Context() g.Expect(c.Create(ctx, &asoresourcesv1.ResourceGroup{ ObjectMeta: metav1.ObjectMeta{ Name: "name", @@ -1109,7 +1109,7 @@ func TestDeleteResource(t *testing.T) { }, } - ctx := context.Background() + ctx := t.Context() g.Expect(s.DeleteResource(ctx, resource, "service")).To(Succeed()) }) @@ -1123,7 +1123,7 @@ func TestDeleteResource(t *testing.T) { Build() s := New[*asoresourcesv1.ResourceGroup](c, clusterName, newOwner()) - ctx := context.Background() + ctx := t.Context() resource := &asoresourcesv1.ResourceGroup{ ObjectMeta: metav1.ObjectMeta{ Name: "name", @@ -1158,7 +1158,7 @@ func TestDeleteResource(t *testing.T) { }, } - ctx := context.Background() + ctx := t.Context() g.Expect(c.Create(ctx, resource)).To(Succeed()) g.Expect(s.DeleteResource(ctx, resource, "service")).To(Succeed()) @@ -1181,7 +1181,7 @@ func TestDeleteResource(t *testing.T) { }, } - ctx := context.Background() + ctx := t.Context() g.Expect(c.Create(ctx, resource)).To(Succeed()) err := s.DeleteResource(ctx, resource, "service") @@ -1206,7 +1206,7 @@ func TestDeleteResource(t *testing.T) { }, } - ctx := context.Background() + ctx := t.Context() g.Expect(c.Create(ctx, resource)).To(Succeed()) err := s.DeleteResource(ctx, resource, "service") @@ -1248,7 +1248,7 @@ func TestPauseResource(t *testing.T) { Build() }, verify: func(g Gomega, ctrlClient client.Client, resource *asoresourcesv1.ResourceGroup) { - ctx := context.Background() + ctx := t.Context() actual := &asoresourcesv1.ResourceGroup{} g.Expect(ctrlClient.Get(ctx, client.ObjectKeyFromObject(resource), actual)).To(Succeed()) g.Expect(actual.Annotations).To(HaveKeyWithValue(prePauseReconcilePolicyAnnotation, string(asoannotations.ReconcilePolicyManage))) @@ -1280,7 +1280,7 @@ func TestPauseResource(t *testing.T) { Build() }, verify: func(g Gomega, ctrlClient client.Client, resource *asoresourcesv1.ResourceGroup) { - ctx := context.Background() + ctx := t.Context() actual := &asoresourcesv1.ResourceGroup{} g.Expect(ctrlClient.Get(ctx, client.ObjectKeyFromObject(resource), actual)).To(Succeed()) g.Expect(actual.Annotations).To(HaveKeyWithValue(prePauseReconcilePolicyAnnotation, string(asoannotations.ReconcilePolicySkip))) @@ -1383,7 +1383,7 @@ func TestPauseResource(t *testing.T) { Build() }, verify: func(g Gomega, ctrlClient client.Client, resource *asoresourcesv1.ResourceGroup) { - ctx := context.Background() + ctx := t.Context() actual := &asoresourcesv1.ResourceGroup{} g.Expect(ctrlClient.Get(ctx, client.ObjectKeyFromObject(resource), actual)).To(Succeed()) g.Expect(actual.Annotations).NotTo(HaveKey(prePauseReconcilePolicyAnnotation)) @@ -1396,7 +1396,7 @@ func TestPauseResource(t *testing.T) { t.Run(test.name, func(t *testing.T) { g := NewWithT(t) - ctx := context.Background() + ctx := t.Context() svcName := "service" ctrlClient := test.clientBuilder(g) diff --git a/azure/services/aso/service_test.go b/azure/services/aso/service_test.go index fb4930ce546..d9af64540a0 100644 --- a/azure/services/aso/service_test.go +++ b/azure/services/aso/service_test.go @@ -65,7 +65,7 @@ func TestServiceReconcile(t *testing.T) { }, } - err := s.Reconcile(context.Background()) + err := s.Reconcile(t.Context()) g.Expect(err).To(MatchError(postReconcileErr)) }) @@ -93,7 +93,7 @@ func TestServiceReconcile(t *testing.T) { ConditionType: conditionType, } - err := s.Reconcile(context.Background()) + err := s.Reconcile(t.Context()) g.Expect(err).To(MatchError(reconcileErr)) }) @@ -124,7 +124,7 @@ func TestServiceReconcile(t *testing.T) { ConditionType: conditionType, } - err := s.Reconcile(context.Background()) + err := s.Reconcile(t.Context()) g.Expect(err).NotTo(HaveOccurred()) }) @@ -156,7 +156,7 @@ func TestServiceReconcile(t *testing.T) { ConditionType: conditionType, } - err := s.Reconcile(context.Background()) + err := s.Reconcile(t.Context()) g.Expect(azure.IsOperationNotDoneError(err)).To(BeTrue()) }) @@ -188,7 +188,7 @@ func TestServiceReconcile(t *testing.T) { ConditionType: conditionType, } - err := s.Reconcile(context.Background()) + err := s.Reconcile(t.Context()) g.Expect(err).To(MatchError(reconcileErr)) }) @@ -233,7 +233,7 @@ func TestServiceReconcile(t *testing.T) { }, } - err := s.Reconcile(context.Background()) + err := s.Reconcile(t.Context()) g.Expect(err).To(MatchError(postReconcileErr)) }) @@ -299,7 +299,7 @@ func TestServiceReconcile(t *testing.T) { ConditionType: conditionType, } - err := s.Reconcile(context.Background()) + err := s.Reconcile(t.Context()) g.Expect(err).To(MatchError(deleteErr)) }) } @@ -324,7 +324,7 @@ func TestServiceDelete(t *testing.T) { }, } - err := s.Delete(context.Background()) + err := s.Delete(t.Context()) g.Expect(err).NotTo(HaveOccurred()) }) @@ -352,7 +352,7 @@ func TestServiceDelete(t *testing.T) { ConditionType: conditionType, } - err := s.Delete(context.Background()) + err := s.Delete(t.Context()) g.Expect(err).To(MatchError(deleteErr)) }) @@ -383,7 +383,7 @@ func TestServiceDelete(t *testing.T) { ConditionType: conditionType, } - err := s.Delete(context.Background()) + err := s.Delete(t.Context()) g.Expect(err).NotTo(HaveOccurred()) }) @@ -415,7 +415,7 @@ func TestServiceDelete(t *testing.T) { ConditionType: conditionType, } - err := s.Delete(context.Background()) + err := s.Delete(t.Context()) g.Expect(azure.IsOperationNotDoneError(err)).To(BeTrue()) }) @@ -447,7 +447,7 @@ func TestServiceDelete(t *testing.T) { ConditionType: conditionType, } - err := s.Delete(context.Background()) + err := s.Delete(t.Context()) g.Expect(err).To(MatchError(deleteErr)) }) @@ -481,7 +481,7 @@ func TestServiceDelete(t *testing.T) { }, } - err := s.Delete(context.Background()) + err := s.Delete(t.Context()) g.Expect(err).To(MatchError(postErr)) }) } @@ -512,7 +512,7 @@ func TestServicePause(t *testing.T) { ConditionType: conditionType, } - err := s.Pause(context.Background()) + err := s.Pause(t.Context()) g.Expect(err).NotTo(HaveOccurred()) }) @@ -547,7 +547,7 @@ func TestServicePause(t *testing.T) { ConditionType: conditionType, } - err := s.Pause(context.Background()) + err := s.Pause(t.Context()) g.Expect(err).To(MatchError(pauseErr)) }) } diff --git a/azure/services/async/async_test.go b/azure/services/async/async_test.go index b6f2cc1b4b3..eb11bc998bd 100644 --- a/azure/services/async/async_test.go +++ b/azure/services/async/async_test.go @@ -182,7 +182,7 @@ func TestServiceCreateOrUpdateResource(t *testing.T) { tc.expect(g, scopeMock.EXPECT(), creatorMock.EXPECT(), specMock.EXPECT()) - result, err := svc.CreateOrUpdateResource(context.TODO(), specMock, serviceName) + result, err := svc.CreateOrUpdateResource(t.Context(), specMock, serviceName) if tc.expectedError != "" { g.Expect(err).To(HaveOccurred()) g.Expect(err.Error()).To(ContainSubstring(tc.expectedError)) @@ -278,7 +278,7 @@ func TestServiceDeleteResource(t *testing.T) { tc.expect(g, scopeMock.EXPECT(), deleterMock.EXPECT(), specMock.EXPECT()) - err := svc.DeleteResource(context.TODO(), specMock, tc.serviceName) + err := svc.DeleteResource(t.Context(), specMock, tc.serviceName) if tc.expectedError != "" { g.Expect(err).To(HaveOccurred()) g.Expect(err.Error()).To(ContainSubstring(tc.expectedError)) diff --git a/azure/services/availabilitysets/availabilitysets_test.go b/azure/services/availabilitysets/availabilitysets_test.go index bd6dca658e5..855712a78b1 100644 --- a/azure/services/availabilitysets/availabilitysets_test.go +++ b/azure/services/availabilitysets/availabilitysets_test.go @@ -17,7 +17,6 @@ limitations under the License. package availabilitysets import ( - "context" "io" "net/http" "strconv" @@ -147,7 +146,7 @@ func TestReconcileAvailabilitySets(t *testing.T) { Reconciler: asyncMock, } - err := s.Reconcile(context.TODO()) + err := s.Reconcile(t.Context()) if tc.expectedError != "" { g.Expect(err).To(HaveOccurred()) g.Expect(err.Error()).To(ContainSubstring(tc.expectedError)) @@ -279,7 +278,7 @@ func TestDeleteAvailabilitySets(t *testing.T) { Reconciler: asyncMock, } - err := s.Delete(context.TODO()) + err := s.Delete(t.Context()) if tc.expectedError != "" { g.Expect(err).To(HaveOccurred()) g.Expect(strings.ReplaceAll(err.Error(), "\n", "")).To(MatchRegexp(tc.expectedError)) diff --git a/azure/services/availabilitysets/spec_test.go b/azure/services/availabilitysets/spec_test.go index 794b61a6c2b..eef19613fe0 100644 --- a/azure/services/availabilitysets/spec_test.go +++ b/azure/services/availabilitysets/spec_test.go @@ -17,7 +17,6 @@ limitations under the License. package availabilitysets import ( - "context" "testing" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v5" @@ -80,7 +79,7 @@ func TestParameters(t *testing.T) { g := NewWithT(t) t.Parallel() - result, err := tc.spec.Parameters(context.TODO(), tc.existing) + result, err := tc.spec.Parameters(t.Context(), tc.existing) if tc.expectedError != "" { g.Expect(err).To(HaveOccurred()) g.Expect(err).To(MatchError(tc.expectedError)) diff --git a/azure/services/bastionhosts/spec_test.go b/azure/services/bastionhosts/spec_test.go index 59a320cf912..08d925575d9 100644 --- a/azure/services/bastionhosts/spec_test.go +++ b/azure/services/bastionhosts/spec_test.go @@ -17,7 +17,6 @@ limitations under the License. package bastionhosts import ( - "context" "fmt" "testing" @@ -187,7 +186,7 @@ func TestAzureBastionSpec_Parameters(t *testing.T) { g := NewWithT(t) t.Parallel() - result, err := tc.spec.Parameters(context.TODO(), tc.existing) + result, err := tc.spec.Parameters(t.Context(), tc.existing) if tc.expectedError != "" { g.Expect(err).To(HaveOccurred()) g.Expect(err).To(MatchError(tc.expectedError)) diff --git a/azure/services/disks/disks_test.go b/azure/services/disks/disks_test.go index e4da474af42..9973e39722c 100644 --- a/azure/services/disks/disks_test.go +++ b/azure/services/disks/disks_test.go @@ -17,7 +17,6 @@ limitations under the License. package disks import ( - "context" "io" "net/http" "strings" @@ -131,7 +130,7 @@ func TestDeleteDisk(t *testing.T) { Reconciler: asyncMock, } - err := s.Delete(context.TODO()) + err := s.Delete(t.Context()) if tc.expectedError != "" { g.Expect(err).To(HaveOccurred()) g.Expect(err.Error()).To(ContainSubstring(tc.expectedError)) diff --git a/azure/services/fleetsmembers/spec_test.go b/azure/services/fleetsmembers/spec_test.go index 2a9b4d24156..bdeda89387c 100644 --- a/azure/services/fleetsmembers/spec_test.go +++ b/azure/services/fleetsmembers/spec_test.go @@ -17,7 +17,6 @@ limitations under the License. package fleetsmembers import ( - "context" "testing" asocontainerservicev1 "github.com/Azure/azure-service-operator/v2/api/containerservice/v1api20230315preview" @@ -120,7 +119,7 @@ func TestAzureFleetsMemberSpec_Parameters(t *testing.T) { g := NewWithT(t) t.Parallel() - result, err := tc.spec.Parameters(context.TODO(), tc.existing) + result, err := tc.spec.Parameters(t.Context(), tc.existing) if tc.expectedError != "" { g.Expect(err).To(HaveOccurred()) g.Expect(err).To(MatchError(tc.expectedError)) diff --git a/azure/services/groups/groups_test.go b/azure/services/groups/groups_test.go index 26e9aa5a919..66ffabd7c28 100644 --- a/azure/services/groups/groups_test.go +++ b/azure/services/groups/groups_test.go @@ -17,7 +17,6 @@ limitations under the License. package groups import ( - "context" "testing" asoresourcesv1 "github.com/Azure/azure-service-operator/v2/api/resources/v1api20200601" @@ -169,7 +168,7 @@ func TestIsManaged(t *testing.T) { scopeMock.EXPECT().ASOOwner().Return(newOwner()).AnyTimes() test.expect(scopeMock.EXPECT()) - actual, err := New(scopeMock).IsManaged(context.Background()) + actual, err := New(scopeMock).IsManaged(t.Context()) if test.expectedError { g.Expect(err).To(HaveOccurred()) } else { diff --git a/azure/services/groups/spec_test.go b/azure/services/groups/spec_test.go index a5a2b935bd4..fb7614372d4 100644 --- a/azure/services/groups/spec_test.go +++ b/azure/services/groups/spec_test.go @@ -17,7 +17,6 @@ limitations under the License. package groups import ( - "context" "testing" asoresourcesv1 "github.com/Azure/azure-service-operator/v2/api/resources/v1api20200601" @@ -72,7 +71,7 @@ func TestParameters(t *testing.T) { t.Run(test.name, func(t *testing.T) { g := NewWithT(t) - actual, err := test.spec.Parameters(context.Background(), test.existing) + actual, err := test.spec.Parameters(t.Context(), test.existing) g.Expect(err).NotTo(HaveOccurred()) if test.expected == nil { g.Expect(actual).To(BeNil()) diff --git a/azure/services/inboundnatrules/inboundnatrules_test.go b/azure/services/inboundnatrules/inboundnatrules_test.go index 8a71f574c40..cd051d71671 100644 --- a/azure/services/inboundnatrules/inboundnatrules_test.go +++ b/azure/services/inboundnatrules/inboundnatrules_test.go @@ -17,7 +17,6 @@ limitations under the License. package inboundnatrules import ( - "context" "io" "net/http" "strings" @@ -207,7 +206,7 @@ func TestReconcileInboundNATRule(t *testing.T) { Reconciler: asyncMock, } - err := s.Reconcile(context.TODO()) + err := s.Reconcile(t.Context()) if tc.expectedError != "" { g.Expect(err).To(HaveOccurred()) g.Expect(strings.ReplaceAll(err.Error(), "\n", "")).To(MatchRegexp(tc.expectedError)) @@ -284,7 +283,7 @@ func TestDeleteNetworkInterface(t *testing.T) { Reconciler: asyncMock, } - err := s.Delete(context.TODO()) + err := s.Delete(t.Context()) if tc.expectedError != "" { g.Expect(err).To(HaveOccurred()) g.Expect(strings.ReplaceAll(err.Error(), "\n", "")).To(MatchRegexp(tc.expectedError)) diff --git a/azure/services/inboundnatrules/spec_test.go b/azure/services/inboundnatrules/spec_test.go index 1e9de0d28e1..e39efca9503 100644 --- a/azure/services/inboundnatrules/spec_test.go +++ b/azure/services/inboundnatrules/spec_test.go @@ -17,7 +17,6 @@ limitations under the License. package inboundnatrules import ( - "context" "reflect" "testing" @@ -65,7 +64,7 @@ func TestParameters(t *testing.T) { g := NewWithT(t) t.Parallel() - result, err := tc.spec.Parameters(context.Background(), tc.existing) + result, err := tc.spec.Parameters(t.Context(), tc.existing) if tc.errorMsg != "" { g.Expect(err).To(HaveOccurred()) g.Expect(err.Error()).To(ContainSubstring(tc.errorMsg)) diff --git a/azure/services/loadbalancers/loadbalancers_test.go b/azure/services/loadbalancers/loadbalancers_test.go index cfcd12fae94..3a61789a507 100644 --- a/azure/services/loadbalancers/loadbalancers_test.go +++ b/azure/services/loadbalancers/loadbalancers_test.go @@ -17,7 +17,6 @@ limitations under the License. package loadbalancers import ( - "context" "io" "net/http" "strings" @@ -226,7 +225,7 @@ func TestReconcileLoadBalancer(t *testing.T) { Scope: scopeMock, Reconciler: asyncMock, } - err := s.Reconcile(context.TODO()) + err := s.Reconcile(t.Context()) if tc.expectedError != "" { g.Expect(err).To(HaveOccurred()) g.Expect(err.Error()).To(ContainSubstring(tc.expectedError)) @@ -303,7 +302,7 @@ func TestDeleteLoadBalancer(t *testing.T) { Reconciler: asyncMock, } - err := s.Delete(context.TODO()) + err := s.Delete(t.Context()) if tc.expectedError != "" { g.Expect(err).To(HaveOccurred()) g.Expect(err.Error()).To(ContainSubstring(tc.expectedError)) diff --git a/azure/services/loadbalancers/spec_test.go b/azure/services/loadbalancers/spec_test.go index bad5a8cec60..9e75779a7c1 100644 --- a/azure/services/loadbalancers/spec_test.go +++ b/azure/services/loadbalancers/spec_test.go @@ -17,7 +17,6 @@ limitations under the License. package loadbalancers import ( - "context" "testing" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v4" @@ -185,7 +184,7 @@ func TestParameters(t *testing.T) { g := NewWithT(t) t.Parallel() - result, err := tc.spec.Parameters(context.TODO(), tc.existing) + result, err := tc.spec.Parameters(t.Context(), tc.existing) if tc.expectedError != "" { g.Expect(err).To(HaveOccurred()) g.Expect(err).To(MatchError(tc.expectedError)) diff --git a/azure/services/managedclusters/managedclusters_test.go b/azure/services/managedclusters/managedclusters_test.go index 6f3d992c45b..db73de3f418 100644 --- a/azure/services/managedclusters/managedclusters_test.go +++ b/azure/services/managedclusters/managedclusters_test.go @@ -17,7 +17,6 @@ limitations under the License. package managedclusters import ( - "context" "errors" "testing" @@ -42,7 +41,7 @@ func TestPostCreateOrUpdateResourceHook(t *testing.T) { mockCtrl := gomock.NewController(t) scope := mock_managedclusters.NewMockManagedClusterScope(mockCtrl) - err := postCreateOrUpdateResourceHook(context.Background(), scope, nil, errors.New("an error")) + err := postCreateOrUpdateResourceHook(t.Context(), scope, nil, errors.New("an error")) g.Expect(err).To(HaveOccurred()) }) @@ -71,7 +70,7 @@ func TestPostCreateOrUpdateResourceHook(t *testing.T) { }, } - err := postCreateOrUpdateResourceHook(context.Background(), scope, managedCluster, nil) + err := postCreateOrUpdateResourceHook(t.Context(), scope, managedCluster, nil) g.Expect(err).NotTo(HaveOccurred()) }) @@ -100,7 +99,7 @@ func TestPostCreateOrUpdateResourceHook(t *testing.T) { }, } - err := postCreateOrUpdateResourceHook(context.Background(), scope, managedCluster, nil) + err := postCreateOrUpdateResourceHook(t.Context(), scope, managedCluster, nil) g.Expect(err).NotTo(HaveOccurred()) }) @@ -136,7 +135,7 @@ func TestPostCreateOrUpdateResourceHook(t *testing.T) { }, } - err := postCreateOrUpdateResourceHook(context.Background(), scope, managedCluster, nil) + err := postCreateOrUpdateResourceHook(t.Context(), scope, managedCluster, nil) g.Expect(err).To(HaveOccurred()) }) } diff --git a/azure/services/managedclusters/spec_test.go b/azure/services/managedclusters/spec_test.go index 56ea289bed0..7886b10b80c 100644 --- a/azure/services/managedclusters/spec_test.go +++ b/azure/services/managedclusters/spec_test.go @@ -17,7 +17,6 @@ limitations under the License. package managedclusters import ( - "context" "encoding/base64" "testing" @@ -300,7 +299,7 @@ func TestParameters(t *testing.T) { }, } - actual, err := spec.Parameters(context.Background(), nil) + actual, err := spec.Parameters(t.Context(), nil) g.Expect(err).NotTo(HaveOccurred()) g.Expect(cmp.Diff(actual, expected)).To(BeEmpty()) @@ -325,7 +324,7 @@ func TestParameters(t *testing.T) { }, } - actual, err := spec.Parameters(context.Background(), nil) + actual, err := spec.Parameters(t.Context(), nil) g.Expect(err).NotTo(HaveOccurred()) _, ok := actual.(*asocontainerservicev1preview.ManagedCluster) g.Expect(ok).To(BeTrue()) @@ -351,7 +350,7 @@ func TestParameters(t *testing.T) { }, } - actualObj, err := spec.Parameters(context.Background(), existing) + actualObj, err := spec.Parameters(t.Context(), existing) actual := actualObj.(*asocontainerservicev1.ManagedCluster) g.Expect(err).NotTo(HaveOccurred()) @@ -384,7 +383,7 @@ func TestParameters(t *testing.T) { }, } - actualObj, err := spec.Parameters(context.Background(), existing) + actualObj, err := spec.Parameters(t.Context(), existing) actual := actualObj.(*asocontainerservicev1.ManagedCluster) g.Expect(err).NotTo(HaveOccurred()) diff --git a/azure/services/natgateways/natgateways_test.go b/azure/services/natgateways/natgateways_test.go index 7bac0fcd62c..ffd1ad66572 100644 --- a/azure/services/natgateways/natgateways_test.go +++ b/azure/services/natgateways/natgateways_test.go @@ -17,7 +17,6 @@ limitations under the License. package natgateways import ( - "context" "testing" asonetworkv1 "github.com/Azure/azure-service-operator/v2/api/network/v1api20220701" @@ -36,7 +35,7 @@ func TestPostCreateOrUpdateResourceHook(t *testing.T) { mockCtrl := gomock.NewController(t) scope := mock_natgateways.NewMockNatGatewayScope(mockCtrl) - err := postCreateOrUpdateResourceHook(context.Background(), scope, nil, errors.New("an error")) + err := postCreateOrUpdateResourceHook(t.Context(), scope, nil, errors.New("an error")) g.Expect(err).To(HaveOccurred()) }) @@ -57,7 +56,7 @@ func TestPostCreateOrUpdateResourceHook(t *testing.T) { }, } - err := postCreateOrUpdateResourceHook(context.Background(), scope, natGateway, nil) + err := postCreateOrUpdateResourceHook(t.Context(), scope, natGateway, nil) g.Expect(err).NotTo(HaveOccurred()) }) } diff --git a/azure/services/natgateways/spec_test.go b/azure/services/natgateways/spec_test.go index 07ec7517010..18db94cbc30 100644 --- a/azure/services/natgateways/spec_test.go +++ b/azure/services/natgateways/spec_test.go @@ -17,7 +17,6 @@ limitations under the License. package natgateways import ( - "context" "testing" asonetworkv1 "github.com/Azure/azure-service-operator/v2/api/network/v1api20220701" @@ -138,7 +137,7 @@ func TestParameters(t *testing.T) { g := NewWithT(t) t.Parallel() - result, _ := tc.spec.Parameters(context.TODO(), tc.existingSpec.DeepCopy()) + result, _ := tc.spec.Parameters(t.Context(), tc.existingSpec.DeepCopy()) tc.expect(g, tc.existingSpec, result) }) } diff --git a/azure/services/networkinterfaces/networkinterfaces_test.go b/azure/services/networkinterfaces/networkinterfaces_test.go index ed1e97595ff..e6951b85c44 100644 --- a/azure/services/networkinterfaces/networkinterfaces_test.go +++ b/azure/services/networkinterfaces/networkinterfaces_test.go @@ -17,7 +17,6 @@ limitations under the License. package networkinterfaces import ( - "context" "fmt" "io" "net/http" @@ -156,7 +155,7 @@ func TestReconcileNetworkInterface(t *testing.T) { Reconciler: asyncMock, } - err := s.Reconcile(context.TODO()) + err := s.Reconcile(t.Context()) if tc.expectedError != "" { g.Expect(err).To(HaveOccurred()) fmt.Print(cmp.Diff(err.Error(), tc.expectedError)) @@ -233,7 +232,7 @@ func TestDeleteNetworkInterface(t *testing.T) { Reconciler: asyncMock, } - err := s.Delete(context.TODO()) + err := s.Delete(t.Context()) if tc.expectedError != "" { g.Expect(err).To(HaveOccurred()) g.Expect(err).To(MatchError(tc.expectedError)) diff --git a/azure/services/networkinterfaces/spec_test.go b/azure/services/networkinterfaces/spec_test.go index 98efe31b9a7..7d2baceaaa2 100644 --- a/azure/services/networkinterfaces/spec_test.go +++ b/azure/services/networkinterfaces/spec_test.go @@ -17,7 +17,6 @@ limitations under the License. package networkinterfaces import ( - "context" "testing" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v5" @@ -823,7 +822,7 @@ func TestParameters(t *testing.T) { g := NewWithT(t) t.Parallel() - result, err := tc.spec.Parameters(context.TODO(), tc.existing) + result, err := tc.spec.Parameters(t.Context(), tc.existing) if tc.expectedError != "" { g.Expect(err).To(HaveOccurred()) g.Expect(err).To(MatchError(tc.expectedError)) diff --git a/azure/services/privatedns/link_spec_test.go b/azure/services/privatedns/link_spec_test.go index 626aef82e0e..e4531428683 100644 --- a/azure/services/privatedns/link_spec_test.go +++ b/azure/services/privatedns/link_spec_test.go @@ -17,7 +17,6 @@ limitations under the License. package privatedns import ( - "context" "testing" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/privatedns/armprivatedns" @@ -115,7 +114,7 @@ func TestLinkSpec_Parameters(t *testing.T) { g := NewWithT(t) t.Parallel() - result, err := tc.spec.Parameters(context.TODO(), tc.existing) + result, err := tc.spec.Parameters(t.Context(), tc.existing) if tc.expectedError != "" { g.Expect(err).To(HaveOccurred()) g.Expect(err).To(MatchError(tc.expectedError)) diff --git a/azure/services/privatedns/privatedns_test.go b/azure/services/privatedns/privatedns_test.go index f975e6fc8a3..c3f834e1d3d 100644 --- a/azure/services/privatedns/privatedns_test.go +++ b/azure/services/privatedns/privatedns_test.go @@ -17,7 +17,6 @@ limitations under the License. package privatedns import ( - "context" "net/http" "testing" @@ -354,7 +353,7 @@ func TestReconcilePrivateDNS(t *testing.T) { TagsGetter: tagsGetterMock, } - err := s.Reconcile(context.TODO()) + err := s.Reconcile(t.Context()) if tc.expectedError != "" { g.Expect(err).To(HaveOccurred()) g.Expect(err).To(MatchError(tc.expectedError)) @@ -579,7 +578,7 @@ func TestDeletePrivateDNS(t *testing.T) { TagsGetter: tagsGetterMock, } - err := s.Delete(context.TODO()) + err := s.Delete(t.Context()) if tc.expectedError != "" { g.Expect(err).To(HaveOccurred()) g.Expect(err).To(MatchError(tc.expectedError)) diff --git a/azure/services/privatedns/record_spec_test.go b/azure/services/privatedns/record_spec_test.go index 4a07540bfa6..82984145e23 100644 --- a/azure/services/privatedns/record_spec_test.go +++ b/azure/services/privatedns/record_spec_test.go @@ -17,7 +17,6 @@ limitations under the License. package privatedns import ( - "context" "testing" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/privatedns/armprivatedns" @@ -105,7 +104,7 @@ func TestRecordSpec_Parameters(t *testing.T) { g := NewWithT(t) t.Parallel() - result, err := tc.spec.Parameters(context.TODO(), tc.existing) + result, err := tc.spec.Parameters(t.Context(), tc.existing) if tc.expectedError != "" { g.Expect(err).To(HaveOccurred()) g.Expect(err).To(MatchError(tc.expectedError)) diff --git a/azure/services/privatedns/zone_spec_test.go b/azure/services/privatedns/zone_spec_test.go index ebbe39abae9..cdae2c23621 100644 --- a/azure/services/privatedns/zone_spec_test.go +++ b/azure/services/privatedns/zone_spec_test.go @@ -17,7 +17,6 @@ limitations under the License. package privatedns import ( - "context" "testing" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/privatedns/armprivatedns" @@ -105,7 +104,7 @@ func TestZoneSpec_Parameters(t *testing.T) { g := NewWithT(t) t.Parallel() - result, err := tc.spec.Parameters(context.TODO(), tc.existing) + result, err := tc.spec.Parameters(t.Context(), tc.existing) if tc.expectedError != "" { g.Expect(err).To(HaveOccurred()) g.Expect(err).To(MatchError(tc.expectedError)) diff --git a/azure/services/privateendpoints/spec_test.go b/azure/services/privateendpoints/spec_test.go index e98361957a7..933271e635e 100644 --- a/azure/services/privateendpoints/spec_test.go +++ b/azure/services/privateendpoints/spec_test.go @@ -17,7 +17,6 @@ limitations under the License. package privateendpoints import ( - "context" "testing" asonetworkv1 "github.com/Azure/azure-service-operator/v2/api/network/v1api20220701" @@ -227,7 +226,7 @@ func TestParameters(t *testing.T) { g := NewWithT(t) t.Parallel() - result, err := tc.spec.Parameters(context.TODO(), tc.existing) + result, err := tc.spec.Parameters(t.Context(), tc.existing) if tc.expectedError != "" { g.Expect(err).To(HaveOccurred()) g.Expect(err).To(MatchError(tc.expectedError)) diff --git a/azure/services/publicips/publicips_test.go b/azure/services/publicips/publicips_test.go index 706d6e60345..a86bf9082aa 100644 --- a/azure/services/publicips/publicips_test.go +++ b/azure/services/publicips/publicips_test.go @@ -17,7 +17,6 @@ limitations under the License. package publicips import ( - "context" "io" "net/http" "strings" @@ -186,7 +185,7 @@ func TestReconcilePublicIP(t *testing.T) { Reconciler: reconcilerMock, } - err := s.Reconcile(context.TODO()) + err := s.Reconcile(t.Context()) if tc.expectedError != "" { g.Expect(err).To(HaveOccurred()) g.Expect(err).To(MatchError(tc.expectedError)) @@ -316,7 +315,7 @@ func TestDeletePublicIP(t *testing.T) { Reconciler: reconcilerMock, } - err := s.Delete(context.TODO()) + err := s.Delete(t.Context()) if tc.expectedError != "" { g.Expect(err).To(HaveOccurred()) g.Expect(err).To(MatchError(tc.expectedError)) diff --git a/azure/services/publicips/spec_test.go b/azure/services/publicips/spec_test.go index b3f86f1765f..bfeea34166c 100644 --- a/azure/services/publicips/spec_test.go +++ b/azure/services/publicips/spec_test.go @@ -17,7 +17,6 @@ limitations under the License. package publicips import ( - "context" "reflect" "testing" @@ -151,7 +150,7 @@ func TestParameters(t *testing.T) { g := NewWithT(t) t.Parallel() - result, err := tc.spec.Parameters(context.TODO(), tc.existing) + result, err := tc.spec.Parameters(t.Context(), tc.existing) if tc.expectedError != "" { g.Expect(err).To(HaveOccurred()) g.Expect(err).To(MatchError(tc.expectedError)) diff --git a/azure/services/resourcehealth/resourcehealth_test.go b/azure/services/resourcehealth/resourcehealth_test.go index 2d6353f52a7..197c6def5c9 100644 --- a/azure/services/resourcehealth/resourcehealth_test.go +++ b/azure/services/resourcehealth/resourcehealth_test.go @@ -17,7 +17,6 @@ limitations under the License. package resourcehealth import ( - "context" "testing" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resourcehealth/armresourcehealth" @@ -128,7 +127,7 @@ func TestReconcileResourceHealth(t *testing.T) { utilfeature.SetFeatureGateDuringTest(t, feature.Gates, feature.AKSResourceHealth, !tc.featureDisabled) - err := s.Reconcile(context.TODO()) + err := s.Reconcile(t.Context()) if tc.expectedError != "" { g.Expect(err).To(HaveOccurred()) diff --git a/azure/services/resourceskus/cache_test.go b/azure/services/resourceskus/cache_test.go index c8a24ae91af..96ecb987318 100644 --- a/azure/services/resourceskus/cache_test.go +++ b/azure/services/resourceskus/cache_test.go @@ -17,7 +17,6 @@ limitations under the License. package resourceskus import ( - "context" "testing" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v5" @@ -71,7 +70,7 @@ func TestCacheGet(t *testing.T) { location: tc.location, } - val, err := cache.Get(context.Background(), tc.sku, tc.resourceType) + val, err := cache.Get(t.Context(), tc.sku, tc.resourceType) if tc.err != "" { if err == nil { t.Fatalf("expected cache.get to fail with error %s, but actual error was nil", tc.err) @@ -233,7 +232,7 @@ func TestCacheGetZones(t *testing.T) { data: tc.have, } - zones, err := cache.GetZones(context.Background(), "baz") + zones, err := cache.GetZones(t.Context(), "baz") if err != nil { t.Error(err) } @@ -381,7 +380,7 @@ func TestCacheGetZonesWithVMSize(t *testing.T) { data: tc.have, } - zones, err := cache.GetZonesWithVMSize(context.Background(), "foo", "baz") + zones, err := cache.GetZonesWithVMSize(t.Context(), "foo", "baz") if err != nil { t.Error(err) } diff --git a/azure/services/roleassignments/roleassignments_test.go b/azure/services/roleassignments/roleassignments_test.go index 9b203db3b45..d3dc691473f 100644 --- a/azure/services/roleassignments/roleassignments_test.go +++ b/azure/services/roleassignments/roleassignments_test.go @@ -17,7 +17,6 @@ limitations under the License. package roleassignments import ( - "context" "fmt" "io" "net/http" @@ -159,7 +158,7 @@ func TestReconcileRoleAssignmentsVM(t *testing.T) { Reconciler: asyncMock, } - err := s.Reconcile(context.TODO()) + err := s.Reconcile(t.Context()) if tc.expectedError != "" { g.Expect(err).To(HaveOccurred()) g.Expect(strings.ReplaceAll(err.Error(), "\n", "")).To(MatchRegexp(tc.expectedError)) @@ -253,7 +252,7 @@ func TestReconcileRoleAssignmentsVMSS(t *testing.T) { virtualMachineScaleSetGetter: vmMock, } - err := s.Reconcile(context.TODO()) + err := s.Reconcile(t.Context()) if tc.expectedError != "" { g.Expect(err).To(HaveOccurred()) g.Expect(strings.ReplaceAll(err.Error(), "\n", "")).To(MatchRegexp(tc.expectedError)) diff --git a/azure/services/roleassignments/spec_test.go b/azure/services/roleassignments/spec_test.go index 95291af516a..5b0517d5140 100644 --- a/azure/services/roleassignments/spec_test.go +++ b/azure/services/roleassignments/spec_test.go @@ -17,7 +17,6 @@ limitations under the License. package roleassignments import ( - "context" "testing" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/authorization/armauthorization/v2" @@ -89,7 +88,7 @@ func TestRoleAssignmentSpec_Parameters(t *testing.T) { g := NewWithT(t) t.Parallel() - result, err := tc.spec.Parameters(context.TODO(), tc.existing) + result, err := tc.spec.Parameters(t.Context(), tc.existing) if tc.expectedError != "" { g.Expect(err).To(HaveOccurred()) g.Expect(err).To(MatchError(tc.expectedError)) diff --git a/azure/services/routetables/routetables_test.go b/azure/services/routetables/routetables_test.go index f4e4964eef4..fcdd930838e 100644 --- a/azure/services/routetables/routetables_test.go +++ b/azure/services/routetables/routetables_test.go @@ -17,7 +17,6 @@ limitations under the License. package routetables import ( - "context" "errors" "testing" @@ -130,7 +129,7 @@ func TestReconcileRouteTables(t *testing.T) { Reconciler: reconcilerMock, } - err := s.Reconcile(context.TODO()) + err := s.Reconcile(t.Context()) if tc.expectedError != "" { g.Expect(err).To(HaveOccurred()) g.Expect(err).To(MatchError(tc.expectedError)) @@ -219,7 +218,7 @@ func TestDeleteRouteTable(t *testing.T) { Reconciler: reconcilerMock, } - err := s.Delete(context.TODO()) + err := s.Delete(t.Context()) if tc.expectedError != "" { g.Expect(err).To(HaveOccurred()) g.Expect(err).To(MatchError(tc.expectedError)) diff --git a/azure/services/routetables/spec_test.go b/azure/services/routetables/spec_test.go index 01abb65dffc..e6b9e6f23db 100644 --- a/azure/services/routetables/spec_test.go +++ b/azure/services/routetables/spec_test.go @@ -17,7 +17,6 @@ limitations under the License. package routetables import ( - "context" "testing" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v4" @@ -98,7 +97,7 @@ func TestRouteTableSpec_Parameters(t *testing.T) { g := NewWithT(t) t.Parallel() - result, err := tc.spec.Parameters(context.TODO(), tc.existing) + result, err := tc.spec.Parameters(t.Context(), tc.existing) if tc.expectedError != "" { g.Expect(err).To(HaveOccurred()) g.Expect(err).To(MatchError(tc.expectedError)) diff --git a/azure/services/scalesets/scalesets_test.go b/azure/services/scalesets/scalesets_test.go index e92fd3956ec..16b625606fc 100644 --- a/azure/services/scalesets/scalesets_test.go +++ b/azure/services/scalesets/scalesets_test.go @@ -17,7 +17,6 @@ limitations under the License. package scalesets import ( - "context" "io" "net/http" "strings" @@ -348,7 +347,7 @@ func TestReconcileVMSS(t *testing.T) { resourceSKUCache: resourceskus.NewStaticCache(getFakeSkus(), "test-location"), } - err := s.Reconcile(context.TODO()) + err := s.Reconcile(t.Context()) if tc.expectedError != "" { g.Expect(err).To(HaveOccurred()) g.Expect(strings.ReplaceAll(err.Error(), "\n", "")).To(MatchRegexp(tc.expectedError), err.Error()) @@ -428,7 +427,7 @@ func TestDeleteVMSS(t *testing.T) { Client: mockClient, } - err := s.Delete(context.TODO()) + err := s.Delete(t.Context()) if tc.expectedError != "" { g.Expect(err).To(HaveOccurred()) g.Expect(err.Error()).To(ContainSubstring(tc.expectedError)) diff --git a/azure/services/scalesets/spec_test.go b/azure/services/scalesets/spec_test.go index b10515132b5..2be2a6f611c 100644 --- a/azure/services/scalesets/spec_test.go +++ b/azure/services/scalesets/spec_test.go @@ -17,7 +17,6 @@ limitations under the License. package scalesets import ( - "context" "reflect" "testing" @@ -769,7 +768,7 @@ func TestScaleSetParameters(t *testing.T) { g := NewWithT(t) t.Parallel() - param, err := tc.spec.Parameters(context.TODO(), tc.existing) + param, err := tc.spec.Parameters(t.Context(), tc.existing) if tc.expectedError != "" { g.Expect(err).To(HaveOccurred()) g.Expect(err).To(MatchError(tc.expectedError)) diff --git a/azure/services/scalesets/vmssextension_spec_test.go b/azure/services/scalesets/vmssextension_spec_test.go index cc4c0db1ea8..d3cb41b1cfd 100644 --- a/azure/services/scalesets/vmssextension_spec_test.go +++ b/azure/services/scalesets/vmssextension_spec_test.go @@ -17,7 +17,6 @@ limitations under the License. package scalesets import ( - "context" "testing" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v5" @@ -84,7 +83,7 @@ func TestVMSSExtensionParameters(t *testing.T) { g := NewWithT(t) t.Parallel() - result, err := tc.spec.Parameters(context.TODO(), tc.existing) + result, err := tc.spec.Parameters(t.Context(), tc.existing) if tc.expectedError != "" { g.Expect(err).To(HaveOccurred()) g.Expect(err).To(MatchError(tc.expectedError)) diff --git a/azure/services/scalesetvms/scalesetvms_test.go b/azure/services/scalesetvms/scalesetvms_test.go index b01af229d22..2544a3a111e 100644 --- a/azure/services/scalesetvms/scalesetvms_test.go +++ b/azure/services/scalesetvms/scalesetvms_test.go @@ -17,7 +17,6 @@ limitations under the License. package scalesetvms import ( - "context" "io" "net/http" "strings" @@ -153,7 +152,7 @@ func TestReconcileVMSS(t *testing.T) { VMReconciler: vmAsyncMock, } - err := s.Reconcile(context.TODO()) + err := s.Reconcile(t.Context()) if tc.expectedError != "" { g.Expect(err).To(HaveOccurred()) g.Expect(err.Error()).To(ContainSubstring(tc.expectedError), err.Error()) @@ -227,7 +226,7 @@ func TestDeleteVMSS(t *testing.T) { VMReconciler: vmAsyncMock, } - err := s.Delete(context.TODO()) + err := s.Delete(t.Context()) if tc.expectedError != "" { g.Expect(err).To(HaveOccurred()) g.Expect(err.Error()).To(ContainSubstring(tc.expectedError), err.Error()) diff --git a/azure/services/securitygroups/securitygroups_test.go b/azure/services/securitygroups/securitygroups_test.go index a98fcd53daf..5d02f2894a1 100644 --- a/azure/services/securitygroups/securitygroups_test.go +++ b/azure/services/securitygroups/securitygroups_test.go @@ -17,7 +17,6 @@ limitations under the License. package securitygroups import ( - "context" "testing" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v4" @@ -197,7 +196,7 @@ func TestReconcileSecurityGroups(t *testing.T) { Reconciler: reconcilerMock, } - err := s.Reconcile(context.TODO()) + err := s.Reconcile(t.Context()) if tc.expectedError != "" { g.Expect(err).To(HaveOccurred()) g.Expect(err).To(MatchError(tc.expectedError)) @@ -287,7 +286,7 @@ func TestDeleteSecurityGroups(t *testing.T) { Reconciler: reconcilerMock, } - err := s.Delete(context.TODO()) + err := s.Delete(t.Context()) if tc.expectedError != "" { g.Expect(err).To(HaveOccurred()) g.Expect(err).To(MatchError(tc.expectedError)) diff --git a/azure/services/securitygroups/spec_test.go b/azure/services/securitygroups/spec_test.go index c132e56bfdc..780ba3cac40 100644 --- a/azure/services/securitygroups/spec_test.go +++ b/azure/services/securitygroups/spec_test.go @@ -17,7 +17,6 @@ limitations under the License. package securitygroups import ( - "context" "testing" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v4" @@ -359,7 +358,7 @@ func TestParameters(t *testing.T) { g := NewWithT(t) t.Parallel() - result, err := tc.spec.Parameters(context.TODO(), tc.existing) + result, err := tc.spec.Parameters(t.Context(), tc.existing) if tc.expectedError != "" { g.Expect(err).To(HaveOccurred()) g.Expect(err).To(MatchError(tc.expectedError)) diff --git a/azure/services/subnets/spec_test.go b/azure/services/subnets/spec_test.go index 40578472f83..89a08e42c97 100644 --- a/azure/services/subnets/spec_test.go +++ b/azure/services/subnets/spec_test.go @@ -17,7 +17,6 @@ limitations under the License. package subnets import ( - "context" "testing" asonetworkv1 "github.com/Azure/azure-service-operator/v2/api/network/v1api20201101" @@ -155,7 +154,7 @@ func TestParameters(t *testing.T) { t.Run(test.name, func(t *testing.T) { g := NewGomegaWithT(t) - result, err := test.spec.Parameters(context.Background(), test.existing) + result, err := test.spec.Parameters(t.Context(), test.existing) g.Expect(err).NotTo(HaveOccurred()) g.Expect(cmp.Diff(test.expected, result)).To(BeEmpty()) }) diff --git a/azure/services/subnets/subnets_test.go b/azure/services/subnets/subnets_test.go index 8a36f1d2dda..7a82cd6c8e1 100644 --- a/azure/services/subnets/subnets_test.go +++ b/azure/services/subnets/subnets_test.go @@ -17,7 +17,6 @@ limitations under the License. package subnets import ( - "context" "testing" asonetworkv1 "github.com/Azure/azure-service-operator/v2/api/network/v1api20201101" @@ -35,7 +34,7 @@ func TestPostCreateOrUpdateResourceHook(t *testing.T) { mockCtrl := gomock.NewController(t) scope := mock_subnets.NewMockSubnetScope(mockCtrl) err := errors.New("an error") - g.Expect(postCreateOrUpdateResourceHook(context.Background(), scope, nil, err)).To(MatchError(err)) + g.Expect(postCreateOrUpdateResourceHook(t.Context(), scope, nil, err)).To(MatchError(err)) }) t.Run("successfully created or updated", func(t *testing.T) { @@ -53,7 +52,7 @@ func TestPostCreateOrUpdateResourceHook(t *testing.T) { AddressPrefixes: []string{"cidr"}, }, } - g.Expect(postCreateOrUpdateResourceHook(context.Background(), scope, subnet, nil)).To(Succeed()) + g.Expect(postCreateOrUpdateResourceHook(t.Context(), scope, subnet, nil)).To(Succeed()) }) t.Run("correctly handles empty and non-empty ASO Status CIDRBlocks", func(t *testing.T) { @@ -72,7 +71,7 @@ func TestPostCreateOrUpdateResourceHook(t *testing.T) { } scope.EXPECT().UpdateSubnetID("empty-cidr-status-subnet", "id-empty").Times(0) scope.EXPECT().UpdateSubnetCIDRs("empty-cidr-status-subnet", []string{}).Times(0) - g.Expect(postCreateOrUpdateResourceHook(context.Background(), scope, emptyCIDRSubnet, nil)).To(Succeed()) + g.Expect(postCreateOrUpdateResourceHook(t.Context(), scope, emptyCIDRSubnet, nil)).To(Succeed()) nonEmptyCIDRSubnet := &asonetworkv1.VirtualNetworksSubnet{ Spec: asonetworkv1.VirtualNetworksSubnet_Spec{ @@ -85,6 +84,6 @@ func TestPostCreateOrUpdateResourceHook(t *testing.T) { } scope.EXPECT().UpdateSubnetID("nonempty-cidr-status-subnet", "id-nonempty").Times(1) scope.EXPECT().UpdateSubnetCIDRs("nonempty-cidr-status-subnet", []string{"cidr"}).Times(1) - g.Expect(postCreateOrUpdateResourceHook(context.Background(), scope, nonEmptyCIDRSubnet, nil)).To(Succeed()) + g.Expect(postCreateOrUpdateResourceHook(t.Context(), scope, nonEmptyCIDRSubnet, nil)).To(Succeed()) }) } diff --git a/azure/services/tags/tags_test.go b/azure/services/tags/tags_test.go index e72cd240a2a..17e0aed0fbd 100644 --- a/azure/services/tags/tags_test.go +++ b/azure/services/tags/tags_test.go @@ -17,7 +17,6 @@ limitations under the License. package tags import ( - "context" "io" "net/http" "strings" @@ -283,7 +282,7 @@ func TestReconcileTags(t *testing.T) { client: clientMock, } - err := s.Reconcile(context.TODO()) + err := s.Reconcile(t.Context()) if tc.expectedError != "" { g.Expect(err).To(HaveOccurred()) g.Expect(strings.ReplaceAll(err.Error(), "\n", "")).To(MatchRegexp(tc.expectedError)) diff --git a/azure/services/virtualmachineimages/images_test.go b/azure/services/virtualmachineimages/images_test.go index d590c4d3efc..a481f489217 100644 --- a/azure/services/virtualmachineimages/images_test.go +++ b/azure/services/virtualmachineimages/images_test.go @@ -17,7 +17,6 @@ limitations under the License. package virtualmachineimages import ( - "context" "testing" . "github.com/onsi/gomega" @@ -91,7 +90,7 @@ func TestGetDefaultLinuxImage(t *testing.T) { g := NewWithT(t) svc := Service{} - image, err := svc.GetDefaultLinuxImage(context.TODO(), location, test.k8sVersion) + image, err := svc.GetDefaultLinuxImage(t.Context(), location, test.k8sVersion) if test.expectErr { g.Expect(err).To(HaveOccurred()) } else { @@ -209,7 +208,7 @@ func TestGetDefaultWindowsImage(t *testing.T) { g := NewWithT(t) svc := Service{} - image, err := svc.GetDefaultWindowsImage(context.TODO(), location, test.k8sVersion, test.runtime, test.osAndVersion) + image, err := svc.GetDefaultWindowsImage(t.Context(), location, test.k8sVersion, test.runtime, test.osAndVersion) if test.expectErr { g.Expect(err).To(HaveOccurred()) } else { diff --git a/azure/services/virtualmachines/spec_test.go b/azure/services/virtualmachines/spec_test.go index 6f6523cc476..9c63a19e2aa 100644 --- a/azure/services/virtualmachines/spec_test.go +++ b/azure/services/virtualmachines/spec_test.go @@ -17,7 +17,6 @@ limitations under the License. package virtualmachines import ( - "context" "testing" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v5" @@ -1423,7 +1422,7 @@ func TestParameters(t *testing.T) { g := NewWithT(t) t.Parallel() - result, err := tc.spec.Parameters(context.TODO(), tc.existing) + result, err := tc.spec.Parameters(t.Context(), tc.existing) if tc.expectedError != "" { g.Expect(err).To(HaveOccurred()) g.Expect(err).To(MatchError(tc.expectedError)) diff --git a/azure/services/virtualmachines/virtualmachines_test.go b/azure/services/virtualmachines/virtualmachines_test.go index 4da42df90b2..de2c0e2e381 100644 --- a/azure/services/virtualmachines/virtualmachines_test.go +++ b/azure/services/virtualmachines/virtualmachines_test.go @@ -17,7 +17,6 @@ limitations under the License. package virtualmachines import ( - "context" "io" "net/http" "strings" @@ -225,7 +224,7 @@ func TestReconcileVM(t *testing.T) { Reconciler: asyncMock, } - err := s.Reconcile(context.TODO()) + err := s.Reconcile(t.Context()) if tc.expectedError != "" { g.Expect(err).To(HaveOccurred()) g.Expect(strings.ReplaceAll(err.Error(), "\n", "")).To(MatchRegexp(tc.expectedError)) @@ -301,7 +300,7 @@ func TestDeleteVM(t *testing.T) { Reconciler: asyncMock, } - err := s.Delete(context.TODO()) + err := s.Delete(t.Context()) if tc.expectedError != "" { g.Expect(err).To(HaveOccurred()) g.Expect(err.Error()).To(ContainSubstring(tc.expectedError)) @@ -410,7 +409,7 @@ func TestCheckUserAssignedIdentities(t *testing.T) { identitiesGetter: identitiesMock, } - err := s.checkUserAssignedIdentities(context.TODO(), tc.specIdentities, tc.actualIdentities) + err := s.checkUserAssignedIdentities(t.Context(), tc.specIdentities, tc.actualIdentities) if tc.expectedError != "" { g.Expect(err).To(HaveOccurred()) g.Expect(err.Error()).To(ContainSubstring(tc.expectedError)) diff --git a/azure/services/virtualnetworks/spec_test.go b/azure/services/virtualnetworks/spec_test.go index 2751fe04352..b187667bcc8 100644 --- a/azure/services/virtualnetworks/spec_test.go +++ b/azure/services/virtualnetworks/spec_test.go @@ -17,7 +17,6 @@ limitations under the License. package virtualnetworks import ( - "context" "testing" asonetworkv1 "github.com/Azure/azure-service-operator/v2/api/network/v1api20201101" @@ -121,7 +120,7 @@ func TestParameters(t *testing.T) { for _, test := range tests { t.Run(test.name, func(t *testing.T) { g := NewGomegaWithT(t) - actual, err := test.spec.Parameters(context.Background(), test.existing) + actual, err := test.spec.Parameters(t.Context(), test.existing) g.Expect(err).NotTo(HaveOccurred()) g.Expect(cmp.Diff(test.expected, actual)).To(BeEmpty()) }) diff --git a/azure/services/virtualnetworks/virtualnetworks_test.go b/azure/services/virtualnetworks/virtualnetworks_test.go index 96e886fcc99..23aac5d51ee 100644 --- a/azure/services/virtualnetworks/virtualnetworks_test.go +++ b/azure/services/virtualnetworks/virtualnetworks_test.go @@ -17,7 +17,6 @@ limitations under the License. package virtualnetworks import ( - "context" "errors" "testing" @@ -42,7 +41,7 @@ func TestPostCreateOrUpdateResourceHook(t *testing.T) { mockCtrl := gomock.NewController(t) scope := mock_virtualnetworks.NewMockVNetScope(mockCtrl) err := errors.New("an error") - g.Expect(postCreateOrUpdateResourceHook(context.Background(), scope, nil, err)).To(MatchError(err)) + g.Expect(postCreateOrUpdateResourceHook(t.Context(), scope, nil, err)).To(MatchError(err)) }) t.Run("successfully created or updated", func(t *testing.T) { @@ -103,7 +102,7 @@ func TestPostCreateOrUpdateResourceHook(t *testing.T) { Build() scope.EXPECT().GetClient().Return(c) - g.Expect(postCreateOrUpdateResourceHook(context.Background(), scope, existing, nil)).To(Succeed()) + g.Expect(postCreateOrUpdateResourceHook(t.Context(), scope, existing, nil)).To(Succeed()) g.Expect(vnet.ID).To(Equal("id")) g.Expect(vnet.Tags).To(Equal(infrav1.Tags{"actual": "tags"})) @@ -170,6 +169,6 @@ func TestPostCreateOrUpdateResourceHook(t *testing.T) { scope.EXPECT().GetClient().Return(c) scope.EXPECT().UpdateSubnetCIDRs("empty-cidr-status-subnet", []string{}).Times(0) scope.EXPECT().UpdateSubnetCIDRs("nonempty-cidr-status-subnet", []string{"cidr"}).Times(1) - g.Expect(postCreateOrUpdateResourceHook(context.Background(), scope, existing, nil)).To(Succeed()) + g.Expect(postCreateOrUpdateResourceHook(t.Context(), scope, existing, nil)).To(Succeed()) }) } diff --git a/azure/services/vmextensions/spec_test.go b/azure/services/vmextensions/spec_test.go index aca5ab970af..2b3836e5b9a 100644 --- a/azure/services/vmextensions/spec_test.go +++ b/azure/services/vmextensions/spec_test.go @@ -17,7 +17,6 @@ limitations under the License. package vmextensions import ( - "context" "testing" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v5" @@ -85,7 +84,7 @@ func TestParameters(t *testing.T) { g := NewWithT(t) t.Parallel() - result, err := tc.spec.Parameters(context.TODO(), tc.existing) + result, err := tc.spec.Parameters(t.Context(), tc.existing) if tc.expectedError != "" { g.Expect(err).To(HaveOccurred()) g.Expect(err).To(MatchError(tc.expectedError)) diff --git a/azure/services/vmextensions/vmextensions_test.go b/azure/services/vmextensions/vmextensions_test.go index 3e83ba1e40b..b72898c4ba2 100644 --- a/azure/services/vmextensions/vmextensions_test.go +++ b/azure/services/vmextensions/vmextensions_test.go @@ -17,7 +17,6 @@ limitations under the License. package vmextensions import ( - "context" "io" "net/http" "strings" @@ -152,7 +151,7 @@ func TestReconcileVMExtension(t *testing.T) { Reconciler: asyncMock, } - err := s.Reconcile(context.TODO()) + err := s.Reconcile(t.Context()) if tc.expectedError != "" { g.Expect(err).To(HaveOccurred()) g.Expect(err).To(MatchError(tc.expectedError)) diff --git a/azure/services/vnetpeerings/spec_test.go b/azure/services/vnetpeerings/spec_test.go index 0594a5f41d1..318ec55d71f 100644 --- a/azure/services/vnetpeerings/spec_test.go +++ b/azure/services/vnetpeerings/spec_test.go @@ -17,7 +17,6 @@ limitations under the License. package vnetpeerings import ( - "context" "testing" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v4" @@ -102,7 +101,7 @@ func TestVnetPeeringSpec_Parameters(t *testing.T) { g := NewWithT(t) t.Parallel() - result, err := tc.spec.Parameters(context.TODO(), tc.existing) + result, err := tc.spec.Parameters(t.Context(), tc.existing) if tc.expectedError != "" { g.Expect(err).To(HaveOccurred()) g.Expect(err).To(MatchError(tc.expectedError)) diff --git a/azure/services/vnetpeerings/vnetpeerings_test.go b/azure/services/vnetpeerings/vnetpeerings_test.go index 442b6ffdd23..d38804f233e 100644 --- a/azure/services/vnetpeerings/vnetpeerings_test.go +++ b/azure/services/vnetpeerings/vnetpeerings_test.go @@ -17,7 +17,6 @@ limitations under the License. package vnetpeerings import ( - "context" "fmt" "io" "net/http" @@ -257,7 +256,7 @@ func TestReconcileVnetPeerings(t *testing.T) { Reconciler: asyncMock, } - err := s.Reconcile(context.TODO()) + err := s.Reconcile(t.Context()) if tc.expectedError != "" { g.Expect(err).To(HaveOccurred()) g.Expect(err.Error()).To(ContainSubstring(tc.expectedError)) @@ -409,7 +408,7 @@ func TestDeleteVnetPeerings(t *testing.T) { Reconciler: asyncMock, } - err := s.Delete(context.TODO()) + err := s.Delete(t.Context()) if tc.expectedError != "" { fmt.Printf("\nExpected error:\t%s\n", tc.expectedError) fmt.Printf("\nActual error:\t%s\n", err.Error()) diff --git a/controllers/agentpooladopt_controller_test.go b/controllers/agentpooladopt_controller_test.go index da5b566549e..6329226af3e 100644 --- a/controllers/agentpooladopt_controller_test.go +++ b/controllers/agentpooladopt_controller_test.go @@ -17,7 +17,6 @@ limitations under the License. package controllers import ( - "context" "testing" asocontainerservicev1 "github.com/Azure/azure-service-operator/v2/api/containerservice/v1api20231001" @@ -37,7 +36,7 @@ import ( func TestAgentPoolAdoptController(t *testing.T) { g := NewWithT(t) req := ctrl.Request{NamespacedName: types.NamespacedName{Name: "fake-agent-pool", Namespace: "fake-ns"}} - ctx := context.Background() + ctx := t.Context() scheme, err := newScheme() g.Expect(err).ToNot(HaveOccurred()) diff --git a/controllers/aso_credential_cache_test.go b/controllers/aso_credential_cache_test.go index 3b7943d6fab..412b226bb40 100644 --- a/controllers/aso_credential_cache_test.go +++ b/controllers/aso_credential_cache_test.go @@ -17,7 +17,6 @@ limitations under the License. package controllers import ( - "context" "reflect" "testing" @@ -477,7 +476,7 @@ func TestAuthTokenForASOResource(t *testing.T) { cache: credCache, client: c, } - _, err := asoCache.authTokenForASOResource(context.Background(), test.resource) + _, err := asoCache.authTokenForASOResource(t.Context(), test.resource) if test.expectedErr != nil { g.Expect(err).To(MatchError(test.expectedErr)) } else { diff --git a/controllers/asosecret_controller_test.go b/controllers/asosecret_controller_test.go index 6ef17490317..f0a8ae7cf7b 100644 --- a/controllers/asosecret_controller_test.go +++ b/controllers/asosecret_controller_test.go @@ -17,7 +17,6 @@ limitations under the License. package controllers import ( - "context" "os" "testing" @@ -323,7 +322,7 @@ func TestASOSecretReconcile(t *testing.T) { CredentialCache: azure.NewCredentialCache(), } - _, err := reconciler.Reconcile(context.Background(), ctrl.Request{ + _, err := reconciler.Reconcile(t.Context(), ctrl.Request{ NamespacedName: types.NamespacedName{ Namespace: "default", Name: tc.clusterName, @@ -331,7 +330,7 @@ func TestASOSecretReconcile(t *testing.T) { }) existingASOSecret := &corev1.Secret{} - asoSecretErr := clientBuilder.Get(context.Background(), types.NamespacedName{ + asoSecretErr := clientBuilder.Get(t.Context(), types.NamespacedName{ Namespace: defaultASOSecret.Namespace, Name: defaultASOSecret.Name, }, existingASOSecret) diff --git a/controllers/azureasomanagedcluster_controller_test.go b/controllers/azureasomanagedcluster_controller_test.go index fa82a4de3fb..692992b34e9 100644 --- a/controllers/azureasomanagedcluster_controller_test.go +++ b/controllers/azureasomanagedcluster_controller_test.go @@ -66,7 +66,7 @@ func (r *fakeResourceReconciler) Delete(ctx context.Context) error { } func TestAzureASOManagedClusterReconcile(t *testing.T) { - ctx := context.Background() + ctx := t.Context() s := runtime.NewScheme() sb := runtime.NewSchemeBuilder( diff --git a/controllers/azureasomanagedcontrolplane_controller_test.go b/controllers/azureasomanagedcontrolplane_controller_test.go index 013ef163f71..f63fa65fb72 100644 --- a/controllers/azureasomanagedcontrolplane_controller_test.go +++ b/controllers/azureasomanagedcontrolplane_controller_test.go @@ -47,7 +47,7 @@ import ( ) func TestAzureASOManagedControlPlaneReconcile(t *testing.T) { - ctx := context.Background() + ctx := t.Context() s := runtime.NewScheme() sb := runtime.NewSchemeBuilder( diff --git a/controllers/azureasomanagedmachinepool_controller_test.go b/controllers/azureasomanagedmachinepool_controller_test.go index 3b915a27f91..7680a533732 100644 --- a/controllers/azureasomanagedmachinepool_controller_test.go +++ b/controllers/azureasomanagedmachinepool_controller_test.go @@ -53,7 +53,7 @@ func (c *FakeClusterTracker) GetClient(ctx context.Context, name types.Namespace } func TestAzureASOManagedMachinePoolReconcile(t *testing.T) { - ctx := context.Background() + ctx := t.Context() s := runtime.NewScheme() sb := runtime.NewSchemeBuilder( diff --git a/controllers/azurecluster_controller.go b/controllers/azurecluster_controller.go index 8a477348578..fd76ad655e9 100644 --- a/controllers/azurecluster_controller.go +++ b/controllers/azurecluster_controller.go @@ -241,8 +241,8 @@ func (acr *AzureClusterReconciler) reconcileNormal(ctx context.Context, clusterS } wrappedErr := errors.Wrap(err, "failed to reconcile cluster services") - acr.Recorder.Eventf(azureCluster, corev1.EventTypeWarning, "ClusterReconcilerNormalFailed", wrappedErr.Error()) - conditions.MarkFalse(azureCluster, infrav1.NetworkInfrastructureReadyCondition, infrav1.FailedReason, clusterv1.ConditionSeverityError, wrappedErr.Error()) + acr.Recorder.Eventf(azureCluster, corev1.EventTypeWarning, "ClusterReconcilerNormalFailed", "%s", wrappedErr.Error()) + conditions.MarkFalse(azureCluster, infrav1.NetworkInfrastructureReadyCondition, infrav1.FailedReason, clusterv1.ConditionSeverityError, "%s", wrappedErr.Error()) return reconcile.Result{}, wrappedErr } @@ -318,8 +318,8 @@ func (acr *AzureClusterReconciler) reconcileDelete(ctx context.Context, clusterS } wrappedErr := errors.Wrapf(err, "error deleting AzureCluster %s/%s", azureCluster.Namespace, azureCluster.Name) - acr.Recorder.Eventf(azureCluster, corev1.EventTypeWarning, "ClusterReconcilerDeleteFailed", wrappedErr.Error()) - conditions.MarkFalse(azureCluster, infrav1.NetworkInfrastructureReadyCondition, clusterv1.DeletionFailedReason, clusterv1.ConditionSeverityWarning, err.Error()) + acr.Recorder.Eventf(azureCluster, corev1.EventTypeWarning, "ClusterReconcilerDeleteFailed", "%s", wrappedErr.Error()) + conditions.MarkFalse(azureCluster, infrav1.NetworkInfrastructureReadyCondition, clusterv1.DeletionFailedReason, clusterv1.ConditionSeverityWarning, "%s", err.Error()) return reconcile.Result{}, wrappedErr } diff --git a/controllers/azurecluster_controller_test.go b/controllers/azurecluster_controller_test.go index 2407acc6c4e..468b733dc62 100644 --- a/controllers/azurecluster_controller_test.go +++ b/controllers/azurecluster_controller_test.go @@ -137,7 +137,7 @@ func TestAzureClusterReconcile(t *testing.T) { Recorder: record.NewFakeRecorder(128), } - _, err := reconciler.Reconcile(context.Background(), ctrl.Request{ + _, err := reconciler.Reconcile(t.Context(), ctrl.Request{ NamespacedName: types.NamespacedName{ Namespace: namespace, Name: "my-azure-cluster", @@ -225,7 +225,7 @@ func TestAzureClusterReconcileNormal(t *testing.T) { reconciler, clusterScope, err := getClusterReconcileInputs(tc) g.Expect(err).NotTo(HaveOccurred()) - result, err := reconciler.reconcileNormal(context.Background(), clusterScope) + result, err := reconciler.reconcileNormal(t.Context(), clusterScope) g.Expect(result).To(Equal(tc.expectedResult)) if tc.ready { @@ -244,7 +244,7 @@ func TestAzureClusterReconcileNormal(t *testing.T) { func TestAzureClusterReconcilePaused(t *testing.T) { g := NewWithT(t) - ctx := context.Background() + ctx := t.Context() sb := runtime.NewSchemeBuilder( clusterv1.AddToScheme, @@ -342,7 +342,7 @@ func TestAzureClusterReconcilePaused(t *testing.T) { } g.Expect(c.Create(ctx, vnet)).To(Succeed()) - result, err := reconciler.Reconcile(context.Background(), ctrl.Request{ + result, err := reconciler.Reconcile(t.Context(), ctrl.Request{ NamespacedName: client.ObjectKey{ Namespace: instance.Namespace, Name: instance.Name, @@ -418,7 +418,7 @@ func TestAzureClusterReconcileDelete(t *testing.T) { reconciler, clusterScope, err := getClusterReconcileInputs(tc) g.Expect(err).NotTo(HaveOccurred()) - result, err := reconciler.reconcileDelete(context.Background(), clusterScope) + result, err := reconciler.reconcileDelete(t.Context(), clusterScope) g.Expect(result).To(Equal(tc.expectedResult)) if tc.expectedErr != "" { diff --git a/controllers/azurecluster_reconciler_test.go b/controllers/azurecluster_reconciler_test.go index 2c0e31e6082..ef71688dc3d 100644 --- a/controllers/azurecluster_reconciler_test.go +++ b/controllers/azurecluster_reconciler_test.go @@ -17,7 +17,6 @@ limitations under the License. package controllers import ( - "context" "errors" "testing" "time" @@ -95,7 +94,7 @@ func TestAzureClusterServiceReconcile(t *testing.T) { skuCache: resourceskus.NewStaticCache([]armcompute.ResourceSKU{}, ""), } - err := s.reconcile(context.TODO()) + err := s.reconcile(t.Context()) if tc.expectedError != "" { g.Expect(err).To(HaveOccurred()) g.Expect(err).To(MatchError(tc.expectedError)) @@ -164,7 +163,7 @@ func TestAzureClusterServicePause(t *testing.T) { }, } - err := s.pause(context.TODO()) + err := s.pause(t.Context()) if tc.expectedError != "" { g.Expect(err).To(HaveOccurred()) g.Expect(err).To(MatchError(tc.expectedError)) @@ -377,7 +376,7 @@ func TestAzureClusterServiceDelete(t *testing.T) { skuCache: resourceskus.NewStaticCache([]armcompute.ResourceSKU{}, ""), } - err := s.delete(context.TODO()) + err := s.delete(t.Context()) if tc.expectedError != "" { g.Expect(err).To(HaveOccurred()) g.Expect(err).To(MatchError(tc.expectedError)) diff --git a/controllers/azurejson_machine_controller_test.go b/controllers/azurejson_machine_controller_test.go index 77ff583151b..f0f0cb0b2dd 100644 --- a/controllers/azurejson_machine_controller_test.go +++ b/controllers/azurejson_machine_controller_test.go @@ -17,7 +17,6 @@ limitations under the License. package controllers import ( - "context" "testing" "github.com/google/go-cmp/cmp" @@ -236,7 +235,7 @@ func TestAzureJSONMachineReconciler(t *testing.T) { CredentialCache: azure.NewCredentialCache(), } - _, err := reconciler.Reconcile(context.Background(), ctrl.Request{ + _, err := reconciler.Reconcile(t.Context(), ctrl.Request{ NamespacedName: types.NamespacedName{ Namespace: "", Name: "my-machine", diff --git a/controllers/azurejson_machinepool_controller_test.go b/controllers/azurejson_machinepool_controller_test.go index 4fa83cfea5f..3a694ab08fc 100644 --- a/controllers/azurejson_machinepool_controller_test.go +++ b/controllers/azurejson_machinepool_controller_test.go @@ -17,7 +17,6 @@ limitations under the License. package controllers import ( - "context" "fmt" "testing" @@ -225,7 +224,7 @@ func TestAzureJSONPoolReconciler(t *testing.T) { CredentialCache: azure.NewCredentialCache(), } - _, err := reconciler.Reconcile(context.Background(), ctrl.Request{ + _, err := reconciler.Reconcile(t.Context(), ctrl.Request{ NamespacedName: types.NamespacedName{ Namespace: "", Name: "my-azure-machine-pool", @@ -250,7 +249,7 @@ func TestAzureJSONPoolReconcilerUserAssignedIdentities(t *testing.T) { ctrlr := gomock.NewController(t) defer ctrlr.Finish() req := ctrl.Request{NamespacedName: types.NamespacedName{Name: "fake-machine-pool", Namespace: "fake-ns"}} - ctx := context.Background() + ctx := t.Context() scheme, err := newScheme() g.Expect(err).NotTo(HaveOccurred()) diff --git a/controllers/azurejson_machinetemplate_controller_test.go b/controllers/azurejson_machinetemplate_controller_test.go index 53101ca5a4a..858b0ea9637 100644 --- a/controllers/azurejson_machinetemplate_controller_test.go +++ b/controllers/azurejson_machinetemplate_controller_test.go @@ -17,7 +17,6 @@ limitations under the License. package controllers import ( - "context" "testing" "github.com/google/go-cmp/cmp" @@ -169,7 +168,7 @@ func TestAzureJSONTemplateReconciler(t *testing.T) { CredentialCache: azure.NewCredentialCache(), } - _, err := reconciler.Reconcile(context.Background(), ctrl.Request{ + _, err := reconciler.Reconcile(t.Context(), ctrl.Request{ NamespacedName: types.NamespacedName{ Namespace: "", Name: "my-json-template", diff --git a/controllers/azuremachine_controller_test.go b/controllers/azuremachine_controller_test.go index d0b91931efc..e61ed32d6ad 100644 --- a/controllers/azuremachine_controller_test.go +++ b/controllers/azuremachine_controller_test.go @@ -143,7 +143,7 @@ func TestAzureMachineReconcile(t *testing.T) { resultIdentity := &infrav1.AzureClusterIdentity{} key := client.ObjectKey{Name: defaultAzureClusterIdentity.Name, Namespace: defaultAzureClusterIdentity.Namespace} - g.Expect(fakeClient.Get(context.TODO(), key, resultIdentity)).To(Succeed()) + g.Expect(fakeClient.Get(t.Context(), key, resultIdentity)).To(Succeed()) reconciler := &AzureMachineReconciler{ Client: fakeClient, @@ -151,7 +151,7 @@ func TestAzureMachineReconcile(t *testing.T) { CredentialCache: azure.NewCredentialCache(), } - _, err := reconciler.Reconcile(context.Background(), ctrl.Request{ + _, err := reconciler.Reconcile(t.Context(), ctrl.Request{ NamespacedName: types.NamespacedName{ Namespace: "default", Name: "my-machine", @@ -246,7 +246,7 @@ func TestAzureMachineReconcileNormal(t *testing.T) { reconciler, machineScope, clusterScope, err := getMachineReconcileInputs(tc) g.Expect(err).NotTo(HaveOccurred()) - result, err := reconciler.reconcileNormal(context.Background(), machineScope, clusterScope) + result, err := reconciler.reconcileNormal(t.Context(), machineScope, clusterScope) g.Expect(result).To(Equal(tc.expectedResult)) if tc.ready { @@ -292,7 +292,7 @@ func TestAzureMachineReconcilePause(t *testing.T) { reconciler, machineScope, _, err := getMachineReconcileInputs(tc) g.Expect(err).NotTo(HaveOccurred()) - result, err := reconciler.reconcilePause(context.Background(), machineScope) + result, err := reconciler.reconcilePause(t.Context(), machineScope) g.Expect(result).To(Equal(tc.expectedResult)) if tc.expectedErr != "" { @@ -336,7 +336,7 @@ func TestAzureMachineReconcileDelete(t *testing.T) { reconciler, machineScope, clusterScope, err := getMachineReconcileInputs(tc) g.Expect(err).NotTo(HaveOccurred()) - result, err := reconciler.reconcileDelete(context.Background(), machineScope, clusterScope) + result, err := reconciler.reconcileDelete(t.Context(), machineScope, clusterScope) g.Expect(result).To(Equal(tc.expectedResult)) if tc.expectedErr != "" { @@ -785,13 +785,13 @@ func TestConditions(t *testing.T) { fakeClient := fake.NewClientBuilder().WithScheme(scheme).WithRuntimeObjects(initObjects...).Build() resultIdentity := &infrav1.AzureClusterIdentity{} key := client.ObjectKey{Name: azureClusterIdentity.Name, Namespace: azureClusterIdentity.Namespace} - g.Expect(fakeClient.Get(context.TODO(), key, resultIdentity)).To(Succeed()) + g.Expect(fakeClient.Get(t.Context(), key, resultIdentity)).To(Succeed()) recorder := record.NewFakeRecorder(10) credCache := azure.NewCredentialCache() reconciler := NewAzureMachineReconciler(fakeClient, recorder, reconciler.Timeouts{}, "", credCache) - clusterScope, err := scope.NewClusterScope(context.TODO(), scope.ClusterScopeParams{ + clusterScope, err := scope.NewClusterScope(t.Context(), scope.ClusterScopeParams{ Client: fakeClient, Cluster: cluster, AzureCluster: azureCluster, @@ -808,7 +808,7 @@ func TestConditions(t *testing.T) { }) g.Expect(err).NotTo(HaveOccurred()) - _, err = reconciler.reconcileNormal(context.TODO(), machineScope, clusterScope) + _, err = reconciler.reconcileNormal(t.Context(), machineScope, clusterScope) g.Expect(err).NotTo(HaveOccurred()) g.Expect(machineScope.AzureMachine.GetConditions()).To(HaveLen(len(tc.expectedConditions))) diff --git a/controllers/azuremachine_reconciler_test.go b/controllers/azuremachine_reconciler_test.go index bd4abb8de3e..cd04f95361d 100644 --- a/controllers/azuremachine_reconciler_test.go +++ b/controllers/azuremachine_reconciler_test.go @@ -17,7 +17,6 @@ limitations under the License. package controllers import ( - "context" "errors" "testing" @@ -93,7 +92,7 @@ func TestAzureMachineServiceReconcile(t *testing.T) { skuCache: resourceskus.NewStaticCache([]armcompute.ResourceSKU{}, ""), } - err := s.reconcile(context.TODO()) + err := s.reconcile(t.Context()) if tc.expectedError != "" { g.Expect(err).To(HaveOccurred()) g.Expect(err).To(MatchError(tc.expectedError)) @@ -162,7 +161,7 @@ func TestAzureMachineServicePause(t *testing.T) { }, } - err := s.pause(context.TODO()) + err := s.pause(t.Context()) if tc.expectedError != "" { g.Expect(err).To(HaveOccurred()) g.Expect(err).To(MatchError(tc.expectedError)) @@ -228,7 +227,7 @@ func TestAzureMachineServiceDelete(t *testing.T) { skuCache: resourceskus.NewStaticCache([]armcompute.ResourceSKU{}, ""), } - err := s.delete(context.TODO()) + err := s.delete(t.Context()) if tc.expectedError != "" { g.Expect(err).To(HaveOccurred()) g.Expect(err).To(MatchError(tc.expectedError)) diff --git a/controllers/azuremanagedcluster_controller_test.go b/controllers/azuremanagedcluster_controller_test.go index 4f8d81e650c..fc20c79691a 100644 --- a/controllers/azuremanagedcluster_controller_test.go +++ b/controllers/azuremanagedcluster_controller_test.go @@ -17,7 +17,6 @@ limitations under the License. package controllers import ( - "context" "testing" . "github.com/onsi/gomega" @@ -37,7 +36,7 @@ import ( func TestAzureManagedClusterController(t *testing.T) { g := NewWithT(t) - ctx := context.Background() + ctx := t.Context() scheme := runtime.NewScheme() g.Expect(infrav1.AddToScheme(scheme)).To(Succeed()) g.Expect(clusterv1.AddToScheme(scheme)).To(Succeed()) diff --git a/controllers/azuremanagedcontrolplane_controller_test.go b/controllers/azuremanagedcontrolplane_controller_test.go index 3c8de1d39f9..f13c3431601 100644 --- a/controllers/azuremanagedcontrolplane_controller_test.go +++ b/controllers/azuremanagedcontrolplane_controller_test.go @@ -17,7 +17,6 @@ limitations under the License. package controllers import ( - "context" "testing" asocontainerservicev1preview "github.com/Azure/azure-service-operator/v2/api/containerservice/v1api20230315preview" @@ -84,7 +83,7 @@ func TestClusterToAzureManagedControlPlane(t *testing.T) { for _, test := range tests { t.Run(test.name, func(t *testing.T) { g := NewWithT(t) - actual := (&AzureManagedControlPlaneReconciler{}).ClusterToAzureManagedControlPlane(context.TODO(), &clusterv1.Cluster{ + actual := (&AzureManagedControlPlaneReconciler{}).ClusterToAzureManagedControlPlane(t.Context(), &clusterv1.Cluster{ Spec: clusterv1.ClusterSpec{ ControlPlaneRef: test.controlPlaneRef, }, @@ -101,7 +100,7 @@ func TestClusterToAzureManagedControlPlane(t *testing.T) { func TestAzureManagedControlPlaneReconcilePaused(t *testing.T) { g := NewWithT(t) - ctx := context.Background() + ctx := t.Context() sb := runtime.NewSchemeBuilder( clusterv1.AddToScheme, @@ -247,7 +246,7 @@ func TestAzureManagedControlPlaneReconcilePaused(t *testing.T) { } g.Expect(c.Create(ctx, subnet)).To(Succeed()) - result, err := reconciler.Reconcile(context.Background(), ctrl.Request{ + result, err := reconciler.Reconcile(t.Context(), ctrl.Request{ NamespacedName: client.ObjectKey{ Namespace: instance.Namespace, Name: instance.Name, @@ -260,7 +259,7 @@ func TestAzureManagedControlPlaneReconcilePaused(t *testing.T) { func TestAzureManagedControlPlaneReconcileNormal(t *testing.T) { g := NewWithT(t) - ctx := context.Background() + ctx := t.Context() cp := &infrav1.AzureManagedControlPlane{ ObjectMeta: metav1.ObjectMeta{ Name: "fake-azmp", diff --git a/controllers/azuremanagedcontrolplane_reconciler_test.go b/controllers/azuremanagedcontrolplane_reconciler_test.go index 0a551eab721..0dbf089b181 100644 --- a/controllers/azuremanagedcontrolplane_reconciler_test.go +++ b/controllers/azuremanagedcontrolplane_reconciler_test.go @@ -17,7 +17,6 @@ limitations under the License. package controllers import ( - "context" "testing" . "github.com/onsi/gomega" @@ -87,7 +86,7 @@ func TestAzureManagedControlPlaneServicePause(t *testing.T) { }, } - err := s.Pause(context.TODO()) + err := s.Pause(t.Context()) if tc.expectedError != "" { g.Expect(err).To(HaveOccurred()) g.Expect(err).To(MatchError(tc.expectedError)) diff --git a/controllers/azuremanagedmachinepool_controller.go b/controllers/azuremanagedmachinepool_controller.go index a4c2abb7705..9be7f1d95bb 100644 --- a/controllers/azuremanagedmachinepool_controller.go +++ b/controllers/azuremanagedmachinepool_controller.go @@ -270,7 +270,7 @@ func (ammpr *AzureManagedMachinePoolReconciler) reconcileNormal(ctx context.Cont // Ensure the ready condition is false, but do not overwrite an existing // error condition which might provide more details. if conditions.IsTrue(scope.InfraMachinePool, infrav1.AgentPoolsReadyCondition) { - conditions.MarkFalse(scope.InfraMachinePool, infrav1.AgentPoolsReadyCondition, infrav1.FailedReason, clusterv1.ConditionSeverityError, err.Error()) + conditions.MarkFalse(scope.InfraMachinePool, infrav1.AgentPoolsReadyCondition, infrav1.FailedReason, clusterv1.ConditionSeverityError, "%s", err.Error()) } // Handle transient and terminal errors diff --git a/controllers/azuremanagedmachinepool_controller_test.go b/controllers/azuremanagedmachinepool_controller_test.go index 98d8195c9db..c41a4181c86 100644 --- a/controllers/azuremanagedmachinepool_controller_test.go +++ b/controllers/azuremanagedmachinepool_controller_test.go @@ -17,7 +17,6 @@ limitations under the License. package controllers import ( - "context" "testing" "time" @@ -185,7 +184,7 @@ func TestAzureManagedMachinePoolReconcile(t *testing.T) { scaleSetsSvc: nodelister, }, nil } - res, err := controller.Reconcile(context.TODO(), ctrl.Request{ + res, err := controller.Reconcile(t.Context(), ctrl.Request{ NamespacedName: types.NamespacedName{ Name: "foo-ammp", Namespace: "foobar", diff --git a/controllers/azuremanagedmachinepool_reconciler_test.go b/controllers/azuremanagedmachinepool_reconciler_test.go index 60e000d6a42..c30f62ce3c0 100644 --- a/controllers/azuremanagedmachinepool_reconciler_test.go +++ b/controllers/azuremanagedmachinepool_reconciler_test.go @@ -17,7 +17,6 @@ limitations under the License. package controllers import ( - "context" "testing" "github.com/onsi/gomega" @@ -125,7 +124,7 @@ func TestAzureManagedMachinePoolServicePause(t *testing.T) { }, } - err := s.Pause(context.TODO()) + err := s.Pause(t.Context()) if tc.expectedError != "" { g.Expect(err).To(gomega.HaveOccurred()) g.Expect(err).To(gomega.MatchError(tc.expectedError)) diff --git a/controllers/helpers_test.go b/controllers/helpers_test.go index e491f9e2940..0e37e74f21c 100644 --- a/controllers/helpers_test.go +++ b/controllers/helpers_test.go @@ -17,7 +17,6 @@ limitations under the License. package controllers import ( - "context" "fmt" "os" "strings" @@ -73,10 +72,10 @@ func TestAzureClusterToAzureMachinesMapper(t *testing.T) { sink := mock_log.NewMockLogSink(mockCtrl) sink.EXPECT().Init(logr.RuntimeInfo{CallDepth: 1}) sink.EXPECT().WithValues("AzureCluster", "my-cluster", "Namespace", "default") - mapper, err := AzureClusterToAzureMachinesMapper(context.Background(), client, &infrav1.AzureMachine{}, scheme, logr.New(sink)) + mapper, err := AzureClusterToAzureMachinesMapper(t.Context(), client, &infrav1.AzureMachine{}, scheme, logr.New(sink)) g.Expect(err).NotTo(HaveOccurred()) - requests := mapper(context.TODO(), &infrav1.AzureCluster{ + requests := mapper(t.Context(), &infrav1.AzureCluster{ ObjectMeta: metav1.ObjectMeta{ Name: clusterName, Namespace: "default", @@ -102,10 +101,10 @@ func TestGetCloudProviderConfig(t *testing.T) { cluster := newCluster("foo") azureCluster := newAzureCluster("bar") - g.Expect((&infrav1.AzureClusterWebhook{}).Default(context.Background(), azureCluster)).To(Succeed()) + g.Expect((&infrav1.AzureClusterWebhook{}).Default(t.Context(), azureCluster)).To(Succeed()) azureClusterCustomVnet := newAzureClusterWithCustomVnet("bar") - g.Expect((&infrav1.AzureClusterWebhook{}).Default(context.Background(), azureClusterCustomVnet)).NotTo(HaveOccurred()) + g.Expect((&infrav1.AzureClusterWebhook{}).Default(t.Context(), azureClusterCustomVnet)).NotTo(HaveOccurred()) cases := map[string]struct { cluster *clusterv1.Cluster @@ -200,9 +199,9 @@ func TestGetCloudProviderConfig(t *testing.T) { fakeClient := fake.NewClientBuilder().WithScheme(scheme).WithRuntimeObjects(initObjects...).Build() resultSecret := &corev1.Secret{} key := client.ObjectKey{Name: fakeSecret.Name, Namespace: fakeSecret.Namespace} - g.Expect(fakeClient.Get(context.Background(), key, resultSecret)).To(Succeed()) + g.Expect(fakeClient.Get(t.Context(), key, resultSecret)).To(Succeed()) - clusterScope, err := scope.NewClusterScope(context.Background(), scope.ClusterScopeParams{ + clusterScope, err := scope.NewClusterScope(t.Context(), scope.ClusterScopeParams{ Cluster: tc.cluster, AzureCluster: tc.azureCluster, Client: fakeClient, @@ -303,7 +302,7 @@ func TestReconcileAzureSecret(t *testing.T) { cluster := newCluster("foo") azureCluster := newAzureCluster("bar") - err := (&infrav1.AzureClusterWebhook{}).Default(context.Background(), azureCluster) + err := (&infrav1.AzureClusterWebhook{}).Default(t.Context(), azureCluster) g.Expect(err).NotTo(HaveOccurred()) cluster.Name = "testCluster" @@ -323,7 +322,7 @@ func TestReconcileAzureSecret(t *testing.T) { scheme := setupScheme(g) kubeclient := fake.NewClientBuilder().WithScheme(scheme).WithRuntimeObjects(initObjects...).Build() - clusterScope, err := scope.NewClusterScope(context.Background(), scope.ClusterScopeParams{ + clusterScope, err := scope.NewClusterScope(t.Context(), scope.ClusterScopeParams{ Cluster: cluster, AzureCluster: azureCluster, Client: kubeclient, @@ -334,10 +333,10 @@ func TestReconcileAzureSecret(t *testing.T) { for name, tc := range cases { t.Run(name, func(t *testing.T) { if tc.existingSecret != nil { - _ = kubeclient.Delete(context.Background(), tc.existingSecret) - _ = kubeclient.Create(context.Background(), tc.existingSecret) + _ = kubeclient.Delete(t.Context(), tc.existingSecret) + _ = kubeclient.Create(t.Context(), tc.existingSecret) defer func() { - _ = kubeclient.Delete(context.Background(), tc.existingSecret) + _ = kubeclient.Delete(t.Context(), tc.existingSecret) }() } @@ -350,7 +349,7 @@ func TestReconcileAzureSecret(t *testing.T) { g.Expect(err).NotTo(HaveOccurred()) g.Expect(cloudConfig.Data).NotTo(BeNil()) - if err := reconcileAzureSecret(context.Background(), kubeclient, owner, cloudConfig, cluster.Name); err != nil { + if err := reconcileAzureSecret(t.Context(), kubeclient, owner, cloudConfig, cluster.Name); err != nil { t.Error(err) } @@ -359,7 +358,7 @@ func TestReconcileAzureSecret(t *testing.T) { Name: fmt.Sprintf("%s-azure-json", tc.ownerName), } found := &corev1.Secret{} - if err := kubeclient.Get(context.Background(), key, found); err != nil { + if err := kubeclient.Get(t.Context(), key, found); err != nil { t.Error(err) } @@ -893,10 +892,10 @@ func TestAzureManagedClusterToAzureManagedMachinePoolsMapper(t *testing.T) { sink.EXPECT().Enabled(4).Return(true) sink.EXPECT().WithValues("AzureManagedCluster", "my-cluster", "Namespace", "default").Return(sink) sink.EXPECT().Info(4, "gk does not match", "gk", gomock.Any(), "infraGK", gomock.Any()) - mapper, err := AzureManagedClusterToAzureManagedMachinePoolsMapper(context.Background(), fakeClient, scheme, logr.New(sink)) + mapper, err := AzureManagedClusterToAzureManagedMachinePoolsMapper(t.Context(), fakeClient, scheme, logr.New(sink)) g.Expect(err).NotTo(HaveOccurred()) - requests := mapper(context.TODO(), &infrav1.AzureManagedCluster{ + requests := mapper(t.Context(), &infrav1.AzureManagedCluster{ ObjectMeta: metav1.ObjectMeta{ Name: clusterName, Namespace: "default", @@ -958,10 +957,10 @@ func TestAzureManagedControlPlaneToAzureManagedMachinePoolsMapper(t *testing.T) sink.EXPECT().Enabled(4).Return(true) sink.EXPECT().WithValues("AzureManagedControlPlane", cpName, "Namespace", cluster.Namespace).Return(sink) sink.EXPECT().Info(4, "gk does not match", "gk", gomock.Any(), "infraGK", gomock.Any()) - mapper, err := AzureManagedControlPlaneToAzureManagedMachinePoolsMapper(context.Background(), fakeClient, scheme, logr.New(sink)) + mapper, err := AzureManagedControlPlaneToAzureManagedMachinePoolsMapper(t.Context(), fakeClient, scheme, logr.New(sink)) g.Expect(err).NotTo(HaveOccurred()) - requests := mapper(context.TODO(), &infrav1.AzureManagedControlPlane{ + requests := mapper(t.Context(), &infrav1.AzureManagedControlPlane{ ObjectMeta: metav1.ObjectMeta{ Name: cpName, Namespace: cluster.Namespace, @@ -1030,10 +1029,10 @@ func TestMachinePoolToAzureManagedControlPlaneMapFuncSuccess(t *testing.T) { sink := mock_log.NewMockLogSink(gomock.NewController(t)) sink.EXPECT().Init(logr.RuntimeInfo{CallDepth: 1}) - mapper := MachinePoolToAzureManagedControlPlaneMapFunc(context.Background(), fakeClient, infrav1.GroupVersion.WithKind(infrav1.AzureManagedControlPlaneKind), logr.New(sink)) + mapper := MachinePoolToAzureManagedControlPlaneMapFunc(t.Context(), fakeClient, infrav1.GroupVersion.WithKind(infrav1.AzureManagedControlPlaneKind), logr.New(sink)) // system pool should trigger - requests := mapper(context.TODO(), newManagedMachinePoolInfraReference(clusterName, "my-mmp-0")) + requests := mapper(t.Context(), newManagedMachinePoolInfraReference(clusterName, "my-mmp-0")) g.Expect(requests).To(ConsistOf([]reconcile.Request{ { NamespacedName: types.NamespacedName{ @@ -1044,7 +1043,7 @@ func TestMachinePoolToAzureManagedControlPlaneMapFuncSuccess(t *testing.T) { })) // any other pool should not trigger - requests = mapper(context.TODO(), newManagedMachinePoolInfraReference(clusterName, "my-mmp-1")) + requests = mapper(t.Context(), newManagedMachinePoolInfraReference(clusterName, "my-mmp-1")) g.Expect(requests).To(BeNil()) } @@ -1074,10 +1073,10 @@ func TestMachinePoolToAzureManagedControlPlaneMapFuncFailure(t *testing.T) { sink.EXPECT().Error(gomock.Any(), "failed to fetch default pool reference") sink.EXPECT().Error(gomock.Any(), "failed to fetch default pool reference") // twice because we are testing two calls - mapper := MachinePoolToAzureManagedControlPlaneMapFunc(context.Background(), fakeClient, infrav1.GroupVersion.WithKind(infrav1.AzureManagedControlPlaneKind), logr.New(sink)) + mapper := MachinePoolToAzureManagedControlPlaneMapFunc(t.Context(), fakeClient, infrav1.GroupVersion.WithKind(infrav1.AzureManagedControlPlaneKind), logr.New(sink)) // default pool should trigger if owned cluster could not be fetched - requests := mapper(context.TODO(), newManagedMachinePoolInfraReference(clusterName, "my-mmp-0")) + requests := mapper(t.Context(), newManagedMachinePoolInfraReference(clusterName, "my-mmp-0")) g.Expect(requests).To(ConsistOf([]reconcile.Request{ { NamespacedName: types.NamespacedName{ @@ -1088,7 +1087,7 @@ func TestMachinePoolToAzureManagedControlPlaneMapFuncFailure(t *testing.T) { })) // any other pool should also trigger if owned cluster could not be fetched - requests = mapper(context.TODO(), newManagedMachinePoolInfraReference(clusterName, "my-mmp-1")) + requests = mapper(t.Context(), newManagedMachinePoolInfraReference(clusterName, "my-mmp-1")) g.Expect(requests).To(ConsistOf([]reconcile.Request{ { NamespacedName: types.NamespacedName{ @@ -1121,9 +1120,9 @@ func TestAzureManagedClusterToAzureManagedControlPlaneMapper(t *testing.T) { sink.EXPECT().Init(logr.RuntimeInfo{CallDepth: 1}) sink.EXPECT().WithValues("AzureManagedCluster", "az-"+cluster.Name, "Namespace", "default") - mapper, err := AzureManagedClusterToAzureManagedControlPlaneMapper(context.Background(), fakeClient, logr.New(sink)) + mapper, err := AzureManagedClusterToAzureManagedControlPlaneMapper(t.Context(), fakeClient, logr.New(sink)) g.Expect(err).NotTo(HaveOccurred()) - requests := mapper(context.TODO(), &infrav1.AzureManagedCluster{ + requests := mapper(t.Context(), &infrav1.AzureManagedCluster{ ObjectMeta: metav1.ObjectMeta{ Name: "az-" + cluster.Name, Namespace: "default", @@ -1190,9 +1189,9 @@ func TestAzureManagedControlPlaneToAzureManagedClusterMapper(t *testing.T) { sink.EXPECT().Init(logr.RuntimeInfo{CallDepth: 1}) sink.EXPECT().WithValues("AzureManagedControlPlane", cpName, "Namespace", cluster.Namespace) - mapper, err := AzureManagedControlPlaneToAzureManagedClusterMapper(context.Background(), fakeClient, logr.New(sink)) + mapper, err := AzureManagedControlPlaneToAzureManagedClusterMapper(t.Context(), fakeClient, logr.New(sink)) g.Expect(err).NotTo(HaveOccurred()) - requests := mapper(context.TODO(), &infrav1.AzureManagedControlPlane{ + requests := mapper(t.Context(), &infrav1.AzureManagedControlPlane{ ObjectMeta: metav1.ObjectMeta{ Name: cpName, Namespace: cluster.Namespace, @@ -1362,7 +1361,7 @@ func Test_ManagedMachinePoolToInfrastructureMapFunc(t *testing.T) { c.Setup(sink) } f := MachinePoolToInfrastructureMapFunc(infrav1.GroupVersion.WithKind("AzureManagedMachinePool"), logr.New(sink)) - reqs := f(context.TODO(), c.MapObjectFactory(g)) + reqs := f(t.Context(), c.MapObjectFactory(g)) c.Expect(g, reqs) }) } diff --git a/controllers/managedclusteradopt_controller_test.go b/controllers/managedclusteradopt_controller_test.go index de8487036fd..8eaad1049c4 100644 --- a/controllers/managedclusteradopt_controller_test.go +++ b/controllers/managedclusteradopt_controller_test.go @@ -17,7 +17,6 @@ limitations under the License. package controllers import ( - "context" "testing" asocontainerservicev1 "github.com/Azure/azure-service-operator/v2/api/containerservice/v1api20231001" @@ -35,7 +34,7 @@ import ( ) func TestManagedClusterAdoptReconcile(t *testing.T) { - ctx := context.Background() + ctx := t.Context() g := NewWithT(t) req := ctrl.Request{ NamespacedName: types.NamespacedName{ diff --git a/controllers/resource_reconciler_test.go b/controllers/resource_reconciler_test.go index 1135ff5c6cf..81e26ea55d3 100644 --- a/controllers/resource_reconciler_test.go +++ b/controllers/resource_reconciler_test.go @@ -65,7 +65,7 @@ func (w *FakeWatcher) Watch(_ logr.Logger, obj client.Object, _ handler.EventHan } func TestResourceReconcilerReconcile(t *testing.T) { - ctx := context.Background() + ctx := t.Context() s := runtime.NewScheme() sb := runtime.NewSchemeBuilder( @@ -231,7 +231,7 @@ func TestResourceReconcilerReconcile(t *testing.T) { } func TestResourceReconcilerPause(t *testing.T) { - ctx := context.Background() + ctx := t.Context() s := runtime.NewScheme() sb := runtime.NewSchemeBuilder( @@ -296,7 +296,7 @@ func TestResourceReconcilerPause(t *testing.T) { } func TestResourceReconcilerDelete(t *testing.T) { - ctx := context.Background() + ctx := t.Context() s := runtime.NewScheme() sb := runtime.NewSchemeBuilder( @@ -373,7 +373,7 @@ func TestResourceReconcilerDelete(t *testing.T) { } func TestReadyStatus(t *testing.T) { - ctx := context.Background() + ctx := t.Context() t.Run("unstructured", func(t *testing.T) { tests := []struct { diff --git a/exp/api/v1beta1/azuremachinepool_webhook_test.go b/exp/api/v1beta1/azuremachinepool_webhook_test.go index 4de99e5fc18..4185fef7167 100644 --- a/exp/api/v1beta1/azuremachinepool_webhook_test.go +++ b/exp/api/v1beta1/azuremachinepool_webhook_test.go @@ -258,7 +258,7 @@ func TestAzureMachinePool_ValidateCreate(t *testing.T) { ampw := &azureMachinePoolWebhook{ Client: client, } - _, err := ampw.ValidateCreate(context.Background(), tc.amp) + _, err := ampw.ValidateCreate(t.Context(), tc.amp) if tc.wantErr { g.Expect(err).To(HaveOccurred()) } else { @@ -394,7 +394,7 @@ func TestAzureMachinePool_ValidateUpdate(t *testing.T) { t.Run(tc.name, func(t *testing.T) { g := NewWithT(t) ampw := &azureMachinePoolWebhook{} - _, err := ampw.ValidateUpdate(context.Background(), tc.oldAMP, tc.amp) + _, err := ampw.ValidateUpdate(t.Context(), tc.oldAMP, tc.amp) if tc.wantErr { g.Expect(err).To(HaveOccurred()) } else { @@ -463,24 +463,24 @@ func TestAzureMachinePool_Default(t *testing.T) { Client: mockClient, } - err := ampw.Default(context.Background(), roleAssignmentExistTest.amp) + err := ampw.Default(t.Context(), roleAssignmentExistTest.amp) g.Expect(err).NotTo(HaveOccurred()) g.Expect(roleAssignmentExistTest.amp.Spec.SystemAssignedIdentityRole.Name).To(Equal(existingRoleAssignmentName)) - err = ampw.Default(context.Background(), publicKeyExistTest.amp) + err = ampw.Default(t.Context(), publicKeyExistTest.amp) g.Expect(err).NotTo(HaveOccurred()) g.Expect(publicKeyExistTest.amp.Spec.Template.SSHPublicKey).To(Equal(existingPublicKey)) - err = ampw.Default(context.Background(), publicKeyNotExistTest.amp) + err = ampw.Default(t.Context(), publicKeyNotExistTest.amp) g.Expect(err).NotTo(HaveOccurred()) g.Expect(publicKeyNotExistTest.amp.Spec.Template.SSHPublicKey).NotTo(BeEmpty()) - err = ampw.Default(context.Background(), systemAssignedIdentityRoleExistTest.amp) + err = ampw.Default(t.Context(), systemAssignedIdentityRoleExistTest.amp) g.Expect(err).NotTo(HaveOccurred()) g.Expect(systemAssignedIdentityRoleExistTest.amp.Spec.SystemAssignedIdentityRole.DefinitionID).To(Equal("testroledefinitionid")) g.Expect(systemAssignedIdentityRoleExistTest.amp.Spec.SystemAssignedIdentityRole.Scope).To(Equal("testscope")) - err = ampw.Default(context.Background(), emptyTest.amp) + err = ampw.Default(t.Context(), emptyTest.amp) g.Expect(err).NotTo(HaveOccurred()) g.Expect(emptyTest.amp.Spec.SystemAssignedIdentityRole.Name).To(Not(BeEmpty())) _, err = guuid.Parse(emptyTest.amp.Spec.SystemAssignedIdentityRole.Name) @@ -719,7 +719,7 @@ func TestAzureMachinePool_ValidateCreateFailure(t *testing.T) { utilfeature.SetFeatureGateDuringTest(t, feature.Gates, capifeature.MachinePool, *tc.featureGateEnabled) } ampw := &azureMachinePoolWebhook{} - _, err := ampw.ValidateCreate(context.Background(), tc.amp) + _, err := ampw.ValidateCreate(t.Context(), tc.amp) if tc.expectError { g.Expect(err).To(HaveOccurred()) } else { diff --git a/exp/controllers/azuremachinepool_controller_test.go b/exp/controllers/azuremachinepool_controller_test.go index feaf354ab05..21582a59246 100644 --- a/exp/controllers/azuremachinepool_controller_test.go +++ b/exp/controllers/azuremachinepool_controller_test.go @@ -64,7 +64,7 @@ var _ = Describe("AzureMachinePoolReconciler", func() { func TestAzureMachinePoolReconcilePaused(t *testing.T) { g := NewWithT(t) - ctx := context.Background() + ctx := t.Context() sb := runtime.NewSchemeBuilder( clusterv1.AddToScheme, @@ -179,7 +179,7 @@ func TestAzureMachinePoolReconcilePaused(t *testing.T) { } g.Expect(c.Create(ctx, instance)).To(Succeed()) - result, err := reconciler.Reconcile(context.Background(), ctrl.Request{ + result, err := reconciler.Reconcile(t.Context(), ctrl.Request{ NamespacedName: client.ObjectKey{ Namespace: instance.Namespace, Name: instance.Name, diff --git a/exp/controllers/azuremachinepool_reconciler_test.go b/exp/controllers/azuremachinepool_reconciler_test.go index ccd2fdceb21..29ed63a8fd8 100644 --- a/exp/controllers/azuremachinepool_reconciler_test.go +++ b/exp/controllers/azuremachinepool_reconciler_test.go @@ -17,7 +17,6 @@ limitations under the License. package controllers import ( - "context" "errors" "testing" @@ -97,7 +96,7 @@ func TestAzureMachinePoolServiceReconcile(t *testing.T) { skuCache: resourceskus.NewStaticCache([]armcompute.ResourceSKU{}, ""), } - err := s.Reconcile(context.TODO()) + err := s.Reconcile(t.Context()) if tc.expectedError != "" { g.Expect(err).To(HaveOccurred()) g.Expect(err).To(MatchError(tc.expectedError)) @@ -166,7 +165,7 @@ func TestAzureMachinePoolServicePause(t *testing.T) { }, } - err := s.Pause(context.TODO()) + err := s.Pause(t.Context()) if tc.expectedError != "" { g.Expect(err).To(HaveOccurred()) g.Expect(err).To(MatchError(tc.expectedError)) @@ -232,7 +231,7 @@ func TestAzureMachinePoolServiceDelete(t *testing.T) { skuCache: resourceskus.NewStaticCache([]armcompute.ResourceSKU{}, ""), } - err := s.Delete(context.TODO()) + err := s.Delete(t.Context()) if tc.expectedError != "" { g.Expect(err).To(HaveOccurred()) g.Expect(err).To(MatchError(tc.expectedError)) diff --git a/exp/controllers/azuremachinepoolmachine_controller_test.go b/exp/controllers/azuremachinepoolmachine_controller_test.go index c72b3a02e2a..b8db38e83d1 100644 --- a/exp/controllers/azuremachinepoolmachine_controller_test.go +++ b/exp/controllers/azuremachinepoolmachine_controller_test.go @@ -17,7 +17,6 @@ limitations under the License. package controllers import ( - "context" "testing" "time" @@ -103,7 +102,7 @@ func TestAzureMachinePoolMachineReconciler_Reconcile(t *testing.T) { g.Expect(err).NotTo(HaveOccurred()) machine := &clusterv1.Machine{} - err = c.Get(context.Background(), types.NamespacedName{ + err = c.Get(t.Context(), types.NamespacedName{ Name: "ma1", Namespace: "default", }, machine) @@ -121,7 +120,7 @@ func TestAzureMachinePoolMachineReconciler_Reconcile(t *testing.T) { g.Expect(err).NotTo(HaveOccurred()) ampm := &infrav1exp.AzureMachinePoolMachine{} - err = c.Get(context.Background(), types.NamespacedName{ + err = c.Get(t.Context(), types.NamespacedName{ Name: "ampm1", Namespace: "default", }, ampm) @@ -161,7 +160,7 @@ func TestAzureMachinePoolMachineReconciler_Reconcile(t *testing.T) { controller.reconcilerFactory = func(_ *scope.MachinePoolMachineScope) (azure.Reconciler, error) { return reconciler, nil } - res, err := controller.Reconcile(context.TODO(), ctrl.Request{ + res, err := controller.Reconcile(t.Context(), ctrl.Request{ NamespacedName: types.NamespacedName{ Name: "ampm1", Namespace: "default", diff --git a/exp/controllers/helpers_test.go b/exp/controllers/helpers_test.go index c60d9864d28..37dc1fa0e03 100644 --- a/exp/controllers/helpers_test.go +++ b/exp/controllers/helpers_test.go @@ -157,10 +157,10 @@ func TestAzureClusterToAzureMachinePoolsMapper(t *testing.T) { sink.EXPECT().Enabled(4).Return(true) sink.EXPECT().WithValues("AzureCluster", "my-cluster", "Namespace", "default").Return(sink) sink.EXPECT().Info(4, "gk does not match", "gk", gomock.Any(), "infraGK", gomock.Any()) - mapper, err := AzureClusterToAzureMachinePoolsMapper(context.Background(), fakeClient, scheme, logr.New(sink)) + mapper, err := AzureClusterToAzureMachinePoolsMapper(t.Context(), fakeClient, scheme, logr.New(sink)) g.Expect(err).NotTo(HaveOccurred()) - requests := mapper(context.Background(), &infrav1.AzureCluster{ + requests := mapper(t.Context(), &infrav1.AzureCluster{ ObjectMeta: metav1.ObjectMeta{ Name: clusterName, Namespace: "default", @@ -244,7 +244,7 @@ func Test_MachinePoolToInfrastructureMapFunc(t *testing.T) { c.Setup(sink) } f := MachinePoolToInfrastructureMapFunc(infrav1exp.GroupVersion.WithKind(infrav1.AzureMachinePoolKind), logr.New(sink)) - reqs := f(context.TODO(), c.MapObjectFactory(g)) + reqs := f(t.Context(), c.MapObjectFactory(g)) c.Expect(g, reqs) }) } @@ -388,8 +388,8 @@ func Test_azureClusterToAzureMachinePoolsFunc(t *testing.T) { sink, mockctrl, fakeClient := c.Setup(t, g) defer mockctrl.Finish() - f := AzureClusterToAzureMachinePoolsFunc(context.Background(), fakeClient, logr.New(sink)) - reqs := f(context.TODO(), c.MapObjectFactory(g)) + f := AzureClusterToAzureMachinePoolsFunc(t.Context(), fakeClient, logr.New(sink)) + reqs := f(t.Context(), c.MapObjectFactory(g)) c.Expect(g, reqs) }) } diff --git a/go.mod b/go.mod index fd12c4103f9..71e0388bcf6 100644 --- a/go.mod +++ b/go.mod @@ -1,8 +1,8 @@ module sigs.k8s.io/cluster-api-provider-azure -go 1.23.2 +go 1.24.0 -toolchain go1.23.8 +toolchain go1.24.4 require ( github.com/Azure/azure-sdk-for-go/sdk/azcore v1.18.0 diff --git a/hack/tools/go.mod b/hack/tools/go.mod index ea4e8f26f9b..0c2a365c74a 100644 --- a/hack/tools/go.mod +++ b/hack/tools/go.mod @@ -1,8 +1,8 @@ module sigs.k8s.io/cluster-api-provider-azure/hack/tools -go 1.23.0 +go 1.24.0 -toolchain go1.23.8 +toolchain go1.24.4 require sigs.k8s.io/cluster-api/hack/tools v0.0.0-20250520093716-525566440a77 diff --git a/pkg/coalescing/reconciler_test.go b/pkg/coalescing/reconciler_test.go index 1a443ccc3de..ba97c0419f9 100644 --- a/pkg/coalescing/reconciler_test.go +++ b/pkg/coalescing/reconciler_test.go @@ -17,7 +17,6 @@ limitations under the License. package coalescing import ( - "context" "testing" "time" @@ -93,7 +92,7 @@ func TestCoalescingReconciler_Reconcile(t *testing.T) { cacherMock := mock_coalescing.NewMockReconcileCacher(mockCtrl) reconcilerMock := mock_coalescing.NewMockReconciler[reconcile.Request](mockCtrl) subject := c.Reconciler(g, cacherMock, reconcilerMock) - result, err := subject.Reconcile(context.Background(), c.Request) + result, err := subject.Reconcile(t.Context(), c.Request) if c.Error != "" || err != nil { g.Expect(err).To(And(HaveOccurred(), MatchError(c.Error))) return diff --git a/pkg/mutators/azureasomanagedcontrolplane_test.go b/pkg/mutators/azureasomanagedcontrolplane_test.go index e3173044a69..77bf63e2552 100644 --- a/pkg/mutators/azureasomanagedcontrolplane_test.go +++ b/pkg/mutators/azureasomanagedcontrolplane_test.go @@ -17,7 +17,6 @@ limitations under the License. package mutators import ( - "context" "encoding/json" "testing" @@ -40,7 +39,7 @@ import ( ) func TestSetManagedClusterDefaults(t *testing.T) { - ctx := context.Background() + ctx := t.Context() g := NewGomegaWithT(t) tests := []struct { @@ -136,7 +135,7 @@ func TestSetManagedClusterDefaults(t *testing.T) { } func TestSetManagedClusterKubernetesVersion(t *testing.T) { - ctx := context.Background() + ctx := t.Context() tests := []struct { name string @@ -244,7 +243,7 @@ func TestSetManagedClusterKubernetesVersion(t *testing.T) { } func TestSetManagedClusterServiceCIDR(t *testing.T) { - ctx := context.Background() + ctx := t.Context() tests := []struct { name string @@ -374,7 +373,7 @@ func TestSetManagedClusterServiceCIDR(t *testing.T) { } func TestSetManagedClusterPodCIDR(t *testing.T) { - ctx := context.Background() + ctx := t.Context() tests := []struct { name string @@ -505,7 +504,7 @@ func TestSetManagedClusterPodCIDR(t *testing.T) { func TestSetManagedClusterAgentPoolProfiles(t *testing.T) { g := NewGomegaWithT(t) - ctx := context.Background() + ctx := t.Context() s := runtime.NewScheme() g.Expect(asocontainerservicev1.AddToScheme(s)).To(Succeed()) g.Expect(infrav1.AddToScheme(s)).To(Succeed()) diff --git a/pkg/mutators/azureasomanagedmachinepool_test.go b/pkg/mutators/azureasomanagedmachinepool_test.go index aa130af76be..96a4e3c874c 100644 --- a/pkg/mutators/azureasomanagedmachinepool_test.go +++ b/pkg/mutators/azureasomanagedmachinepool_test.go @@ -17,7 +17,6 @@ limitations under the License. package mutators import ( - "context" "errors" "testing" @@ -37,7 +36,7 @@ import ( ) func TestSetAgentPoolDefaults(t *testing.T) { - ctx := context.Background() + ctx := t.Context() g := NewGomegaWithT(t) tests := []struct { @@ -109,7 +108,7 @@ func TestSetAgentPoolDefaults(t *testing.T) { } func TestSetAgentPoolOrchestratorVersion(t *testing.T) { - ctx := context.Background() + ctx := t.Context() tests := []struct { name string @@ -351,7 +350,7 @@ func TestReconcileAutoscaling(t *testing.T) { } func TestSetAgentPoolCount(t *testing.T) { - ctx := context.Background() + ctx := t.Context() tests := []struct { name string diff --git a/pkg/mutators/mutator_test.go b/pkg/mutators/mutator_test.go index 5cdf9ea48de..7cc2546590e 100644 --- a/pkg/mutators/mutator_test.go +++ b/pkg/mutators/mutator_test.go @@ -30,7 +30,7 @@ import ( ) func TestApplyMutators(t *testing.T) { - ctx := context.Background() + ctx := t.Context() tests := []struct { name string @@ -120,7 +120,7 @@ func TestApplyMutators(t *testing.T) { } func TestPause(t *testing.T) { - ctx := context.Background() + ctx := t.Context() tests := []struct { name string From 0ba7a690cbedfa14f51ceb5f156c301c82a58328 Mon Sep 17 00:00:00 2001 From: Matt Boersma Date: Fri, 30 May 2025 13:13:17 -0600 Subject: [PATCH 2/2] Bump CAPI to v1.11.0-alpha.1 --- Makefile | 2 +- Tiltfile | 2 +- .../getting-started-with-capi-operator.md | 2 +- go.mod | 4 ++-- test/e2e/config/azure-dev.yaml | 20 +++++++++---------- test/e2e/data/shared/v1beta1/metadata.yaml | 3 +++ 6 files changed, 18 insertions(+), 15 deletions(-) diff --git a/Makefile b/Makefile index 18ece275997..1688c908cc7 100644 --- a/Makefile +++ b/Makefile @@ -333,7 +333,7 @@ create-management-cluster: $(KUSTOMIZE) $(ENVSUBST) $(KUBECTL) $(KIND) ## Create ./hack/create-custom-cloud-provider-config.sh # Deploy CAPI - timeout --foreground 300 bash -c "until curl --retry $(CURL_RETRIES) -sSL https://github.com/kubernetes-sigs/cluster-api/releases/download/v1.10.2/cluster-api-components.yaml | $(ENVSUBST) | $(KUBECTL) apply -f -; do sleep 5; done" + timeout --foreground 300 bash -c "until curl --retry $(CURL_RETRIES) -sSL https://github.com/kubernetes-sigs/cluster-api/releases/download/v1.11.0-alpha.1/cluster-api-components.yaml | $(ENVSUBST) | $(KUBECTL) apply -f -; do sleep 5; done" # Deploy CAAPH timeout --foreground 300 bash -c "until curl --retry $(CURL_RETRIES) -sSL https://github.com/kubernetes-sigs/cluster-api-addon-provider-helm/releases/download/v0.2.5/addon-components.yaml | $(ENVSUBST) | $(KUBECTL) apply -f -; do sleep 5; done" diff --git a/Tiltfile b/Tiltfile index 6b8641ea1a5..ee5e7ef45b9 100644 --- a/Tiltfile +++ b/Tiltfile @@ -22,7 +22,7 @@ settings = { "deploy_cert_manager": True, "preload_images_for_kind": True, "kind_cluster_name": "capz", - "capi_version": "v1.10.2", + "capi_version": "v1.11.0-alpha.1", "caaph_version": "v0.2.5", "cert_manager_version": "v1.17.2", "kubernetes_version": "v1.32.2", diff --git a/docs/book/src/developers/getting-started-with-capi-operator.md b/docs/book/src/developers/getting-started-with-capi-operator.md index fb367666cc8..2e14077a594 100644 --- a/docs/book/src/developers/getting-started-with-capi-operator.md +++ b/docs/book/src/developers/getting-started-with-capi-operator.md @@ -120,7 +120,7 @@ helm install cert-manager jetstack/cert-manager --namespace cert-manager --creat Create a `values.yaml` file for the CAPI Operator Helm chart like so: ```yaml -core: "cluster-api:v1.10.2" +core: "cluster-api:v1.11.0-alpha.1" infrastructure: "azure:v1.17.2" addon: "helm:v0.2.5" manager: diff --git a/go.mod b/go.mod index 71e0388bcf6..76003e38639 100644 --- a/go.mod +++ b/go.mod @@ -58,8 +58,8 @@ require ( k8s.io/kubectl v0.32.3 k8s.io/utils v0.0.0-20250321185631-1f6e0b77f77e sigs.k8s.io/cloud-provider-azure v1.32.3 - sigs.k8s.io/cluster-api v1.10.2 - sigs.k8s.io/cluster-api/test v1.10.2 + sigs.k8s.io/cluster-api v1.11.0-alpha.1 + sigs.k8s.io/cluster-api/test v1.11.0-alpha.1 sigs.k8s.io/controller-runtime v0.20.4 sigs.k8s.io/kind v0.29.0 ) diff --git a/test/e2e/config/azure-dev.yaml b/test/e2e/config/azure-dev.yaml index cf18a1107d8..c6e21b9069c 100644 --- a/test/e2e/config/azure-dev.yaml +++ b/test/e2e/config/azure-dev.yaml @@ -3,11 +3,11 @@ managementClusterName: capz-e2e images: - name: ${MANAGER_IMAGE} loadBehavior: mustLoad - - name: registry.k8s.io/cluster-api/cluster-api-controller:v1.10.2 + - name: registry.k8s.io/cluster-api/cluster-api-controller:v1.11.0-alpha.1 loadBehavior: tryLoad - - name: registry.k8s.io/cluster-api/kubeadm-bootstrap-controller:v1.10.2 + - name: registry.k8s.io/cluster-api/kubeadm-bootstrap-controller:v1.11.0-alpha.1 loadBehavior: tryLoad - - name: registry.k8s.io/cluster-api/kubeadm-control-plane-controller:v1.10.2 + - name: registry.k8s.io/cluster-api/kubeadm-control-plane-controller:v1.11.0-alpha.1 loadBehavior: tryLoad - name: registry.k8s.io/cluster-api-helm/cluster-api-helm-controller:v0.2.5 loadBehavior: tryLoad @@ -25,8 +25,8 @@ providers: new: --metrics-addr=:8080 files: - sourcePath: "../data/shared/v1beta1/metadata.yaml" - - name: v1.10.2 - value: https://github.com/kubernetes-sigs/cluster-api/releases/download/v1.10.2/core-components.yaml + - name: v1.11.0-alpha.1 + value: https://github.com/kubernetes-sigs/cluster-api/releases/download/v1.11.0-alpha.1/core-components.yaml type: url contract: v1beta1 files: @@ -48,8 +48,8 @@ providers: new: --metrics-addr=:8080 files: - sourcePath: "../data/shared/v1beta1/metadata.yaml" - - name: v1.10.2 - value: https://github.com/kubernetes-sigs/cluster-api/releases/download/v1.10.2/bootstrap-components.yaml + - name: v1.11.0-alpha.1 + value: https://github.com/kubernetes-sigs/cluster-api/releases/download/v1.11.0-alpha.1/bootstrap-components.yaml type: url contract: v1beta1 files: @@ -70,8 +70,8 @@ providers: new: --metrics-addr=:8080 files: - sourcePath: "../data/shared/v1beta1/metadata.yaml" - - name: v1.10.2 - value: https://github.com/kubernetes-sigs/cluster-api/releases/download/v1.10.2/control-plane-components.yaml + - name: v1.11.0-alpha.1 + value: https://github.com/kubernetes-sigs/cluster-api/releases/download/v1.11.0-alpha.1/control-plane-components.yaml type: url contract: v1beta1 files: @@ -243,7 +243,7 @@ variables: WINDOWS_CONTAINERD_URL: "${WINDOWS_CONTAINERD_URL:-}" AZURE_CNI_V1_MANIFEST_PATH: "${PWD}/templates/addons/azure-cni-v1.yaml" OLD_CAPI_UPGRADE_VERSION: "v1.9.7" - LATEST_CAPI_UPGRADE_VERSION: "v1.10.2" + LATEST_CAPI_UPGRADE_VERSION: "v1.11.0-alpha.1" OLD_PROVIDER_UPGRADE_VERSION: "v1.19.4" LATEST_PROVIDER_UPGRADE_VERSION: "v1.20.0" OLD_CAAPH_UPGRADE_VERSION: "v0.1.0-alpha.10" diff --git a/test/e2e/data/shared/v1beta1/metadata.yaml b/test/e2e/data/shared/v1beta1/metadata.yaml index c95dcf9bd96..b171bcf25b8 100644 --- a/test/e2e/data/shared/v1beta1/metadata.yaml +++ b/test/e2e/data/shared/v1beta1/metadata.yaml @@ -1,6 +1,9 @@ apiVersion: clusterctl.cluster.x-k8s.io/v1alpha3 kind: Metadata releaseSeries: + - major: 1 + minor: 11 + contract: v1beta1 - major: 1 minor: 10 contract: v1beta1