From 97b2c128ff3966fbedf34dbae710309270214bc0 Mon Sep 17 00:00:00 2001 From: Nawaz Hussain Khazielakha Date: Thu, 3 Oct 2024 11:47:15 -0700 Subject: [PATCH] this commit scaffolds golangci-lint for capz Adds - pr-golangci-lint job - exports GO_VERSION in the makefile that is used in other make targets - updates .golangci.yml with CAPI changes, and also rebases CAPZ additions to it. - update .golangci.yml - ignore package comments across CAPZ --- .github/workflows/pr-golangci-lint.yaml | 49 +++ .golangci.yml | 305 +++++++++++++----- Makefile | 28 +- .../azureasomanagedcluster_webhook.go | 9 +- .../azureasomanagedcontrolplane_webhook.go | 9 +- .../azureasomanagedmachinepool_webhook.go | 9 +- api/v1beta1/azurecluster_validation.go | 5 +- api/v1beta1/azurecluster_validation_test.go | 5 - api/v1beta1/azurecluster_webhook.go | 3 +- api/v1beta1/azurecluster_webhook_test.go | 1 - api/v1beta1/azureclusteridentity_webhook.go | 3 +- api/v1beta1/azuremachine_default.go | 3 +- api/v1beta1/azuremachine_validation.go | 3 +- api/v1beta1/azuremachine_webhook.go | 11 +- api/v1beta1/azuremachinetemplate_webhook.go | 6 +- .../azuremachinetemplate_webhook_test.go | 3 - api/v1beta1/azuremanagedcluster_webhook.go | 5 +- .../azuremanagedcluster_webhook_test.go | 3 +- .../azuremanagedclustertemplate_webhook.go | 3 +- .../azuremanagedcontrolplane_default.go | 3 +- .../azuremanagedcontrolplane_webhook.go | 15 +- .../azuremanagedcontrolplane_webhook_test.go | 7 +- ...zuremanagedcontrolplanetemplate_webhook.go | 15 +- .../azuremanagedmachinepool_webhook.go | 15 +- .../azuremanagedmachinepool_webhook_test.go | 4 +- ...azuremanagedmachinepooltemplate_webhook.go | 13 +- ...managedmachinepooltemplate_webhook_test.go | 1 + api/v1beta1/tags_test.go | 1 - azure/converters/diagnostics.go | 1 + azure/converters/diagnostics_test.go | 2 +- azure/converters/dns_test.go | 1 - azure/converters/extendedlocation.go | 1 + azure/converters/extendedlocation_test.go | 1 + azure/converters/futures.go | 1 + azure/converters/futures_test.go | 3 +- azure/converters/identity.go | 1 + azure/converters/identity_test.go | 4 +- azure/converters/image.go | 1 + azure/converters/image_test.go | 4 +- azure/converters/loadbalancers.go | 1 + azure/converters/loadbalancers_test.go | 2 +- azure/converters/managedagentpool_test.go | 1 - azure/converters/publicips.go | 1 + azure/converters/publicips_test.go | 1 + azure/converters/resourcehealth.go | 5 +- azure/converters/resourcehealth_test.go | 1 - azure/converters/rules.go | 1 + azure/converters/spotinstances.go | 3 +- azure/converters/spotinstances_test.go | 2 +- azure/converters/subnets_test.go | 1 - azure/converters/tags.go | 1 + azure/converters/tags_test.go | 5 +- azure/converters/vm.go | 1 + azure/converters/vm_test.go | 2 +- azure/converters/vmss.go | 1 + azure/converters/vmss_test.go | 5 +- azure/defaults.go | 1 + azure/defaults_test.go | 3 +- azure/errors.go | 1 + azure/errors_test.go | 1 - azure/interfaces.go | 3 +- azure/regional_baseuri_test.go | 2 +- azure/scope/clients.go | 1 + azure/scope/cluster.go | 11 +- azure/scope/cluster_test.go | 17 +- azure/scope/identity.go | 3 +- azure/scope/identity_test.go | 4 +- azure/scope/machine.go | 13 +- azure/scope/machine_test.go | 5 +- azure/scope/machinepool.go | 28 +- azure/scope/machinepool_test.go | 10 +- azure/scope/machinepoolmachine.go | 17 +- azure/scope/machinepoolmachine_test.go | 10 +- azure/scope/managedcontrolplane.go | 15 +- azure/scope/managedcontrolplane_test.go | 15 +- azure/scope/managedmachinepool.go | 11 +- azure/scope/managedmachinepool_test.go | 14 +- .../machinepool_deployment_strategy.go | 7 +- .../machinepool_deployment_strategy_test.go | 3 +- azure/services/agentpools/agentpools.go | 7 +- azure/services/agentpools/agentpools_test.go | 3 +- azure/services/agentpools/spec.go | 5 +- azure/services/agentpools/spec_test.go | 1 + azure/services/aksextensions/aksextensions.go | 3 +- azure/services/aksextensions/spec.go | 5 +- azure/services/aksextensions/spec_test.go | 2 +- azure/services/aso/aso.go | 11 +- azure/services/aso/aso_test.go | 9 +- azure/services/aso/interfaces.go | 3 +- azure/services/aso/service.go | 5 +- azure/services/aso/service_test.go | 7 +- azure/services/aso/tags.go | 1 + azure/services/aso/tags_test.go | 1 + azure/services/async/async.go | 1 + azure/services/async/async_test.go | 3 +- azure/services/async/interfaces.go | 1 + .../availabilitysets/availabilitysets.go | 3 +- .../availabilitysets/availabilitysets_test.go | 3 +- azure/services/availabilitysets/client.go | 5 +- azure/services/availabilitysets/spec.go | 3 +- azure/services/availabilitysets/spec_test.go | 2 +- azure/services/bastionhosts/bastionhosts.go | 3 +- azure/services/bastionhosts/spec.go | 5 +- azure/services/bastionhosts/spec_test.go | 2 +- azure/services/disks/client.go | 1 + azure/services/disks/disks.go | 3 +- azure/services/disks/disks_test.go | 2 +- azure/services/disks/spec.go | 2 +- azure/services/fleetsmembers/fleetsmembers.go | 3 +- azure/services/fleetsmembers/spec.go | 5 +- azure/services/fleetsmembers/spec_test.go | 2 +- azure/services/groups/groups.go | 3 +- azure/services/groups/groups_test.go | 5 +- azure/services/groups/spec.go | 3 +- azure/services/groups/spec_test.go | 1 + azure/services/identities/client.go | 1 + azure/services/inboundnatrules/client.go | 1 + .../inboundnatrules/inboundnatrules.go | 3 +- .../inboundnatrules/inboundnatrules_test.go | 3 +- azure/services/inboundnatrules/spec.go | 2 +- azure/services/inboundnatrules/spec_test.go | 2 - azure/services/loadbalancers/client.go | 1 + azure/services/loadbalancers/loadbalancers.go | 3 +- .../loadbalancers/loadbalancers_test.go | 3 +- azure/services/loadbalancers/spec.go | 3 +- azure/services/loadbalancers/spec_test.go | 2 +- .../managedclusters/managedclusters.go | 7 +- .../managedclusters/managedclusters_test.go | 5 +- azure/services/managedclusters/spec.go | 7 +- azure/services/managedclusters/spec_test.go | 3 +- azure/services/natgateways/natgateways.go | 3 +- .../services/natgateways/natgateways_test.go | 1 + azure/services/natgateways/spec.go | 5 +- azure/services/natgateways/spec_test.go | 2 +- azure/services/networkinterfaces/client.go | 3 +- .../networkinterfaces/networkinterfaces.go | 3 +- .../networkinterfaces_test.go | 3 +- azure/services/networkinterfaces/spec.go | 3 +- azure/services/networkinterfaces/spec_test.go | 2 +- azure/services/privatedns/link_client.go | 1 + azure/services/privatedns/link_reconciler.go | 1 + azure/services/privatedns/link_spec.go | 3 +- azure/services/privatedns/link_spec_test.go | 2 +- azure/services/privatedns/privatedns.go | 1 + azure/services/privatedns/privatedns_test.go | 3 +- azure/services/privatedns/record_client.go | 7 +- azure/services/privatedns/record_spec.go | 3 +- azure/services/privatedns/record_spec_test.go | 2 +- azure/services/privatedns/zone_client.go | 1 + azure/services/privatedns/zone_reconciler.go | 1 + azure/services/privatedns/zone_spec.go | 3 +- azure/services/privatedns/zone_spec_test.go | 2 +- .../privateendpoints/privateendpoints.go | 1 + azure/services/privateendpoints/spec.go | 5 +- azure/services/privateendpoints/spec_test.go | 2 +- azure/services/publicips/client.go | 1 + azure/services/publicips/publicips.go | 3 +- azure/services/publicips/publicips_test.go | 5 +- azure/services/publicips/spec.go | 3 +- azure/services/publicips/spec_test.go | 2 +- azure/services/resourcehealth/client.go | 1 + .../services/resourcehealth/resourcehealth.go | 7 +- .../resourcehealth/resourcehealth_test.go | 3 +- azure/services/resourceskus/cache.go | 1 + azure/services/resourceskus/cache_test.go | 7 +- azure/services/resourceskus/client.go | 1 + azure/services/roleassignments/client.go | 3 +- .../roleassignments/roleassignments.go | 3 +- .../roleassignments/roleassignments_test.go | 3 +- azure/services/roleassignments/spec.go | 2 +- azure/services/roleassignments/spec_test.go | 1 - azure/services/routetables/client.go | 1 + azure/services/routetables/routetables.go | 1 + .../services/routetables/routetables_test.go | 3 +- azure/services/routetables/spec.go | 3 +- azure/services/routetables/spec_test.go | 1 - azure/services/scalesets/client.go | 1 + azure/services/scalesets/scalesets.go | 3 +- azure/services/scalesets/scalesets_test.go | 5 +- azure/services/scalesets/spec.go | 4 +- azure/services/scalesets/spec_test.go | 2 +- .../services/scalesets/vmssextension_spec.go | 3 +- .../scalesets/vmssextension_spec_test.go | 2 +- azure/services/scalesetvms/client.go | 3 +- azure/services/scalesetvms/scalesetvms.go | 1 + .../services/scalesetvms/scalesetvms_test.go | 3 +- azure/services/scalesetvms/spec.go | 4 +- azure/services/securitygroups/client.go | 1 + .../services/securitygroups/securitygroups.go | 1 + .../securitygroups/securitygroups_test.go | 3 +- azure/services/securitygroups/spec.go | 3 +- azure/services/securitygroups/spec_test.go | 3 +- azure/services/subnets/spec.go | 8 +- azure/services/subnets/spec_test.go | 1 + azure/services/subnets/subnets.go | 3 +- azure/services/subnets/subnets_test.go | 1 + azure/services/tags/client.go | 1 + azure/services/tags/tags.go | 3 +- azure/services/tags/tags_test.go | 3 +- azure/services/virtualmachineimages/cache.go | 1 + .../virtualmachineimages/cache_test.go | 2 +- azure/services/virtualmachineimages/client.go | 1 + azure/services/virtualmachineimages/images.go | 1 + .../virtualmachineimages/images_test.go | 3 +- azure/services/virtualmachines/client.go | 1 + azure/services/virtualmachines/spec.go | 3 +- azure/services/virtualmachines/spec_test.go | 2 +- .../virtualmachines/virtualmachines.go | 5 +- .../virtualmachines/virtualmachines_test.go | 6 +- azure/services/virtualnetworks/spec.go | 3 +- azure/services/virtualnetworks/spec_test.go | 1 + .../virtualnetworks/virtualnetworks.go | 3 +- .../virtualnetworks/virtualnetworks_test.go | 5 +- azure/services/vmextensions/client.go | 1 + azure/services/vmextensions/spec.go | 3 +- azure/services/vmextensions/spec_test.go | 2 +- azure/services/vmextensions/vmextensions.go | 3 +- .../vmextensions/vmextensions_test.go | 2 +- azure/services/vnetpeerings/client.go | 1 + azure/services/vnetpeerings/spec.go | 3 +- azure/services/vnetpeerings/spec_test.go | 2 +- azure/services/vnetpeerings/vnetpeerings.go | 3 +- .../vnetpeerings/vnetpeerings_test.go | 3 +- azure/types.go | 1 + azure/types_test.go | 2 +- controllers/agentpooladopt_controller.go | 7 +- controllers/asosecret_controller.go | 17 +- controllers/asosecret_controller_test.go | 11 +- .../azureasomanagedcluster_controller.go | 9 +- .../azureasomanagedcluster_controller_test.go | 3 +- .../azureasomanagedcontrolplane_controller.go | 9 +- ...easomanagedcontrolplane_controller_test.go | 3 +- .../azureasomanagedmachinepool_controller.go | 9 +- ...reasomanagedmachinepool_controller_test.go | 3 +- controllers/azurecluster_controller.go | 14 +- controllers/azurecluster_controller_test.go | 13 +- controllers/azurecluster_reconciler.go | 3 +- controllers/azurecluster_reconciler_test.go | 10 +- controllers/azurejson_machine_controller.go | 13 +- .../azurejson_machine_controller_test.go | 7 +- .../azurejson_machinepool_controller.go | 13 +- .../azurejson_machinepool_controller_test.go | 9 +- .../azurejson_machinetemplate_controller.go | 13 +- ...urejson_machinetemplate_controller_test.go | 3 +- controllers/azuremachine_controller.go | 14 +- controllers/azuremachine_controller_test.go | 11 +- controllers/azuremachine_reconciler.go | 1 + controllers/azuremachine_reconciler_test.go | 6 +- controllers/azuremanagedcluster_controller.go | 9 +- .../azuremanagedcluster_controller_test.go | 5 +- .../azuremanagedcontrolplane_controller.go | 14 +- ...zuremanagedcontrolplane_controller_test.go | 11 +- .../azuremanagedcontrolplane_reconciler.go | 9 +- ...zuremanagedcontrolplane_reconciler_test.go | 2 +- .../azuremanagedmachinepool_controller.go | 14 +- ...azuremanagedmachinepool_controller_test.go | 10 +- .../azuremanagedmachinepool_reconciler.go | 2 +- ...azuremanagedmachinepool_reconciler_test.go | 3 +- controllers/helpers.go | 39 +-- controllers/helpers_test.go | 21 +- controllers/managedclusteradopt_controller.go | 7 +- controllers/resource_reconciler.go | 12 +- controllers/resource_reconciler_test.go | 3 +- controllers/suite_test.go | 3 +- exp/api/v1beta1/azuremachinepool_default.go | 3 +- .../v1beta1/azuremachinepool_default_test.go | 3 +- exp/api/v1beta1/azuremachinepool_test.go | 2 +- exp/api/v1beta1/azuremachinepool_types.go | 3 +- exp/api/v1beta1/azuremachinepool_webhook.go | 17 +- .../v1beta1/azuremachinepool_webhook_test.go | 11 +- .../v1beta1/azuremachinepoolmachine_types.go | 3 +- .../azuremachinepoolmachine_webhook.go | 3 +- .../azuremachinepool_controller.go | 19 +- .../azuremachinepool_controller_test.go | 9 +- .../azuremachinepool_controller_unit_test.go | 5 +- .../azuremachinepool_reconciler.go | 1 + .../azuremachinepool_reconciler_test.go | 8 +- .../azuremachinepoolmachine_controller.go | 19 +- ...azuremachinepoolmachine_controller_test.go | 12 +- exp/controllers/helpers.go | 35 +- exp/controllers/helpers_test.go | 11 +- exp/controllers/suite_test.go | 5 +- internal/test/env/env.go | 9 +- internal/test/matchers/gomega/matchers.go | 1 + .../test/matchers/gomega/matchers_test.go | 2 +- internal/test/record/logger.go | 6 +- main.go | 21 +- pkg/coalescing/reconciler.go | 3 +- pkg/coalescing/reconciler_test.go | 4 +- pkg/mutators/azureasomanagedcontrolplane.go | 9 +- .../azureasomanagedcontrolplane_test.go | 3 +- pkg/mutators/azureasomanagedmachinepool.go | 7 +- .../azureasomanagedmachinepool_test.go | 3 +- pkg/mutators/mutator.go | 3 +- pkg/ot/traces.go | 1 + test/e2e/aks.go | 5 +- test/e2e/aks_adopt.go | 3 +- test/e2e/aks_autoscaler.go | 3 +- test/e2e/aks_azure_cluster_autoscaler.go | 3 +- test/e2e/aks_byo_node.go | 5 +- test/e2e/aks_clusterclass.go | 3 +- test/e2e/aks_fleets_member.go | 5 +- test/e2e/aks_machinepools.go | 7 +- test/e2e/aks_marketplace.go | 5 +- test/e2e/aks_node_labels.go | 3 +- test/e2e/aks_node_taints.go | 3 +- test/e2e/aks_patches.go | 3 +- test/e2e/aks_public_ip_prefix.go | 7 +- test/e2e/aks_spot.go | 3 +- test/e2e/aks_tags.go | 5 +- test/e2e/aks_upgrade.go | 3 +- test/e2e/aks_versions.go | 2 +- test/e2e/azure_clusterproxy.go | 7 +- test/e2e/azure_csidriver.go | 5 +- test/e2e/azure_edgezone.go | 5 +- test/e2e/azure_lb.go | 5 +- test/e2e/azure_logcollector.go | 15 +- test/e2e/azure_machinepools.go | 7 +- test/e2e/azure_net_pol.go | 3 +- test/e2e/azure_privatecluster.go | 6 +- test/e2e/azure_securitygroups.go | 3 +- test/e2e/azure_selfhosted.go | 3 +- test/e2e/azure_vmextensions.go | 7 +- test/e2e/cni.go | 2 +- test/e2e/common.go | 7 +- test/e2e/conformance_test.go | 3 +- test/e2e/helm.go | 6 +- test/e2e/helpers.go | 15 +- .../kubernetes/networkpolicy/networkpolicy.go | 3 +- test/e2e/kubernetes/node/node.go | 1 + test/e2e/kubernetes/windows/windows.go | 2 +- test/logger.go | 5 +- util/cache/ttllru/ttllru_test.go | 2 +- util/futures/getter.go | 3 +- util/futures/getter_test.go | 1 + util/futures/setter_test.go | 1 + util/reconciler/defaults_test.go | 5 +- util/system/namespace_test.go | 3 +- util/tele/span_logger.go | 6 +- 339 files changed, 1177 insertions(+), 827 deletions(-) create mode 100644 .github/workflows/pr-golangci-lint.yaml diff --git a/.github/workflows/pr-golangci-lint.yaml b/.github/workflows/pr-golangci-lint.yaml new file mode 100644 index 00000000000..0be8b03a914 --- /dev/null +++ b/.github/workflows/pr-golangci-lint.yaml @@ -0,0 +1,49 @@ +name: PR golangci-lint + +on: + pull_request: + types: [opened, edited, synchronize, reopened] + +# Remove all permissions from GITHUB_TOKEN except metadata. +permissions: {} + +jobs: + golangci: + name: lint + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + working-directory: + - "" + - test + steps: + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # tag=v4.1.7 + + - name: Calculate go version + id: vars + run: echo "go_version=$(make go-version)" >> $GITHUB_OUTPUT + + - name: Set up Go + uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # tag=v5.0.2 + with: + go-version: ${{ steps.vars.outputs.go_version }} + + - name: Cache golangci-lint binary + id: golangci-cache + uses: actions/cache@v3 + with: + # Cache location used by golangci-lint-action + path: ~/.cache/golangci-lint + # Change this when updating golangci-lint version + key: golangci-lint-v1.60.2 + restore-keys: | + golangci-lint- + + - name: golangci-lint + uses: golangci/golangci-lint-action@aaa42aa0628b4ae2578232a66b541047968fac86 # tag=v6.1.0 + with: + # update the version when updating golangci-lint + version: v1.60.2 + args: --out-format=colored-line-number + working-directory: ${{matrix.working-directory}} diff --git a/.golangci.yml b/.golangci.yml index cd75acf4d18..0cc015a2203 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,64 +1,98 @@ run: - deadline: 10m - skip-files: - - 'zz_generated\.(\w*)\.go$' + timeout: 10m build-tags: - e2e + allow-parallel-runners: true + linters: disable-all: true enable: - - asasalint - - asciicheck - - bidichk - - bodyclose - - containedctx - - decorder - - dogsled - - dupword - - durationcheck - - errcheck - - errchkjson - - errorlint - - execinquery - - exportloopref - - gci - - ginkgolinter - - goconst - - gocritic - - gocyclo - - godot - - gofmt - - goimports - - goprintffuncname - - gosec - - gosimple - - govet - - importas - - ineffassign - - loggercheck - - misspell - - nakedret - - nilerr - - noctx - - nolintlint - - nosprintfhostport - - predeclared - - reassign - - revive - - rowserrcheck - - staticcheck - - stylecheck - - thelper - - typecheck - - unconvert - - unparam - - unused - - usestdlibvars - - whitespace - # Run with --fast=false for more extensive checks - fast: true + - asasalint # warns about passing []any to func(...any) without expanding it + - asciicheck # non ascii symbols + - bidichk # dangerous unicode sequences + - bodyclose # unclosed http bodies + - containedctx # context.Context nested in a struct + - copyloopvar # copying loop variables + - dogsled # too many blank identifiers in assignments + - dupword # duplicate words + - durationcheck # multiplying two durations + - errcheck # unchecked errors + - errchkjson # invalid types passed to json encoder + - gci # ensures imports are organized + - ginkgolinter # ginkgo and gomega + - goconst # strings that can be replaced by constants + - gocritic # bugs, performance, style (we could add custom ones to this one) + - godot # checks that comments end in a period + - gofmt # warns about incorrect use of fmt functions + - goimports # import formatting + - goprintffuncname # printft-like functions should be named with f at the end + - gosec # potential security problems + - gosimple # simplify code + - govet # basically 'go vet' + - importas # consistent import aliases + - ineffassign # ineffectual assignments + - intrange # suggest using integer range in for loops + - loggercheck # check for even key/value pairs in logger calls + - misspell # spelling + - nakedret # naked returns (named return parameters and an empty return) + - nilerr # returning nil after checking err is not nil + - noctx # http requests without context.Context + - nolintlint # badly formatted nolint directives + - nosprintfhostport # using sprintf to construct host:port in a URL + - prealloc # suggest preallocating slices + - predeclared # shadowing predeclared identifiers + - revive # better version of golint + - staticcheck # some of staticcheck's rules + - stylecheck # another replacement for golint + - tenv # using os.Setenv instead of t.Setenv in tests + - thelper # test helpers not starting with t.Helper() + - unconvert # unnecessary type conversions + - unparam # unused function parameters + - unused # unused constants, variables,functions, types + - usestdlibvars # using variables/constants from the standard library + - whitespace # unnecessary newlines linters-settings: + gosec: + excludes: + - G307 # Deferring unsafe method "Close" on type "\*os.File" + - G108 # Profiling endpoint is automatically exposed on /debug/pprof + - G115 # integer overflow conversion int -> int32 + gci: + sections: + - standard # Standard section: captures all standard packages. + - default # Default section: contains all imports that could not be matched to another section type. + - prefix(sigs.k8s.io/cluster-api-provider-azure) # Custom section: groups all imports with the specified Prefix. + custom-order: true + ginkgolinter: + forbid-focus-container: true + goconst: + ignore-tests: true + godot: + # declarations - for top level declaration comments (default); + # toplevel - for top level comments; + # all - for all comments. + scope: toplevel + exclude: + - '^ \+.*' + - '^ ANCHOR.*' + gocritic: + enabled-tags: + - "experimental" + disabled-checks: + - appendAssign + - dupImport # https://github.com/go-critic/go-critic/issues/845 + - evalOrder + - ifElseChain + - octalLiteral + - regexpSimplify + - sloppyReassign + - truncateCmp + - typeDefFirst + - unnamedResult + - unnecessaryDefer + - whyNoLint + - wrapperFunc importas: no-unaliased: true alias: @@ -102,34 +136,49 @@ linters-settings: # Deprecated - pkg: github.com/Azure/go-autorest/autorest/to alias: deprecated-use-k8s.io-utils-pointer - gocritic: - enabled-tags: - - "experimental" - godot: - # declarations - for top level declaration comments (default); - # toplevel - for top level comments; - # all - for all comments. - scope: toplevel - exclude: - - '^ \+.*' - - '^ ANCHOR.*' - gosec: - excludes: - - G307 # Deferring unsafe method "Close" on type "\*os.File" - - G108 # Profiling endpoint is automatically exposed on /debug/pprof + nolintlint: + allow-unused: false + require-specific: true revive: rules: + # The following rules are recommended https://github.com/mgechev/revive#recommended-configuration + - name: blank-imports + - name: context-as-argument + - name: context-keys-type + - name: dot-imports + - name: error-return + - name: error-strings + - name: error-naming + - name: if-return + - name: increment-decrement + - name: var-naming + - name: var-declaration + - name: package-comments + - name: range + - name: receiver-naming + - name: time-naming + - name: unexported-return + - name: indent-error-flow + - name: errorf + - name: empty-block + - name: superfluous-else + - name: unused-parameter + - name: unreachable-code + - name: redefines-builtin-id + # + # Rules in addition to the recommended configuration above. + # + - name: bool-literal-in-expr + - name: constant-logical-expr - name: exported arguments: - disableStutteringCheck - staticcheck: - go: "1.22" - stylecheck: - go: "1.22" unused: go: "1.22" issues: + exclude-files: + - 'zz_generated\.(\w*)\.go$' exclude-rules: - path: '(\w*)conversion.go' text: "use underscores in Go names|receiver name (.+) should be consistent|methods on the same type should have the same receiver name" @@ -145,8 +194,114 @@ issues: text: exported (.+) should have comment( \(or a comment on this block\))? or be unexported - source: \"github.com/onsi/(ginkgo/v2|gomega)\" text: "should not use dot imports" - include: - - EXC0012 # revive: check for comments - - EXC0014 # revive: check for comments + # Exclude some packages or code to require comments, for example test code, or fake clients. + - linters: + - revive + text: exported (method|function|type|const) (.+) should have comment or be unexported + source: (func|type).*Fake.* + - linters: + - revive + text: exported (method|function|type|const) (.+) should have comment or be unexported + path: fake_\.go + # Dot imports for gomega and ginkgo are allowed + # within test files and test utils. + - linters: + - revive + - stylecheck + path: _test\.go + text: should not use dot imports + - linters: + - revive + # Checking if an error is nil to just after return the error or nil is redundant + text: "if-return: redundant if ...; err != nil check, just return error instead" + # Ignoring stylistic checks for generated code + path: .*(api|types|test)\/.*\/conversion.*\.go$ + - linters: + - revive + # Exported function and methods should have comments. This warns on undocumented exported functions and methods. + text: exported (method|function|type|const) (.+) should have comment or be unexported + # Ignoring stylistic checks for generated code + path: .*(api|types|test)\/.*\/conversion.*\.go$ + - linters: + - revive + # By convention, receiver names in a method should reflect their identity. + text: "receiver-naming: receiver name" + # Ignoring stylistic checks for generated code + path: .*(api|types)\/.*\/conversion.*\.go$ + - linters: + - stylecheck + text: "ST1016: methods on the same type should have the same receiver name" + path: .*(api|types)\/.*\/conversion.*\.go$ + # We don't care about defer in for loops in test files. + - linters: + - gocritic + text: "deferInLoop: Possible resource leak, 'defer' is called in the 'for' loop" + path: _test\.go + # Ignore non-constant format string in call to condition utils + - linters: + - govet + text: "non-constant format string in call to sigs\\.k8s\\.io\\/cluster-api\\/util\\/conditions\\." + # for i = x; i < y; i++ {} is already optimal; Ignore this linter message + - linters: + - intrange + text: "for loop can be changed to use an integer range" + # Ignore the return value of below functions in test files + - linters: + - errcheck + text: Error return value of (`os.Setenv`|`fmt.Fprintf`|`resp.Body.Close`|`os.Unsetenv`|`fmt.Fprintln`|`[\w\.]+\.Close`|`[\w\.]+\.Flush`|`[\w\.]+\.RemoveAll`) is not checked + path: (^test\/e2e\/.*\.go$|.*_test\.go$) + # Do not validate file paths in tests + - linters: + - gosec + text: "G304: Potential file inclusion via variable" + path: ^test\/e2e\/.*\.go$ + # Ignore the elevated access that "others" have for dirs/files created in tests with 0755 permissions + - linters: + - gosec + text: "G301: Expect directory permissions to be 0750 or less" + path: ^test\/e2e\/.*\.go$ + # Ignore the elevated access that "group" and "others" have for dirs/files opened in tests with 0644 permissions + - linters: + - gosec + text: "G302: Expect file permissions to be 0600 or less" + path: ^test\/e2e\/.*\.go$ + # Ignore unhandled errors in test files when using os.Setenv + - linters: + - gosec + text: "G104: Errors unhandled." + path: ^test\/e2e\/.*\.go$ + # Ignore the unhandled errors on using os.Setenv in test files + - linters: + - gosec + text: "G104: Errors unhandled." + path: .*_test\.go$ + # Ignore unused parameters in test files + - linters: + - revive + text: "^unused-parameter: parameter '.*' seems to be unused, consider removing or renaming it as _$" + path: .*(_test|test)\.go$ + # Ignore adding package comments for all files. TODO: Ideally, we should add package comments to all the packages files. + - linters: + - revive + text: "^package-comments: package comment should be of the form \".*\"$" + path: .*\.go$ + # Ignore adding package comments for all files. TODO: Ideally, we should add package comments to all the packages files. + - linters: + - revive + text: "package-comments: should have a package comment" + path: .*\.go$ + # Ignore adding package comments for all files. TODO: Ideally, we should add package comments to all the packages files. + - linters: + - stylecheck + text: "ST1000: at least one file in a package should have a package comment" + path: .*\.go$ + # Ignore adding package comments for all files. TODO: Ideally, we should add package comments to all the packages files. + - linters: + - stylecheck + text: "ST1000: package comment should be of the form \".*\"$" + path: .*\.go$ + # We are disabling default golangci exclusions because we want to help reviewers to focus on reviewing the most relevant + # changes in PRs and avoid nitpicking. + exclude-use-default: false max-issues-per-linter: 0 max-same-issues: 0 diff --git a/Makefile b/Makefile index 13300eb3c62..c24fb6749cd 100644 --- a/Makefile +++ b/Makefile @@ -20,6 +20,7 @@ SHELL:=/usr/bin/env bash .DEFAULT_GOAL:=help +GO_VERSION ?= $(shell sed -n 's/^go //p' go.mod) GOPATH := $(shell go env GOPATH) GOARCH := $(shell go env GOARCH) GOOS := $(shell go env GOOS) @@ -81,7 +82,7 @@ ENVSUBST_VER := $(shell go list -m -f '{{.Version}}' github.com/drone/envsubst/v ENVSUBST_BIN := envsubst ENVSUBST := $(TOOLS_BIN_DIR)/$(ENVSUBST_BIN)-$(ENVSUBST_VER) -GOLANGCI_LINT_VER := v1.55.2 +GOLANGCI_LINT_VER := $(shell cat .github/workflows/pr-golangci-lint.yaml | grep [[:space:]]version: | sed 's/.*version: //') GOLANGCI_LINT_BIN := golangci-lint GOLANGCI_LINT := $(TOOLS_BIN_DIR)/$(GOLANGCI_LINT_BIN)-$(GOLANGCI_LINT_VER) @@ -275,7 +276,7 @@ verify-gen: generate ## Verify generated files are the latest. fi .PHONY: verify-shellcheck -verify-shellcheck: ## Verify shell files are passing lint. +verify-shellcheck: ## Verify shell files are shellcheck. ./hack/verify-shellcheck.sh .PHONY: verify-conversions @@ -395,7 +396,7 @@ acr-login: ## Login to Azure Container Registry. .PHONY: docker-pull-prerequisites docker-pull-prerequisites: ## Pull prerequisites for building controller-manager. docker pull docker/dockerfile:1.4 - docker pull docker.io/library/golang:1.22 + docker pull docker.io/library/golang:$(GO_VERSION) docker pull gcr.io/distroless/static:latest .PHONY: docker-build @@ -564,18 +565,18 @@ help: ## Display this help. .PHONY: lint lint: $(GOLANGCI_LINT) lint-latest ## Lint codebase. - $(GOLANGCI_LINT) run -v --timeout=8m0s --print-resources-usage $(GOLANGCI_LINT_EXTRA_ARGS) + $(GOLANGCI_LINT) run -v --print-resources-usage --go=$(GO_VERSION) $(GOLANGCI_LINT_EXTRA_ARGS) .PHONY: lint-fix lint-fix: $(GOLANGCI_LINT) ## Lint the codebase and run auto-fixers if supported by the linter. GOLANGCI_LINT_EXTRA_ARGS=--fix $(MAKE) lint lint-full: $(GOLANGCI_LINT) ## Run slower linters to detect possible issues. - $(GOLANGCI_LINT) run -v --fast=false + $(GOLANGCI_LINT) run -v --fast=false --go=$(GO_VERSION) -.PHONY: lint-latest +.PHONY: lint-latest ## TODO: update the lint-latest to lint-azure-latest lint-latest: - ./hack/lint-latest.sh + ./hack/lint-latest.sh ## TODO: update the lint-latest.sh to lint-azure-latest.sh ## -------------------------------------- ## Release @@ -649,7 +650,7 @@ release-binary: $(RELEASE_DIR) ## Compile and build release binaries. -e GOARCH=$(GOARCH) \ -v "$$(pwd):/workspace" \ -w /workspace \ - golang:1.22 \ + golang:$(GO_VERSION) \ go build -a -ldflags '$(LDFLAGS) -extldflags "-static"' \ -o $(RELEASE_DIR)/$(notdir $(RELEASE_BINARY))-$(GOOS)-$(GOARCH) $(RELEASE_BINARY) @@ -683,7 +684,7 @@ promote-images: $(KPROMO) ## Promote images. ##@ Testing: .PHONY: test -test: generate lint go-test-race ## Run "generate", "lint" and "go-test-race" rules. +test: generate go-test-race ## Run "generate" and "go-test-race" rules. .PHONY: go-test-race go-test-race: TEST_ARGS+= -race @@ -870,5 +871,14 @@ $(CODESPELL): ## Build codespell from tools folder. rm -r $(TOOLS_BIN_DIR)/$(CODESPELL_DIST_DIR)/bin; \ ) +## -------------------------------------- +## Helpers +## -------------------------------------- + +##@ helpers: + +go-version: ## Print the go version we use to compile our binaries and images + @echo $(GO_VERSION) + include conformance.mk include e2e.mk diff --git a/api/v1alpha1/azureasomanagedcluster_webhook.go b/api/v1alpha1/azureasomanagedcluster_webhook.go index 445151a9679..44b170327f2 100644 --- a/api/v1alpha1/azureasomanagedcluster_webhook.go +++ b/api/v1alpha1/azureasomanagedcluster_webhook.go @@ -23,9 +23,10 @@ import ( apierrors "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/util/validation/field" - "sigs.k8s.io/cluster-api-provider-azure/feature" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/webhook/admission" + + "sigs.k8s.io/cluster-api-provider-azure/feature" ) // SetupAzureASOManagedClusterWebhookWithManager sets up and registers the webhook with the manager. @@ -44,7 +45,7 @@ type azureASOManagedClusterWebhook struct { // +kubebuilder:webhook:verbs=create,path=/validate-infrastructure-cluster-x-k8s-io-v1alpha1-azureasomanagedcluster,mutating=false,failurePolicy=fail,groups=infrastructure.cluster.x-k8s.io,resources=azureasomanagedclusters,versions=v1alpha1,name=validation.azureasomanagedcluster.infrastructure.cluster.x-k8s.io,sideEffects=None,admissionReviewVersions=v1;v1beta1 // ValidateCreate implements webhook.Validator so a webhook will be registered for the type. -func (ampw *azureASOManagedClusterWebhook) ValidateCreate(ctx context.Context, obj runtime.Object) (admission.Warnings, error) { +func (ampw *azureASOManagedClusterWebhook) ValidateCreate(_ context.Context, obj runtime.Object) (admission.Warnings, error) { _, ok := obj.(*AzureASOManagedCluster) if !ok { return nil, apierrors.NewBadRequest("expected an AzureASOManagedCluster") @@ -59,11 +60,11 @@ func (ampw *azureASOManagedClusterWebhook) ValidateCreate(ctx context.Context, o } // ValidateUpdate implements webhook.Validator so a webhook will be registered for the type. -func (ampw *azureASOManagedClusterWebhook) ValidateUpdate(ctx context.Context, oldObj, newObj runtime.Object) (admission.Warnings, error) { +func (ampw *azureASOManagedClusterWebhook) ValidateUpdate(_ context.Context, _, _ runtime.Object) (admission.Warnings, error) { return nil, nil } // ValidateDelete implements webhook.Validator so a webhook will be registered for the type. -func (ampw *azureASOManagedClusterWebhook) ValidateDelete(ctx context.Context, obj runtime.Object) (admission.Warnings, error) { +func (ampw *azureASOManagedClusterWebhook) ValidateDelete(_ context.Context, _ runtime.Object) (admission.Warnings, error) { return nil, nil } diff --git a/api/v1alpha1/azureasomanagedcontrolplane_webhook.go b/api/v1alpha1/azureasomanagedcontrolplane_webhook.go index 1c694579f63..05006549ee9 100644 --- a/api/v1alpha1/azureasomanagedcontrolplane_webhook.go +++ b/api/v1alpha1/azureasomanagedcontrolplane_webhook.go @@ -23,9 +23,10 @@ import ( apierrors "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/util/validation/field" - "sigs.k8s.io/cluster-api-provider-azure/feature" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/webhook/admission" + + "sigs.k8s.io/cluster-api-provider-azure/feature" ) // SetupAzureASOManagedControlPlaneWebhookWithManager sets up and registers the webhook with the manager. @@ -44,7 +45,7 @@ type azureASOManagedControlPlaneWebhook struct { // +kubebuilder:webhook:verbs=create,path=/validate-infrastructure-cluster-x-k8s-io-v1alpha1-azureasomanagedcontrolplane,mutating=false,failurePolicy=fail,groups=infrastructure.cluster.x-k8s.io,resources=azureasomanagedcontrolplanes,versions=v1alpha1,name=validation.azureasomanagedcontrolplane.infrastructure.cluster.x-k8s.io,sideEffects=None,admissionReviewVersions=v1;v1beta1 // ValidateCreate implements webhook.Validator so a webhook will be registered for the type. -func (ampw *azureASOManagedControlPlaneWebhook) ValidateCreate(ctx context.Context, obj runtime.Object) (admission.Warnings, error) { +func (ampw *azureASOManagedControlPlaneWebhook) ValidateCreate(_ context.Context, obj runtime.Object) (admission.Warnings, error) { _, ok := obj.(*AzureASOManagedControlPlane) if !ok { return nil, apierrors.NewBadRequest("expected an AzureASOManagedControlPlane") @@ -59,11 +60,11 @@ func (ampw *azureASOManagedControlPlaneWebhook) ValidateCreate(ctx context.Conte } // ValidateUpdate implements webhook.Validator so a webhook will be registered for the type. -func (ampw *azureASOManagedControlPlaneWebhook) ValidateUpdate(ctx context.Context, oldObj, newObj runtime.Object) (admission.Warnings, error) { +func (ampw *azureASOManagedControlPlaneWebhook) ValidateUpdate(_ context.Context, _, _ runtime.Object) (admission.Warnings, error) { return nil, nil } // ValidateDelete implements webhook.Validator so a webhook will be registered for the type. -func (ampw *azureASOManagedControlPlaneWebhook) ValidateDelete(ctx context.Context, obj runtime.Object) (admission.Warnings, error) { +func (ampw *azureASOManagedControlPlaneWebhook) ValidateDelete(_ context.Context, _ runtime.Object) (admission.Warnings, error) { return nil, nil } diff --git a/api/v1alpha1/azureasomanagedmachinepool_webhook.go b/api/v1alpha1/azureasomanagedmachinepool_webhook.go index 443c62f44d4..86b9ddead4a 100644 --- a/api/v1alpha1/azureasomanagedmachinepool_webhook.go +++ b/api/v1alpha1/azureasomanagedmachinepool_webhook.go @@ -23,9 +23,10 @@ import ( apierrors "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/util/validation/field" - "sigs.k8s.io/cluster-api-provider-azure/feature" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/webhook/admission" + + "sigs.k8s.io/cluster-api-provider-azure/feature" ) // SetupAzureASOManagedMachinePoolWebhookWithManager sets up and registers the webhook with the manager. @@ -44,7 +45,7 @@ type azureASOManagedMachinePoolWebhook struct { // +kubebuilder:webhook:verbs=create,path=/validate-infrastructure-cluster-x-k8s-io-v1alpha1-azureasomanagedmachinepool,mutating=false,failurePolicy=fail,groups=infrastructure.cluster.x-k8s.io,resources=azureasomanagedmachinepools,versions=v1alpha1,name=validation.azureasomanagedmachinepool.infrastructure.cluster.x-k8s.io,sideEffects=None,admissionReviewVersions=v1;v1beta1 // ValidateCreate implements webhook.Validator so a webhook will be registered for the type. -func (ampw *azureASOManagedMachinePoolWebhook) ValidateCreate(ctx context.Context, obj runtime.Object) (admission.Warnings, error) { +func (ampw *azureASOManagedMachinePoolWebhook) ValidateCreate(_ context.Context, obj runtime.Object) (admission.Warnings, error) { _, ok := obj.(*AzureASOManagedMachinePool) if !ok { return nil, apierrors.NewBadRequest("expected an AzureASOManagedMachinePool") @@ -59,11 +60,11 @@ func (ampw *azureASOManagedMachinePoolWebhook) ValidateCreate(ctx context.Contex } // ValidateUpdate implements webhook.Validator so a webhook will be registered for the type. -func (ampw *azureASOManagedMachinePoolWebhook) ValidateUpdate(ctx context.Context, oldObj, newObj runtime.Object) (admission.Warnings, error) { +func (ampw *azureASOManagedMachinePoolWebhook) ValidateUpdate(_ context.Context, _, _ runtime.Object) (admission.Warnings, error) { return nil, nil } // ValidateDelete implements webhook.Validator so a webhook will be registered for the type. -func (ampw *azureASOManagedMachinePoolWebhook) ValidateDelete(ctx context.Context, obj runtime.Object) (admission.Warnings, error) { +func (ampw *azureASOManagedMachinePoolWebhook) ValidateDelete(_ context.Context, _ runtime.Object) (admission.Warnings, error) { return nil, nil } diff --git a/api/v1beta1/azurecluster_validation.go b/api/v1beta1/azurecluster_validation.go index 6cd04b6a04a..51350662631 100644 --- a/api/v1beta1/azurecluster_validation.go +++ b/api/v1beta1/azurecluster_validation.go @@ -28,8 +28,9 @@ import ( "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/util/validation/field" "k8s.io/utils/ptr" - "sigs.k8s.io/cluster-api-provider-azure/feature" "sigs.k8s.io/controller-runtime/pkg/webhook/admission" + + "sigs.k8s.io/cluster-api-provider-azure/feature" ) const ( @@ -508,7 +509,7 @@ func validateControlPlaneOutboundLB(lb *LoadBalancerSpec, apiserverLB LoadBalanc func validatePrivateDNSZoneName(privateDNSZoneName string, apiserverLBType LBType, fldPath *field.Path) field.ErrorList { var allErrs field.ErrorList - if len(privateDNSZoneName) > 0 { + if privateDNSZoneName != "" { if apiserverLBType != Internal { allErrs = append(allErrs, field.Invalid(fldPath, apiserverLBType, "PrivateDNSZoneName is available only if APIServerLB.Type is Internal")) diff --git a/api/v1beta1/azurecluster_validation_test.go b/api/v1beta1/azurecluster_validation_test.go index 31b3fcbf668..e4052d49045 100644 --- a/api/v1beta1/azurecluster_validation_test.go +++ b/api/v1beta1/azurecluster_validation_test.go @@ -811,7 +811,6 @@ func TestValidateSecurityRule(t *testing.T) { }, } for _, testCase := range tests { - testCase := testCase t.Run(testCase.name, func(t *testing.T) { t.Parallel() g := NewWithT(t) @@ -1030,7 +1029,6 @@ func TestValidateAPIServerLB(t *testing.T) { } for _, test := range testcases { - test := test t.Run(test.name, func(t *testing.T) { t.Parallel() g := NewWithT(t) @@ -1110,7 +1108,6 @@ func TestPrivateDNSZoneName(t *testing.T) { } for _, test := range testcases { - test := test t.Run(test.name, func(t *testing.T) { t.Parallel() g := NewWithT(t) @@ -1267,7 +1264,6 @@ func TestValidateNodeOutboundLB(t *testing.T) { } for _, test := range testcases { - test := test t.Run(test.name, func(t *testing.T) { t.Parallel() g := NewWithT(t) @@ -1347,7 +1343,6 @@ func TestValidateControlPlaneNodeOutboundLB(t *testing.T) { } for _, test := range testcases { - test := test t.Run(test.name, func(t *testing.T) { t.Parallel() g := NewWithT(t) diff --git a/api/v1beta1/azurecluster_webhook.go b/api/v1beta1/azurecluster_webhook.go index 8dc51a0bcfd..e2db7db86da 100644 --- a/api/v1beta1/azurecluster_webhook.go +++ b/api/v1beta1/azurecluster_webhook.go @@ -22,10 +22,11 @@ import ( apierrors "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/util/validation/field" - webhookutils "sigs.k8s.io/cluster-api-provider-azure/util/webhook" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/webhook" "sigs.k8s.io/controller-runtime/pkg/webhook/admission" + + webhookutils "sigs.k8s.io/cluster-api-provider-azure/util/webhook" ) // SetupWebhookWithManager sets up and registers the webhook with the manager. diff --git a/api/v1beta1/azurecluster_webhook_test.go b/api/v1beta1/azurecluster_webhook_test.go index 0096ddf79bf..97b52bb8f63 100644 --- a/api/v1beta1/azurecluster_webhook_test.go +++ b/api/v1beta1/azurecluster_webhook_test.go @@ -341,7 +341,6 @@ func TestAzureCluster_ValidateUpdate(t *testing.T) { }, } for _, tc := range tests { - tc := tc t.Run(tc.name, func(t *testing.T) { t.Parallel() g := NewWithT(t) diff --git a/api/v1beta1/azureclusteridentity_webhook.go b/api/v1beta1/azureclusteridentity_webhook.go index 3d961dab1d0..9887f77b145 100644 --- a/api/v1beta1/azureclusteridentity_webhook.go +++ b/api/v1beta1/azureclusteridentity_webhook.go @@ -20,10 +20,11 @@ import ( apierrors "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/util/validation/field" - webhookutils "sigs.k8s.io/cluster-api-provider-azure/util/webhook" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/webhook" "sigs.k8s.io/controller-runtime/pkg/webhook/admission" + + webhookutils "sigs.k8s.io/cluster-api-provider-azure/util/webhook" ) // SetupWebhookWithManager sets up and registers the webhook with the manager. diff --git a/api/v1beta1/azuremachine_default.go b/api/v1beta1/azuremachine_default.go index 3cc22d92233..bf688ecdb20 100644 --- a/api/v1beta1/azuremachine_default.go +++ b/api/v1beta1/azuremachine_default.go @@ -27,9 +27,10 @@ import ( "golang.org/x/crypto/ssh" kerrors "k8s.io/apimachinery/pkg/util/errors" "k8s.io/apimachinery/pkg/util/uuid" - utilSSH "sigs.k8s.io/cluster-api-provider-azure/util/ssh" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" "sigs.k8s.io/controller-runtime/pkg/client" + + utilSSH "sigs.k8s.io/cluster-api-provider-azure/util/ssh" ) // ContributorRoleID is the ID of the built-in "Contributor" role. diff --git a/api/v1beta1/azuremachine_validation.go b/api/v1beta1/azuremachine_validation.go index a6be65081ea..d370f3eb590 100644 --- a/api/v1beta1/azuremachine_validation.go +++ b/api/v1beta1/azuremachine_validation.go @@ -25,6 +25,7 @@ import ( "golang.org/x/crypto/ssh" "k8s.io/apimachinery/pkg/util/validation/field" "k8s.io/utils/ptr" + azureutil "sigs.k8s.io/cluster-api-provider-azure/util/azure" ) @@ -491,7 +492,7 @@ func ValidateCapacityReservationGroupID(capacityReservationGroupID *string, fldP } // ValidateVMExtensions validates the VMExtensions spec. -func ValidateVMExtensions(disableExtensionOperations *bool, vmExtensions []VMExtension, fldPath *field.Path) field.ErrorList { +func ValidateVMExtensions(disableExtensionOperations *bool, vmExtensions []VMExtension, _ *field.Path) field.ErrorList { allErrs := field.ErrorList{} if ptr.Deref(disableExtensionOperations, false) && len(vmExtensions) > 0 { diff --git a/api/v1beta1/azuremachine_webhook.go b/api/v1beta1/azuremachine_webhook.go index 3953dcad3e3..d3f892da778 100644 --- a/api/v1beta1/azuremachine_webhook.go +++ b/api/v1beta1/azuremachine_webhook.go @@ -23,10 +23,11 @@ import ( apierrors "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/util/validation/field" - webhookutils "sigs.k8s.io/cluster-api-provider-azure/util/webhook" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/webhook/admission" + + webhookutils "sigs.k8s.io/cluster-api-provider-azure/util/webhook" ) // SetupAzureMachineWebhookWithManager sets up and registers the webhook with the manager. @@ -48,7 +49,7 @@ type azureMachineWebhook struct { } // ValidateCreate implements webhook.Validator so a webhook will be registered for the type. -func (mw *azureMachineWebhook) ValidateCreate(ctx context.Context, obj runtime.Object) (admission.Warnings, error) { +func (mw *azureMachineWebhook) ValidateCreate(_ context.Context, obj runtime.Object) (admission.Warnings, error) { m, ok := obj.(*AzureMachine) if !ok { return nil, apierrors.NewBadRequest("expected an AzureMachine resource") @@ -74,7 +75,7 @@ func (mw *azureMachineWebhook) ValidateCreate(ctx context.Context, obj runtime.O } // ValidateUpdate implements webhook.Validator so a webhook will be registered for the type. -func (mw *azureMachineWebhook) ValidateUpdate(ctx context.Context, oldObj, newObj runtime.Object) (admission.Warnings, error) { +func (mw *azureMachineWebhook) ValidateUpdate(_ context.Context, oldObj, newObj runtime.Object) (admission.Warnings, error) { var allErrs field.ErrorList old, ok := oldObj.(*AzureMachine) if !ok { @@ -227,12 +228,12 @@ func (mw *azureMachineWebhook) ValidateUpdate(ctx context.Context, oldObj, newOb } // ValidateDelete implements webhook.Validator so a webhook will be registered for the type. -func (mw *azureMachineWebhook) ValidateDelete(ctx context.Context, obj runtime.Object) (admission.Warnings, error) { +func (mw *azureMachineWebhook) ValidateDelete(_ context.Context, _ runtime.Object) (admission.Warnings, error) { return nil, nil } // Default implements webhook.Defaulter so a webhook will be registered for the type. -func (mw *azureMachineWebhook) Default(ctx context.Context, obj runtime.Object) error { +func (mw *azureMachineWebhook) Default(_ context.Context, obj runtime.Object) error { m, ok := obj.(*AzureMachine) if !ok { return apierrors.NewBadRequest("expected an AzureMachine resource") diff --git a/api/v1beta1/azuremachinetemplate_webhook.go b/api/v1beta1/azuremachinetemplate_webhook.go index 9130f92ac19..a6e74bef25b 100644 --- a/api/v1beta1/azuremachinetemplate_webhook.go +++ b/api/v1beta1/azuremachinetemplate_webhook.go @@ -54,7 +54,7 @@ var _ webhook.CustomDefaulter = &AzureMachineTemplate{} var _ webhook.CustomValidator = &AzureMachineTemplate{} // ValidateCreate implements webhook.CustomValidator so a webhook will be registered for the type. -func (r *AzureMachineTemplate) ValidateCreate(ctx context.Context, obj runtime.Object) (admission.Warnings, error) { +func (r *AzureMachineTemplate) ValidateCreate(_ context.Context, obj runtime.Object) (admission.Warnings, error) { t := obj.(*AzureMachineTemplate) spec := t.Spec.Template.Spec @@ -142,12 +142,12 @@ func (r *AzureMachineTemplate) ValidateUpdate(ctx context.Context, oldRaw runtim } // ValidateDelete implements webhook.Validator so a webhook will be registered for the type. -func (r *AzureMachineTemplate) ValidateDelete(ctx context.Context, obj runtime.Object) (admission.Warnings, error) { +func (r *AzureMachineTemplate) ValidateDelete(_ context.Context, _ runtime.Object) (admission.Warnings, error) { return nil, nil } // Default implements webhookutil.defaulter so a webhook will be registered for the type. -func (r *AzureMachineTemplate) Default(ctx context.Context, obj runtime.Object) error { +func (r *AzureMachineTemplate) Default(_ context.Context, obj runtime.Object) error { t := obj.(*AzureMachineTemplate) if err := t.Spec.Template.Spec.SetDefaultSSHPublicKey(); err != nil { ctrl.Log.WithName("SetDefault").Error(err, "SetDefaultSSHPublicKey failed") diff --git a/api/v1beta1/azuremachinetemplate_webhook_test.go b/api/v1beta1/azuremachinetemplate_webhook_test.go index 210112533c8..cd5e1203257 100644 --- a/api/v1beta1/azuremachinetemplate_webhook_test.go +++ b/api/v1beta1/azuremachinetemplate_webhook_test.go @@ -245,7 +245,6 @@ func TestAzureMachineTemplate_ValidateCreate(t *testing.T) { } for _, test := range tests { - test := test t.Run(test.name, func(t *testing.T) { t.Parallel() g := NewWithT(t) @@ -593,7 +592,6 @@ func TestAzureMachineTemplate_ValidateUpdate(t *testing.T) { // dry-run=true for _, amt := range tests { - amt := amt 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)}}) @@ -607,7 +605,6 @@ func TestAzureMachineTemplate_ValidateUpdate(t *testing.T) { } // dry-run=false for _, amt := range tests { - amt := amt t.Run(amt.name, func(t *testing.T) { t.Parallel() g := NewWithT(t) diff --git a/api/v1beta1/azuremanagedcluster_webhook.go b/api/v1beta1/azuremanagedcluster_webhook.go index 1ef3fd84db2..e0b0c66df6c 100644 --- a/api/v1beta1/azuremanagedcluster_webhook.go +++ b/api/v1beta1/azuremanagedcluster_webhook.go @@ -19,11 +19,12 @@ package v1beta1 import ( "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/util/validation/field" - "sigs.k8s.io/cluster-api-provider-azure/feature" capifeature "sigs.k8s.io/cluster-api/feature" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/webhook" "sigs.k8s.io/controller-runtime/pkg/webhook/admission" + + "sigs.k8s.io/cluster-api-provider-azure/feature" ) // SetupWebhookWithManager sets up and registers the webhook with the manager. @@ -51,7 +52,7 @@ func (r *AzureManagedCluster) ValidateCreate() (admission.Warnings, error) { } // ValidateUpdate implements webhook.Validator so a webhook will be registered for the type. -func (r *AzureManagedCluster) ValidateUpdate(oldRaw runtime.Object) (admission.Warnings, error) { +func (r *AzureManagedCluster) ValidateUpdate(_ runtime.Object) (admission.Warnings, error) { return nil, nil } diff --git a/api/v1beta1/azuremanagedcluster_webhook_test.go b/api/v1beta1/azuremanagedcluster_webhook_test.go index 913fda67833..e97807aacb9 100644 --- a/api/v1beta1/azuremanagedcluster_webhook_test.go +++ b/api/v1beta1/azuremanagedcluster_webhook_test.go @@ -23,9 +23,10 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" utilfeature "k8s.io/component-base/featuregate/testing" "k8s.io/utils/ptr" - "sigs.k8s.io/cluster-api-provider-azure/feature" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" capifeature "sigs.k8s.io/cluster-api/feature" + + "sigs.k8s.io/cluster-api-provider-azure/feature" ) func TestAzureManagedCluster_ValidateUpdate(t *testing.T) { diff --git a/api/v1beta1/azuremanagedclustertemplate_webhook.go b/api/v1beta1/azuremanagedclustertemplate_webhook.go index 048d79adf06..b8627f5f66e 100644 --- a/api/v1beta1/azuremanagedclustertemplate_webhook.go +++ b/api/v1beta1/azuremanagedclustertemplate_webhook.go @@ -19,11 +19,12 @@ package v1beta1 import ( "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/util/validation/field" - "sigs.k8s.io/cluster-api-provider-azure/feature" capifeature "sigs.k8s.io/cluster-api/feature" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/webhook" "sigs.k8s.io/controller-runtime/pkg/webhook/admission" + + "sigs.k8s.io/cluster-api-provider-azure/feature" ) // SetupWebhookWithManager sets up and registers the webhook with the manager. diff --git a/api/v1beta1/azuremanagedcontrolplane_default.go b/api/v1beta1/azuremanagedcontrolplane_default.go index d66a37fd3ed..859793da4aa 100644 --- a/api/v1beta1/azuremanagedcontrolplane_default.go +++ b/api/v1beta1/azuremanagedcontrolplane_default.go @@ -23,9 +23,10 @@ import ( "golang.org/x/crypto/ssh" "k8s.io/utils/ptr" - utilSSH "sigs.k8s.io/cluster-api-provider-azure/util/ssh" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" ctrl "sigs.k8s.io/controller-runtime" + + utilSSH "sigs.k8s.io/cluster-api-provider-azure/util/ssh" ) const ( diff --git a/api/v1beta1/azuremanagedcontrolplane_webhook.go b/api/v1beta1/azuremanagedcontrolplane_webhook.go index a0190288ae6..029945c29ad 100644 --- a/api/v1beta1/azuremanagedcontrolplane_webhook.go +++ b/api/v1beta1/azuremanagedcontrolplane_webhook.go @@ -30,14 +30,15 @@ import ( "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/util/validation/field" "k8s.io/utils/ptr" - "sigs.k8s.io/cluster-api-provider-azure/feature" - "sigs.k8s.io/cluster-api-provider-azure/util/versions" - webhookutils "sigs.k8s.io/cluster-api-provider-azure/util/webhook" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" capifeature "sigs.k8s.io/cluster-api/feature" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/webhook/admission" + + "sigs.k8s.io/cluster-api-provider-azure/feature" + "sigs.k8s.io/cluster-api-provider-azure/util/versions" + webhookutils "sigs.k8s.io/cluster-api-provider-azure/util/webhook" ) var ( @@ -66,7 +67,7 @@ type azureManagedControlPlaneWebhook struct { } // Default implements webhook.Defaulter so a webhook will be registered for the type. -func (mw *azureManagedControlPlaneWebhook) Default(ctx context.Context, obj runtime.Object) error { +func (mw *azureManagedControlPlaneWebhook) Default(_ context.Context, obj runtime.Object) error { m, ok := obj.(*AzureManagedControlPlane) if !ok { return apierrors.NewBadRequest("expected an AzureManagedControlPlane") @@ -105,7 +106,7 @@ func (mw *azureManagedControlPlaneWebhook) Default(ctx context.Context, obj runt // +kubebuilder:webhook:verbs=create;update,path=/validate-infrastructure-cluster-x-k8s-io-v1beta1-azuremanagedcontrolplane,mutating=false,failurePolicy=fail,groups=infrastructure.cluster.x-k8s.io,resources=azuremanagedcontrolplanes,versions=v1beta1,name=validation.azuremanagedcontrolplanes.infrastructure.cluster.x-k8s.io,sideEffects=None,admissionReviewVersions=v1;v1beta1 // ValidateCreate implements webhook.Validator so a webhook will be registered for the type. -func (mw *azureManagedControlPlaneWebhook) ValidateCreate(ctx context.Context, obj runtime.Object) (admission.Warnings, error) { +func (mw *azureManagedControlPlaneWebhook) ValidateCreate(_ context.Context, obj runtime.Object) (admission.Warnings, error) { m, ok := obj.(*AzureManagedControlPlane) if !ok { return nil, apierrors.NewBadRequest("expected an AzureManagedControlPlane") @@ -123,7 +124,7 @@ func (mw *azureManagedControlPlaneWebhook) ValidateCreate(ctx context.Context, o } // ValidateUpdate implements webhook.Validator so a webhook will be registered for the type. -func (mw *azureManagedControlPlaneWebhook) ValidateUpdate(ctx context.Context, oldObj, newObj runtime.Object) (admission.Warnings, error) { +func (mw *azureManagedControlPlaneWebhook) ValidateUpdate(_ context.Context, oldObj, newObj runtime.Object) (admission.Warnings, error) { var allErrs field.ErrorList old, ok := oldObj.(*AzureManagedControlPlane) if !ok { @@ -240,7 +241,7 @@ func (mw *azureManagedControlPlaneWebhook) ValidateUpdate(ctx context.Context, o } // ValidateDelete implements webhook.Validator so a webhook will be registered for the type. -func (mw *azureManagedControlPlaneWebhook) ValidateDelete(ctx context.Context, obj runtime.Object) (admission.Warnings, error) { +func (mw *azureManagedControlPlaneWebhook) ValidateDelete(_ context.Context, _ runtime.Object) (admission.Warnings, error) { return nil, nil } diff --git a/api/v1beta1/azuremanagedcontrolplane_webhook_test.go b/api/v1beta1/azuremanagedcontrolplane_webhook_test.go index ad6504612ec..e24a9c24e7d 100644 --- a/api/v1beta1/azuremanagedcontrolplane_webhook_test.go +++ b/api/v1beta1/azuremanagedcontrolplane_webhook_test.go @@ -25,9 +25,10 @@ import ( "k8s.io/apimachinery/pkg/util/validation/field" utilfeature "k8s.io/component-base/featuregate/testing" "k8s.io/utils/ptr" - "sigs.k8s.io/cluster-api-provider-azure/feature" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" capifeature "sigs.k8s.io/cluster-api/feature" + + "sigs.k8s.io/cluster-api-provider-azure/feature" ) func TestDefaultingWebhook(t *testing.T) { @@ -204,7 +205,6 @@ func TestValidateVersion(t *testing.T) { } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { g := NewWithT(t) allErrs := validateVersion(tt.version, field.NewPath("spec").Child("Version")) @@ -272,7 +272,6 @@ func TestValidateLoadBalancerProfile(t *testing.T) { }, } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { g := NewWithT(t) allErrs := validateLoadBalancerProfile(tt.profile, field.NewPath("spec").Child("loadBalancerProfile")) @@ -464,7 +463,6 @@ func TestValidateAutoScalerProfile(t *testing.T) { } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { g := NewWithT(t) allErrs := validateAutoScalerProfile(tt.profile, field.NewPath("spec").Child("autoScalerProfile")) @@ -1389,7 +1387,6 @@ func TestValidatingWebhook(t *testing.T) { } for _, tt := range tests { - tt := tt // client is used to fetch the AzureManagedControlPlane, we do not want to return an error on client.Get client := mockClient{ReturnError: false} t.Run(tt.name, func(t *testing.T) { diff --git a/api/v1beta1/azuremanagedcontrolplanetemplate_webhook.go b/api/v1beta1/azuremanagedcontrolplanetemplate_webhook.go index f2b25b36743..18f73e91246 100644 --- a/api/v1beta1/azuremanagedcontrolplanetemplate_webhook.go +++ b/api/v1beta1/azuremanagedcontrolplanetemplate_webhook.go @@ -23,13 +23,14 @@ import ( apierrors "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/util/validation/field" - "sigs.k8s.io/cluster-api-provider-azure/feature" - "sigs.k8s.io/cluster-api-provider-azure/util/versions" - webhookutils "sigs.k8s.io/cluster-api-provider-azure/util/webhook" capifeature "sigs.k8s.io/cluster-api/feature" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/webhook/admission" + + "sigs.k8s.io/cluster-api-provider-azure/feature" + "sigs.k8s.io/cluster-api-provider-azure/util/versions" + webhookutils "sigs.k8s.io/cluster-api-provider-azure/util/webhook" ) // SetupAzureManagedControlPlaneTemplateWebhookWithManager will set up the webhook to be managed by the specified manager. @@ -50,7 +51,7 @@ type azureManagedControlPlaneTemplateWebhook struct { } // Default implements webhook.Defaulter so a webhook will be registered for the type. -func (mcpw *azureManagedControlPlaneTemplateWebhook) Default(ctx context.Context, obj runtime.Object) error { +func (mcpw *azureManagedControlPlaneTemplateWebhook) Default(_ context.Context, obj runtime.Object) error { mcp, ok := obj.(*AzureManagedControlPlaneTemplate) if !ok { return apierrors.NewBadRequest("expected an AzureManagedControlPlaneTemplate") @@ -60,7 +61,7 @@ func (mcpw *azureManagedControlPlaneTemplateWebhook) Default(ctx context.Context } // ValidateCreate implements webhook.Validator so a webhook will be registered for the type. -func (mcpw *azureManagedControlPlaneTemplateWebhook) ValidateCreate(ctx context.Context, obj runtime.Object) (admission.Warnings, error) { +func (mcpw *azureManagedControlPlaneTemplateWebhook) ValidateCreate(_ context.Context, obj runtime.Object) (admission.Warnings, error) { mcp, ok := obj.(*AzureManagedControlPlaneTemplate) if !ok { return nil, apierrors.NewBadRequest("expected an AzureManagedControlPlaneTemplate") @@ -78,7 +79,7 @@ func (mcpw *azureManagedControlPlaneTemplateWebhook) ValidateCreate(ctx context. } // ValidateUpdate implements webhook.Validator so a webhook will be registered for the type. -func (mcpw *azureManagedControlPlaneTemplateWebhook) ValidateUpdate(ctx context.Context, oldObj, newObj runtime.Object) (admission.Warnings, error) { +func (mcpw *azureManagedControlPlaneTemplateWebhook) ValidateUpdate(_ context.Context, oldObj, newObj runtime.Object) (admission.Warnings, error) { var allErrs field.ErrorList old, ok := oldObj.(*AzureManagedControlPlaneTemplate) if !ok { @@ -234,7 +235,7 @@ func (mcp *AzureManagedControlPlaneTemplate) validateManagedControlPlaneTemplate } // ValidateDelete implements webhook.Validator so a webhook will be registered for the type. -func (mcpw *azureManagedControlPlaneTemplateWebhook) ValidateDelete(ctx context.Context, _ runtime.Object) (admission.Warnings, error) { +func (mcpw *azureManagedControlPlaneTemplateWebhook) ValidateDelete(_ context.Context, _ runtime.Object) (admission.Warnings, error) { return nil, nil } diff --git a/api/v1beta1/azuremanagedmachinepool_webhook.go b/api/v1beta1/azuremanagedmachinepool_webhook.go index d5abde51657..3c2cc657cc0 100644 --- a/api/v1beta1/azuremanagedmachinepool_webhook.go +++ b/api/v1beta1/azuremanagedmachinepool_webhook.go @@ -30,15 +30,16 @@ import ( kerrors "k8s.io/apimachinery/pkg/util/errors" "k8s.io/apimachinery/pkg/util/validation/field" "k8s.io/utils/ptr" - "sigs.k8s.io/cluster-api-provider-azure/feature" - azureutil "sigs.k8s.io/cluster-api-provider-azure/util/azure" - webhookutils "sigs.k8s.io/cluster-api-provider-azure/util/webhook" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" clusterctlv1alpha3 "sigs.k8s.io/cluster-api/cmd/clusterctl/api/v1alpha3" capifeature "sigs.k8s.io/cluster-api/feature" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/webhook/admission" + + "sigs.k8s.io/cluster-api-provider-azure/feature" + azureutil "sigs.k8s.io/cluster-api-provider-azure/util/azure" + webhookutils "sigs.k8s.io/cluster-api-provider-azure/util/webhook" ) var validNodePublicPrefixID = regexp.MustCompile(`(?i)^/?subscriptions/[0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12}/resourcegroups/[^/]+/providers/microsoft\.network/publicipprefixes/[^/]+$`) @@ -61,7 +62,7 @@ type azureManagedMachinePoolWebhook struct { } // Default implements webhook.Defaulter so a webhook will be registered for the type. -func (mw *azureManagedMachinePoolWebhook) Default(ctx context.Context, obj runtime.Object) error { +func (mw *azureManagedMachinePoolWebhook) Default(_ context.Context, obj runtime.Object) error { m, ok := obj.(*AzureManagedMachinePool) if !ok { return apierrors.NewBadRequest("expected an AzureManagedMachinePool") @@ -85,7 +86,7 @@ func (mw *azureManagedMachinePoolWebhook) Default(ctx context.Context, obj runti //+kubebuilder:webhook:verbs=create;update;delete,path=/validate-infrastructure-cluster-x-k8s-io-v1beta1-azuremanagedmachinepool,mutating=false,failurePolicy=fail,matchPolicy=Equivalent,groups=infrastructure.cluster.x-k8s.io,resources=azuremanagedmachinepools,versions=v1beta1,name=validation.azuremanagedmachinepools.infrastructure.cluster.x-k8s.io,sideEffects=None,admissionReviewVersions=v1;v1beta1 // ValidateCreate implements webhook.Validator so a webhook will be registered for the type. -func (mw *azureManagedMachinePoolWebhook) ValidateCreate(ctx context.Context, obj runtime.Object) (admission.Warnings, error) { +func (mw *azureManagedMachinePoolWebhook) ValidateCreate(_ context.Context, obj runtime.Object) (admission.Warnings, error) { m, ok := obj.(*AzureManagedMachinePool) if !ok { return nil, apierrors.NewBadRequest("expected an AzureManagedMachinePool") @@ -146,7 +147,7 @@ func (mw *azureManagedMachinePoolWebhook) ValidateCreate(ctx context.Context, ob } // ValidateUpdate implements webhook.Validator so a webhook will be registered for the type. -func (mw *azureManagedMachinePoolWebhook) ValidateUpdate(ctx context.Context, oldObj, newObj runtime.Object) (admission.Warnings, error) { +func (mw *azureManagedMachinePoolWebhook) ValidateUpdate(_ context.Context, oldObj, newObj runtime.Object) (admission.Warnings, error) { old, ok := oldObj.(*AzureManagedMachinePool) if !ok { return nil, apierrors.NewBadRequest("expected an AzureManagedMachinePool") @@ -300,7 +301,7 @@ func (mw *azureManagedMachinePoolWebhook) ValidateUpdate(ctx context.Context, ol } // ValidateDelete implements webhook.Validator so a webhook will be registered for the type. -func (mw *azureManagedMachinePoolWebhook) ValidateDelete(ctx context.Context, obj runtime.Object) (admission.Warnings, error) { +func (mw *azureManagedMachinePoolWebhook) ValidateDelete(_ context.Context, obj runtime.Object) (admission.Warnings, error) { m, ok := obj.(*AzureManagedMachinePool) if !ok { return nil, apierrors.NewBadRequest("expected an AzureManagedMachinePool") diff --git a/api/v1beta1/azuremanagedmachinepool_webhook_test.go b/api/v1beta1/azuremanagedmachinepool_webhook_test.go index 442de80d4a5..f3b0603fb02 100644 --- a/api/v1beta1/azuremanagedmachinepool_webhook_test.go +++ b/api/v1beta1/azuremanagedmachinepool_webhook_test.go @@ -26,12 +26,13 @@ import ( "k8s.io/apimachinery/pkg/runtime" utilfeature "k8s.io/component-base/featuregate/testing" "k8s.io/utils/ptr" - "sigs.k8s.io/cluster-api-provider-azure/feature" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" clusterctlv1alpha3 "sigs.k8s.io/cluster-api/cmd/clusterctl/api/v1alpha3" capifeature "sigs.k8s.io/cluster-api/feature" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/client/fake" + + "sigs.k8s.io/cluster-api-provider-azure/feature" ) func TestAzureManagedMachinePoolDefaultingWebhook(t *testing.T) { @@ -636,7 +637,6 @@ func TestAzureManagedMachinePoolUpdatingWebhook(t *testing.T) { } var client client.Client for _, tc := range tests { - tc := tc t.Run(tc.name, func(t *testing.T) { t.Parallel() g := NewWithT(t) diff --git a/api/v1beta1/azuremanagedmachinepooltemplate_webhook.go b/api/v1beta1/azuremanagedmachinepooltemplate_webhook.go index 9a85c5e1107..1db56744687 100644 --- a/api/v1beta1/azuremanagedmachinepooltemplate_webhook.go +++ b/api/v1beta1/azuremanagedmachinepooltemplate_webhook.go @@ -25,12 +25,13 @@ import ( kerrors "k8s.io/apimachinery/pkg/util/errors" "k8s.io/apimachinery/pkg/util/validation/field" "k8s.io/utils/ptr" - "sigs.k8s.io/cluster-api-provider-azure/feature" - webhookutils "sigs.k8s.io/cluster-api-provider-azure/util/webhook" capifeature "sigs.k8s.io/cluster-api/feature" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/webhook/admission" + + "sigs.k8s.io/cluster-api-provider-azure/feature" + webhookutils "sigs.k8s.io/cluster-api-provider-azure/util/webhook" ) // SetupAzureManagedMachinePoolTemplateWebhookWithManager will set up the webhook to be managed by the specified manager. @@ -50,7 +51,7 @@ type azureManagedMachinePoolTemplateWebhook struct { } // Default implements webhook.Defaulter so a webhook will be registered for the type. -func (mpw *azureManagedMachinePoolTemplateWebhook) Default(ctx context.Context, obj runtime.Object) error { +func (mpw *azureManagedMachinePoolTemplateWebhook) Default(_ context.Context, obj runtime.Object) error { mp, ok := obj.(*AzureManagedMachinePoolTemplate) if !ok { return apierrors.NewBadRequest("expected an AzureManagedMachinePoolTemplate") @@ -72,7 +73,7 @@ func (mpw *azureManagedMachinePoolTemplateWebhook) Default(ctx context.Context, //+kubebuilder:webhook:verbs=create;update;delete,path=/validate-infrastructure-cluster-x-k8s-io-v1beta1-azuremanagedmachinepooltemplate,mutating=false,failurePolicy=fail,groups=infrastructure.cluster.x-k8s.io,resources=azuremanagedmachinepooltemplates,versions=v1beta1,name=validation.azuremanagedmachinepooltemplates.infrastructure.cluster.x-k8s.io,sideEffects=None,admissionReviewVersions=v1;v1beta1 // ValidateCreate implements webhook.Validator so a webhook will be registered for the type. -func (mpw *azureManagedMachinePoolTemplateWebhook) ValidateCreate(ctx context.Context, obj runtime.Object) (admission.Warnings, error) { +func (mpw *azureManagedMachinePoolTemplateWebhook) ValidateCreate(_ context.Context, obj runtime.Object) (admission.Warnings, error) { mp, ok := obj.(*AzureManagedMachinePoolTemplate) if !ok { return nil, apierrors.NewBadRequest("expected an AzureManagedMachinePoolTemplate") @@ -128,7 +129,7 @@ func (mpw *azureManagedMachinePoolTemplateWebhook) ValidateCreate(ctx context.Co } // ValidateUpdate implements webhook.Validator so a webhook will be registered for the type. -func (mpw *azureManagedMachinePoolTemplateWebhook) ValidateUpdate(ctx context.Context, oldObj, newObj runtime.Object) (admission.Warnings, error) { +func (mpw *azureManagedMachinePoolTemplateWebhook) ValidateUpdate(_ context.Context, oldObj, newObj runtime.Object) (admission.Warnings, error) { var allErrs field.ErrorList old, ok := oldObj.(*AzureManagedMachinePoolTemplate) if !ok { @@ -274,7 +275,7 @@ func (mpw *azureManagedMachinePoolTemplateWebhook) ValidateUpdate(ctx context.Co } // ValidateDelete implements webhook.Validator so a webhook will be registered for the type. -func (mpw *azureManagedMachinePoolTemplateWebhook) ValidateDelete(ctx context.Context, obj runtime.Object) (admission.Warnings, error) { +func (mpw *azureManagedMachinePoolTemplateWebhook) ValidateDelete(_ context.Context, obj runtime.Object) (admission.Warnings, error) { mp, ok := obj.(*AzureManagedMachinePoolTemplate) if !ok { return nil, apierrors.NewBadRequest("expected an AzureManagedMachinePoolTemplate") diff --git a/api/v1beta1/azuremanagedmachinepooltemplate_webhook_test.go b/api/v1beta1/azuremanagedmachinepooltemplate_webhook_test.go index 5f2c1bdf714..0b572a01e74 100644 --- a/api/v1beta1/azuremanagedmachinepooltemplate_webhook_test.go +++ b/api/v1beta1/azuremanagedmachinepooltemplate_webhook_test.go @@ -23,6 +23,7 @@ import ( . "github.com/onsi/gomega" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/utils/ptr" + azureutil "sigs.k8s.io/cluster-api-provider-azure/util/azure" ) diff --git a/api/v1beta1/tags_test.go b/api/v1beta1/tags_test.go index 8cba88dba4c..5c2227235a5 100644 --- a/api/v1beta1/tags_test.go +++ b/api/v1beta1/tags_test.go @@ -73,7 +73,6 @@ func TestTags_Merge(t *testing.T) { }, } for _, tc := range tests { - tc := tc t.Run(tc.name, func(t *testing.T) { t.Parallel() g := NewWithT(t) diff --git a/azure/converters/diagnostics.go b/azure/converters/diagnostics.go index c28c144847c..6af74f9f8f4 100644 --- a/azure/converters/diagnostics.go +++ b/azure/converters/diagnostics.go @@ -19,6 +19,7 @@ package converters import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v5" "k8s.io/utils/ptr" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" ) diff --git a/azure/converters/diagnostics_test.go b/azure/converters/diagnostics_test.go index 4af80a9da33..8d2b7d1c6fc 100644 --- a/azure/converters/diagnostics_test.go +++ b/azure/converters/diagnostics_test.go @@ -22,6 +22,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v5" "github.com/google/go-cmp/cmp" "k8s.io/utils/ptr" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" ) @@ -93,7 +94,6 @@ func TestGetDiagnosticsProfile(t *testing.T) { }, } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() got := GetDiagnosticsProfile(tt.diagnostics) diff --git a/azure/converters/dns_test.go b/azure/converters/dns_test.go index 1f329156c09..ee548d903dc 100644 --- a/azure/converters/dns_test.go +++ b/azure/converters/dns_test.go @@ -47,7 +47,6 @@ func Test_GetRecordType(t *testing.T) { } for _, c := range cases { - c := c t.Run(c.name, func(t *testing.T) { t.Parallel() g := gomega.NewGomegaWithT(t) diff --git a/azure/converters/extendedlocation.go b/azure/converters/extendedlocation.go index eef089f505c..42fdc72b18c 100644 --- a/azure/converters/extendedlocation.go +++ b/azure/converters/extendedlocation.go @@ -21,6 +21,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v4" asonetworkv1 "github.com/Azure/azure-service-operator/v2/api/network/v1api20201101" "k8s.io/utils/ptr" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" ) diff --git a/azure/converters/extendedlocation_test.go b/azure/converters/extendedlocation_test.go index e4cd01af62d..260e180300d 100644 --- a/azure/converters/extendedlocation_test.go +++ b/azure/converters/extendedlocation_test.go @@ -24,6 +24,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v4" asonetworkv1 "github.com/Azure/azure-service-operator/v2/api/network/v1api20201101" "k8s.io/utils/ptr" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" ) diff --git a/azure/converters/futures.go b/azure/converters/futures.go index 2de5d714ed1..e2571515e0a 100644 --- a/azure/converters/futures.go +++ b/azure/converters/futures.go @@ -21,6 +21,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/pkg/errors" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" ) diff --git a/azure/converters/futures_test.go b/azure/converters/futures_test.go index 345366e5551..2c7ef3247f1 100644 --- a/azure/converters/futures_test.go +++ b/azure/converters/futures_test.go @@ -26,6 +26,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" . "github.com/onsi/gomega" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" ) @@ -95,7 +96,6 @@ func TestPollerToFuture(t *testing.T) { } for _, c := range cases { - c := c t.Run(c.name, func(t *testing.T) { t.Parallel() g := NewGomegaWithT(t) @@ -163,7 +163,6 @@ func TestFutureToResumeToken(t *testing.T) { } for _, c := range cases { - c := c t.Run(c.name, func(t *testing.T) { t.Parallel() g := NewGomegaWithT(t) diff --git a/azure/converters/identity.go b/azure/converters/identity.go index 6d3cdb6b3ec..c24f9802be1 100644 --- a/azure/converters/identity.go +++ b/azure/converters/identity.go @@ -22,6 +22,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v5" "github.com/pkg/errors" "k8s.io/utils/ptr" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" azureutil "sigs.k8s.io/cluster-api-provider-azure/util/azure" ) diff --git a/azure/converters/identity_test.go b/azure/converters/identity_test.go index 24d1bbfd6e5..6207812879a 100644 --- a/azure/converters/identity_test.go +++ b/azure/converters/identity_test.go @@ -22,6 +22,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v5" . "github.com/onsi/gomega" "k8s.io/utils/ptr" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" ) @@ -100,7 +101,6 @@ func Test_VMIdentityToVMSDK(t *testing.T) { } for _, c := range cases { - c := c t.Run(c.Name, func(t *testing.T) { t.Parallel() g := NewGomegaWithT(t) @@ -135,7 +135,6 @@ func Test_UserAssignedIdentitiesToVMSDK(t *testing.T) { } for _, c := range cases { - c := c t.Run(c.Name, func(t *testing.T) { t.Parallel() g := NewGomegaWithT(t) @@ -170,7 +169,6 @@ func Test_UserAssignedIdentitiesToVMSSSDK(t *testing.T) { } for _, c := range cases { - c := c t.Run(c.Name, func(t *testing.T) { t.Parallel() g := NewGomegaWithT(t) diff --git a/azure/converters/image.go b/azure/converters/image.go index 938f22e1d10..dacf97f6ec1 100644 --- a/azure/converters/image.go +++ b/azure/converters/image.go @@ -22,6 +22,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v5" "github.com/pkg/errors" "k8s.io/utils/ptr" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" ) diff --git a/azure/converters/image_test.go b/azure/converters/image_test.go index 3c4b72c6f28..51249521045 100644 --- a/azure/converters/image_test.go +++ b/azure/converters/image_test.go @@ -22,6 +22,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v5" . "github.com/onsi/gomega" "k8s.io/utils/ptr" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" ) @@ -137,7 +138,6 @@ func Test_ImageToPlan(t *testing.T) { } for _, c := range cases { - c := c t.Run(c.name, func(t *testing.T) { t.Parallel() g := NewGomegaWithT(t) @@ -218,7 +218,6 @@ func Test_ComputeImageToSDK(t *testing.T) { } for _, c := range cases { - c := c t.Run(c.name, func(t *testing.T) { t.Parallel() g := NewGomegaWithT(t) @@ -333,7 +332,6 @@ func Test_ImageToSDK(t *testing.T) { } for _, c := range cases { - c := c t.Run(c.name, func(t *testing.T) { t.Parallel() g := NewGomegaWithT(t) diff --git a/azure/converters/loadbalancers.go b/azure/converters/loadbalancers.go index 7feab492988..dee423d5d63 100644 --- a/azure/converters/loadbalancers.go +++ b/azure/converters/loadbalancers.go @@ -18,6 +18,7 @@ package converters import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v4" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" ) diff --git a/azure/converters/loadbalancers_test.go b/azure/converters/loadbalancers_test.go index 815fd094597..ce991150088 100644 --- a/azure/converters/loadbalancers_test.go +++ b/azure/converters/loadbalancers_test.go @@ -21,6 +21,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v4" "github.com/google/go-cmp/cmp" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" ) @@ -42,7 +43,6 @@ func TestSKUtoSDK(t *testing.T) { }, } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() got := SKUtoSDK(tt.sku) diff --git a/azure/converters/managedagentpool_test.go b/azure/converters/managedagentpool_test.go index ab430459296..815542fb7f7 100644 --- a/azure/converters/managedagentpool_test.go +++ b/azure/converters/managedagentpool_test.go @@ -99,7 +99,6 @@ func Test_AgentPoolToManagedClusterAgentPoolProfile(t *testing.T) { } for _, c := range cases { - c := c t.Run(c.name, func(t *testing.T) { t.Parallel() g := NewGomegaWithT(t) diff --git a/azure/converters/publicips.go b/azure/converters/publicips.go index 79493cb2e9a..a57cb49b0e9 100644 --- a/azure/converters/publicips.go +++ b/azure/converters/publicips.go @@ -19,6 +19,7 @@ package converters import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v4" "k8s.io/utils/ptr" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" ) diff --git a/azure/converters/publicips_test.go b/azure/converters/publicips_test.go index ed123e08e5b..7494caa2632 100644 --- a/azure/converters/publicips_test.go +++ b/azure/converters/publicips_test.go @@ -22,6 +22,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v4" "k8s.io/utils/ptr" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" ) diff --git a/azure/converters/resourcehealth.go b/azure/converters/resourcehealth.go index 298c2e25b04..5497dd53043 100644 --- a/azure/converters/resourcehealth.go +++ b/azure/converters/resourcehealth.go @@ -21,9 +21,10 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resourcehealth/armresourcehealth" "k8s.io/utils/ptr" - infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" "sigs.k8s.io/cluster-api/util/conditions" + + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" ) // SDKAvailabilityStatusToCondition converts an Azure Resource Health availability status to a status condition. @@ -44,7 +45,7 @@ func SDKAvailabilityStatusToCondition(availStatus armresourcehealth.Availability // response may include spaces (e.g. "Customer Initiated") words := strings.Split(*availStatus.Properties.ReasonType, " ") for _, word := range words { - if len(word) > 0 { + if word != "" { reason.WriteString(strings.ToTitle(word[:1])) } if len(word) > 1 { diff --git a/azure/converters/resourcehealth_test.go b/azure/converters/resourcehealth_test.go index 0c27768227e..b75ba1d0dcd 100644 --- a/azure/converters/resourcehealth_test.go +++ b/azure/converters/resourcehealth_test.go @@ -85,7 +85,6 @@ func TestAzureAvailabilityStatusToCondition(t *testing.T) { } for _, test := range tests { - test := test t.Run(test.name, func(t *testing.T) { g := NewWithT(t) t.Parallel() diff --git a/azure/converters/rules.go b/azure/converters/rules.go index 961cb0c11b8..4725fbe975d 100644 --- a/azure/converters/rules.go +++ b/azure/converters/rules.go @@ -19,6 +19,7 @@ package converters import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v4" "k8s.io/utils/ptr" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" ) diff --git a/azure/converters/spotinstances.go b/azure/converters/spotinstances.go index 0d3c4e9a664..183f84ec14f 100644 --- a/azure/converters/spotinstances.go +++ b/azure/converters/spotinstances.go @@ -21,12 +21,13 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v5" "k8s.io/utils/ptr" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" ) // GetSpotVMOptions takes the spot vm options // and returns the individual vm priority, eviction policy and billing profile. -func GetSpotVMOptions(spotVMOptions *infrav1.SpotVMOptions, diffDiskSettings *infrav1.DiffDiskSettings) (*armcompute.VirtualMachinePriorityTypes, *armcompute.VirtualMachineEvictionPolicyTypes, *armcompute.BillingProfile, error) { +func GetSpotVMOptions(spotVMOptions *infrav1.SpotVMOptions, _ *infrav1.DiffDiskSettings) (*armcompute.VirtualMachinePriorityTypes, *armcompute.VirtualMachineEvictionPolicyTypes, *armcompute.BillingProfile, error) { // Spot VM not requested, return zero values to apply defaults if spotVMOptions == nil { return nil, nil, nil, nil diff --git a/azure/converters/spotinstances_test.go b/azure/converters/spotinstances_test.go index b94a29755f7..015c191b73a 100644 --- a/azure/converters/spotinstances_test.go +++ b/azure/converters/spotinstances_test.go @@ -24,6 +24,7 @@ import ( . "github.com/onsi/gomega" "k8s.io/apimachinery/pkg/api/resource" "k8s.io/utils/ptr" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" ) @@ -123,7 +124,6 @@ func TestGetSpotVMOptions(t *testing.T) { }, } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() g := NewGomegaWithT(t) diff --git a/azure/converters/subnets_test.go b/azure/converters/subnets_test.go index 609d2ec0293..7935f3bdeb5 100644 --- a/azure/converters/subnets_test.go +++ b/azure/converters/subnets_test.go @@ -58,7 +58,6 @@ func TestGetSubnetAddresses(t *testing.T) { }, } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() g := NewGomegaWithT(t) diff --git a/azure/converters/tags.go b/azure/converters/tags.go index 3f47a5162af..feb98a33dea 100644 --- a/azure/converters/tags.go +++ b/azure/converters/tags.go @@ -18,6 +18,7 @@ package converters import ( "k8s.io/utils/ptr" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" ) diff --git a/azure/converters/tags_test.go b/azure/converters/tags_test.go index fc7c6540ff0..cfffc2113aa 100644 --- a/azure/converters/tags_test.go +++ b/azure/converters/tags_test.go @@ -21,6 +21,7 @@ import ( "github.com/onsi/gomega" "k8s.io/utils/ptr" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" ) @@ -44,7 +45,6 @@ func Test_TagsToMap(t *testing.T) { } for _, c := range cases { - c := c t.Run("name", func(t *testing.T) { t.Parallel() g := gomega.NewGomegaWithT(t) @@ -74,7 +74,6 @@ func Test_MapToTags(t *testing.T) { } for _, c := range cases { - c := c t.Run("name", func(t *testing.T) { t.Parallel() g := gomega.NewGomegaWithT(t) @@ -107,7 +106,6 @@ func Test_TagsToMapRoundTrip(t *testing.T) { } for _, c := range cases { - c := c t.Run("name", func(t *testing.T) { t.Parallel() g := gomega.NewGomegaWithT(t) @@ -140,7 +138,6 @@ func Test_MapToTagsMapRoundTrip(t *testing.T) { } for _, c := range cases { - c := c t.Run("name", func(t *testing.T) { t.Parallel() g := gomega.NewGomegaWithT(t) diff --git a/azure/converters/vm.go b/azure/converters/vm.go index a73eb44a331..07a70d35220 100644 --- a/azure/converters/vm.go +++ b/azure/converters/vm.go @@ -20,6 +20,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v5" corev1 "k8s.io/api/core/v1" "k8s.io/utils/ptr" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" ) diff --git a/azure/converters/vm_test.go b/azure/converters/vm_test.go index c767c6f364b..5ae623267e5 100644 --- a/azure/converters/vm_test.go +++ b/azure/converters/vm_test.go @@ -23,6 +23,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v5" "github.com/google/go-cmp/cmp" "k8s.io/utils/ptr" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" ) @@ -125,7 +126,6 @@ func TestSDKToVM(t *testing.T) { }, } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() got := SDKToVM(tt.sdk) diff --git a/azure/converters/vmss.go b/azure/converters/vmss.go index 52257bfdbb8..a80613dcc02 100644 --- a/azure/converters/vmss.go +++ b/azure/converters/vmss.go @@ -22,6 +22,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v5" "k8s.io/utils/ptr" azprovider "sigs.k8s.io/cloud-provider-azure/pkg/provider" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" ) diff --git a/azure/converters/vmss_test.go b/azure/converters/vmss_test.go index e3d6d63a777..3331f9f2ad6 100644 --- a/azure/converters/vmss_test.go +++ b/azure/converters/vmss_test.go @@ -23,6 +23,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v5" "github.com/onsi/gomega" "k8s.io/utils/ptr" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" "sigs.k8s.io/cluster-api-provider-azure/azure/converters" @@ -113,7 +114,6 @@ func Test_SDKToVMSS(t *testing.T) { } for _, c := range cases { - c := c t.Run(c.Name, func(t *testing.T) { t.Parallel() g := gomega.NewGomegaWithT(t) @@ -205,7 +205,6 @@ func Test_SDKToVMSSVM(t *testing.T) { } for _, c := range cases { - c := c t.Run(c.Name, func(t *testing.T) { t.Parallel() g := gomega.NewGomegaWithT(t) @@ -314,7 +313,6 @@ func Test_SDKImageToImage(t *testing.T) { } for _, c := range cases { - c := c t.Run(c.Name, func(t *testing.T) { t.Parallel() g := gomega.NewGomegaWithT(t) @@ -400,7 +398,6 @@ func Test_SDKVMToVMSSVM(t *testing.T) { } for _, c := range cases { - c := c t.Run(c.Name, func(t *testing.T) { t.Parallel() g := gomega.NewGomegaWithT(t) diff --git a/azure/defaults.go b/azure/defaults.go index fb03dbfa069..abe3e66aee6 100644 --- a/azure/defaults.go +++ b/azure/defaults.go @@ -28,6 +28,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v5" "github.com/Azure/azure-sdk-for-go/sdk/tracing/azotel" + "sigs.k8s.io/cluster-api-provider-azure/pkg/ot" "sigs.k8s.io/cluster-api-provider-azure/util/tele" "sigs.k8s.io/cluster-api-provider-azure/version" diff --git a/azure/defaults_test.go b/azure/defaults_test.go index 254e62a6a26..88708df72cf 100644 --- a/azure/defaults_test.go +++ b/azure/defaults_test.go @@ -28,6 +28,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" . "github.com/onsi/gomega" "go.uber.org/mock/gomock" + "sigs.k8s.io/cluster-api-provider-azure/azure/mock_azure" "sigs.k8s.io/cluster-api-provider-azure/util/tele" ) @@ -67,7 +68,6 @@ func TestARMClientOptions(t *testing.T) { }, } for _, tc := range tests { - tc := tc t.Run(tc.name, func(t *testing.T) { t.Parallel() g := NewWithT(t) @@ -165,7 +165,6 @@ func TestCustomPutPatchHeaderPolicy(t *testing.T) { }, } for _, tc := range testcases { - tc := tc t.Run(tc.name, func(t *testing.T) { t.Parallel() g := NewWithT(t) diff --git a/azure/errors.go b/azure/errors.go index 35ae376dbf3..849801bf4e5 100644 --- a/azure/errors.go +++ b/azure/errors.go @@ -24,6 +24,7 @@ import ( "time" "github.com/Azure/azure-sdk-for-go/sdk/azcore" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" ) diff --git a/azure/errors_test.go b/azure/errors_test.go index d8ea18b333b..bb0b5befcf0 100644 --- a/azure/errors_test.go +++ b/azure/errors_test.go @@ -93,7 +93,6 @@ func TestResourceNotFound(t *testing.T) { }, } for _, tc := range tests { - tc := tc t.Run(tc.name, func(t *testing.T) { t.Parallel() if got := ResourceNotFound(tc.err); got != tc.success { diff --git a/azure/interfaces.go b/azure/interfaces.go index 774566a3f6e..2b57d9217e7 100644 --- a/azure/interfaces.go +++ b/azure/interfaces.go @@ -23,9 +23,10 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-service-operator/v2/pkg/genruntime" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" "sigs.k8s.io/controller-runtime/pkg/client" + + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" ) // Reconciler is a generic interface for a controller reconciler which has Reconcile and Delete methods. diff --git a/azure/regional_baseuri_test.go b/azure/regional_baseuri_test.go index 7bb8ad658f4..4120f0f65e2 100644 --- a/azure/regional_baseuri_test.go +++ b/azure/regional_baseuri_test.go @@ -21,6 +21,7 @@ import ( . "github.com/onsi/gomega" "go.uber.org/mock/gomock" + "sigs.k8s.io/cluster-api-provider-azure/azure/mock_azure" ) @@ -60,7 +61,6 @@ func TestWithRegionalBaseURI(t *testing.T) { } for _, c := range cases { - c := c t.Run(c.Name, func(t *testing.T) { g := NewWithT(t) mockCtrl := gomock.NewController(t) diff --git a/azure/scope/clients.go b/azure/scope/clients.go index 27bc8bbb6b1..b766b066747 100644 --- a/azure/scope/clients.go +++ b/azure/scope/clients.go @@ -27,6 +27,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore" azureautorest "github.com/Azure/go-autorest/autorest/azure" "github.com/Azure/go-autorest/autorest/azure/auth" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" ) diff --git a/azure/scope/cluster.go b/azure/scope/cluster.go index 00f3ac06cd6..8d67710b236 100644 --- a/azure/scope/cluster.go +++ b/azure/scope/cluster.go @@ -32,6 +32,11 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/utils/net" "k8s.io/utils/ptr" + clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" + "sigs.k8s.io/cluster-api/util/conditions" + "sigs.k8s.io/cluster-api/util/patch" + "sigs.k8s.io/controller-runtime/pkg/client" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" "sigs.k8s.io/cluster-api-provider-azure/azure/services/bastionhosts" @@ -48,10 +53,6 @@ import ( "sigs.k8s.io/cluster-api-provider-azure/azure/services/vnetpeerings" "sigs.k8s.io/cluster-api-provider-azure/util/futures" "sigs.k8s.io/cluster-api-provider-azure/util/tele" - clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" - "sigs.k8s.io/cluster-api/util/conditions" - "sigs.k8s.io/cluster-api/util/patch" - "sigs.k8s.io/controller-runtime/pkg/client" ) // ClusterScopeParams defines the input parameters used to create a new Scope. @@ -720,7 +721,7 @@ func (s *ClusterScope) APIServerPrivateIP() string { // GetPrivateDNSZoneName returns the Private DNS Zone from the spec or generate it from cluster name. func (s *ClusterScope) GetPrivateDNSZoneName() string { - if len(s.AzureCluster.Spec.NetworkSpec.PrivateDNSZoneName) > 0 { + if s.AzureCluster.Spec.NetworkSpec.PrivateDNSZoneName != "" { return s.AzureCluster.Spec.NetworkSpec.PrivateDNSZoneName } return azure.GeneratePrivateDNSZoneName(s.ClusterName()) diff --git a/azure/scope/cluster_test.go b/azure/scope/cluster_test.go index 9f7dd49fff6..f42d7270bd1 100644 --- a/azure/scope/cluster_test.go +++ b/azure/scope/cluster_test.go @@ -33,6 +33,9 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/utils/ptr" + clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" + "sigs.k8s.io/controller-runtime/pkg/client/fake" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" "sigs.k8s.io/cluster-api-provider-azure/azure/services/bastionhosts" @@ -45,8 +48,6 @@ import ( "sigs.k8s.io/cluster-api-provider-azure/azure/services/securitygroups" "sigs.k8s.io/cluster-api-provider-azure/azure/services/subnets" "sigs.k8s.io/cluster-api-provider-azure/azure/services/vnetpeerings" - clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" - "sigs.k8s.io/controller-runtime/pkg/client/fake" ) const fakeClientID = "fake-client-id" @@ -193,7 +194,6 @@ func TestAPIServerHost(t *testing.T) { } for _, tc := range tests { - tc := tc g := NewWithT(t) cluster := &clusterv1.Cluster{ @@ -794,7 +794,6 @@ func TestRouteTableSpecs(t *testing.T) { } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() if got := tt.clusterScope.RouteTableSpecs(); !reflect.DeepEqual(got, tt.want) { @@ -1090,7 +1089,6 @@ func TestNatGatewaySpecs(t *testing.T) { } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() fakeIdentity := &infrav1.AzureClusterIdentity{ @@ -1173,7 +1171,6 @@ func TestSetNatGatewayIDInSubnets(t *testing.T) { } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { g := NewWithT(t) t.Parallel() @@ -1263,7 +1260,6 @@ func TestNSGSpecs(t *testing.T) { } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() if got := tt.clusterScope.NSGSpecs(); !reflect.DeepEqual(got, tt.want) { @@ -1500,7 +1496,6 @@ func TestSubnetSpecs(t *testing.T) { } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() fakeIdentity := &infrav1.AzureClusterIdentity{ @@ -1628,7 +1623,6 @@ func TestIsVnetManaged(t *testing.T) { } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() fakeIdentity := &infrav1.AzureClusterIdentity{ @@ -1781,7 +1775,6 @@ func TestAzureBastionSpec(t *testing.T) { } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() if got := tt.clusterScope.AzureBastionSpec(); !reflect.DeepEqual(got, tt.want) { @@ -2793,7 +2786,6 @@ func TestClusterScope_LBSpecs(t *testing.T) { }, } for _, tc := range tests { - tc := tc t.Run(tc.name, func(t *testing.T) { t.Parallel() @@ -3373,7 +3365,6 @@ func TestPrivateEndpointSpecs(t *testing.T) { } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() if got := tt.clusterScope.PrivateEndpointSpecs(); !reflect.DeepEqual(got, tt.want) { @@ -3422,7 +3413,6 @@ func TestSetFailureDomain(t *testing.T) { } for name, tc := range cases { - tc := tc t.Run(name, func(t *testing.T) { t.Parallel() g := NewWithT(t) @@ -3598,7 +3588,6 @@ func TestGroupSpecs(t *testing.T) { } for _, c := range cases { - c := c t.Run(c.name, func(t *testing.T) { s := &ClusterScope{ AzureCluster: c.input.AzureCluster, diff --git a/azure/scope/identity.go b/azure/scope/identity.go index c401d5b7db4..7c76bc8dbc0 100644 --- a/azure/scope/identity.go +++ b/azure/scope/identity.go @@ -28,10 +28,11 @@ import ( corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" + "sigs.k8s.io/controller-runtime/pkg/client" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/pkg/ot" "sigs.k8s.io/cluster-api-provider-azure/util/tele" - "sigs.k8s.io/controller-runtime/pkg/client" ) // AzureSecretKey is the value for they client secret key. diff --git a/azure/scope/identity_test.go b/azure/scope/identity_test.go index c9f8d4c5c6c..384e5ae4a74 100644 --- a/azure/scope/identity_test.go +++ b/azure/scope/identity_test.go @@ -25,8 +25,9 @@ import ( corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" - infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/controller-runtime/pkg/client/fake" + + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" ) func TestAllowedNamespaces(t *testing.T) { @@ -339,7 +340,6 @@ func TestGetTokenCredential(t *testing.T) { _ = infrav1.AddToScheme(scheme) _ = corev1.AddToScheme(scheme) for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() g := NewWithT(t) diff --git a/azure/scope/machine.go b/azure/scope/machine.go index 278e0f6afb2..153b009fad5 100644 --- a/azure/scope/machine.go +++ b/azure/scope/machine.go @@ -28,6 +28,13 @@ import ( corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/types" "k8s.io/utils/ptr" + clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" + capierrors "sigs.k8s.io/cluster-api/errors" + "sigs.k8s.io/cluster-api/util" + "sigs.k8s.io/cluster-api/util/conditions" + "sigs.k8s.io/cluster-api/util/patch" + "sigs.k8s.io/controller-runtime/pkg/client" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" "sigs.k8s.io/cluster-api-provider-azure/azure/services/availabilitysets" @@ -43,12 +50,6 @@ import ( azureutil "sigs.k8s.io/cluster-api-provider-azure/util/azure" "sigs.k8s.io/cluster-api-provider-azure/util/futures" "sigs.k8s.io/cluster-api-provider-azure/util/tele" - clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" - capierrors "sigs.k8s.io/cluster-api/errors" - "sigs.k8s.io/cluster-api/util" - "sigs.k8s.io/cluster-api/util/conditions" - "sigs.k8s.io/cluster-api/util/patch" - "sigs.k8s.io/controller-runtime/pkg/client" ) // MachineScopeParams defines the input parameters used to create a new MachineScope. diff --git a/azure/scope/machine_test.go b/azure/scope/machine_test.go index 98c772c51f5..f9f5b59683e 100644 --- a/azure/scope/machine_test.go +++ b/azure/scope/machine_test.go @@ -31,6 +31,8 @@ import ( "k8s.io/apimachinery/pkg/api/resource" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/utils/ptr" + clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" "sigs.k8s.io/cluster-api-provider-azure/azure/mock_azure" @@ -43,7 +45,6 @@ import ( "sigs.k8s.io/cluster-api-provider-azure/azure/services/virtualmachineimages" "sigs.k8s.io/cluster-api-provider-azure/azure/services/virtualmachineimages/mock_virtualmachineimages" "sigs.k8s.io/cluster-api-provider-azure/azure/services/vmextensions" - clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" ) func TestMachineScope_Name(t *testing.T) { @@ -411,7 +412,6 @@ func TestMachineScope_InboundNatSpecs(t *testing.T) { }, } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() if got := tt.machineScope.InboundNatSpecs(); !reflect.DeepEqual(got, tt.want) { @@ -3153,7 +3153,6 @@ func TestDiskSpecs(t *testing.T) { } for _, tt := range testcases { - tt := tt t.Run(tt.name, func(t *testing.T) { g := NewWithT(t) diff --git a/azure/scope/machinepool.go b/azure/scope/machinepool.go index 611a6aa5c57..e5cbdc7452e 100644 --- a/azure/scope/machinepool.go +++ b/azure/scope/machinepool.go @@ -32,6 +32,17 @@ import ( "k8s.io/apimachinery/pkg/types" "k8s.io/klog/v2" "k8s.io/utils/ptr" + clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" + capierrors "sigs.k8s.io/cluster-api/errors" + expv1 "sigs.k8s.io/cluster-api/exp/api/v1beta1" + "sigs.k8s.io/cluster-api/util" + "sigs.k8s.io/cluster-api/util/annotations" + "sigs.k8s.io/cluster-api/util/conditions" + "sigs.k8s.io/cluster-api/util/labels/format" + "sigs.k8s.io/cluster-api/util/patch" + "sigs.k8s.io/controller-runtime/pkg/client" + "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" machinepool "sigs.k8s.io/cluster-api-provider-azure/azure/scope/strategies/machinepool_deployments" @@ -43,16 +54,6 @@ import ( azureutil "sigs.k8s.io/cluster-api-provider-azure/util/azure" "sigs.k8s.io/cluster-api-provider-azure/util/futures" "sigs.k8s.io/cluster-api-provider-azure/util/tele" - clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" - capierrors "sigs.k8s.io/cluster-api/errors" - expv1 "sigs.k8s.io/cluster-api/exp/api/v1beta1" - "sigs.k8s.io/cluster-api/util" - "sigs.k8s.io/cluster-api/util/annotations" - "sigs.k8s.io/cluster-api/util/conditions" - "sigs.k8s.io/cluster-api/util/labels/format" - "sigs.k8s.io/cluster-api/util/patch" - "sigs.k8s.io/controller-runtime/pkg/client" - "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" ) // ScalesetsServiceName is the name of the scalesets service. @@ -452,7 +453,6 @@ func (m *MachinePoolScope) applyAzureMachinePoolMachines(ctx context.Context) er deleted := false // Delete MachinePool Machines for instances that no longer exist in Azure, i.e. deleted out-of-band for key, ampm := range existingMachinesByProviderID { - ampm := ampm if _, ok := azureMachinesByProviderID[key]; !ok { deleted = true log.V(4).Info("deleting AzureMachinePoolMachine because it no longer exists in the VMSS", "providerID", key) @@ -948,12 +948,12 @@ func (m *MachinePoolScope) PatchCAPIMachinePoolObject(ctx context.Context) error } // UpdateCAPIMachinePoolReplicas updates the associated MachinePool replica count. -func (m *MachinePoolScope) UpdateCAPIMachinePoolReplicas(ctx context.Context, replicas *int32) { +func (m *MachinePoolScope) UpdateCAPIMachinePoolReplicas(_ context.Context, replicas *int32) { m.MachinePool.Spec.Replicas = replicas } // HasReplicasExternallyManaged returns true if the externally managed annotation is set on the CAPI MachinePool resource. -func (m *MachinePoolScope) HasReplicasExternallyManaged(ctx context.Context) bool { +func (m *MachinePoolScope) HasReplicasExternallyManaged(_ context.Context) bool { return annotations.ReplicasManagedByExternalAutoscaler(m.MachinePool) } @@ -963,7 +963,7 @@ func (m *MachinePoolScope) ReconcileReplicas(ctx context.Context, vmss *azure.VM return nil } - var replicas int32 = 0 + var replicas int32 if m.MachinePool.Spec.Replicas != nil { replicas = *m.MachinePool.Spec.Replicas } diff --git a/azure/scope/machinepool_test.go b/azure/scope/machinepool_test.go index 83d8b5d740c..895d5c668a8 100644 --- a/azure/scope/machinepool_test.go +++ b/azure/scope/machinepool_test.go @@ -34,6 +34,11 @@ import ( "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/util/intstr" "k8s.io/utils/ptr" + clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" + expv1 "sigs.k8s.io/cluster-api/exp/api/v1beta1" + "sigs.k8s.io/controller-runtime/pkg/client" + "sigs.k8s.io/controller-runtime/pkg/client/fake" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" "sigs.k8s.io/cluster-api-provider-azure/azure/mock_azure" @@ -41,10 +46,6 @@ import ( "sigs.k8s.io/cluster-api-provider-azure/azure/services/roleassignments" "sigs.k8s.io/cluster-api-provider-azure/azure/services/scalesets" infrav1exp "sigs.k8s.io/cluster-api-provider-azure/exp/api/v1beta1" - clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" - expv1 "sigs.k8s.io/cluster-api/exp/api/v1beta1" - "sigs.k8s.io/controller-runtime/pkg/client" - "sigs.k8s.io/controller-runtime/pkg/client/fake" ) func TestMachinePoolScope_Name(t *testing.T) { @@ -1330,7 +1331,6 @@ func TestMachinePoolScope_SetInfrastructureMachineKind(t *testing.T) { } for _, tt := range testcases { - tt := tt t.Run(tt.name, func(t *testing.T) { g := NewWithT(t) diff --git a/azure/scope/machinepoolmachine.go b/azure/scope/machinepoolmachine.go index 80661e9361e..1f26c7f05b6 100644 --- a/azure/scope/machinepoolmachine.go +++ b/azure/scope/machinepoolmachine.go @@ -25,14 +25,6 @@ import ( corev1 "k8s.io/api/core/v1" apierrors "k8s.io/apimachinery/pkg/api/errors" "k8s.io/utils/ptr" - infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" - "sigs.k8s.io/cluster-api-provider-azure/azure" - "sigs.k8s.io/cluster-api-provider-azure/azure/converters" - "sigs.k8s.io/cluster-api-provider-azure/azure/services/scalesetvms" - infrav1exp "sigs.k8s.io/cluster-api-provider-azure/exp/api/v1beta1" - azureutil "sigs.k8s.io/cluster-api-provider-azure/util/azure" - "sigs.k8s.io/cluster-api-provider-azure/util/futures" - "sigs.k8s.io/cluster-api-provider-azure/util/tele" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" "sigs.k8s.io/cluster-api/controllers/noderefutil" "sigs.k8s.io/cluster-api/controllers/remote" @@ -41,6 +33,15 @@ import ( "sigs.k8s.io/cluster-api/util/conditions" "sigs.k8s.io/cluster-api/util/patch" "sigs.k8s.io/controller-runtime/pkg/client" + + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" + "sigs.k8s.io/cluster-api-provider-azure/azure" + "sigs.k8s.io/cluster-api-provider-azure/azure/converters" + "sigs.k8s.io/cluster-api-provider-azure/azure/services/scalesetvms" + infrav1exp "sigs.k8s.io/cluster-api-provider-azure/exp/api/v1beta1" + azureutil "sigs.k8s.io/cluster-api-provider-azure/util/azure" + "sigs.k8s.io/cluster-api-provider-azure/util/futures" + "sigs.k8s.io/cluster-api-provider-azure/util/tele" ) const ( diff --git a/azure/scope/machinepoolmachine_test.go b/azure/scope/machinepoolmachine_test.go index d92bc83c5a5..5d9186cd55c 100644 --- a/azure/scope/machinepoolmachine_test.go +++ b/azure/scope/machinepoolmachine_test.go @@ -29,6 +29,11 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/utils/ptr" + clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" + expv1 "sigs.k8s.io/cluster-api/exp/api/v1beta1" + "sigs.k8s.io/cluster-api/util/conditions" + "sigs.k8s.io/controller-runtime/pkg/client/fake" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" "sigs.k8s.io/cluster-api-provider-azure/azure/mock_azure" @@ -36,10 +41,6 @@ import ( "sigs.k8s.io/cluster-api-provider-azure/azure/services/scalesetvms" infrav1exp "sigs.k8s.io/cluster-api-provider-azure/exp/api/v1beta1" gomock2 "sigs.k8s.io/cluster-api-provider-azure/internal/test/matchers/gomock" - clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" - expv1 "sigs.k8s.io/cluster-api/exp/api/v1beta1" - "sigs.k8s.io/cluster-api/util/conditions" - "sigs.k8s.io/controller-runtime/pkg/client/fake" ) const ( @@ -306,7 +307,6 @@ func TestMachineScope_updateDeleteMachineAnnotation(t *testing.T) { } for _, c := range cases { - c := c t.Run(c.name, func(t *testing.T) { g := NewWithT(t) diff --git a/azure/scope/managedcontrolplane.go b/azure/scope/managedcontrolplane.go index 81ac2da5741..62760b7b83b 100644 --- a/azure/scope/managedcontrolplane.go +++ b/azure/scope/managedcontrolplane.go @@ -38,6 +38,14 @@ import ( clientcmdapi "k8s.io/client-go/tools/clientcmd/api" bootstrapapi "k8s.io/cluster-bootstrap/token/api" "k8s.io/utils/ptr" + clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" + "sigs.k8s.io/cluster-api/controllers/remote" + "sigs.k8s.io/cluster-api/util/conditions" + "sigs.k8s.io/cluster-api/util/patch" + "sigs.k8s.io/cluster-api/util/secret" + "sigs.k8s.io/controller-runtime/pkg/client" + "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" "sigs.k8s.io/cluster-api-provider-azure/azure/services/aksextensions" @@ -49,13 +57,6 @@ import ( "sigs.k8s.io/cluster-api-provider-azure/azure/services/virtualnetworks" "sigs.k8s.io/cluster-api-provider-azure/util/futures" "sigs.k8s.io/cluster-api-provider-azure/util/tele" - clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" - "sigs.k8s.io/cluster-api/controllers/remote" - "sigs.k8s.io/cluster-api/util/conditions" - "sigs.k8s.io/cluster-api/util/patch" - "sigs.k8s.io/cluster-api/util/secret" - "sigs.k8s.io/controller-runtime/pkg/client" - "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" ) const ( diff --git a/azure/scope/managedcontrolplane_test.go b/azure/scope/managedcontrolplane_test.go index b14a4168b20..10de5b2685a 100644 --- a/azure/scope/managedcontrolplane_test.go +++ b/azure/scope/managedcontrolplane_test.go @@ -30,6 +30,10 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/utils/ptr" + clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" + expv1 "sigs.k8s.io/cluster-api/exp/api/v1beta1" + "sigs.k8s.io/controller-runtime/pkg/client/fake" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" "sigs.k8s.io/cluster-api-provider-azure/azure/services/agentpools" @@ -37,9 +41,6 @@ import ( "sigs.k8s.io/cluster-api-provider-azure/azure/services/groups" "sigs.k8s.io/cluster-api-provider-azure/azure/services/managedclusters" "sigs.k8s.io/cluster-api-provider-azure/azure/services/privateendpoints" - clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" - expv1 "sigs.k8s.io/cluster-api/exp/api/v1beta1" - "sigs.k8s.io/controller-runtime/pkg/client/fake" ) func TestNewManagedControlPlaneScope(t *testing.T) { @@ -135,7 +136,6 @@ func TestManagedControlPlaneScope_OutboundType(t *testing.T) { }, } for _, c := range cases { - c := c t.Run(c.Name, func(t *testing.T) { g := NewWithT(t) @@ -347,7 +347,6 @@ func TestManagedControlPlaneScope_AddonProfiles(t *testing.T) { } for _, c := range cases { - c := c t.Run(c.Name, func(t *testing.T) { g := NewWithT(t) managedCluster := c.Scope.ManagedClusterSpec() @@ -468,7 +467,6 @@ func TestManagedControlPlaneScope_OSType(t *testing.T) { } for _, c := range cases { - c := c t.Run(c.Name, func(t *testing.T) { g := NewWithT(t) agentPools, err := c.Scope.GetAllAgentPoolSpecs() @@ -621,7 +619,6 @@ func TestManagedControlPlaneScope_IsVnetManagedCache(t *testing.T) { } for _, c := range cases { - c := c t.Run(c.Name, func(t *testing.T) { g := NewWithT(t) initObjects := []runtime.Object{c.Scope.ControlPlane} @@ -1064,7 +1061,6 @@ func TestManagedControlPlaneScope_PrivateEndpointSpecs(t *testing.T) { }, } for _, c := range cases { - c := c t.Run(c.Name, func(t *testing.T) { s := &ManagedControlPlaneScope{ ControlPlane: c.Input.ControlPlane, @@ -1168,7 +1164,6 @@ func TestManagedControlPlaneScope_AKSExtensionSpecs(t *testing.T) { } for _, c := range cases { - c := c t.Run(c.Name, func(t *testing.T) { s := &ManagedControlPlaneScope{ ControlPlane: c.Input.ControlPlane, @@ -1252,7 +1247,6 @@ func TestManagedControlPlaneScope_AutoUpgradeProfile(t *testing.T) { }, } for _, c := range cases { - c := c t.Run(c.name, func(t *testing.T) { g := NewWithT(t) s := &ManagedControlPlaneScope{ @@ -1409,7 +1403,6 @@ func TestManagedControlPlaneScope_GroupSpecs(t *testing.T) { } for _, c := range cases { - c := c t.Run(c.name, func(t *testing.T) { s := &ManagedControlPlaneScope{ ControlPlane: c.input.ControlPlane, diff --git a/azure/scope/managedmachinepool.go b/azure/scope/managedmachinepool.go index d25b21ecaad..f6093c63654 100644 --- a/azure/scope/managedmachinepool.go +++ b/azure/scope/managedmachinepool.go @@ -24,17 +24,18 @@ import ( "github.com/Azure/azure-service-operator/v2/pkg/genruntime" "github.com/pkg/errors" "k8s.io/utils/ptr" + clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" + expv1 "sigs.k8s.io/cluster-api/exp/api/v1beta1" + "sigs.k8s.io/cluster-api/util/conditions" + "sigs.k8s.io/cluster-api/util/patch" + "sigs.k8s.io/controller-runtime/pkg/client" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" "sigs.k8s.io/cluster-api-provider-azure/azure/services/agentpools" "sigs.k8s.io/cluster-api-provider-azure/util/futures" "sigs.k8s.io/cluster-api-provider-azure/util/tele" "sigs.k8s.io/cluster-api-provider-azure/util/versions" - clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" - expv1 "sigs.k8s.io/cluster-api/exp/api/v1beta1" - "sigs.k8s.io/cluster-api/util/conditions" - "sigs.k8s.io/cluster-api/util/patch" - "sigs.k8s.io/controller-runtime/pkg/client" ) // ManagedMachinePoolScopeParams defines the input parameters used to create a new managed diff --git a/azure/scope/managedmachinepool_test.go b/azure/scope/managedmachinepool_test.go index 44ccba9aa6b..9b6154b585c 100644 --- a/azure/scope/managedmachinepool_test.go +++ b/azure/scope/managedmachinepool_test.go @@ -28,12 +28,13 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/utils/ptr" - infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" - "sigs.k8s.io/cluster-api-provider-azure/azure" - "sigs.k8s.io/cluster-api-provider-azure/azure/services/agentpools" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" expv1 "sigs.k8s.io/cluster-api/exp/api/v1beta1" "sigs.k8s.io/controller-runtime/pkg/client/fake" + + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" + "sigs.k8s.io/cluster-api-provider-azure/azure" + "sigs.k8s.io/cluster-api-provider-azure/azure/services/agentpools" ) func TestNewManagedMachinePoolScope(t *testing.T) { @@ -742,7 +743,6 @@ func TestManagedMachinePoolScope_EnablePreviewFeatures(t *testing.T) { }, } for _, c := range cases { - c := c t.Run(c.Name, func(t *testing.T) { g := NewWithT(t) s := &ManagedMachinePoolScope{ @@ -907,11 +907,11 @@ func getAzureMachinePool(name string, mode infrav1.NodePoolMode) *infrav1.AzureM } } -func getAzureMachinePoolWithScaling(name string, min, max int) *infrav1.AzureManagedMachinePool { +func getAzureMachinePoolWithScaling(name string, minVal, maxVal int) *infrav1.AzureManagedMachinePool { managedPool := getAzureMachinePool(name, infrav1.NodePoolModeUser) managedPool.Spec.Scaling = &infrav1.ManagedMachinePoolScaling{ - MinSize: ptr.To(min), - MaxSize: ptr.To(max), + MinSize: ptr.To(minVal), + MaxSize: ptr.To(maxVal), } return managedPool } diff --git a/azure/scope/strategies/machinepool_deployments/machinepool_deployment_strategy.go b/azure/scope/strategies/machinepool_deployments/machinepool_deployment_strategy.go index 30afa56a8ab..d213060388b 100644 --- a/azure/scope/strategies/machinepool_deployments/machinepool_deployment_strategy.go +++ b/azure/scope/strategies/machinepool_deployments/machinepool_deployment_strategy.go @@ -24,11 +24,12 @@ import ( "github.com/pkg/errors" "k8s.io/apimachinery/pkg/util/intstr" + clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" + ctrl "sigs.k8s.io/controller-runtime" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" infrav1exp "sigs.k8s.io/cluster-api-provider-azure/exp/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/util/tele" - clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" - ctrl "sigs.k8s.io/controller-runtime" ) type ( @@ -325,7 +326,7 @@ func orderRandom(machines []infrav1exp.AzureMachinePoolMachine) []infrav1exp.Azu // orderByDeleteMachineAnnotation will sort AzureMachinePoolMachines with the clusterv1.DeleteMachineAnnotation to the front of the list. // It will preserve the existing order of the list otherwise so that it respects the existing delete priority otherwise. func orderByDeleteMachineAnnotation(machines []infrav1exp.AzureMachinePoolMachine) []infrav1exp.AzureMachinePoolMachine { - sort.SliceStable(machines, func(i, j int) bool { + sort.SliceStable(machines, func(i, _ int) bool { _, iHasAnnotation := machines[i].Annotations[clusterv1.DeleteMachineAnnotation] return iHasAnnotation 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 0d429f87b4c..066acaf0c06 100644 --- a/azure/scope/strategies/machinepool_deployments/machinepool_deployment_strategy_test.go +++ b/azure/scope/strategies/machinepool_deployments/machinepool_deployment_strategy_test.go @@ -25,10 +25,11 @@ import ( "github.com/onsi/gomega/types" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/intstr" + clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" infrav1exp "sigs.k8s.io/cluster-api-provider-azure/exp/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/internal/test/matchers/gomega" - clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" ) func TestMachinePoolRollingUpdateStrategy_Type(t *testing.T) { diff --git a/azure/services/agentpools/agentpools.go b/azure/services/agentpools/agentpools.go index cce10ea6407..dbe155a1692 100644 --- a/azure/services/agentpools/agentpools.go +++ b/azure/services/agentpools/agentpools.go @@ -22,11 +22,12 @@ import ( asocontainerservicev1hub "github.com/Azure/azure-service-operator/v2/api/containerservice/v1api20231001/storage" "github.com/Azure/azure-service-operator/v2/pkg/genruntime" "k8s.io/utils/ptr" + clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" + "sigs.k8s.io/controller-runtime/pkg/conversion" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" "sigs.k8s.io/cluster-api-provider-azure/azure/services/aso" - clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" - "sigs.k8s.io/controller-runtime/pkg/conversion" ) const serviceName = "agentpools" @@ -57,7 +58,7 @@ func New(scope AgentPoolScope) *aso.Service[genruntime.MetaObject, AgentPoolScop return svc } -func postCreateOrUpdateResourceHook(ctx context.Context, scope AgentPoolScope, obj genruntime.MetaObject, err error) error { +func postCreateOrUpdateResourceHook(_ context.Context, scope AgentPoolScope, obj genruntime.MetaObject, err error) error { if err != nil { return err } diff --git a/azure/services/agentpools/agentpools_test.go b/azure/services/agentpools/agentpools_test.go index ab0b759a6fc..01bdfa83da8 100644 --- a/azure/services/agentpools/agentpools_test.go +++ b/azure/services/agentpools/agentpools_test.go @@ -26,8 +26,9 @@ import ( "github.com/pkg/errors" "go.uber.org/mock/gomock" "k8s.io/utils/ptr" - "sigs.k8s.io/cluster-api-provider-azure/azure/services/agentpools/mock_agentpools" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" + + "sigs.k8s.io/cluster-api-provider-azure/azure/services/agentpools/mock_agentpools" ) func TestPostCreateOrUpdateResourceHook(t *testing.T) { diff --git a/azure/services/agentpools/spec.go b/azure/services/agentpools/spec.go index 913fe14d562..4286ca38c9c 100644 --- a/azure/services/agentpools/spec.go +++ b/azure/services/agentpools/spec.go @@ -26,12 +26,13 @@ import ( "k8s.io/apimachinery/pkg/api/resource" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/utils/ptr" + "sigs.k8s.io/controller-runtime/pkg/conversion" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" "sigs.k8s.io/cluster-api-provider-azure/azure/services/aso" "sigs.k8s.io/cluster-api-provider-azure/util/tele" "sigs.k8s.io/cluster-api-provider-azure/util/versions" - "sigs.k8s.io/controller-runtime/pkg/conversion" ) // KubeletConfig defines the set of kubelet configurations for nodes in pools. @@ -342,7 +343,7 @@ func (s *AgentPoolSpec) Parameters(ctx context.Context, existingObj genruntime.M } // WasManaged implements azure.ASOResourceSpecGetter. -func (s *AgentPoolSpec) WasManaged(resource genruntime.MetaObject) bool { +func (s *AgentPoolSpec) WasManaged(_ genruntime.MetaObject) bool { // CAPZ has never supported BYO agent pools. return true } diff --git a/azure/services/agentpools/spec_test.go b/azure/services/agentpools/spec_test.go index ae25f798133..d4b31e9e6ba 100644 --- a/azure/services/agentpools/spec_test.go +++ b/azure/services/agentpools/spec_test.go @@ -27,6 +27,7 @@ import ( . "github.com/onsi/gomega" "k8s.io/apimachinery/pkg/api/resource" "k8s.io/utils/ptr" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" ) diff --git a/azure/services/aksextensions/aksextensions.go b/azure/services/aksextensions/aksextensions.go index 8924a1eca64..a925e5bee74 100644 --- a/azure/services/aksextensions/aksextensions.go +++ b/azure/services/aksextensions/aksextensions.go @@ -20,11 +20,12 @@ import ( "context" asokubernetesconfigurationv1 "github.com/Azure/azure-service-operator/v2/api/kubernetesconfiguration/v1api20230501" + "sigs.k8s.io/controller-runtime/pkg/client" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" "sigs.k8s.io/cluster-api-provider-azure/azure/services/aso" "sigs.k8s.io/cluster-api-provider-azure/util/slice" - "sigs.k8s.io/controller-runtime/pkg/client" ) const serviceName = "extension" diff --git a/azure/services/aksextensions/spec.go b/azure/services/aksextensions/spec.go index 4b179f4567a..c0c3bcbe526 100644 --- a/azure/services/aksextensions/spec.go +++ b/azure/services/aksextensions/spec.go @@ -23,6 +23,7 @@ import ( "github.com/Azure/azure-service-operator/v2/pkg/genruntime" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/utils/ptr" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" ) @@ -55,7 +56,7 @@ func (s *AKSExtensionSpec) ResourceRef() *asokubernetesconfigurationv1.Extension } // Parameters implements azure.ASOResourceSpecGetter. -func (s *AKSExtensionSpec) Parameters(ctx context.Context, existingAKSExtension *asokubernetesconfigurationv1.Extension) (parameters *asokubernetesconfigurationv1.Extension, err error) { +func (s *AKSExtensionSpec) Parameters(_ context.Context, existingAKSExtension *asokubernetesconfigurationv1.Extension) (parameters *asokubernetesconfigurationv1.Extension, err error) { aksExtension := &asokubernetesconfigurationv1.Extension{} if existingAKSExtension != nil { aksExtension = existingAKSExtension @@ -108,7 +109,7 @@ func (s *AKSExtensionSpec) Parameters(ctx context.Context, existingAKSExtension } // WasManaged implements azure.ASOResourceSpecGetter. -func (s *AKSExtensionSpec) WasManaged(resource *asokubernetesconfigurationv1.Extension) bool { +func (s *AKSExtensionSpec) WasManaged(_ *asokubernetesconfigurationv1.Extension) bool { // returns always returns true as CAPZ does not support BYO extension. return true } diff --git a/azure/services/aksextensions/spec_test.go b/azure/services/aksextensions/spec_test.go index b127cce519c..309e1d7e83e 100644 --- a/azure/services/aksextensions/spec_test.go +++ b/azure/services/aksextensions/spec_test.go @@ -25,6 +25,7 @@ import ( . "github.com/onsi/gomega" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/utils/ptr" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" ) @@ -137,7 +138,6 @@ func TestAzureAKSExtensionSpec_Parameters(t *testing.T) { }, } for _, tc := range testcases { - tc := tc t.Run(tc.name, func(t *testing.T) { g := NewWithT(t) t.Parallel() diff --git a/azure/services/aso/aso.go b/azure/services/aso/aso.go index c79af673fc3..56cb356c2e2 100644 --- a/azure/services/aso/aso.go +++ b/azure/services/aso/aso.go @@ -33,14 +33,15 @@ import ( "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/serializer" "k8s.io/apimachinery/pkg/util/yaml" - infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" - "sigs.k8s.io/cluster-api-provider-azure/azure" - "sigs.k8s.io/cluster-api-provider-azure/util/aso" - "sigs.k8s.io/cluster-api-provider-azure/util/tele" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/client/apiutil" "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" + + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" + "sigs.k8s.io/cluster-api-provider-azure/azure" + "sigs.k8s.io/cluster-api-provider-azure/util/aso" + "sigs.k8s.io/cluster-api-provider-azure/util/tele" ) const ( @@ -302,7 +303,7 @@ func (r *reconciler[T]) createOrUpdateResource(ctx context.Context, existing T, Name: parameters.GetName(), }), requeueInterval) } - return zero, errors.Wrapf(err, fmt.Sprintf("failed to %se resource %s/%s (service: %s)", logMessageVerbPrefix, parameters.GetNamespace(), parameters.GetName(), serviceName)) + return zero, errors.Wrapf(err, "failed to %se resource %s/%s (service: %s)", logMessageVerbPrefix, parameters.GetNamespace(), parameters.GetName(), serviceName) } // DeleteResource implements the logic for deleting a resource Asynchronously. diff --git a/azure/services/aso/aso_test.go b/azure/services/aso/aso_test.go index a0e127feac0..5f6e56f44b4 100644 --- a/azure/services/aso/aso_test.go +++ b/azure/services/aso/aso_test.go @@ -30,15 +30,16 @@ import ( "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/types" "k8s.io/utils/ptr" + clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" + "sigs.k8s.io/controller-runtime/pkg/client" + "sigs.k8s.io/controller-runtime/pkg/client/apiutil" + fakeclient "sigs.k8s.io/controller-runtime/pkg/client/fake" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" "sigs.k8s.io/cluster-api-provider-azure/azure/mock_azure" "sigs.k8s.io/cluster-api-provider-azure/azure/services/aso/mock_aso" gomockinternal "sigs.k8s.io/cluster-api-provider-azure/internal/test/matchers/gomock" - clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" - "sigs.k8s.io/controller-runtime/pkg/client" - "sigs.k8s.io/controller-runtime/pkg/client/apiutil" - fakeclient "sigs.k8s.io/controller-runtime/pkg/client/fake" ) const clusterName = "cluster" diff --git a/azure/services/aso/interfaces.go b/azure/services/aso/interfaces.go index 0acbafac75b..9e3bda9eea4 100644 --- a/azure/services/aso/interfaces.go +++ b/azure/services/aso/interfaces.go @@ -20,9 +20,10 @@ import ( "context" "github.com/Azure/azure-service-operator/v2/pkg/genruntime" + "sigs.k8s.io/controller-runtime/pkg/client" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" - "sigs.k8s.io/controller-runtime/pkg/client" ) // Reconciler is a generic interface used to perform reconciliation of Azure resources backed by ASO. diff --git a/azure/services/aso/service.go b/azure/services/aso/service.go index 7eaf4639124..bb8ebe09cb7 100644 --- a/azure/services/aso/service.go +++ b/azure/services/aso/service.go @@ -21,10 +21,11 @@ import ( "github.com/Azure/azure-service-operator/v2/pkg/genruntime" "github.com/pkg/errors" - "sigs.k8s.io/cluster-api-provider-azure/azure" - "sigs.k8s.io/cluster-api-provider-azure/util/tele" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" "sigs.k8s.io/controller-runtime/pkg/client" + + "sigs.k8s.io/cluster-api-provider-azure/azure" + "sigs.k8s.io/cluster-api-provider-azure/util/tele" ) // Service provides operations on Azure resources. diff --git a/azure/services/aso/service_test.go b/azure/services/aso/service_test.go index d03d8bbc1c9..fb4930ce546 100644 --- a/azure/services/aso/service_test.go +++ b/azure/services/aso/service_test.go @@ -26,15 +26,16 @@ import ( "go.uber.org/mock/gomock" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" + clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" + "sigs.k8s.io/controller-runtime/pkg/client" + "sigs.k8s.io/controller-runtime/pkg/client/fake" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" "sigs.k8s.io/cluster-api-provider-azure/azure/mock_azure" "sigs.k8s.io/cluster-api-provider-azure/azure/services/aso/mock_aso" gomockinternal "sigs.k8s.io/cluster-api-provider-azure/internal/test/matchers/gomock" reconcilerutils "sigs.k8s.io/cluster-api-provider-azure/util/reconciler" - clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" - "sigs.k8s.io/controller-runtime/pkg/client" - "sigs.k8s.io/controller-runtime/pkg/client/fake" ) const ( diff --git a/azure/services/aso/tags.go b/azure/services/aso/tags.go index 0a830fc1093..134fa254b62 100644 --- a/azure/services/aso/tags.go +++ b/azure/services/aso/tags.go @@ -21,6 +21,7 @@ import ( "github.com/Azure/azure-service-operator/v2/pkg/genruntime" "github.com/pkg/errors" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure/converters" "sigs.k8s.io/cluster-api-provider-azure/azure/services/tags" diff --git a/azure/services/aso/tags_test.go b/azure/services/aso/tags_test.go index 9fc5a87f256..442214595a7 100644 --- a/azure/services/aso/tags_test.go +++ b/azure/services/aso/tags_test.go @@ -24,6 +24,7 @@ import ( . "github.com/onsi/gomega" "go.uber.org/mock/gomock" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure/services/aso/mock_aso" ) diff --git a/azure/services/async/async.go b/azure/services/async/async.go index 58ad1f473bb..afadc2864d8 100644 --- a/azure/services/async/async.go +++ b/azure/services/async/async.go @@ -24,6 +24,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/pkg/errors" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" "sigs.k8s.io/cluster-api-provider-azure/azure/converters" diff --git a/azure/services/async/async_test.go b/azure/services/async/async_test.go index 9d90a9f92af..b6f2cc1b4b3 100644 --- a/azure/services/async/async_test.go +++ b/azure/services/async/async_test.go @@ -32,6 +32,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources" . "github.com/onsi/gomega" "go.uber.org/mock/gomock" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" "sigs.k8s.io/cluster-api-provider-azure/azure/mock_azure" @@ -168,7 +169,6 @@ func TestServiceCreateOrUpdateResource(t *testing.T) { } for _, tc := range testcases { - tc := tc t.Run(tc.name, func(t *testing.T) { g := NewWithT(t) @@ -265,7 +265,6 @@ func TestServiceDeleteResource(t *testing.T) { } for _, tc := range testcases { - tc := tc t.Run(tc.name, func(t *testing.T) { g := NewWithT(t) diff --git a/azure/services/async/interfaces.go b/azure/services/async/interfaces.go index 45f22e0bfd7..88bdf6ccf64 100644 --- a/azure/services/async/interfaces.go +++ b/azure/services/async/interfaces.go @@ -21,6 +21,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources" + "sigs.k8s.io/cluster-api-provider-azure/azure" ) diff --git a/azure/services/availabilitysets/availabilitysets.go b/azure/services/availabilitysets/availabilitysets.go index e38635ee2f3..6277a29a1de 100644 --- a/azure/services/availabilitysets/availabilitysets.go +++ b/azure/services/availabilitysets/availabilitysets.go @@ -21,6 +21,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v5" "github.com/pkg/errors" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" "sigs.k8s.io/cluster-api-provider-azure/azure/services/async" @@ -124,6 +125,6 @@ func (s *Service) Delete(ctx context.Context) error { } // IsManaged returns always returns true as CAPZ does not support BYO availability set. -func (s *Service) IsManaged(ctx context.Context) (bool, error) { +func (s *Service) IsManaged(_ context.Context) (bool, error) { return true, nil } diff --git a/azure/services/availabilitysets/availabilitysets_test.go b/azure/services/availabilitysets/availabilitysets_test.go index ac0d32ffd64..bd6dca658e5 100644 --- a/azure/services/availabilitysets/availabilitysets_test.go +++ b/azure/services/availabilitysets/availabilitysets_test.go @@ -30,6 +30,7 @@ import ( "github.com/pkg/errors" "go.uber.org/mock/gomock" "k8s.io/utils/ptr" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure/services/async/mock_async" "sigs.k8s.io/cluster-api-provider-azure/azure/services/availabilitysets/mock_availabilitysets" @@ -130,7 +131,6 @@ func TestReconcileAvailabilitySets(t *testing.T) { }, } for _, tc := range testcases { - tc := tc t.Run(tc.name, func(t *testing.T) { g := NewWithT(t) @@ -261,7 +261,6 @@ func TestDeleteAvailabilitySets(t *testing.T) { }, } for _, tc := range testcases { - tc := tc t.Run(tc.name, func(t *testing.T) { g := NewWithT(t) diff --git a/azure/services/availabilitysets/client.go b/azure/services/availabilitysets/client.go index b659e3ffbbf..859789d3f37 100644 --- a/azure/services/availabilitysets/client.go +++ b/azure/services/availabilitysets/client.go @@ -22,6 +22,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v5" "github.com/pkg/errors" + "sigs.k8s.io/cluster-api-provider-azure/azure" "sigs.k8s.io/cluster-api-provider-azure/util/tele" ) @@ -59,7 +60,7 @@ func (ac *AzureClient) Get(ctx context.Context, spec azure.ResourceSpecGetter) ( // CreateOrUpdateAsync creates or updates an availability set asynchronously. // It sends a PUT request to Azure and if accepted without error, the func will return a Poller which can be used to track the ongoing // progress of the operation. -func (ac *AzureClient) CreateOrUpdateAsync(ctx context.Context, spec azure.ResourceSpecGetter, _resumeToken string, parameters interface{}) (result interface{}, poller *runtime.Poller[armcompute.AvailabilitySetsClientCreateOrUpdateResponse], err error) { +func (ac *AzureClient) CreateOrUpdateAsync(ctx context.Context, spec azure.ResourceSpecGetter, _resumeToken string, parameters interface{}) (result interface{}, poller *runtime.Poller[armcompute.AvailabilitySetsClientCreateOrUpdateResponse], err error) { //nolint:revive // keeping _resumeToken for understanding purposes ctx, _, done := tele.StartSpanWithLogger(ctx, "availabilitySets.AzureClient.CreateOrUpdateAsync") defer done() @@ -81,7 +82,7 @@ func (ac *AzureClient) CreateOrUpdateAsync(ctx context.Context, spec azure.Resou // DeleteAsync deletes a availability set asynchronously. DeleteAsync sends a DELETE // request to Azure and if accepted without error, the func will return a Poller which can be used to track the ongoing // progress of the operation. -func (ac *AzureClient) DeleteAsync(ctx context.Context, spec azure.ResourceSpecGetter, _resumeToken string) (poller *runtime.Poller[armcompute.AvailabilitySetsClientDeleteResponse], err error) { +func (ac *AzureClient) DeleteAsync(ctx context.Context, spec azure.ResourceSpecGetter, _resumeToken string) (poller *runtime.Poller[armcompute.AvailabilitySetsClientDeleteResponse], err error) { //nolint:revive // keeping _resumeToken for understanding purposes ctx, _, done := tele.StartSpanWithLogger(ctx, "availabilitysets.AzureClient.DeleteAsync") defer done() diff --git a/azure/services/availabilitysets/spec.go b/azure/services/availabilitysets/spec.go index cf58416e864..ea522da07ee 100644 --- a/azure/services/availabilitysets/spec.go +++ b/azure/services/availabilitysets/spec.go @@ -23,6 +23,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v5" "github.com/pkg/errors" "k8s.io/utils/ptr" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure/converters" "sigs.k8s.io/cluster-api-provider-azure/azure/services/resourceskus" @@ -54,7 +55,7 @@ func (s *AvailabilitySetSpec) OwnerResourceName() string { } // Parameters returns the parameters for the availability set. -func (s *AvailabilitySetSpec) Parameters(ctx context.Context, existing interface{}) (params interface{}, err error) { +func (s *AvailabilitySetSpec) Parameters(_ context.Context, existing interface{}) (params interface{}, err error) { if existing != nil { if _, ok := existing.(armcompute.AvailabilitySet); !ok { return nil, errors.Errorf("%T is not an armcompute.AvailabilitySet", existing) diff --git a/azure/services/availabilitysets/spec_test.go b/azure/services/availabilitysets/spec_test.go index 4ab3453ca14..794b61a6c2b 100644 --- a/azure/services/availabilitysets/spec_test.go +++ b/azure/services/availabilitysets/spec_test.go @@ -23,6 +23,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v5" . "github.com/onsi/gomega" "k8s.io/utils/ptr" + "sigs.k8s.io/cluster-api-provider-azure/azure/services/resourceskus" ) @@ -75,7 +76,6 @@ func TestParameters(t *testing.T) { }, } for _, tc := range testcases { - tc := tc t.Run(tc.name, func(t *testing.T) { g := NewWithT(t) t.Parallel() diff --git a/azure/services/bastionhosts/bastionhosts.go b/azure/services/bastionhosts/bastionhosts.go index 8210bb9adaf..8169f8a054c 100644 --- a/azure/services/bastionhosts/bastionhosts.go +++ b/azure/services/bastionhosts/bastionhosts.go @@ -20,11 +20,12 @@ import ( "context" asonetworkv1 "github.com/Azure/azure-service-operator/v2/api/network/v1api20220701" + "sigs.k8s.io/controller-runtime/pkg/client" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" "sigs.k8s.io/cluster-api-provider-azure/azure/services/aso" "sigs.k8s.io/cluster-api-provider-azure/util/slice" - "sigs.k8s.io/controller-runtime/pkg/client" ) const serviceName = "bastionhosts" diff --git a/azure/services/bastionhosts/spec.go b/azure/services/bastionhosts/spec.go index 350863c9531..288a99219a0 100644 --- a/azure/services/bastionhosts/spec.go +++ b/azure/services/bastionhosts/spec.go @@ -25,6 +25,7 @@ import ( "github.com/Azure/azure-service-operator/v2/pkg/genruntime" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/utils/ptr" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" ) @@ -51,7 +52,7 @@ func (s *AzureBastionSpec) ResourceRef() *asonetworkv1.BastionHost { } // Parameters implements azure.ASOResourceSpecGetter. -func (s *AzureBastionSpec) Parameters(ctx context.Context, existingBastionHost *asonetworkv1.BastionHost) (parameters *asonetworkv1.BastionHost, err error) { +func (s *AzureBastionSpec) Parameters(_ context.Context, existingBastionHost *asonetworkv1.BastionHost) (parameters *asonetworkv1.BastionHost, err error) { bastionHost := &asonetworkv1.BastionHost{} if existingBastionHost != nil { bastionHost = existingBastionHost @@ -95,7 +96,7 @@ func (s *AzureBastionSpec) Parameters(ctx context.Context, existingBastionHost * } // WasManaged implements azure.ASOResourceSpecGetter. -func (s *AzureBastionSpec) WasManaged(resource *asonetworkv1.BastionHost) bool { +func (s *AzureBastionSpec) WasManaged(_ *asonetworkv1.BastionHost) bool { // returns always returns true as CAPZ does not support BYO bastion. return true } diff --git a/azure/services/bastionhosts/spec_test.go b/azure/services/bastionhosts/spec_test.go index 4d5fccd084f..f94d2cba6c9 100644 --- a/azure/services/bastionhosts/spec_test.go +++ b/azure/services/bastionhosts/spec_test.go @@ -26,6 +26,7 @@ import ( . "github.com/onsi/gomega" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/utils/ptr" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" ) @@ -182,7 +183,6 @@ func TestAzureBastionSpec_Parameters(t *testing.T) { } for _, tc := range testcases { - tc := tc t.Run(tc.name, func(t *testing.T) { g := NewWithT(t) t.Parallel() diff --git a/azure/services/disks/client.go b/azure/services/disks/client.go index 8e9434dbcb8..58cdb4345fc 100644 --- a/azure/services/disks/client.go +++ b/azure/services/disks/client.go @@ -23,6 +23,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v5" "github.com/pkg/errors" + "sigs.k8s.io/cluster-api-provider-azure/azure" "sigs.k8s.io/cluster-api-provider-azure/azure/services/async" "sigs.k8s.io/cluster-api-provider-azure/util/tele" diff --git a/azure/services/disks/disks.go b/azure/services/disks/disks.go index 4f0f6ded3cd..2fd0e99f37a 100644 --- a/azure/services/disks/disks.go +++ b/azure/services/disks/disks.go @@ -20,6 +20,7 @@ import ( "context" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v5" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" "sigs.k8s.io/cluster-api-provider-azure/azure/services/async" @@ -97,6 +98,6 @@ func (s *Service) Delete(ctx context.Context) error { } // IsManaged returns always returns true as CAPZ does not support BYO disk. -func (s *Service) IsManaged(ctx context.Context) (bool, error) { +func (s *Service) IsManaged(_ context.Context) (bool, error) { return true, nil } diff --git a/azure/services/disks/disks_test.go b/azure/services/disks/disks_test.go index 42ffe86c5bd..e4da474af42 100644 --- a/azure/services/disks/disks_test.go +++ b/azure/services/disks/disks_test.go @@ -26,6 +26,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore" . "github.com/onsi/gomega" "go.uber.org/mock/gomock" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" "sigs.k8s.io/cluster-api-provider-azure/azure/services/async/mock_async" @@ -114,7 +115,6 @@ func TestDeleteDisk(t *testing.T) { } for _, tc := range testcases { - tc := tc t.Run(tc.name, func(t *testing.T) { g := NewWithT(t) diff --git a/azure/services/disks/spec.go b/azure/services/disks/spec.go index a05ac7ee87e..5d326ea4002 100644 --- a/azure/services/disks/spec.go +++ b/azure/services/disks/spec.go @@ -40,6 +40,6 @@ func (s *DiskSpec) OwnerResourceName() string { } // Parameters is a no-op for disks. -func (s *DiskSpec) Parameters(ctx context.Context, existing interface{}) (params interface{}, err error) { +func (s *DiskSpec) Parameters(_ context.Context, _ interface{}) (params interface{}, err error) { return nil, nil } diff --git a/azure/services/fleetsmembers/fleetsmembers.go b/azure/services/fleetsmembers/fleetsmembers.go index 1a709aa6af7..7ca1a55a056 100644 --- a/azure/services/fleetsmembers/fleetsmembers.go +++ b/azure/services/fleetsmembers/fleetsmembers.go @@ -20,11 +20,12 @@ import ( "context" asocontainerservicev1 "github.com/Azure/azure-service-operator/v2/api/containerservice/v1api20230315preview" + "sigs.k8s.io/controller-runtime/pkg/client" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" "sigs.k8s.io/cluster-api-provider-azure/azure/services/aso" "sigs.k8s.io/cluster-api-provider-azure/util/slice" - "sigs.k8s.io/controller-runtime/pkg/client" ) const serviceName = "fleetsmember" diff --git a/azure/services/fleetsmembers/spec.go b/azure/services/fleetsmembers/spec.go index 6f1fc8db68a..9c68d4e66cb 100644 --- a/azure/services/fleetsmembers/spec.go +++ b/azure/services/fleetsmembers/spec.go @@ -23,6 +23,7 @@ import ( "github.com/Azure/azure-service-operator/v2/pkg/genruntime" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/utils/ptr" + "sigs.k8s.io/cluster-api-provider-azure/azure" ) @@ -47,7 +48,7 @@ func (s *AzureFleetsMemberSpec) ResourceRef() *asocontainerservicev1.FleetsMembe } // Parameters implements azure.ASOResourceSpecGetter. -func (s *AzureFleetsMemberSpec) Parameters(ctx context.Context, existingFleetsMember *asocontainerservicev1.FleetsMember) (parameters *asocontainerservicev1.FleetsMember, err error) { +func (s *AzureFleetsMemberSpec) Parameters(_ context.Context, existingFleetsMember *asocontainerservicev1.FleetsMember) (parameters *asocontainerservicev1.FleetsMember, err error) { fleetsMember := &asocontainerservicev1.FleetsMember{} if existingFleetsMember != nil { fleetsMember = existingFleetsMember @@ -66,7 +67,7 @@ func (s *AzureFleetsMemberSpec) Parameters(ctx context.Context, existingFleetsMe } // WasManaged implements azure.ASOResourceSpecGetter. -func (s *AzureFleetsMemberSpec) WasManaged(resource *asocontainerservicev1.FleetsMember) bool { +func (s *AzureFleetsMemberSpec) WasManaged(_ *asocontainerservicev1.FleetsMember) bool { // returns false because previous versions of CAPZ did not support Fleets. return false } diff --git a/azure/services/fleetsmembers/spec_test.go b/azure/services/fleetsmembers/spec_test.go index be766b26a17..800edf40130 100644 --- a/azure/services/fleetsmembers/spec_test.go +++ b/azure/services/fleetsmembers/spec_test.go @@ -25,6 +25,7 @@ import ( . "github.com/onsi/gomega" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/utils/ptr" + "sigs.k8s.io/cluster-api-provider-azure/azure" ) @@ -115,7 +116,6 @@ func TestAzureFleetsMemberSpec_Parameters(t *testing.T) { }, } for _, tc := range testcases { - tc := tc t.Run(tc.name, func(t *testing.T) { g := NewWithT(t) t.Parallel() diff --git a/azure/services/groups/groups.go b/azure/services/groups/groups.go index dfda50109a0..5dcd40c9bf5 100644 --- a/azure/services/groups/groups.go +++ b/azure/services/groups/groups.go @@ -21,11 +21,12 @@ import ( asoresourcesv1 "github.com/Azure/azure-service-operator/v2/api/resources/v1api20200601" asoannotations "github.com/Azure/azure-service-operator/v2/pkg/common/annotations" + "sigs.k8s.io/controller-runtime/pkg/client" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" "sigs.k8s.io/cluster-api-provider-azure/azure/services/aso" "sigs.k8s.io/cluster-api-provider-azure/util/slice" - "sigs.k8s.io/controller-runtime/pkg/client" ) // ServiceName is the name of this service. diff --git a/azure/services/groups/groups_test.go b/azure/services/groups/groups_test.go index 789f19f9e6d..26e9aa5a919 100644 --- a/azure/services/groups/groups_test.go +++ b/azure/services/groups/groups_test.go @@ -27,11 +27,12 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/utils/ptr" - "sigs.k8s.io/cluster-api-provider-azure/azure" - "sigs.k8s.io/cluster-api-provider-azure/azure/services/groups/mock_groups" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/client/apiutil" fakeclient "sigs.k8s.io/controller-runtime/pkg/client/fake" + + "sigs.k8s.io/cluster-api-provider-azure/azure" + "sigs.k8s.io/cluster-api-provider-azure/azure/services/groups/mock_groups" ) func TestIsManaged(t *testing.T) { diff --git a/azure/services/groups/spec.go b/azure/services/groups/spec.go index 78ff3931cad..79e1b3c4c87 100644 --- a/azure/services/groups/spec.go +++ b/azure/services/groups/spec.go @@ -22,6 +22,7 @@ import ( asoresourcesv1 "github.com/Azure/azure-service-operator/v2/api/resources/v1api20200601" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/utils/ptr" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" "sigs.k8s.io/cluster-api-provider-azure/azure/services/aso" @@ -46,7 +47,7 @@ func (s *GroupSpec) ResourceRef() *asoresourcesv1.ResourceGroup { } // Parameters implements aso.ResourceSpecGetter. -func (s *GroupSpec) Parameters(ctx context.Context, existing *asoresourcesv1.ResourceGroup) (*asoresourcesv1.ResourceGroup, error) { +func (s *GroupSpec) Parameters(_ context.Context, existing *asoresourcesv1.ResourceGroup) (*asoresourcesv1.ResourceGroup, error) { if existing != nil { return existing, nil } diff --git a/azure/services/groups/spec_test.go b/azure/services/groups/spec_test.go index 9e286e30a47..a5a2b935bd4 100644 --- a/azure/services/groups/spec_test.go +++ b/azure/services/groups/spec_test.go @@ -24,6 +24,7 @@ import ( . "github.com/onsi/gomega" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/utils/ptr" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" ) diff --git a/azure/services/identities/client.go b/azure/services/identities/client.go index c72c98b5bd4..e12a25a10ab 100644 --- a/azure/services/identities/client.go +++ b/azure/services/identities/client.go @@ -22,6 +22,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/msi/armmsi" "github.com/pkg/errors" "k8s.io/utils/ptr" + "sigs.k8s.io/cluster-api-provider-azure/azure" azureutil "sigs.k8s.io/cluster-api-provider-azure/util/azure" "sigs.k8s.io/cluster-api-provider-azure/util/tele" diff --git a/azure/services/inboundnatrules/client.go b/azure/services/inboundnatrules/client.go index a7f7c57fa42..0b8f5f6e3a9 100644 --- a/azure/services/inboundnatrules/client.go +++ b/azure/services/inboundnatrules/client.go @@ -23,6 +23,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v4" "github.com/pkg/errors" + "sigs.k8s.io/cluster-api-provider-azure/azure" "sigs.k8s.io/cluster-api-provider-azure/azure/services/async" "sigs.k8s.io/cluster-api-provider-azure/util/tele" diff --git a/azure/services/inboundnatrules/inboundnatrules.go b/azure/services/inboundnatrules/inboundnatrules.go index b5893e19fdf..057732bad68 100644 --- a/azure/services/inboundnatrules/inboundnatrules.go +++ b/azure/services/inboundnatrules/inboundnatrules.go @@ -21,6 +21,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v4" "github.com/pkg/errors" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" "sigs.k8s.io/cluster-api-provider-azure/azure/services/async" @@ -153,6 +154,6 @@ func (s *Service) Delete(ctx context.Context) error { } // IsManaged returns always returns true as CAPZ does not support BYO inbound NAT rules. -func (s *Service) IsManaged(ctx context.Context) (bool, error) { +func (s *Service) IsManaged(_ context.Context) (bool, error) { return true, nil } diff --git a/azure/services/inboundnatrules/inboundnatrules_test.go b/azure/services/inboundnatrules/inboundnatrules_test.go index 25ff7f931f9..8a71f574c40 100644 --- a/azure/services/inboundnatrules/inboundnatrules_test.go +++ b/azure/services/inboundnatrules/inboundnatrules_test.go @@ -28,6 +28,7 @@ import ( . "github.com/onsi/gomega" "go.uber.org/mock/gomock" "k8s.io/utils/ptr" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" "sigs.k8s.io/cluster-api-provider-azure/azure/services/async/mock_async" @@ -189,7 +190,6 @@ func TestReconcileInboundNATRule(t *testing.T) { } for _, tc := range testcases { - tc := tc t.Run(tc.name, func(t *testing.T) { g := NewWithT(t) // TODO: investigate why t.Parallel() trips the race detector here. @@ -267,7 +267,6 @@ func TestDeleteNetworkInterface(t *testing.T) { } for _, tc := range testcases { - tc := tc t.Run(tc.name, func(t *testing.T) { g := NewWithT(t) t.Parallel() diff --git a/azure/services/inboundnatrules/spec.go b/azure/services/inboundnatrules/spec.go index 6ee5c98c510..b836e5efb52 100644 --- a/azure/services/inboundnatrules/spec.go +++ b/azure/services/inboundnatrules/spec.go @@ -49,7 +49,7 @@ func (s *InboundNatSpec) OwnerResourceName() string { } // Parameters returns the parameters for the inbound NAT rule. -func (s *InboundNatSpec) Parameters(ctx context.Context, existing interface{}) (parameters interface{}, err error) { +func (s *InboundNatSpec) Parameters(_ context.Context, existing interface{}) (parameters interface{}, err error) { if existing != nil { if _, ok := existing.(armnetwork.InboundNatRule); !ok { return nil, errors.Errorf("%T is not an armnetwork.InboundNatRule", existing) diff --git a/azure/services/inboundnatrules/spec_test.go b/azure/services/inboundnatrules/spec_test.go index ba677cb1cfb..1e9de0d28e1 100644 --- a/azure/services/inboundnatrules/spec_test.go +++ b/azure/services/inboundnatrules/spec_test.go @@ -61,7 +61,6 @@ func TestParameters(t *testing.T) { }, } for _, tc := range testcases { - tc := tc t.Run(tc.name, func(t *testing.T) { g := NewWithT(t) t.Parallel() @@ -148,7 +147,6 @@ func TestGetAvailablePort(t *testing.T) { }, } for _, tc := range testcases { - tc := tc t.Run(tc.name, func(t *testing.T) { g := NewWithT(t) t.Parallel() diff --git a/azure/services/loadbalancers/client.go b/azure/services/loadbalancers/client.go index 143ee86e7bf..0981f4855a4 100644 --- a/azure/services/loadbalancers/client.go +++ b/azure/services/loadbalancers/client.go @@ -24,6 +24,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v4" "github.com/pkg/errors" + "sigs.k8s.io/cluster-api-provider-azure/azure" "sigs.k8s.io/cluster-api-provider-azure/azure/services/async" "sigs.k8s.io/cluster-api-provider-azure/util/tele" diff --git a/azure/services/loadbalancers/loadbalancers.go b/azure/services/loadbalancers/loadbalancers.go index 94ca914cb9a..a5ff22d65a6 100644 --- a/azure/services/loadbalancers/loadbalancers.go +++ b/azure/services/loadbalancers/loadbalancers.go @@ -20,6 +20,7 @@ import ( "context" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v4" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" "sigs.k8s.io/cluster-api-provider-azure/azure/services/async" @@ -124,6 +125,6 @@ func (s *Service) Delete(ctx context.Context) error { } // IsManaged returns always returns true as CAPZ does not support BYO load balancers. -func (s *Service) IsManaged(ctx context.Context) (bool, error) { +func (s *Service) IsManaged(_ context.Context) (bool, error) { return true, nil } diff --git a/azure/services/loadbalancers/loadbalancers_test.go b/azure/services/loadbalancers/loadbalancers_test.go index 3ca849923e6..238bde7ed3a 100644 --- a/azure/services/loadbalancers/loadbalancers_test.go +++ b/azure/services/loadbalancers/loadbalancers_test.go @@ -27,6 +27,7 @@ import ( . "github.com/onsi/gomega" "go.uber.org/mock/gomock" "k8s.io/utils/ptr" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" "sigs.k8s.io/cluster-api-provider-azure/azure/services/async/mock_async" @@ -181,7 +182,6 @@ func TestReconcileLoadBalancer(t *testing.T) { } for _, tc := range testcases { - tc := tc t.Run(tc.name, func(t *testing.T) { g := NewWithT(t) t.Parallel() @@ -258,7 +258,6 @@ func TestDeleteLoadBalancer(t *testing.T) { } for _, tc := range testcases { - tc := tc t.Run(tc.name, func(t *testing.T) { g := NewWithT(t) t.Parallel() diff --git a/azure/services/loadbalancers/spec.go b/azure/services/loadbalancers/spec.go index 41a1ffb484a..c01c34c8d04 100644 --- a/azure/services/loadbalancers/spec.go +++ b/azure/services/loadbalancers/spec.go @@ -22,6 +22,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v4" "github.com/pkg/errors" "k8s.io/utils/ptr" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" "sigs.k8s.io/cluster-api-provider-azure/azure/converters" @@ -64,7 +65,7 @@ func (s *LBSpec) OwnerResourceName() string { } // Parameters returns the parameters for the load balancer. -func (s *LBSpec) Parameters(ctx context.Context, existing interface{}) (parameters interface{}, err error) { +func (s *LBSpec) Parameters(_ context.Context, existing interface{}) (parameters interface{}, err error) { var ( etag *string frontendIDs []*armnetwork.SubResource diff --git a/azure/services/loadbalancers/spec_test.go b/azure/services/loadbalancers/spec_test.go index 120e96c4dcb..7b8fc339f13 100644 --- a/azure/services/loadbalancers/spec_test.go +++ b/azure/services/loadbalancers/spec_test.go @@ -23,6 +23,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v4" . "github.com/onsi/gomega" "k8s.io/utils/ptr" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" ) @@ -148,7 +149,6 @@ func TestParameters(t *testing.T) { }, } for _, tc := range testcases { - tc := tc t.Run(tc.name, func(t *testing.T) { g := NewWithT(t) t.Parallel() diff --git a/azure/services/managedclusters/managedclusters.go b/azure/services/managedclusters/managedclusters.go index 3878970703e..d42db39050c 100644 --- a/azure/services/managedclusters/managedclusters.go +++ b/azure/services/managedclusters/managedclusters.go @@ -27,13 +27,14 @@ import ( corev1 "k8s.io/api/core/v1" "k8s.io/client-go/tools/clientcmd" "k8s.io/utils/ptr" - infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" - "sigs.k8s.io/cluster-api-provider-azure/azure" - "sigs.k8s.io/cluster-api-provider-azure/azure/services/aso" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" "sigs.k8s.io/cluster-api/util/secret" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/conversion" + + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" + "sigs.k8s.io/cluster-api-provider-azure/azure" + "sigs.k8s.io/cluster-api-provider-azure/azure/services/aso" ) const ( diff --git a/azure/services/managedclusters/managedclusters_test.go b/azure/services/managedclusters/managedclusters_test.go index c7c718935a0..6f3d992c45b 100644 --- a/azure/services/managedclusters/managedclusters_test.go +++ b/azure/services/managedclusters/managedclusters_test.go @@ -28,11 +28,12 @@ import ( corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/utils/ptr" - infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" - "sigs.k8s.io/cluster-api-provider-azure/azure/services/managedclusters/mock_managedclusters" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" "sigs.k8s.io/cluster-api/util/secret" fakeclient "sigs.k8s.io/controller-runtime/pkg/client/fake" + + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" + "sigs.k8s.io/cluster-api-provider-azure/azure/services/managedclusters/mock_managedclusters" ) func TestPostCreateOrUpdateResourceHook(t *testing.T) { diff --git a/azure/services/managedclusters/spec.go b/azure/services/managedclusters/spec.go index 23a699e733e..e58a2827aab 100644 --- a/azure/services/managedclusters/spec.go +++ b/azure/services/managedclusters/spec.go @@ -31,6 +31,9 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/utils/ptr" + "sigs.k8s.io/cluster-api/util/secret" + "sigs.k8s.io/controller-runtime/pkg/conversion" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" "sigs.k8s.io/cluster-api-provider-azure/azure/converters" @@ -38,8 +41,6 @@ import ( "sigs.k8s.io/cluster-api-provider-azure/azure/services/aso" "sigs.k8s.io/cluster-api-provider-azure/util/tele" "sigs.k8s.io/cluster-api-provider-azure/util/versions" - "sigs.k8s.io/cluster-api/util/secret" - "sigs.k8s.io/controller-runtime/pkg/conversion" ) // ManagedClusterSpec contains properties to create a managed cluster. @@ -814,7 +815,7 @@ func userKubeconfigSecretName(clusterName string) string { } // WasManaged implements azure.ASOResourceSpecGetter. -func (s *ManagedClusterSpec) WasManaged(resource genruntime.MetaObject) bool { +func (s *ManagedClusterSpec) WasManaged(_ genruntime.MetaObject) bool { // CAPZ has never supported BYO managed clusters. return true } diff --git a/azure/services/managedclusters/spec_test.go b/azure/services/managedclusters/spec_test.go index a5b388d87cd..56ea289bed0 100644 --- a/azure/services/managedclusters/spec_test.go +++ b/azure/services/managedclusters/spec_test.go @@ -27,10 +27,11 @@ import ( "github.com/google/go-cmp/cmp" . "github.com/onsi/gomega" "k8s.io/utils/ptr" + "sigs.k8s.io/cluster-api/util/secret" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" "sigs.k8s.io/cluster-api-provider-azure/azure/services/agentpools" - "sigs.k8s.io/cluster-api/util/secret" ) func TestParameters(t *testing.T) { diff --git a/azure/services/natgateways/natgateways.go b/azure/services/natgateways/natgateways.go index 5ebe9cd7934..a6caf0cbe05 100644 --- a/azure/services/natgateways/natgateways.go +++ b/azure/services/natgateways/natgateways.go @@ -20,11 +20,12 @@ import ( "context" asonetworkv1 "github.com/Azure/azure-service-operator/v2/api/network/v1api20220701" + "sigs.k8s.io/controller-runtime/pkg/client" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" "sigs.k8s.io/cluster-api-provider-azure/azure/services/aso" "sigs.k8s.io/cluster-api-provider-azure/util/slice" - "sigs.k8s.io/controller-runtime/pkg/client" ) const serviceName = "natgateways" diff --git a/azure/services/natgateways/natgateways_test.go b/azure/services/natgateways/natgateways_test.go index ad5e97cc3b6..7bac0fcd62c 100644 --- a/azure/services/natgateways/natgateways_test.go +++ b/azure/services/natgateways/natgateways_test.go @@ -26,6 +26,7 @@ import ( "go.uber.org/mock/gomock" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/utils/ptr" + "sigs.k8s.io/cluster-api-provider-azure/azure/services/natgateways/mock_natgateways" ) diff --git a/azure/services/natgateways/spec.go b/azure/services/natgateways/spec.go index 6eb7fff39c5..0b17612e7ec 100644 --- a/azure/services/natgateways/spec.go +++ b/azure/services/natgateways/spec.go @@ -23,6 +23,7 @@ import ( "github.com/Azure/azure-service-operator/v2/pkg/genruntime" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/utils/ptr" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" ) @@ -49,7 +50,7 @@ func (s *NatGatewaySpec) ResourceRef() *asonetworkv1.NatGateway { } // Parameters implements azure.ASOResourceSpecGetter. -func (s *NatGatewaySpec) Parameters(ctx context.Context, existingNatGateway *asonetworkv1.NatGateway) (params *asonetworkv1.NatGateway, err error) { +func (s *NatGatewaySpec) Parameters(_ context.Context, existingNatGateway *asonetworkv1.NatGateway) (params *asonetworkv1.NatGateway, err error) { natGateway := &asonetworkv1.NatGateway{} natGateway.Spec = asonetworkv1.NatGateway_Spec{} @@ -83,6 +84,6 @@ func (s *NatGatewaySpec) Parameters(ctx context.Context, existingNatGateway *aso } // WasManaged implements azure.ASOResourceSpecGetter. -func (s *NatGatewaySpec) WasManaged(resource *asonetworkv1.NatGateway) bool { +func (s *NatGatewaySpec) WasManaged(_ *asonetworkv1.NatGateway) bool { return s.IsVnetManaged } diff --git a/azure/services/natgateways/spec_test.go b/azure/services/natgateways/spec_test.go index 3a1102ce44f..8c502f7f641 100644 --- a/azure/services/natgateways/spec_test.go +++ b/azure/services/natgateways/spec_test.go @@ -26,6 +26,7 @@ import ( . "github.com/onsi/gomega" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/utils/ptr" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" ) @@ -133,7 +134,6 @@ func TestParameters(t *testing.T) { }, } for _, tc := range testcases { - tc := tc t.Run(tc.name, func(t *testing.T) { g := NewWithT(t) t.Parallel() diff --git a/azure/services/networkinterfaces/client.go b/azure/services/networkinterfaces/client.go index 0f6a62302d3..62fefd8d304 100644 --- a/azure/services/networkinterfaces/client.go +++ b/azure/services/networkinterfaces/client.go @@ -23,6 +23,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v4" "github.com/pkg/errors" + "sigs.k8s.io/cluster-api-provider-azure/azure" "sigs.k8s.io/cluster-api-provider-azure/azure/services/async" "sigs.k8s.io/cluster-api-provider-azure/util/tele" @@ -35,7 +36,7 @@ type azureClient struct { } // NewClient creates a new network interfaces client from an authorizer. -func NewClient(auth azure.Authorizer, apiCallTimeout time.Duration) (*azureClient, error) { +func NewClient(auth azure.Authorizer, apiCallTimeout time.Duration) (*azureClient, error) { //nolint:revive // leave it as is opts, err := azure.ARMClientOptions(auth.CloudEnvironment()) if err != nil { return nil, errors.Wrap(err, "failed to create networkinterfaces client options") diff --git a/azure/services/networkinterfaces/networkinterfaces.go b/azure/services/networkinterfaces/networkinterfaces.go index 4f0b20d6f6d..b826d4446dc 100644 --- a/azure/services/networkinterfaces/networkinterfaces.go +++ b/azure/services/networkinterfaces/networkinterfaces.go @@ -20,6 +20,7 @@ import ( "context" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v4" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" "sigs.k8s.io/cluster-api-provider-azure/azure/services/async" @@ -121,6 +122,6 @@ func (s *Service) Delete(ctx context.Context) error { } // IsManaged returns always returns true as CAPZ does not support BYO network interfaces. -func (s *Service) IsManaged(ctx context.Context) (bool, error) { +func (s *Service) IsManaged(_ context.Context) (bool, error) { return true, nil } diff --git a/azure/services/networkinterfaces/networkinterfaces_test.go b/azure/services/networkinterfaces/networkinterfaces_test.go index aee471a00a5..ed1e97595ff 100644 --- a/azure/services/networkinterfaces/networkinterfaces_test.go +++ b/azure/services/networkinterfaces/networkinterfaces_test.go @@ -28,6 +28,7 @@ import ( "github.com/google/go-cmp/cmp" . "github.com/onsi/gomega" "go.uber.org/mock/gomock" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" "sigs.k8s.io/cluster-api-provider-azure/azure/services/async/mock_async" @@ -140,7 +141,6 @@ func TestReconcileNetworkInterface(t *testing.T) { } for _, tc := range testcases { - tc := tc t.Run(tc.name, func(t *testing.T) { g := NewWithT(t) t.Parallel() @@ -218,7 +218,6 @@ func TestDeleteNetworkInterface(t *testing.T) { } for _, tc := range testcases { - tc := tc t.Run(tc.name, func(t *testing.T) { g := NewWithT(t) t.Parallel() diff --git a/azure/services/networkinterfaces/spec.go b/azure/services/networkinterfaces/spec.go index 9c751ad0b24..06187a59055 100644 --- a/azure/services/networkinterfaces/spec.go +++ b/azure/services/networkinterfaces/spec.go @@ -23,6 +23,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v4" "github.com/pkg/errors" "k8s.io/utils/ptr" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" "sigs.k8s.io/cluster-api-provider-azure/azure/converters" @@ -79,7 +80,7 @@ func (s *NICSpec) OwnerResourceName() string { } // Parameters returns the parameters for the network interface. -func (s *NICSpec) Parameters(ctx context.Context, existing interface{}) (parameters interface{}, err error) { +func (s *NICSpec) Parameters(_ context.Context, existing interface{}) (parameters interface{}, err error) { if existing != nil { if _, ok := existing.(armnetwork.Interface); !ok { return nil, errors.Errorf("%T is not an armnetwork.Interface", existing) diff --git a/azure/services/networkinterfaces/spec_test.go b/azure/services/networkinterfaces/spec_test.go index 96b53f39c7e..9708256f77d 100644 --- a/azure/services/networkinterfaces/spec_test.go +++ b/azure/services/networkinterfaces/spec_test.go @@ -25,6 +25,7 @@ import ( . "github.com/onsi/gomega" "github.com/onsi/gomega/format" "k8s.io/utils/ptr" + "sigs.k8s.io/cluster-api-provider-azure/azure/services/resourceskus" ) @@ -671,7 +672,6 @@ func TestParameters(t *testing.T) { } format.MaxLength = 10000 for _, tc := range testcases { - tc := tc t.Run(tc.name, func(t *testing.T) { g := NewWithT(t) t.Parallel() diff --git a/azure/services/privatedns/link_client.go b/azure/services/privatedns/link_client.go index 495f73f3b66..0c2104d32ae 100644 --- a/azure/services/privatedns/link_client.go +++ b/azure/services/privatedns/link_client.go @@ -23,6 +23,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/privatedns/armprivatedns" "github.com/pkg/errors" + "sigs.k8s.io/cluster-api-provider-azure/azure" "sigs.k8s.io/cluster-api-provider-azure/azure/services/async" "sigs.k8s.io/cluster-api-provider-azure/util/tele" diff --git a/azure/services/privatedns/link_reconciler.go b/azure/services/privatedns/link_reconciler.go index 926e0dfaad9..f972bf0085e 100644 --- a/azure/services/privatedns/link_reconciler.go +++ b/azure/services/privatedns/link_reconciler.go @@ -20,6 +20,7 @@ import ( "context" "github.com/pkg/errors" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" "sigs.k8s.io/cluster-api-provider-azure/util/tele" diff --git a/azure/services/privatedns/link_spec.go b/azure/services/privatedns/link_spec.go index b28cfc4448d..9359c071338 100644 --- a/azure/services/privatedns/link_spec.go +++ b/azure/services/privatedns/link_spec.go @@ -22,6 +22,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/privatedns/armprivatedns" "github.com/pkg/errors" "k8s.io/utils/ptr" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" "sigs.k8s.io/cluster-api-provider-azure/azure/converters" @@ -55,7 +56,7 @@ func (s LinkSpec) ResourceGroupName() string { } // Parameters returns the parameters for the virtual network link. -func (s LinkSpec) Parameters(ctx context.Context, existing interface{}) (params interface{}, err error) { +func (s LinkSpec) Parameters(_ context.Context, existing interface{}) (params interface{}, err error) { if existing != nil { _, ok := existing.(armprivatedns.VirtualNetworkLink) if !ok { diff --git a/azure/services/privatedns/link_spec_test.go b/azure/services/privatedns/link_spec_test.go index ca1c2a40a06..626aef82e0e 100644 --- a/azure/services/privatedns/link_spec_test.go +++ b/azure/services/privatedns/link_spec_test.go @@ -23,6 +23,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/privatedns/armprivatedns" . "github.com/onsi/gomega" "k8s.io/utils/ptr" + "sigs.k8s.io/cluster-api-provider-azure/azure" ) @@ -110,7 +111,6 @@ func TestLinkSpec_Parameters(t *testing.T) { } for _, tc := range testcases { - tc := tc t.Run(tc.name, func(t *testing.T) { g := NewWithT(t) t.Parallel() diff --git a/azure/services/privatedns/privatedns.go b/azure/services/privatedns/privatedns.go index e719d3761b1..f8223d786ef 100644 --- a/azure/services/privatedns/privatedns.go +++ b/azure/services/privatedns/privatedns.go @@ -21,6 +21,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/privatedns/armprivatedns" "github.com/pkg/errors" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" "sigs.k8s.io/cluster-api-provider-azure/azure/converters" diff --git a/azure/services/privatedns/privatedns_test.go b/azure/services/privatedns/privatedns_test.go index 754ef3d6cde..f975e6fc8a3 100644 --- a/azure/services/privatedns/privatedns_test.go +++ b/azure/services/privatedns/privatedns_test.go @@ -27,6 +27,7 @@ import ( "github.com/pkg/errors" "go.uber.org/mock/gomock" "k8s.io/utils/ptr" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" "sigs.k8s.io/cluster-api-provider-azure/azure/services/async/mock_async" @@ -331,7 +332,6 @@ func TestReconcilePrivateDNS(t *testing.T) { } for _, tc := range testcases { - tc := tc t.Run(tc.name, func(t *testing.T) { g := NewWithT(t) @@ -559,7 +559,6 @@ func TestDeletePrivateDNS(t *testing.T) { } for _, tc := range testcases { - tc := tc t.Run(tc.name, func(t *testing.T) { g := NewWithT(t) diff --git a/azure/services/privatedns/record_client.go b/azure/services/privatedns/record_client.go index 581ae6f160a..01e6ce7ff8c 100644 --- a/azure/services/privatedns/record_client.go +++ b/azure/services/privatedns/record_client.go @@ -22,6 +22,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/privatedns/armprivatedns" "github.com/pkg/errors" + "sigs.k8s.io/cluster-api-provider-azure/azure" "sigs.k8s.io/cluster-api-provider-azure/util/tele" ) @@ -45,13 +46,13 @@ func newRecordSetsClient(auth azure.Authorizer) (*azureRecordsClient, error) { } // Get gets the specified record set. Noop for records. -func (arc *azureRecordsClient) Get(ctx context.Context, spec azure.ResourceSpecGetter) (result interface{}, err error) { +func (arc *azureRecordsClient) Get(_ context.Context, _ azure.ResourceSpecGetter) (result interface{}, err error) { return nil, nil } // CreateOrUpdateAsync creates or updates a record asynchronously. // Creating a record set is not a long-running operation, so we don't ever return a future. -func (arc *azureRecordsClient) CreateOrUpdateAsync(ctx context.Context, spec azure.ResourceSpecGetter, resumeToken string, parameters interface{}) (result interface{}, poller *runtime.Poller[armprivatedns.RecordSetsClientCreateOrUpdateResponse], err error) { +func (arc *azureRecordsClient) CreateOrUpdateAsync(ctx context.Context, spec azure.ResourceSpecGetter, _ string, parameters interface{}) (result interface{}, poller *runtime.Poller[armprivatedns.RecordSetsClientCreateOrUpdateResponse], err error) { ctx, _, done := tele.StartSpanWithLogger(ctx, "privatedns.azureRecordsClient.CreateOrUpdateAsync") defer done() @@ -80,6 +81,6 @@ func (arc *azureRecordsClient) CreateOrUpdateAsync(ctx context.Context, spec azu } // DeleteAsync deletes a record asynchronously. Noop for records. -func (arc *azureRecordsClient) DeleteAsync(ctx context.Context, spec azure.ResourceSpecGetter, resumeToken string) (poller *runtime.Poller[armprivatedns.RecordSetsClientDeleteResponse], err error) { +func (arc *azureRecordsClient) DeleteAsync(_ context.Context, _ azure.ResourceSpecGetter, _ string) (poller *runtime.Poller[armprivatedns.RecordSetsClientDeleteResponse], err error) { return nil, nil } diff --git a/azure/services/privatedns/record_spec.go b/azure/services/privatedns/record_spec.go index d4eff9b8b3a..33bf74594ff 100644 --- a/azure/services/privatedns/record_spec.go +++ b/azure/services/privatedns/record_spec.go @@ -22,6 +22,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/privatedns/armprivatedns" "github.com/pkg/errors" "k8s.io/utils/ptr" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure/converters" ) @@ -49,7 +50,7 @@ func (s RecordSpec) ResourceGroupName() string { } // Parameters returns the parameters for a record set. -func (s RecordSpec) Parameters(ctx context.Context, existing interface{}) (params interface{}, err error) { +func (s RecordSpec) Parameters(_ context.Context, existing interface{}) (params interface{}, err error) { if existing != nil { if _, ok := existing.(armprivatedns.RecordSet); !ok { return nil, errors.Errorf("%T is not an armprivatedns.RecordSet", existing) diff --git a/azure/services/privatedns/record_spec_test.go b/azure/services/privatedns/record_spec_test.go index dd027e5d689..4a07540bfa6 100644 --- a/azure/services/privatedns/record_spec_test.go +++ b/azure/services/privatedns/record_spec_test.go @@ -23,6 +23,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/privatedns/armprivatedns" . "github.com/onsi/gomega" "k8s.io/utils/ptr" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" ) @@ -100,7 +101,6 @@ func TestRecordSpec_Parameters(t *testing.T) { } for _, tc := range testcases { - tc := tc t.Run(tc.name, func(t *testing.T) { g := NewWithT(t) t.Parallel() diff --git a/azure/services/privatedns/zone_client.go b/azure/services/privatedns/zone_client.go index a391b6964f1..86e137251c5 100644 --- a/azure/services/privatedns/zone_client.go +++ b/azure/services/privatedns/zone_client.go @@ -23,6 +23,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/privatedns/armprivatedns" "github.com/pkg/errors" + "sigs.k8s.io/cluster-api-provider-azure/azure" "sigs.k8s.io/cluster-api-provider-azure/azure/services/async" "sigs.k8s.io/cluster-api-provider-azure/util/tele" diff --git a/azure/services/privatedns/zone_reconciler.go b/azure/services/privatedns/zone_reconciler.go index 8470b33cd46..26f5ac597b8 100644 --- a/azure/services/privatedns/zone_reconciler.go +++ b/azure/services/privatedns/zone_reconciler.go @@ -20,6 +20,7 @@ import ( "context" "github.com/pkg/errors" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" "sigs.k8s.io/cluster-api-provider-azure/util/tele" diff --git a/azure/services/privatedns/zone_spec.go b/azure/services/privatedns/zone_spec.go index 65292b7ff40..a2fc750195b 100644 --- a/azure/services/privatedns/zone_spec.go +++ b/azure/services/privatedns/zone_spec.go @@ -22,6 +22,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/privatedns/armprivatedns" "github.com/pkg/errors" "k8s.io/utils/ptr" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" "sigs.k8s.io/cluster-api-provider-azure/azure/converters" @@ -51,7 +52,7 @@ func (s ZoneSpec) ResourceGroupName() string { } // Parameters returns the parameters for the private dns zone. -func (s ZoneSpec) Parameters(ctx context.Context, existing interface{}) (params interface{}, err error) { +func (s ZoneSpec) Parameters(_ context.Context, existing interface{}) (params interface{}, err error) { if existing != nil { _, ok := existing.(armprivatedns.PrivateZone) if !ok { diff --git a/azure/services/privatedns/zone_spec_test.go b/azure/services/privatedns/zone_spec_test.go index 81abfa1a3e7..ebbe39abae9 100644 --- a/azure/services/privatedns/zone_spec_test.go +++ b/azure/services/privatedns/zone_spec_test.go @@ -23,6 +23,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/privatedns/armprivatedns" . "github.com/onsi/gomega" "k8s.io/utils/ptr" + "sigs.k8s.io/cluster-api-provider-azure/azure" ) @@ -100,7 +101,6 @@ func TestZoneSpec_Parameters(t *testing.T) { } for _, tc := range testcases { - tc := tc t.Run(tc.name, func(t *testing.T) { g := NewWithT(t) t.Parallel() diff --git a/azure/services/privateendpoints/privateendpoints.go b/azure/services/privateendpoints/privateendpoints.go index aab3d74db1c..b3c09809381 100644 --- a/azure/services/privateendpoints/privateendpoints.go +++ b/azure/services/privateendpoints/privateendpoints.go @@ -18,6 +18,7 @@ package privateendpoints import ( asonetworkv1 "github.com/Azure/azure-service-operator/v2/api/network/v1api20220701" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" "sigs.k8s.io/cluster-api-provider-azure/azure/services/aso" diff --git a/azure/services/privateendpoints/spec.go b/azure/services/privateendpoints/spec.go index f49d753d29b..c5656353e07 100644 --- a/azure/services/privateendpoints/spec.go +++ b/azure/services/privateendpoints/spec.go @@ -24,6 +24,7 @@ import ( "github.com/Azure/azure-service-operator/v2/pkg/genruntime" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/utils/ptr" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" ) @@ -61,7 +62,7 @@ func (s *PrivateEndpointSpec) ResourceRef() *asonetworkv1.PrivateEndpoint { } // Parameters implements azure.ASOResourceSpecGetter. -func (s *PrivateEndpointSpec) Parameters(ctx context.Context, existingPrivateEndpoint *asonetworkv1.PrivateEndpoint) (*asonetworkv1.PrivateEndpoint, error) { +func (s *PrivateEndpointSpec) Parameters(_ context.Context, existingPrivateEndpoint *asonetworkv1.PrivateEndpoint) (*asonetworkv1.PrivateEndpoint, error) { privateEndpoint := &asonetworkv1.PrivateEndpoint{} if existingPrivateEndpoint != nil { privateEndpoint = existingPrivateEndpoint @@ -151,6 +152,6 @@ func (s *PrivateEndpointSpec) Parameters(ctx context.Context, existingPrivateEnd // WasManaged implements azure.ASOResourceSpecGetter. // It always returns true since CAPZ doesn't support BYO private endpoints. -func (s *PrivateEndpointSpec) WasManaged(privateEndpoint *asonetworkv1.PrivateEndpoint) bool { +func (s *PrivateEndpointSpec) WasManaged(_ *asonetworkv1.PrivateEndpoint) bool { return true } diff --git a/azure/services/privateendpoints/spec_test.go b/azure/services/privateendpoints/spec_test.go index 667807a5875..e98361957a7 100644 --- a/azure/services/privateendpoints/spec_test.go +++ b/azure/services/privateendpoints/spec_test.go @@ -25,6 +25,7 @@ import ( . "github.com/onsi/gomega" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/utils/ptr" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" ) @@ -222,7 +223,6 @@ func TestParameters(t *testing.T) { } for _, tc := range testcases { - tc := tc t.Run(tc.name, func(t *testing.T) { g := NewWithT(t) t.Parallel() diff --git a/azure/services/publicips/client.go b/azure/services/publicips/client.go index eb3059e84a9..b37d05529f2 100644 --- a/azure/services/publicips/client.go +++ b/azure/services/publicips/client.go @@ -23,6 +23,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v4" "github.com/pkg/errors" + "sigs.k8s.io/cluster-api-provider-azure/azure" "sigs.k8s.io/cluster-api-provider-azure/azure/services/async" "sigs.k8s.io/cluster-api-provider-azure/util/tele" diff --git a/azure/services/publicips/publicips.go b/azure/services/publicips/publicips.go index 023a2d65e50..0854f89f583 100644 --- a/azure/services/publicips/publicips.go +++ b/azure/services/publicips/publicips.go @@ -21,6 +21,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v4" "github.com/pkg/errors" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" "sigs.k8s.io/cluster-api-provider-azure/azure/converters" @@ -166,6 +167,6 @@ func (s *Service) isIPManaged(ctx context.Context, spec azure.ResourceSpecGetter } // IsManaged returns always returns true as public IPs are managed on a one-by-one basis. -func (s *Service) IsManaged(ctx context.Context) (bool, error) { +func (s *Service) IsManaged(_ context.Context) (bool, error) { return true, nil } diff --git a/azure/services/publicips/publicips_test.go b/azure/services/publicips/publicips_test.go index 1aeaf21c320..706d6e60345 100644 --- a/azure/services/publicips/publicips_test.go +++ b/azure/services/publicips/publicips_test.go @@ -29,13 +29,14 @@ import ( "go.uber.org/mock/gomock" "k8s.io/client-go/kubernetes/scheme" "k8s.io/utils/ptr" + clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" "sigs.k8s.io/cluster-api-provider-azure/azure/services/async/mock_async" "sigs.k8s.io/cluster-api-provider-azure/azure/services/publicips/mock_publicips" gomockinternal "sigs.k8s.io/cluster-api-provider-azure/internal/test/matchers/gomock" "sigs.k8s.io/cluster-api-provider-azure/util/reconciler" - clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" ) func init() { @@ -166,7 +167,6 @@ func TestReconcilePublicIP(t *testing.T) { } for _, tc := range testcases { - tc := tc t.Run(tc.name, func(t *testing.T) { g := NewWithT(t) @@ -297,7 +297,6 @@ func TestDeletePublicIP(t *testing.T) { } for _, tc := range testcases { - tc := tc t.Run(tc.name, func(t *testing.T) { g := NewWithT(t) diff --git a/azure/services/publicips/spec.go b/azure/services/publicips/spec.go index 2be124fe42e..7fe506c0b87 100644 --- a/azure/services/publicips/spec.go +++ b/azure/services/publicips/spec.go @@ -23,6 +23,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v4" "github.com/pkg/errors" "k8s.io/utils/ptr" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure/converters" ) @@ -57,7 +58,7 @@ func (s *PublicIPSpec) OwnerResourceName() string { } // Parameters returns the parameters for the public IP. -func (s *PublicIPSpec) Parameters(ctx context.Context, existing interface{}) (params interface{}, err error) { +func (s *PublicIPSpec) Parameters(_ context.Context, existing interface{}) (params interface{}, err error) { if existing != nil { if _, ok := existing.(armnetwork.PublicIPAddress); !ok { return nil, errors.Errorf("%T is not an armnetwork.PublicIPAddress", existing) diff --git a/azure/services/publicips/spec_test.go b/azure/services/publicips/spec_test.go index 00a82474f47..b3f86f1765f 100644 --- a/azure/services/publicips/spec_test.go +++ b/azure/services/publicips/spec_test.go @@ -25,6 +25,7 @@ import ( "github.com/google/go-cmp/cmp" . "github.com/onsi/gomega" "k8s.io/utils/ptr" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" ) @@ -146,7 +147,6 @@ func TestParameters(t *testing.T) { } for _, tc := range testCases { - tc := tc t.Run(tc.name, func(t *testing.T) { g := NewWithT(t) t.Parallel() diff --git a/azure/services/resourcehealth/client.go b/azure/services/resourcehealth/client.go index 7c0574a36f8..a597dbfae97 100644 --- a/azure/services/resourcehealth/client.go +++ b/azure/services/resourcehealth/client.go @@ -21,6 +21,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resourcehealth/armresourcehealth" "github.com/pkg/errors" + "sigs.k8s.io/cluster-api-provider-azure/azure" "sigs.k8s.io/cluster-api-provider-azure/util/tele" ) diff --git a/azure/services/resourcehealth/resourcehealth.go b/azure/services/resourcehealth/resourcehealth.go index 74381fe54ee..df4171b0f6b 100644 --- a/azure/services/resourcehealth/resourcehealth.go +++ b/azure/services/resourcehealth/resourcehealth.go @@ -21,13 +21,14 @@ import ( "github.com/pkg/errors" corev1 "k8s.io/api/core/v1" + clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" + "sigs.k8s.io/cluster-api/util/conditions" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" "sigs.k8s.io/cluster-api-provider-azure/azure/converters" "sigs.k8s.io/cluster-api-provider-azure/feature" "sigs.k8s.io/cluster-api-provider-azure/util/tele" - clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" - "sigs.k8s.io/cluster-api/util/conditions" ) const serviceName = "resourcehealth" @@ -109,6 +110,6 @@ func (s *Service) Delete(ctx context.Context) error { } // IsManaged always returns true. -func (s *Service) IsManaged(ctx context.Context) (bool, error) { +func (s *Service) IsManaged(_ context.Context) (bool, error) { return true, nil } diff --git a/azure/services/resourcehealth/resourcehealth_test.go b/azure/services/resourcehealth/resourcehealth_test.go index 52a621884dd..2c871d6e104 100644 --- a/azure/services/resourcehealth/resourcehealth_test.go +++ b/azure/services/resourcehealth/resourcehealth_test.go @@ -26,11 +26,12 @@ import ( "go.uber.org/mock/gomock" utilfeature "k8s.io/component-base/featuregate/testing" "k8s.io/utils/ptr" + "sigs.k8s.io/cluster-api/util/conditions" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure/services/resourcehealth/mock_resourcehealth" "sigs.k8s.io/cluster-api-provider-azure/feature" gomockinternal "sigs.k8s.io/cluster-api-provider-azure/internal/test/matchers/gomock" - "sigs.k8s.io/cluster-api/util/conditions" ) func TestReconcileResourceHealth(t *testing.T) { diff --git a/azure/services/resourceskus/cache.go b/azure/services/resourceskus/cache.go index d4d542cb2df..10a4af0c796 100644 --- a/azure/services/resourceskus/cache.go +++ b/azure/services/resourceskus/cache.go @@ -27,6 +27,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v5" "github.com/pkg/errors" "k8s.io/utils/ptr" + "sigs.k8s.io/cluster-api-provider-azure/azure" "sigs.k8s.io/cluster-api-provider-azure/util/cache/ttllru" "sigs.k8s.io/cluster-api-provider-azure/util/tele" diff --git a/azure/services/resourceskus/cache_test.go b/azure/services/resourceskus/cache_test.go index 864fc8dbe9c..c8a24ae91af 100644 --- a/azure/services/resourceskus/cache_test.go +++ b/azure/services/resourceskus/cache_test.go @@ -63,7 +63,6 @@ func TestCacheGet(t *testing.T) { } for name, tc := range cases { - tc := tc t.Run(name, func(t *testing.T) { t.Parallel() @@ -227,7 +226,6 @@ func TestCacheGetZones(t *testing.T) { } for name, tc := range cases { - tc := tc t.Run(name, func(t *testing.T) { t.Parallel() @@ -240,7 +238,7 @@ func TestCacheGetZones(t *testing.T) { t.Error(err) } if diff := cmp.Diff(zones, tc.want, []cmp.Option{cmpopts.EquateEmpty()}...); diff != "" { - t.Errorf(diff) + t.Errorf("%s", diff) } }) } @@ -376,7 +374,6 @@ func TestCacheGetZonesWithVMSize(t *testing.T) { } for name, tc := range cases { - tc := tc t.Run(name, func(t *testing.T) { t.Parallel() @@ -389,7 +386,7 @@ func TestCacheGetZonesWithVMSize(t *testing.T) { t.Error(err) } if diff := cmp.Diff(zones, tc.want, []cmp.Option{cmpopts.EquateEmpty()}...); diff != "" { - t.Fatalf(diff) + t.Fatalf("%s", diff) } }) } diff --git a/azure/services/resourceskus/client.go b/azure/services/resourceskus/client.go index 70b9b6a3f13..ed84116192f 100644 --- a/azure/services/resourceskus/client.go +++ b/azure/services/resourceskus/client.go @@ -21,6 +21,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v5" "github.com/pkg/errors" + "sigs.k8s.io/cluster-api-provider-azure/azure" "sigs.k8s.io/cluster-api-provider-azure/util/tele" ) diff --git a/azure/services/roleassignments/client.go b/azure/services/roleassignments/client.go index 4ea6ffc3e70..dd7643ec8d3 100644 --- a/azure/services/roleassignments/client.go +++ b/azure/services/roleassignments/client.go @@ -22,6 +22,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/authorization/armauthorization/v2" "github.com/pkg/errors" + "sigs.k8s.io/cluster-api-provider-azure/azure" "sigs.k8s.io/cluster-api-provider-azure/util/tele" ) @@ -58,7 +59,7 @@ func (ac *azureClient) Get(ctx context.Context, spec azure.ResourceSpecGetter) ( // CreateOrUpdateAsync creates a roleassignment. // Creating a roleassignment is not a long running operation, so we don't ever return a poller. -func (ac *azureClient) CreateOrUpdateAsync(ctx context.Context, spec azure.ResourceSpecGetter, resumeToken string, parameters interface{}) (result interface{}, poller *runtime.Poller[armauthorization.RoleAssignmentsClientCreateResponse], err error) { +func (ac *azureClient) CreateOrUpdateAsync(ctx context.Context, spec azure.ResourceSpecGetter, resumeToken string, parameters interface{}) (result interface{}, poller *runtime.Poller[armauthorization.RoleAssignmentsClientCreateResponse], err error) { //nolint:revive // keeping resumeToken for readability ctx, _, done := tele.StartSpanWithLogger(ctx, "roleassignments.azureClient.CreateOrUpdateAsync") defer done() diff --git a/azure/services/roleassignments/roleassignments.go b/azure/services/roleassignments/roleassignments.go index 344c319cde9..c8cb16d5352 100644 --- a/azure/services/roleassignments/roleassignments.go +++ b/azure/services/roleassignments/roleassignments.go @@ -22,6 +22,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/authorization/armauthorization/v2" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v5" "github.com/pkg/errors" + "sigs.k8s.io/cluster-api-provider-azure/azure" "sigs.k8s.io/cluster-api-provider-azure/azure/services/async" "sigs.k8s.io/cluster-api-provider-azure/azure/services/scalesets" @@ -180,6 +181,6 @@ func (s *Service) Delete(ctx context.Context) error { } // IsManaged returns always returns true as CAPZ does not support BYO role assignments. -func (s *Service) IsManaged(ctx context.Context) (bool, error) { +func (s *Service) IsManaged(_ context.Context) (bool, error) { return true, nil } diff --git a/azure/services/roleassignments/roleassignments_test.go b/azure/services/roleassignments/roleassignments_test.go index 1a2824b24c0..9b203db3b45 100644 --- a/azure/services/roleassignments/roleassignments_test.go +++ b/azure/services/roleassignments/roleassignments_test.go @@ -29,6 +29,7 @@ import ( . "github.com/onsi/gomega" "go.uber.org/mock/gomock" "k8s.io/utils/ptr" + "sigs.k8s.io/cluster-api-provider-azure/azure" "sigs.k8s.io/cluster-api-provider-azure/azure/services/async/mock_async" "sigs.k8s.io/cluster-api-provider-azure/azure/services/roleassignments/mock_roleassignments" @@ -141,7 +142,6 @@ func TestReconcileRoleAssignmentsVM(t *testing.T) { } for _, tc := range testcases { - tc := tc t.Run(tc.name, func(t *testing.T) { g := NewWithT(t) t.Parallel() @@ -236,7 +236,6 @@ func TestReconcileRoleAssignmentsVMSS(t *testing.T) { } for _, tc := range testcases { - tc := tc t.Run(tc.name, func(t *testing.T) { g := NewWithT(t) t.Parallel() diff --git a/azure/services/roleassignments/spec.go b/azure/services/roleassignments/spec.go index 42b86629146..78b91e7f227 100644 --- a/azure/services/roleassignments/spec.go +++ b/azure/services/roleassignments/spec.go @@ -53,7 +53,7 @@ func (s *RoleAssignmentSpec) OwnerResourceName() string { } // Parameters returns the parameters for the RoleAssignmentSpec. -func (s *RoleAssignmentSpec) Parameters(ctx context.Context, existing interface{}) (interface{}, error) { +func (s *RoleAssignmentSpec) Parameters(_ context.Context, existing interface{}) (interface{}, error) { if existing != nil { if _, ok := existing.(armauthorization.RoleAssignment); !ok { return nil, errors.Errorf("%T is not an armauthorization.RoleAssignment", existing) diff --git a/azure/services/roleassignments/spec_test.go b/azure/services/roleassignments/spec_test.go index 12806ca7921..95291af516a 100644 --- a/azure/services/roleassignments/spec_test.go +++ b/azure/services/roleassignments/spec_test.go @@ -85,7 +85,6 @@ func TestRoleAssignmentSpec_Parameters(t *testing.T) { }, } for _, tc := range testCases { - tc := tc t.Run(tc.name, func(t *testing.T) { g := NewWithT(t) t.Parallel() diff --git a/azure/services/routetables/client.go b/azure/services/routetables/client.go index 1225fa6cbbe..b535d6d0c66 100644 --- a/azure/services/routetables/client.go +++ b/azure/services/routetables/client.go @@ -23,6 +23,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v4" "github.com/pkg/errors" + "sigs.k8s.io/cluster-api-provider-azure/azure" "sigs.k8s.io/cluster-api-provider-azure/azure/services/async" "sigs.k8s.io/cluster-api-provider-azure/util/tele" diff --git a/azure/services/routetables/routetables.go b/azure/services/routetables/routetables.go index b4bc34a3b11..54812a51b0a 100644 --- a/azure/services/routetables/routetables.go +++ b/azure/services/routetables/routetables.go @@ -21,6 +21,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v4" "github.com/pkg/errors" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" "sigs.k8s.io/cluster-api-provider-azure/azure/services/async" diff --git a/azure/services/routetables/routetables_test.go b/azure/services/routetables/routetables_test.go index 91e54f2d2eb..f4e4964eef4 100644 --- a/azure/services/routetables/routetables_test.go +++ b/azure/services/routetables/routetables_test.go @@ -23,6 +23,7 @@ import ( . "github.com/onsi/gomega" "go.uber.org/mock/gomock" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" "sigs.k8s.io/cluster-api-provider-azure/azure/services/async/mock_async" @@ -114,7 +115,6 @@ func TestReconcileRouteTables(t *testing.T) { } for _, tc := range testcases { - tc := tc t.Run(tc.name, func(t *testing.T) { g := NewWithT(t) t.Parallel() @@ -204,7 +204,6 @@ func TestDeleteRouteTable(t *testing.T) { } for _, tc := range testcases { - tc := tc t.Run(tc.name, func(t *testing.T) { g := NewWithT(t) t.Parallel() diff --git a/azure/services/routetables/spec.go b/azure/services/routetables/spec.go index 2b16eca4b05..091a25e4118 100644 --- a/azure/services/routetables/spec.go +++ b/azure/services/routetables/spec.go @@ -22,6 +22,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v4" "github.com/pkg/errors" "k8s.io/utils/ptr" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure/converters" ) @@ -51,7 +52,7 @@ func (s *RouteTableSpec) OwnerResourceName() string { } // Parameters returns the parameters for the route table. -func (s *RouteTableSpec) Parameters(ctx context.Context, existing interface{}) (params interface{}, err error) { +func (s *RouteTableSpec) Parameters(_ context.Context, existing interface{}) (params interface{}, err error) { if existing != nil { if _, ok := existing.(armnetwork.RouteTable); !ok { return nil, errors.Errorf("%T is not an armnetwork.RouteTable", existing) diff --git a/azure/services/routetables/spec_test.go b/azure/services/routetables/spec_test.go index 2c4352e46a6..01abb65dffc 100644 --- a/azure/services/routetables/spec_test.go +++ b/azure/services/routetables/spec_test.go @@ -94,7 +94,6 @@ func TestRouteTableSpec_Parameters(t *testing.T) { }, } for _, tc := range testCases { - tc := tc t.Run(tc.name, func(t *testing.T) { g := NewWithT(t) t.Parallel() diff --git a/azure/services/scalesets/client.go b/azure/services/scalesets/client.go index 3bbc94990a3..d498a37240d 100644 --- a/azure/services/scalesets/client.go +++ b/azure/services/scalesets/client.go @@ -23,6 +23,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v5" "github.com/pkg/errors" + "sigs.k8s.io/cluster-api-provider-azure/azure" "sigs.k8s.io/cluster-api-provider-azure/azure/services/async" "sigs.k8s.io/cluster-api-provider-azure/util/tele" diff --git a/azure/services/scalesets/scalesets.go b/azure/services/scalesets/scalesets.go index 383965482e9..4311b43283e 100644 --- a/azure/services/scalesets/scalesets.go +++ b/azure/services/scalesets/scalesets.go @@ -23,6 +23,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v5" "github.com/pkg/errors" azprovider "sigs.k8s.io/cloud-provider-azure/pkg/provider" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" "sigs.k8s.io/cluster-api-provider-azure/azure/converters" @@ -297,6 +298,6 @@ func (s *Service) getVirtualMachineScaleSet(ctx context.Context, spec azure.Reso } // IsManaged returns always returns true as CAPZ does not support BYO scale set. -func (s *Service) IsManaged(ctx context.Context) (bool, error) { +func (s *Service) IsManaged(_ context.Context) (bool, error) { return true, nil } diff --git a/azure/services/scalesets/scalesets_test.go b/azure/services/scalesets/scalesets_test.go index 459feb25b8d..36cc4657de4 100644 --- a/azure/services/scalesets/scalesets_test.go +++ b/azure/services/scalesets/scalesets_test.go @@ -29,6 +29,8 @@ import ( "go.uber.org/mock/gomock" "k8s.io/client-go/kubernetes/scheme" "k8s.io/utils/ptr" + clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" "sigs.k8s.io/cluster-api-provider-azure/azure/converters" @@ -38,7 +40,6 @@ import ( gomockinternal "sigs.k8s.io/cluster-api-provider-azure/internal/test/matchers/gomock" azureutil "sigs.k8s.io/cluster-api-provider-azure/util/azure" "sigs.k8s.io/cluster-api-provider-azure/util/reconciler" - clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" ) const ( @@ -310,7 +311,6 @@ func TestReconcileVMSS(t *testing.T) { } for _, tc := range testcases { - tc := tc t.Run(tc.name, func(t *testing.T) { g := NewWithT(t) t.Parallel() @@ -393,7 +393,6 @@ func TestDeleteVMSS(t *testing.T) { } for _, tc := range testcases { - tc := tc t.Run(tc.name, func(t *testing.T) { g := NewWithT(t) t.Parallel() diff --git a/azure/services/scalesets/spec.go b/azure/services/scalesets/spec.go index c014d7db5c2..e75d9ac62e2 100644 --- a/azure/services/scalesets/spec.go +++ b/azure/services/scalesets/spec.go @@ -25,6 +25,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v5" "github.com/pkg/errors" "k8s.io/utils/ptr" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" "sigs.k8s.io/cluster-api-provider-azure/azure/converters" @@ -288,7 +289,6 @@ func hasModelModifyingDifferences(infraVMSS *azure.VMSS, vmss armcompute.Virtual func (s *ScaleSetSpec) generateExtensions(ctx context.Context) ([]armcompute.VirtualMachineScaleSetExtension, error) { extensions := make([]armcompute.VirtualMachineScaleSetExtension, len(s.VMSSExtensionSpecs)) for i, extensionSpec := range s.VMSSExtensionSpecs { - extensionSpec := extensionSpec parameters, err := extensionSpec.Parameters(ctx, nil) if err != nil { return nil, err @@ -331,7 +331,7 @@ func (s *ScaleSetSpec) getVirtualMachineScaleSetNetworkConfiguration() *[]armcom ipconfigs := []armcompute.VirtualMachineScaleSetIPConfiguration{} for j := 0; j < n.PrivateIPConfigs; j++ { ipconfig := armcompute.VirtualMachineScaleSetIPConfiguration{ - Name: ptr.To(fmt.Sprintf("ipConfig" + strconv.Itoa(j))), + Name: ptr.To(fmt.Sprintf("ipConfig%d", j)), Properties: &armcompute.VirtualMachineScaleSetIPConfigurationProperties{ PrivateIPAddressVersion: ptr.To(armcompute.IPVersionIPv4), Subnet: &armcompute.APIEntityReference{ diff --git a/azure/services/scalesets/spec_test.go b/azure/services/scalesets/spec_test.go index 361741dab7b..de28224c2f3 100644 --- a/azure/services/scalesets/spec_test.go +++ b/azure/services/scalesets/spec_test.go @@ -26,6 +26,7 @@ import ( . "github.com/onsi/gomega" "k8s.io/apimachinery/pkg/api/resource" "k8s.io/utils/ptr" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" "sigs.k8s.io/cluster-api-provider-azure/azure/services/resourceskus" @@ -713,7 +714,6 @@ func TestScaleSetParameters(t *testing.T) { }, } for _, tc := range testcases { - tc := tc t.Run(tc.name, func(t *testing.T) { g := NewWithT(t) t.Parallel() diff --git a/azure/services/scalesets/vmssextension_spec.go b/azure/services/scalesets/vmssextension_spec.go index 0f5c7e8d57c..f8e45e6e49f 100644 --- a/azure/services/scalesets/vmssextension_spec.go +++ b/azure/services/scalesets/vmssextension_spec.go @@ -22,6 +22,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v5" "github.com/pkg/errors" "k8s.io/utils/ptr" + "sigs.k8s.io/cluster-api-provider-azure/azure" ) @@ -47,7 +48,7 @@ func (s *VMSSExtensionSpec) OwnerResourceName() string { } // Parameters returns the parameters for the VMSS extension. -func (s *VMSSExtensionSpec) Parameters(ctx context.Context, existing interface{}) (interface{}, error) { +func (s *VMSSExtensionSpec) Parameters(_ context.Context, existing interface{}) (interface{}, error) { if existing != nil { _, ok := existing.(armcompute.VirtualMachineScaleSetExtension) if !ok { diff --git a/azure/services/scalesets/vmssextension_spec_test.go b/azure/services/scalesets/vmssextension_spec_test.go index 8bed3d5a5cc..cc4c0db1ea8 100644 --- a/azure/services/scalesets/vmssextension_spec_test.go +++ b/azure/services/scalesets/vmssextension_spec_test.go @@ -23,6 +23,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v5" . "github.com/onsi/gomega" "k8s.io/utils/ptr" + "sigs.k8s.io/cluster-api-provider-azure/azure" ) @@ -79,7 +80,6 @@ func TestVMSSExtensionParameters(t *testing.T) { }, } for _, tc := range testcases { - tc := tc t.Run(tc.name, func(t *testing.T) { g := NewWithT(t) t.Parallel() diff --git a/azure/services/scalesetvms/client.go b/azure/services/scalesetvms/client.go index d146984dec7..b4aab4471e5 100644 --- a/azure/services/scalesetvms/client.go +++ b/azure/services/scalesetvms/client.go @@ -23,6 +23,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v5" "github.com/pkg/errors" + "sigs.k8s.io/cluster-api-provider-azure/azure" "sigs.k8s.io/cluster-api-provider-azure/azure/services/async" "sigs.k8s.io/cluster-api-provider-azure/util/tele" @@ -69,7 +70,7 @@ func (ac *azureClient) Get(ctx context.Context, spec azure.ResourceSpecGetter) ( } // CreateOrUpdateAsync is a dummy implementation to fulfill the async.Reconciler interface. -func (ac *azureClient) CreateOrUpdateAsync(ctx context.Context, spec azure.ResourceSpecGetter, resumeToken string, parameters interface{}) (result interface{}, poller *runtime.Poller[armcompute.VirtualMachineScaleSetVMsClientUpdateResponse], err error) { +func (ac *azureClient) CreateOrUpdateAsync(ctx context.Context, _ azure.ResourceSpecGetter, _ string, _ interface{}) (result interface{}, poller *runtime.Poller[armcompute.VirtualMachineScaleSetVMsClientUpdateResponse], err error) { _, _, done := tele.StartSpanWithLogger(ctx, "scalesets.AzureClient.CreateOrUpdateAsync") defer done() diff --git a/azure/services/scalesetvms/scalesetvms.go b/azure/services/scalesetvms/scalesetvms.go index 42de959547a..1478f0a390b 100644 --- a/azure/services/scalesetvms/scalesetvms.go +++ b/azure/services/scalesetvms/scalesetvms.go @@ -23,6 +23,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v5" "github.com/pkg/errors" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" "sigs.k8s.io/cluster-api-provider-azure/azure/converters" diff --git a/azure/services/scalesetvms/scalesetvms_test.go b/azure/services/scalesetvms/scalesetvms_test.go index 7072cd9b054..b01af229d22 100644 --- a/azure/services/scalesetvms/scalesetvms_test.go +++ b/azure/services/scalesetvms/scalesetvms_test.go @@ -27,6 +27,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v5" . "github.com/onsi/gomega" "go.uber.org/mock/gomock" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure/converters" "sigs.k8s.io/cluster-api-provider-azure/azure/services/async/mock_async" @@ -134,7 +135,6 @@ func TestReconcileVMSS(t *testing.T) { } for _, tc := range testcases { - tc := tc t.Run(tc.name, func(t *testing.T) { g := NewWithT(t) t.Parallel() @@ -209,7 +209,6 @@ func TestDeleteVMSS(t *testing.T) { } for _, tc := range testcases { - tc := tc t.Run(tc.name, func(t *testing.T) { g := NewWithT(t) t.Parallel() diff --git a/azure/services/scalesetvms/spec.go b/azure/services/scalesetvms/spec.go index 2dbba5cbe1f..38960869730 100644 --- a/azure/services/scalesetvms/spec.go +++ b/azure/services/scalesetvms/spec.go @@ -47,7 +47,7 @@ func (s *ScaleSetVMSpec) OwnerResourceName() string { } // Parameters is a no-op for VMSS VMs as this spec is only used to Get(). -func (s *ScaleSetVMSpec) Parameters(ctx context.Context, existing interface{}) (params interface{}, err error) { +func (s *ScaleSetVMSpec) Parameters(_ context.Context, _ interface{}) (params interface{}, err error) { return nil, nil } @@ -73,6 +73,6 @@ func (s *VMSSFlexGetter) OwnerResourceName() string { } // Parameters is a no-op for flex VMs as this spec is only used to Get(). -func (s *VMSSFlexGetter) Parameters(ctx context.Context, existing interface{}) (params interface{}, err error) { +func (s *VMSSFlexGetter) Parameters(_ context.Context, _ interface{}) (params interface{}, err error) { return nil, nil } diff --git a/azure/services/securitygroups/client.go b/azure/services/securitygroups/client.go index 94d1ecd89f5..607048860d0 100644 --- a/azure/services/securitygroups/client.go +++ b/azure/services/securitygroups/client.go @@ -24,6 +24,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v4" "github.com/pkg/errors" + "sigs.k8s.io/cluster-api-provider-azure/azure" "sigs.k8s.io/cluster-api-provider-azure/azure/services/async" "sigs.k8s.io/cluster-api-provider-azure/util/tele" diff --git a/azure/services/securitygroups/securitygroups.go b/azure/services/securitygroups/securitygroups.go index c56d056224b..8922b5a71b5 100644 --- a/azure/services/securitygroups/securitygroups.go +++ b/azure/services/securitygroups/securitygroups.go @@ -21,6 +21,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v4" "github.com/pkg/errors" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" "sigs.k8s.io/cluster-api-provider-azure/azure/services/async" diff --git a/azure/services/securitygroups/securitygroups_test.go b/azure/services/securitygroups/securitygroups_test.go index 7468045ad81..a98fcd53daf 100644 --- a/azure/services/securitygroups/securitygroups_test.go +++ b/azure/services/securitygroups/securitygroups_test.go @@ -25,6 +25,7 @@ import ( "github.com/pkg/errors" "go.uber.org/mock/gomock" "k8s.io/utils/ptr" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" "sigs.k8s.io/cluster-api-provider-azure/azure/services/async/mock_async" @@ -180,7 +181,6 @@ func TestReconcileSecurityGroups(t *testing.T) { }, } for _, tc := range testcases { - tc := tc t.Run(tc.name, func(t *testing.T) { g := NewWithT(t) t.Parallel() @@ -271,7 +271,6 @@ func TestDeleteSecurityGroups(t *testing.T) { }, } for _, tc := range testcases { - tc := tc t.Run(tc.name, func(t *testing.T) { g := NewWithT(t) t.Parallel() diff --git a/azure/services/securitygroups/spec.go b/azure/services/securitygroups/spec.go index a63c12fce85..c2a7d711f1e 100644 --- a/azure/services/securitygroups/spec.go +++ b/azure/services/securitygroups/spec.go @@ -23,6 +23,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v4" "github.com/pkg/errors" "k8s.io/utils/ptr" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure/converters" ) @@ -54,7 +55,7 @@ func (s *NSGSpec) OwnerResourceName() string { } // Parameters returns the parameters for the security group. -func (s *NSGSpec) Parameters(ctx context.Context, existing interface{}) (interface{}, error) { +func (s *NSGSpec) Parameters(_ context.Context, existing interface{}) (interface{}, error) { securityRules := make([]*armnetwork.SecurityRule, 0) newAnnotation := map[string]string{} var etag *string diff --git a/azure/services/securitygroups/spec_test.go b/azure/services/securitygroups/spec_test.go index 6383c879500..c132e56bfdc 100644 --- a/azure/services/securitygroups/spec_test.go +++ b/azure/services/securitygroups/spec_test.go @@ -23,6 +23,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v4" . "github.com/onsi/gomega" "k8s.io/utils/ptr" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure/converters" ) @@ -354,7 +355,6 @@ func TestParameters(t *testing.T) { } for _, tc := range testcases { - tc := tc t.Run(tc.name, func(t *testing.T) { g := NewWithT(t) t.Parallel() @@ -398,7 +398,6 @@ func TestRuleExists(t *testing.T) { }, } for _, tc := range testcases { - tc := tc t.Run(tc.name, func(t *testing.T) { g := NewWithT(t) t.Parallel() diff --git a/azure/services/subnets/spec.go b/azure/services/subnets/spec.go index fef46534d40..039d1213e2a 100644 --- a/azure/services/subnets/spec.go +++ b/azure/services/subnets/spec.go @@ -24,6 +24,7 @@ import ( "github.com/Azure/azure-service-operator/v2/pkg/genruntime" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/utils/ptr" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" ) @@ -55,7 +56,7 @@ func (s *SubnetSpec) ResourceRef() *asonetworkv1.VirtualNetworksSubnet { } // Parameters implements azure.ASOResourceSpecGetter. -func (s *SubnetSpec) Parameters(ctx context.Context, existing *asonetworkv1.VirtualNetworksSubnet) (parameters *asonetworkv1.VirtualNetworksSubnet, err error) { +func (s *SubnetSpec) Parameters(_ context.Context, existing *asonetworkv1.VirtualNetworksSubnet) (parameters *asonetworkv1.VirtualNetworksSubnet, err error) { subnet := existing if subnet == nil { subnet = &asonetworkv1.VirtualNetworksSubnet{} @@ -97,7 +98,8 @@ func (s *SubnetSpec) Parameters(ctx context.Context, existing *asonetworkv1.Virt } } - var serviceEndpoints []asonetworkv1.ServiceEndpointPropertiesFormat + // TODO (nojnhuh) : do we want to initialize serviceEndpoints with an empty slice instead? + var serviceEndpoints []asonetworkv1.ServiceEndpointPropertiesFormat //nolint:prealloc // leaving it as is for now for _, se := range s.ServiceEndpoints { serviceEndpoints = append(serviceEndpoints, asonetworkv1.ServiceEndpointPropertiesFormat{Service: ptr.To(se.Service), Locations: se.Locations}) } @@ -107,6 +109,6 @@ func (s *SubnetSpec) Parameters(ctx context.Context, existing *asonetworkv1.Virt } // WasManaged implements azure.ASOResourceSpecGetter. -func (s *SubnetSpec) WasManaged(resource *asonetworkv1.VirtualNetworksSubnet) bool { +func (s *SubnetSpec) WasManaged(_ *asonetworkv1.VirtualNetworksSubnet) bool { return s.IsVNetManaged } diff --git a/azure/services/subnets/spec_test.go b/azure/services/subnets/spec_test.go index b1700428e48..127c9b91aaf 100644 --- a/azure/services/subnets/spec_test.go +++ b/azure/services/subnets/spec_test.go @@ -25,6 +25,7 @@ import ( "github.com/google/go-cmp/cmp" . "github.com/onsi/gomega" "k8s.io/utils/ptr" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" ) diff --git a/azure/services/subnets/subnets.go b/azure/services/subnets/subnets.go index 22a90756d81..91e233a941f 100644 --- a/azure/services/subnets/subnets.go +++ b/azure/services/subnets/subnets.go @@ -21,12 +21,13 @@ import ( asonetworkv1 "github.com/Azure/azure-service-operator/v2/api/network/v1api20201101" "k8s.io/utils/ptr" + "sigs.k8s.io/controller-runtime/pkg/client" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" "sigs.k8s.io/cluster-api-provider-azure/azure/converters" "sigs.k8s.io/cluster-api-provider-azure/azure/services/aso" "sigs.k8s.io/cluster-api-provider-azure/util/slice" - "sigs.k8s.io/controller-runtime/pkg/client" ) const serviceName = "subnets" diff --git a/azure/services/subnets/subnets_test.go b/azure/services/subnets/subnets_test.go index 21dee693de5..c02f3df89ff 100644 --- a/azure/services/subnets/subnets_test.go +++ b/azure/services/subnets/subnets_test.go @@ -25,6 +25,7 @@ import ( "github.com/pkg/errors" "go.uber.org/mock/gomock" "k8s.io/utils/ptr" + "sigs.k8s.io/cluster-api-provider-azure/azure/services/subnets/mock_subnets" ) diff --git a/azure/services/tags/client.go b/azure/services/tags/client.go index 4663853cae8..ebde41d8e79 100644 --- a/azure/services/tags/client.go +++ b/azure/services/tags/client.go @@ -21,6 +21,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources" "github.com/pkg/errors" + "sigs.k8s.io/cluster-api-provider-azure/azure" "sigs.k8s.io/cluster-api-provider-azure/util/tele" ) diff --git a/azure/services/tags/tags.go b/azure/services/tags/tags.go index 567479dae0e..14adb0a629b 100644 --- a/azure/services/tags/tags.go +++ b/azure/services/tags/tags.go @@ -22,6 +22,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources" "github.com/pkg/errors" "k8s.io/utils/ptr" + "sigs.k8s.io/cluster-api-provider-azure/azure" "sigs.k8s.io/cluster-api-provider-azure/azure/converters" "sigs.k8s.io/cluster-api-provider-azure/util/tele" @@ -209,6 +210,6 @@ func TagsChanged(lastAppliedTags map[string]interface{}, desiredTags map[string] } // IsManaged returns always returns true as CAPZ does not support BYO tags. -func (s *Service) IsManaged(ctx context.Context) (bool, error) { +func (s *Service) IsManaged(_ context.Context) (bool, error) { return true, nil } diff --git a/azure/services/tags/tags_test.go b/azure/services/tags/tags_test.go index da88992ad4a..e72cd240a2a 100644 --- a/azure/services/tags/tags_test.go +++ b/azure/services/tags/tags_test.go @@ -28,6 +28,7 @@ import ( . "github.com/onsi/gomega" "go.uber.org/mock/gomock" "k8s.io/utils/ptr" + "sigs.k8s.io/cluster-api-provider-azure/azure" "sigs.k8s.io/cluster-api-provider-azure/azure/services/tags/mock_tags" gomockinternal "sigs.k8s.io/cluster-api-provider-azure/internal/test/matchers/gomock" @@ -267,7 +268,6 @@ func TestReconcileTags(t *testing.T) { } for _, tc := range testcases { - tc := tc t.Run(tc.name, func(t *testing.T) { g := NewWithT(t) t.Parallel() @@ -442,7 +442,6 @@ func TestTagsChanged(t *testing.T) { }} for name, test := range tests { - test := test t.Run(name, func(t *testing.T) { t.Parallel() changed, createdOrUpdated, deleted, newAnnotation := TagsChanged(test.lastAppliedTags, test.desiredTags, test.currentTags) diff --git a/azure/services/virtualmachineimages/cache.go b/azure/services/virtualmachineimages/cache.go index b8ad7ff14ff..d27648d5053 100644 --- a/azure/services/virtualmachineimages/cache.go +++ b/azure/services/virtualmachineimages/cache.go @@ -23,6 +23,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v5" "github.com/pkg/errors" + "sigs.k8s.io/cluster-api-provider-azure/azure" "sigs.k8s.io/cluster-api-provider-azure/util/cache/ttllru" "sigs.k8s.io/cluster-api-provider-azure/util/tele" diff --git a/azure/services/virtualmachineimages/cache_test.go b/azure/services/virtualmachineimages/cache_test.go index 79b944842d3..7842975c6ef 100644 --- a/azure/services/virtualmachineimages/cache_test.go +++ b/azure/services/virtualmachineimages/cache_test.go @@ -25,6 +25,7 @@ import ( "github.com/pkg/errors" "go.uber.org/mock/gomock" "k8s.io/utils/ptr" + "sigs.k8s.io/cluster-api-provider-azure/azure/services/virtualmachineimages/mock_virtualmachineimages" ) @@ -56,7 +57,6 @@ func TestCacheGet(t *testing.T) { } for name, tc := range cases { - tc := tc t.Run(name, func(t *testing.T) { t.Parallel() diff --git a/azure/services/virtualmachineimages/client.go b/azure/services/virtualmachineimages/client.go index 4c958196334..81d60455a25 100644 --- a/azure/services/virtualmachineimages/client.go +++ b/azure/services/virtualmachineimages/client.go @@ -21,6 +21,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v5" "github.com/pkg/errors" + "sigs.k8s.io/cluster-api-provider-azure/azure" "sigs.k8s.io/cluster-api-provider-azure/util/tele" ) diff --git a/azure/services/virtualmachineimages/images.go b/azure/services/virtualmachineimages/images.go index 54ba6691221..69637bd23dc 100644 --- a/azure/services/virtualmachineimages/images.go +++ b/azure/services/virtualmachineimages/images.go @@ -24,6 +24,7 @@ import ( "github.com/blang/semver" "github.com/pkg/errors" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" "sigs.k8s.io/cluster-api-provider-azure/util/tele" diff --git a/azure/services/virtualmachineimages/images_test.go b/azure/services/virtualmachineimages/images_test.go index a2f95042680..e46be00a67a 100644 --- a/azure/services/virtualmachineimages/images_test.go +++ b/azure/services/virtualmachineimages/images_test.go @@ -26,6 +26,7 @@ import ( . "github.com/onsi/gomega" "go.uber.org/mock/gomock" "k8s.io/utils/ptr" + "sigs.k8s.io/cluster-api-provider-azure/azure" "sigs.k8s.io/cluster-api-provider-azure/azure/mock_azure" "sigs.k8s.io/cluster-api-provider-azure/azure/services/virtualmachineimages/mock_virtualmachineimages" @@ -218,7 +219,6 @@ func TestGetDefaultUbuntuImage(t *testing.T) { location := "westus3" for _, test := range tests { - test := test t.Run(test.k8sVersion, func(t *testing.T) { t.Parallel() @@ -559,7 +559,6 @@ func TestGetDefaultImageSKUID(t *testing.T) { location := "francesouth" for _, test := range tests { - test := test t.Run(test.k8sVersion, func(t *testing.T) { t.Parallel() diff --git a/azure/services/virtualmachines/client.go b/azure/services/virtualmachines/client.go index 2862f4b90d2..1e2bbea08d4 100644 --- a/azure/services/virtualmachines/client.go +++ b/azure/services/virtualmachines/client.go @@ -24,6 +24,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v5" "github.com/pkg/errors" "k8s.io/utils/ptr" + "sigs.k8s.io/cluster-api-provider-azure/azure" "sigs.k8s.io/cluster-api-provider-azure/azure/services/async" "sigs.k8s.io/cluster-api-provider-azure/util/tele" diff --git a/azure/services/virtualmachines/spec.go b/azure/services/virtualmachines/spec.go index b60e88e81d0..7f626366edc 100644 --- a/azure/services/virtualmachines/spec.go +++ b/azure/services/virtualmachines/spec.go @@ -24,6 +24,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v5" "github.com/pkg/errors" "k8s.io/utils/ptr" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" "sigs.k8s.io/cluster-api-provider-azure/azure/converters" @@ -77,7 +78,7 @@ func (s *VMSpec) OwnerResourceName() string { } // Parameters returns the parameters for the virtual machine. -func (s *VMSpec) Parameters(ctx context.Context, existing interface{}) (params interface{}, err error) { +func (s *VMSpec) Parameters(_ context.Context, existing interface{}) (params interface{}, err error) { if existing != nil { if _, ok := existing.(armcompute.VirtualMachine); !ok { return nil, errors.Errorf("%T is not an armcompute.VirtualMachine", existing) diff --git a/azure/services/virtualmachines/spec_test.go b/azure/services/virtualmachines/spec_test.go index 1e5613b74c2..6f6523cc476 100644 --- a/azure/services/virtualmachines/spec_test.go +++ b/azure/services/virtualmachines/spec_test.go @@ -25,6 +25,7 @@ import ( "github.com/google/go-cmp/cmp" . "github.com/onsi/gomega" "k8s.io/utils/ptr" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" "sigs.k8s.io/cluster-api-provider-azure/azure/services/resourceskus" @@ -1418,7 +1419,6 @@ func TestParameters(t *testing.T) { }, } for _, tc := range testcases { - tc := tc t.Run(tc.name, func(t *testing.T) { g := NewWithT(t) t.Parallel() diff --git a/azure/services/virtualmachines/virtualmachines.go b/azure/services/virtualmachines/virtualmachines.go index 3fd31370786..64623d494a3 100644 --- a/azure/services/virtualmachines/virtualmachines.go +++ b/azure/services/virtualmachines/virtualmachines.go @@ -26,6 +26,8 @@ import ( corev1 "k8s.io/api/core/v1" "k8s.io/utils/ptr" azprovider "sigs.k8s.io/cloud-provider-azure/pkg/provider" + clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" "sigs.k8s.io/cluster-api-provider-azure/azure/converters" @@ -35,7 +37,6 @@ import ( "sigs.k8s.io/cluster-api-provider-azure/azure/services/publicips" azureutil "sigs.k8s.io/cluster-api-provider-azure/util/azure" "sigs.k8s.io/cluster-api-provider-azure/util/tele" - clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" ) const serviceName = "virtualmachine" @@ -312,6 +313,6 @@ func getResourceNameByID(resourceID string) string { } // IsManaged returns always returns true as CAPZ does not support BYO VM. -func (s *Service) IsManaged(ctx context.Context) (bool, error) { +func (s *Service) IsManaged(_ context.Context) (bool, error) { return true, nil } diff --git a/azure/services/virtualmachines/virtualmachines_test.go b/azure/services/virtualmachines/virtualmachines_test.go index 8fcc031d0e1..4da42df90b2 100644 --- a/azure/services/virtualmachines/virtualmachines_test.go +++ b/azure/services/virtualmachines/virtualmachines_test.go @@ -31,6 +31,8 @@ import ( "go.uber.org/mock/gomock" corev1 "k8s.io/api/core/v1" "k8s.io/utils/ptr" + clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure/services/async/mock_async" "sigs.k8s.io/cluster-api-provider-azure/azure/services/identities/mock_identities" @@ -39,7 +41,6 @@ import ( "sigs.k8s.io/cluster-api-provider-azure/azure/services/virtualmachines/mock_virtualmachines" gomockinternal "sigs.k8s.io/cluster-api-provider-azure/internal/test/matchers/gomock" "sigs.k8s.io/cluster-api-provider-azure/util/reconciler" - clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" ) var ( @@ -204,7 +205,6 @@ func TestReconcileVM(t *testing.T) { } for _, tc := range testcases { - tc := tc t.Run(tc.name, func(t *testing.T) { g := NewWithT(t) t.Parallel() @@ -286,7 +286,6 @@ func TestDeleteVM(t *testing.T) { } for _, tc := range testcases { - tc := tc t.Run(tc.name, func(t *testing.T) { g := NewWithT(t) t.Parallel() @@ -395,7 +394,6 @@ func TestCheckUserAssignedIdentities(t *testing.T) { }, } for _, tc := range testcases { - tc := tc t.Run(tc.name, func(t *testing.T) { g := NewWithT(t) t.Parallel() diff --git a/azure/services/virtualnetworks/spec.go b/azure/services/virtualnetworks/spec.go index b2697becd75..1d3100b5ae9 100644 --- a/azure/services/virtualnetworks/spec.go +++ b/azure/services/virtualnetworks/spec.go @@ -23,6 +23,7 @@ import ( "github.com/Azure/azure-service-operator/v2/pkg/genruntime" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/utils/ptr" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" "sigs.k8s.io/cluster-api-provider-azure/azure/converters" @@ -49,7 +50,7 @@ func (s *VNetSpec) ResourceRef() *asonetworkv1.VirtualNetwork { } // Parameters implements azure.ASOResourceSpecGetter. -func (s *VNetSpec) Parameters(ctx context.Context, existing *asonetworkv1.VirtualNetwork) (*asonetworkv1.VirtualNetwork, error) { +func (s *VNetSpec) Parameters(_ context.Context, existing *asonetworkv1.VirtualNetwork) (*asonetworkv1.VirtualNetwork, error) { vnet := existing if existing == nil { vnet = &asonetworkv1.VirtualNetwork{ diff --git a/azure/services/virtualnetworks/spec_test.go b/azure/services/virtualnetworks/spec_test.go index 1af78995b9c..2751fe04352 100644 --- a/azure/services/virtualnetworks/spec_test.go +++ b/azure/services/virtualnetworks/spec_test.go @@ -25,6 +25,7 @@ import ( "github.com/google/go-cmp/cmp" . "github.com/onsi/gomega" "k8s.io/utils/ptr" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" ) diff --git a/azure/services/virtualnetworks/virtualnetworks.go b/azure/services/virtualnetworks/virtualnetworks.go index f320dc13608..e73b9eb1f5d 100644 --- a/azure/services/virtualnetworks/virtualnetworks.go +++ b/azure/services/virtualnetworks/virtualnetworks.go @@ -23,11 +23,12 @@ import ( "github.com/Azure/azure-service-operator/v2/pkg/common/labels" "github.com/pkg/errors" "k8s.io/utils/ptr" + "sigs.k8s.io/controller-runtime/pkg/client" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" "sigs.k8s.io/cluster-api-provider-azure/azure/converters" "sigs.k8s.io/cluster-api-provider-azure/azure/services/aso" - "sigs.k8s.io/controller-runtime/pkg/client" ) const serviceName = "virtualnetworks" diff --git a/azure/services/virtualnetworks/virtualnetworks_test.go b/azure/services/virtualnetworks/virtualnetworks_test.go index a19b6bc33a1..b25c78a2322 100644 --- a/azure/services/virtualnetworks/virtualnetworks_test.go +++ b/azure/services/virtualnetworks/virtualnetworks_test.go @@ -29,10 +29,11 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/utils/ptr" - infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" - "sigs.k8s.io/cluster-api-provider-azure/azure/services/virtualnetworks/mock_virtualnetworks" "sigs.k8s.io/controller-runtime/pkg/client" fakeclient "sigs.k8s.io/controller-runtime/pkg/client/fake" + + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" + "sigs.k8s.io/cluster-api-provider-azure/azure/services/virtualnetworks/mock_virtualnetworks" ) func TestPostCreateOrUpdateResourceHook(t *testing.T) { diff --git a/azure/services/vmextensions/client.go b/azure/services/vmextensions/client.go index e9afaa624e1..187007ff784 100644 --- a/azure/services/vmextensions/client.go +++ b/azure/services/vmextensions/client.go @@ -23,6 +23,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v5" "github.com/pkg/errors" + "sigs.k8s.io/cluster-api-provider-azure/azure" "sigs.k8s.io/cluster-api-provider-azure/azure/services/async" "sigs.k8s.io/cluster-api-provider-azure/util/tele" diff --git a/azure/services/vmextensions/spec.go b/azure/services/vmextensions/spec.go index 2f582375b1a..88ad1eab83a 100644 --- a/azure/services/vmextensions/spec.go +++ b/azure/services/vmextensions/spec.go @@ -22,6 +22,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v5" "github.com/pkg/errors" "k8s.io/utils/ptr" + "sigs.k8s.io/cluster-api-provider-azure/azure" ) @@ -48,7 +49,7 @@ func (s *VMExtensionSpec) OwnerResourceName() string { } // Parameters returns the parameters for the VM extension. -func (s *VMExtensionSpec) Parameters(ctx context.Context, existing interface{}) (interface{}, error) { +func (s *VMExtensionSpec) Parameters(_ context.Context, existing interface{}) (interface{}, error) { if existing != nil { _, ok := existing.(armcompute.VirtualMachineExtension) if !ok { diff --git a/azure/services/vmextensions/spec_test.go b/azure/services/vmextensions/spec_test.go index 2a63cb75a06..aca5ab970af 100644 --- a/azure/services/vmextensions/spec_test.go +++ b/azure/services/vmextensions/spec_test.go @@ -23,6 +23,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v5" . "github.com/onsi/gomega" "k8s.io/utils/ptr" + "sigs.k8s.io/cluster-api-provider-azure/azure" ) @@ -80,7 +81,6 @@ func TestParameters(t *testing.T) { }, } for _, tc := range testcases { - tc := tc t.Run(tc.name, func(t *testing.T) { g := NewWithT(t) t.Parallel() diff --git a/azure/services/vmextensions/vmextensions.go b/azure/services/vmextensions/vmextensions.go index f2bc2110dc1..ef0d3d8aa8c 100644 --- a/azure/services/vmextensions/vmextensions.go +++ b/azure/services/vmextensions/vmextensions.go @@ -21,6 +21,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v5" "github.com/pkg/errors" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" "sigs.k8s.io/cluster-api-provider-azure/azure/services/async" @@ -102,6 +103,6 @@ func (s *Service) Delete(_ context.Context) error { } // IsManaged returns always returns true as CAPZ does not support BYO VM extension. -func (s *Service) IsManaged(ctx context.Context) (bool, error) { +func (s *Service) IsManaged(_ context.Context) (bool, error) { return true, nil } diff --git a/azure/services/vmextensions/vmextensions_test.go b/azure/services/vmextensions/vmextensions_test.go index 6b8ac1f65f9..3e83ba1e40b 100644 --- a/azure/services/vmextensions/vmextensions_test.go +++ b/azure/services/vmextensions/vmextensions_test.go @@ -27,6 +27,7 @@ import ( . "github.com/onsi/gomega" "github.com/pkg/errors" "go.uber.org/mock/gomock" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" "sigs.k8s.io/cluster-api-provider-azure/azure/services/async/mock_async" @@ -135,7 +136,6 @@ func TestReconcileVMExtension(t *testing.T) { }, } for _, tc := range testcases { - tc := tc t.Run(tc.name, func(t *testing.T) { g := NewWithT(t) diff --git a/azure/services/vnetpeerings/client.go b/azure/services/vnetpeerings/client.go index fc537d7e7e3..893c545d487 100644 --- a/azure/services/vnetpeerings/client.go +++ b/azure/services/vnetpeerings/client.go @@ -23,6 +23,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v4" "github.com/pkg/errors" + "sigs.k8s.io/cluster-api-provider-azure/azure" "sigs.k8s.io/cluster-api-provider-azure/azure/services/async" "sigs.k8s.io/cluster-api-provider-azure/util/tele" diff --git a/azure/services/vnetpeerings/spec.go b/azure/services/vnetpeerings/spec.go index d3138adeefe..3e414189db1 100644 --- a/azure/services/vnetpeerings/spec.go +++ b/azure/services/vnetpeerings/spec.go @@ -22,6 +22,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v4" "github.com/pkg/errors" "k8s.io/utils/ptr" + "sigs.k8s.io/cluster-api-provider-azure/azure" ) @@ -55,7 +56,7 @@ func (s *VnetPeeringSpec) OwnerResourceName() string { } // Parameters returns the parameters for the virtual network peering. -func (s *VnetPeeringSpec) Parameters(ctx context.Context, existing interface{}) (params interface{}, err error) { +func (s *VnetPeeringSpec) Parameters(_ context.Context, existing interface{}) (params interface{}, err error) { if existing != nil { if _, ok := existing.(armnetwork.VirtualNetworkPeering); !ok { return nil, errors.Errorf("%T is not an armnetwork.VnetPeering", existing) diff --git a/azure/services/vnetpeerings/spec_test.go b/azure/services/vnetpeerings/spec_test.go index 61e24951a2d..0594a5f41d1 100644 --- a/azure/services/vnetpeerings/spec_test.go +++ b/azure/services/vnetpeerings/spec_test.go @@ -23,6 +23,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v4" . "github.com/onsi/gomega" "k8s.io/utils/ptr" + "sigs.k8s.io/cluster-api-provider-azure/azure" ) @@ -97,7 +98,6 @@ func TestVnetPeeringSpec_Parameters(t *testing.T) { }, } for _, tc := range testCases { - tc := tc t.Run(tc.name, func(t *testing.T) { g := NewWithT(t) t.Parallel() diff --git a/azure/services/vnetpeerings/vnetpeerings.go b/azure/services/vnetpeerings/vnetpeerings.go index e2c1c4c5d6f..2da81551b58 100644 --- a/azure/services/vnetpeerings/vnetpeerings.go +++ b/azure/services/vnetpeerings/vnetpeerings.go @@ -20,6 +20,7 @@ import ( "context" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v4" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" "sigs.k8s.io/cluster-api-provider-azure/azure/services/async" @@ -118,6 +119,6 @@ func (s *Service) Delete(ctx context.Context) error { } // IsManaged returns always returns true as CAPZ does not support BYO VNet peering. -func (s *Service) IsManaged(ctx context.Context) (bool, error) { +func (s *Service) IsManaged(_ context.Context) (bool, error) { return true, nil } diff --git a/azure/services/vnetpeerings/vnetpeerings_test.go b/azure/services/vnetpeerings/vnetpeerings_test.go index 7b30083e86a..442b6ffdd23 100644 --- a/azure/services/vnetpeerings/vnetpeerings_test.go +++ b/azure/services/vnetpeerings/vnetpeerings_test.go @@ -28,6 +28,7 @@ import ( . "github.com/onsi/gomega" "go.uber.org/mock/gomock" "k8s.io/utils/ptr" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" "sigs.k8s.io/cluster-api-provider-azure/azure/services/async/mock_async" @@ -240,7 +241,6 @@ func TestReconcileVnetPeerings(t *testing.T) { } for _, tc := range testcases { - tc := tc t.Run(tc.name, func(t *testing.T) { g := NewWithT(t) @@ -393,7 +393,6 @@ func TestDeleteVnetPeerings(t *testing.T) { } for _, tc := range testcases { - tc := tc t.Run(tc.name, func(t *testing.T) { g := NewWithT(t) diff --git a/azure/types.go b/azure/types.go index 2e040edcc2b..da54913a54f 100644 --- a/azure/types.go +++ b/azure/types.go @@ -21,6 +21,7 @@ import ( "strings" "github.com/google/go-cmp/cmp" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" azureutil "sigs.k8s.io/cluster-api-provider-azure/util/azure" ) diff --git a/azure/types_test.go b/azure/types_test.go index f84b79761b6..fb19bb18824 100644 --- a/azure/types_test.go +++ b/azure/types_test.go @@ -21,6 +21,7 @@ import ( . "github.com/onsi/gomega" "k8s.io/utils/ptr" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" ) @@ -127,7 +128,6 @@ func TestVMSS_HasModelChanges(t *testing.T) { } for _, c := range cases { - c := c t.Run(c.Name, func(t *testing.T) { l, r := c.Factory() g := NewWithT(t) diff --git a/controllers/agentpooladopt_controller.go b/controllers/agentpooladopt_controller.go index f5e6b26089f..23726491d10 100644 --- a/controllers/agentpooladopt_controller.go +++ b/controllers/agentpooladopt_controller.go @@ -25,8 +25,6 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/utils/ptr" - infrav1alpha "sigs.k8s.io/cluster-api-provider-azure/api/v1alpha1" - "sigs.k8s.io/cluster-api-provider-azure/util/tele" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" expv1 "sigs.k8s.io/cluster-api/exp/api/v1beta1" ctrl "sigs.k8s.io/controller-runtime" @@ -34,6 +32,9 @@ import ( "sigs.k8s.io/controller-runtime/pkg/controller" "sigs.k8s.io/controller-runtime/pkg/event" "sigs.k8s.io/controller-runtime/pkg/predicate" + + infrav1alpha "sigs.k8s.io/cluster-api-provider-azure/api/v1alpha1" + "sigs.k8s.io/cluster-api-provider-azure/util/tele" ) // AgentPoolAdoptReconciler adopts ASO ManagedClustersAgentPool resources into a CAPI Cluster. @@ -42,7 +43,7 @@ type AgentPoolAdoptReconciler struct { } // SetupWithManager sets up the controller with the Manager. -func (r *AgentPoolAdoptReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Manager, options controller.Options) error { +func (r *AgentPoolAdoptReconciler) SetupWithManager(_ context.Context, mgr ctrl.Manager, options controller.Options) error { _, err := ctrl.NewControllerManagedBy(mgr). WithOptions(options). For(&asocontainerservicev1.ManagedClustersAgentPool{}). diff --git a/controllers/asosecret_controller.go b/controllers/asosecret_controller.go index 87cf98ff8f0..143b0bc9e78 100644 --- a/controllers/asosecret_controller.go +++ b/controllers/asosecret_controller.go @@ -28,11 +28,6 @@ import ( "k8s.io/apimachinery/pkg/types" "k8s.io/client-go/tools/record" "k8s.io/utils/ptr" - infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" - "sigs.k8s.io/cluster-api-provider-azure/azure/scope" - "sigs.k8s.io/cluster-api-provider-azure/util/aso" - "sigs.k8s.io/cluster-api-provider-azure/util/reconciler" - "sigs.k8s.io/cluster-api-provider-azure/util/tele" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" "sigs.k8s.io/cluster-api/util" "sigs.k8s.io/cluster-api/util/annotations" @@ -43,6 +38,12 @@ import ( "sigs.k8s.io/controller-runtime/pkg/controller" "sigs.k8s.io/controller-runtime/pkg/handler" "sigs.k8s.io/controller-runtime/pkg/reconcile" + + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" + "sigs.k8s.io/cluster-api-provider-azure/azure/scope" + "sigs.k8s.io/cluster-api-provider-azure/util/aso" + "sigs.k8s.io/cluster-api-provider-azure/util/reconciler" + "sigs.k8s.io/cluster-api-provider-azure/util/tele" ) // ASOSecretReconciler reconciles ASO secrets associated with AzureCluster objects. @@ -139,12 +140,10 @@ func (asos *ASOSecretReconciler) Reconcile(ctx context.Context, req ctrl.Request fmt.Sprintf("AzureManagedControlPlane object %s/%s not found", req.Namespace, req.Name)) log.Info("object was not found") return reconcile.Result{}, nil - } else { - return reconcile.Result{}, err } - } else { - log = log.WithValues("AzureManagedControlPlane", req.Name) + return reconcile.Result{}, err } + log = log.WithValues("AzureManagedControlPlane", req.Name) } var clusterIdentity *corev1.ObjectReference diff --git a/controllers/asosecret_controller_test.go b/controllers/asosecret_controller_test.go index 966a1c122af..bea1a9f7aba 100644 --- a/controllers/asosecret_controller_test.go +++ b/controllers/asosecret_controller_test.go @@ -29,18 +29,19 @@ import ( clientgoscheme "k8s.io/client-go/kubernetes/scheme" "k8s.io/client-go/tools/record" "k8s.io/utils/ptr" - infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/client/fake" + + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" ) func TestASOSecretReconcile(t *testing.T) { - os.Setenv("AZURE_CLIENT_ID", "fooClient") - os.Setenv("AZURE_CLIENT_SECRET", "fooSecret") - os.Setenv("AZURE_TENANT_ID", "fooTenant") - os.Setenv("AZURE_SUBSCRIPTION_ID", "fooSubscription") + os.Setenv("AZURE_CLIENT_ID", "fooClient") //nolint:tenv // we want to use os.Setenv here instead of t.Setenv + os.Setenv("AZURE_CLIENT_SECRET", "fooSecret") //nolint:tenv // we want to use os.Setenv here instead of t.Setenv + os.Setenv("AZURE_TENANT_ID", "fooTenant") //nolint:tenv // we want to use os.Setenv here instead of t.Setenv + os.Setenv("AZURE_SUBSCRIPTION_ID", "fooSubscription") //nolint:tenv // we want to use os.Setenv here instead of t.Setenv scheme := runtime.NewScheme() _ = clusterv1.AddToScheme(scheme) diff --git a/controllers/azureasomanagedcluster_controller.go b/controllers/azureasomanagedcluster_controller.go index 2c2a4ef2399..99a32c4abd3 100644 --- a/controllers/azureasomanagedcluster_controller.go +++ b/controllers/azureasomanagedcluster_controller.go @@ -23,9 +23,6 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" - infrav1alpha "sigs.k8s.io/cluster-api-provider-azure/api/v1alpha1" - "sigs.k8s.io/cluster-api-provider-azure/pkg/mutators" - "sigs.k8s.io/cluster-api-provider-azure/util/tele" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" "sigs.k8s.io/cluster-api/controllers/external" "sigs.k8s.io/cluster-api/util" @@ -41,6 +38,10 @@ import ( "sigs.k8s.io/controller-runtime/pkg/handler" "sigs.k8s.io/controller-runtime/pkg/predicate" "sigs.k8s.io/controller-runtime/pkg/reconcile" + + infrav1alpha "sigs.k8s.io/cluster-api-provider-azure/api/v1alpha1" + "sigs.k8s.io/cluster-api-provider-azure/pkg/mutators" + "sigs.k8s.io/cluster-api-provider-azure/util/tele" ) var errInvalidControlPlaneKind = errors.New("AzureASOManagedCluster cannot be used without AzureASOManagedControlPlane") @@ -264,7 +265,6 @@ func (r *AzureASOManagedClusterReconciler) reconcileNormal(ctx context.Context, return ctrl.Result{}, nil } -//nolint:unparam // an empty ctrl.Result is always returned here, leaving it as-is to avoid churn in refactoring later if that changes. func (r *AzureASOManagedClusterReconciler) reconcilePaused(ctx context.Context, asoManagedCluster *infrav1alpha.AzureASOManagedCluster) (ctrl.Result, error) { ctx, log, done := tele.StartSpanWithLogger(ctx, "controllers.AzureASOManagedClusterReconciler.reconcilePaused") defer done() @@ -285,7 +285,6 @@ func (r *AzureASOManagedClusterReconciler) reconcilePaused(ctx context.Context, return ctrl.Result{}, nil } -//nolint:unparam // an empty ctrl.Result is always returned here, leaving it as-is to avoid churn in refactoring later if that changes. func (r *AzureASOManagedClusterReconciler) reconcileDelete(ctx context.Context, asoManagedCluster *infrav1alpha.AzureASOManagedCluster) (ctrl.Result, error) { ctx, log, done := tele.StartSpanWithLogger(ctx, "controllers.AzureASOManagedClusterReconciler.reconcileDelete", diff --git a/controllers/azureasomanagedcluster_controller_test.go b/controllers/azureasomanagedcluster_controller_test.go index 4767e64469b..03f34915720 100644 --- a/controllers/azureasomanagedcluster_controller_test.go +++ b/controllers/azureasomanagedcluster_controller_test.go @@ -28,12 +28,13 @@ import ( "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/types" - infrav1alpha "sigs.k8s.io/cluster-api-provider-azure/api/v1alpha1" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" clusterctlv1 "sigs.k8s.io/cluster-api/cmd/clusterctl/api/v1alpha3" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/client" fakeclient "sigs.k8s.io/controller-runtime/pkg/client/fake" + + infrav1alpha "sigs.k8s.io/cluster-api-provider-azure/api/v1alpha1" ) type fakeResourceReconciler struct { diff --git a/controllers/azureasomanagedcontrolplane_controller.go b/controllers/azureasomanagedcontrolplane_controller.go index 3d8ed0f310a..362ffdc989e 100644 --- a/controllers/azureasomanagedcontrolplane_controller.go +++ b/controllers/azureasomanagedcontrolplane_controller.go @@ -26,9 +26,6 @@ import ( corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" - infrav1alpha "sigs.k8s.io/cluster-api-provider-azure/api/v1alpha1" - "sigs.k8s.io/cluster-api-provider-azure/pkg/mutators" - "sigs.k8s.io/cluster-api-provider-azure/util/tele" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" "sigs.k8s.io/cluster-api/controllers/external" "sigs.k8s.io/cluster-api/util" @@ -43,6 +40,10 @@ import ( "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" "sigs.k8s.io/controller-runtime/pkg/handler" "sigs.k8s.io/controller-runtime/pkg/reconcile" + + infrav1alpha "sigs.k8s.io/cluster-api-provider-azure/api/v1alpha1" + "sigs.k8s.io/cluster-api-provider-azure/pkg/mutators" + "sigs.k8s.io/cluster-api-provider-azure/util/tele" ) var errInvalidClusterKind = errors.New("AzureASOManagedControlPlane cannot be used without AzureASOManagedCluster") @@ -297,7 +298,6 @@ func (r *AzureASOManagedControlPlaneReconciler) reconcileKubeconfig(ctx context. return r.Patch(ctx, expectedSecret, client.Apply, client.FieldOwner("capz-manager"), client.ForceOwnership) } -//nolint:unparam // an empty ctrl.Result is always returned here, leaving it as-is to avoid churn in refactoring later if that changes. func (r *AzureASOManagedControlPlaneReconciler) reconcilePaused(ctx context.Context, asoManagedControlPlane *infrav1alpha.AzureASOManagedControlPlane) (ctrl.Result, error) { ctx, log, done := tele.StartSpanWithLogger(ctx, "controllers.AzureASOManagedControlPlaneReconciler.reconcilePaused") defer done() @@ -318,7 +318,6 @@ func (r *AzureASOManagedControlPlaneReconciler) reconcilePaused(ctx context.Cont return ctrl.Result{}, nil } -//nolint:unparam // an empty ctrl.Result is always returned here, leaving it as-is to avoid churn in refactoring later if that changes. func (r *AzureASOManagedControlPlaneReconciler) reconcileDelete(ctx context.Context, asoManagedControlPlane *infrav1alpha.AzureASOManagedControlPlane) (ctrl.Result, error) { ctx, log, done := tele.StartSpanWithLogger(ctx, "controllers.AzureASOManagedControlPlaneReconciler.reconcileDelete", diff --git a/controllers/azureasomanagedcontrolplane_controller_test.go b/controllers/azureasomanagedcontrolplane_controller_test.go index 707ddf9db81..1981dee1103 100644 --- a/controllers/azureasomanagedcontrolplane_controller_test.go +++ b/controllers/azureasomanagedcontrolplane_controller_test.go @@ -32,13 +32,14 @@ import ( "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/types" "k8s.io/utils/ptr" - infrav1alpha "sigs.k8s.io/cluster-api-provider-azure/api/v1alpha1" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" clusterctlv1 "sigs.k8s.io/cluster-api/cmd/clusterctl/api/v1alpha3" "sigs.k8s.io/cluster-api/util/secret" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/client" fakeclient "sigs.k8s.io/controller-runtime/pkg/client/fake" + + infrav1alpha "sigs.k8s.io/cluster-api-provider-azure/api/v1alpha1" ) func TestAzureASOManagedControlPlaneReconcile(t *testing.T) { diff --git a/controllers/azureasomanagedmachinepool_controller.go b/controllers/azureasomanagedmachinepool_controller.go index c57f8df9738..1994569d966 100644 --- a/controllers/azureasomanagedmachinepool_controller.go +++ b/controllers/azureasomanagedmachinepool_controller.go @@ -27,9 +27,6 @@ import ( "k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/util/validation" "k8s.io/utils/ptr" - infrav1alpha "sigs.k8s.io/cluster-api-provider-azure/api/v1alpha1" - "sigs.k8s.io/cluster-api-provider-azure/pkg/mutators" - "sigs.k8s.io/cluster-api-provider-azure/util/tele" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" "sigs.k8s.io/cluster-api/controllers/external" expv1 "sigs.k8s.io/cluster-api/exp/api/v1beta1" @@ -45,6 +42,10 @@ import ( "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" "sigs.k8s.io/controller-runtime/pkg/handler" "sigs.k8s.io/controller-runtime/pkg/reconcile" + + infrav1alpha "sigs.k8s.io/cluster-api-provider-azure/api/v1alpha1" + "sigs.k8s.io/cluster-api-provider-azure/pkg/mutators" + "sigs.k8s.io/cluster-api-provider-azure/util/tele" ) // AzureASOManagedMachinePoolReconciler reconciles a AzureASOManagedMachinePool object. @@ -300,7 +301,6 @@ func expectedNodeLabels(poolName, nodeRG string) map[string]string { } } -//nolint:unparam // an empty ctrl.Result is always returned here, leaving it as-is to avoid churn in refactoring later if that changes. func (r *AzureASOManagedMachinePoolReconciler) reconcilePaused(ctx context.Context, asoManagedMachinePool *infrav1alpha.AzureASOManagedMachinePool) (ctrl.Result, error) { ctx, log, done := tele.StartSpanWithLogger(ctx, "controllers.AzureASOManagedMachinePoolReconciler.reconcilePaused") defer done() @@ -321,7 +321,6 @@ func (r *AzureASOManagedMachinePoolReconciler) reconcilePaused(ctx context.Conte return ctrl.Result{}, nil } -//nolint:unparam // an empty ctrl.Result is always returned here, leaving it as-is to avoid churn in refactoring later if that changes. func (r *AzureASOManagedMachinePoolReconciler) reconcileDelete(ctx context.Context, asoManagedMachinePool *infrav1alpha.AzureASOManagedMachinePool, cluster *clusterv1.Cluster) (ctrl.Result, error) { ctx, log, done := tele.StartSpanWithLogger(ctx, "controllers.AzureASOManagedMachinePoolReconciler.reconcileDelete", diff --git a/controllers/azureasomanagedmachinepool_controller_test.go b/controllers/azureasomanagedmachinepool_controller_test.go index c66caf1630c..76aac0fd6a4 100644 --- a/controllers/azureasomanagedmachinepool_controller_test.go +++ b/controllers/azureasomanagedmachinepool_controller_test.go @@ -31,13 +31,14 @@ import ( "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/types" "k8s.io/utils/ptr" - infrav1alpha "sigs.k8s.io/cluster-api-provider-azure/api/v1alpha1" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" clusterctlv1 "sigs.k8s.io/cluster-api/cmd/clusterctl/api/v1alpha3" expv1 "sigs.k8s.io/cluster-api/exp/api/v1beta1" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/client" fakeclient "sigs.k8s.io/controller-runtime/pkg/client/fake" + + infrav1alpha "sigs.k8s.io/cluster-api-provider-azure/api/v1alpha1" ) type FakeClusterTracker struct { diff --git a/controllers/azurecluster_controller.go b/controllers/azurecluster_controller.go index fcec1e5d9b7..b32e17ab987 100644 --- a/controllers/azurecluster_controller.go +++ b/controllers/azurecluster_controller.go @@ -24,12 +24,6 @@ import ( corev1 "k8s.io/api/core/v1" apierrors "k8s.io/apimachinery/pkg/api/errors" "k8s.io/client-go/tools/record" - infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" - "sigs.k8s.io/cluster-api-provider-azure/azure" - "sigs.k8s.io/cluster-api-provider-azure/azure/scope" - "sigs.k8s.io/cluster-api-provider-azure/pkg/coalescing" - "sigs.k8s.io/cluster-api-provider-azure/util/reconciler" - "sigs.k8s.io/cluster-api-provider-azure/util/tele" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" "sigs.k8s.io/cluster-api/util" "sigs.k8s.io/cluster-api/util/annotations" @@ -41,6 +35,13 @@ import ( "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" "sigs.k8s.io/controller-runtime/pkg/handler" "sigs.k8s.io/controller-runtime/pkg/reconcile" + + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" + "sigs.k8s.io/cluster-api-provider-azure/azure" + "sigs.k8s.io/cluster-api-provider-azure/azure/scope" + "sigs.k8s.io/cluster-api-provider-azure/pkg/coalescing" + "sigs.k8s.io/cluster-api-provider-azure/util/reconciler" + "sigs.k8s.io/cluster-api-provider-azure/util/tele" ) // AzureClusterReconciler reconciles an AzureCluster object. @@ -257,7 +258,6 @@ func (acr *AzureClusterReconciler) reconcileNormal(ctx context.Context, clusterS return reconcile.Result{}, nil } -//nolint:unparam // Always returns an empty struct for reconcile.Result func (acr *AzureClusterReconciler) reconcilePause(ctx context.Context, clusterScope *scope.ClusterScope) (reconcile.Result, error) { ctx, log, done := tele.StartSpanWithLogger(ctx, "controllers.AzureClusterReconciler.reconcilePause") defer done() diff --git a/controllers/azurecluster_controller_test.go b/controllers/azurecluster_controller_test.go index 7b2ecd7550e..13609761814 100644 --- a/controllers/azurecluster_controller_test.go +++ b/controllers/azurecluster_controller_test.go @@ -32,12 +32,6 @@ import ( "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/types" "k8s.io/client-go/tools/record" - infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" - "sigs.k8s.io/cluster-api-provider-azure/azure" - "sigs.k8s.io/cluster-api-provider-azure/azure/scope" - "sigs.k8s.io/cluster-api-provider-azure/azure/services/resourceskus" - "sigs.k8s.io/cluster-api-provider-azure/internal/test" - "sigs.k8s.io/cluster-api-provider-azure/util/reconciler" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" clusterctlv1 "sigs.k8s.io/cluster-api/cmd/clusterctl/api/v1alpha3" capierrors "sigs.k8s.io/cluster-api/errors" @@ -45,6 +39,13 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/client/fake" "sigs.k8s.io/controller-runtime/pkg/reconcile" + + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" + "sigs.k8s.io/cluster-api-provider-azure/azure" + "sigs.k8s.io/cluster-api-provider-azure/azure/scope" + "sigs.k8s.io/cluster-api-provider-azure/azure/services/resourceskus" + "sigs.k8s.io/cluster-api-provider-azure/internal/test" + "sigs.k8s.io/cluster-api-provider-azure/util/reconciler" ) type TestClusterReconcileInput struct { diff --git a/controllers/azurecluster_reconciler.go b/controllers/azurecluster_reconciler.go index ec83660e731..f7b528e9132 100644 --- a/controllers/azurecluster_reconciler.go +++ b/controllers/azurecluster_reconciler.go @@ -20,6 +20,8 @@ import ( "context" "github.com/pkg/errors" + clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" + "sigs.k8s.io/cluster-api-provider-azure/azure" "sigs.k8s.io/cluster-api-provider-azure/azure/scope" "sigs.k8s.io/cluster-api-provider-azure/azure/services/bastionhosts" @@ -36,7 +38,6 @@ import ( "sigs.k8s.io/cluster-api-provider-azure/azure/services/virtualnetworks" "sigs.k8s.io/cluster-api-provider-azure/azure/services/vnetpeerings" "sigs.k8s.io/cluster-api-provider-azure/util/tele" - clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" ) // azureClusterService is the reconciler called by the AzureCluster controller. diff --git a/controllers/azurecluster_reconciler_test.go b/controllers/azurecluster_reconciler_test.go index 079b73bd363..2c0e31e6082 100644 --- a/controllers/azurecluster_reconciler_test.go +++ b/controllers/azurecluster_reconciler_test.go @@ -30,6 +30,10 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/utils/ptr" + clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" + "sigs.k8s.io/controller-runtime/pkg/client" + fakeclient "sigs.k8s.io/controller-runtime/pkg/client/fake" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" "sigs.k8s.io/cluster-api-provider-azure/azure/mock_azure" @@ -38,9 +42,6 @@ import ( "sigs.k8s.io/cluster-api-provider-azure/azure/services/resourceskus" "sigs.k8s.io/cluster-api-provider-azure/azure/services/vnetpeerings" gomockinternal "sigs.k8s.io/cluster-api-provider-azure/internal/test/matchers/gomock" - clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" - "sigs.k8s.io/controller-runtime/pkg/client" - fakeclient "sigs.k8s.io/controller-runtime/pkg/client/fake" ) func TestAzureClusterServiceReconcile(t *testing.T) { @@ -69,7 +70,6 @@ func TestAzureClusterServiceReconcile(t *testing.T) { } for name, tc := range cases { - tc := tc t.Run(name, func(t *testing.T) { g := NewWithT(t) @@ -137,7 +137,6 @@ func TestAzureClusterServicePause(t *testing.T) { } for name, tc := range cases { - tc := tc t.Run(name, func(t *testing.T) { g := NewWithT(t) @@ -328,7 +327,6 @@ func TestAzureClusterServiceDelete(t *testing.T) { } for name, tc := range cases { - tc := tc t.Run(name, func(t *testing.T) { g := NewWithT(t) diff --git a/controllers/azurejson_machine_controller.go b/controllers/azurejson_machine_controller.go index d0abe751594..68fa53287c2 100644 --- a/controllers/azurejson_machine_controller.go +++ b/controllers/azurejson_machine_controller.go @@ -28,12 +28,6 @@ import ( "k8s.io/apimachinery/pkg/types" "k8s.io/client-go/tools/record" "k8s.io/utils/ptr" - infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" - "sigs.k8s.io/cluster-api-provider-azure/azure/scope" - "sigs.k8s.io/cluster-api-provider-azure/azure/services/identities" - azureutil "sigs.k8s.io/cluster-api-provider-azure/util/azure" - "sigs.k8s.io/cluster-api-provider-azure/util/reconciler" - "sigs.k8s.io/cluster-api-provider-azure/util/tele" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" "sigs.k8s.io/cluster-api/util" "sigs.k8s.io/cluster-api/util/annotations" @@ -46,6 +40,13 @@ import ( "sigs.k8s.io/controller-runtime/pkg/handler" "sigs.k8s.io/controller-runtime/pkg/predicate" "sigs.k8s.io/controller-runtime/pkg/reconcile" + + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" + "sigs.k8s.io/cluster-api-provider-azure/azure/scope" + "sigs.k8s.io/cluster-api-provider-azure/azure/services/identities" + azureutil "sigs.k8s.io/cluster-api-provider-azure/util/azure" + "sigs.k8s.io/cluster-api-provider-azure/util/reconciler" + "sigs.k8s.io/cluster-api-provider-azure/util/tele" ) // AzureJSONMachineReconciler reconciles Azure json secrets for AzureMachine objects. diff --git a/controllers/azurejson_machine_controller_test.go b/controllers/azurejson_machine_controller_test.go index 1cd4f8c9e2d..5a1e32e8faa 100644 --- a/controllers/azurejson_machine_controller_test.go +++ b/controllers/azurejson_machine_controller_test.go @@ -27,13 +27,14 @@ import ( "k8s.io/apimachinery/pkg/types" clientgoscheme "k8s.io/client-go/kubernetes/scheme" "k8s.io/client-go/tools/record" - infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" - infrav1exp "sigs.k8s.io/cluster-api-provider-azure/exp/api/v1beta1" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" expv1 "sigs.k8s.io/cluster-api/exp/api/v1beta1" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/client/fake" "sigs.k8s.io/controller-runtime/pkg/event" + + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" + infrav1exp "sigs.k8s.io/cluster-api-provider-azure/exp/api/v1beta1" ) func TestUnclonedMachinesPredicate(t *testing.T) { @@ -64,7 +65,6 @@ func TestUnclonedMachinesPredicate(t *testing.T) { } for name, tc := range cases { - tc := tc t.Run(name, func(t *testing.T) { t.Parallel() machine := &infrav1.AzureMachine{ @@ -264,7 +264,6 @@ func newScheme() (*runtime.Scheme, error) { corev1.AddToScheme, } for _, fn := range schemeFn { - fn := fn if err := fn(scheme); err != nil { return nil, err } diff --git a/controllers/azurejson_machinepool_controller.go b/controllers/azurejson_machinepool_controller.go index 2cfec6ed430..cce4fdc6123 100644 --- a/controllers/azurejson_machinepool_controller.go +++ b/controllers/azurejson_machinepool_controller.go @@ -26,12 +26,6 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/client-go/tools/record" "k8s.io/utils/ptr" - infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" - "sigs.k8s.io/cluster-api-provider-azure/azure/services/identities" - infrav1exp "sigs.k8s.io/cluster-api-provider-azure/exp/api/v1beta1" - azureutil "sigs.k8s.io/cluster-api-provider-azure/util/azure" - "sigs.k8s.io/cluster-api-provider-azure/util/reconciler" - "sigs.k8s.io/cluster-api-provider-azure/util/tele" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" "sigs.k8s.io/cluster-api/util" "sigs.k8s.io/cluster-api/util/predicates" @@ -41,6 +35,13 @@ import ( "sigs.k8s.io/controller-runtime/pkg/controller" "sigs.k8s.io/controller-runtime/pkg/handler" "sigs.k8s.io/controller-runtime/pkg/reconcile" + + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" + "sigs.k8s.io/cluster-api-provider-azure/azure/services/identities" + infrav1exp "sigs.k8s.io/cluster-api-provider-azure/exp/api/v1beta1" + azureutil "sigs.k8s.io/cluster-api-provider-azure/util/azure" + "sigs.k8s.io/cluster-api-provider-azure/util/reconciler" + "sigs.k8s.io/cluster-api-provider-azure/util/tele" ) // AzureJSONMachinePoolReconciler reconciles Azure json secrets for AzureMachinePool objects. diff --git a/controllers/azurejson_machinepool_controller_test.go b/controllers/azurejson_machinepool_controller_test.go index d870a1c570d..547c67137d9 100644 --- a/controllers/azurejson_machinepool_controller_test.go +++ b/controllers/azurejson_machinepool_controller_test.go @@ -31,16 +31,17 @@ import ( "k8s.io/apimachinery/pkg/types" "k8s.io/client-go/tools/record" "k8s.io/utils/ptr" + clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" + expv1 "sigs.k8s.io/cluster-api/exp/api/v1beta1" + ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/client/fake" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" "sigs.k8s.io/cluster-api-provider-azure/azure/services/identities" "sigs.k8s.io/cluster-api-provider-azure/azure/services/identities/mock_identities" infrav1exp "sigs.k8s.io/cluster-api-provider-azure/exp/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/util/reconciler" - clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" - expv1 "sigs.k8s.io/cluster-api/exp/api/v1beta1" - ctrl "sigs.k8s.io/controller-runtime" - "sigs.k8s.io/controller-runtime/pkg/client/fake" ) func TestAzureJSONPoolReconciler(t *testing.T) { diff --git a/controllers/azurejson_machinetemplate_controller.go b/controllers/azurejson_machinetemplate_controller.go index 25ad9f0e836..be801d35131 100644 --- a/controllers/azurejson_machinetemplate_controller.go +++ b/controllers/azurejson_machinetemplate_controller.go @@ -27,12 +27,6 @@ import ( "k8s.io/apimachinery/pkg/types" "k8s.io/client-go/tools/record" "k8s.io/utils/ptr" - infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" - "sigs.k8s.io/cluster-api-provider-azure/azure/scope" - "sigs.k8s.io/cluster-api-provider-azure/azure/services/identities" - azureutil "sigs.k8s.io/cluster-api-provider-azure/util/azure" - "sigs.k8s.io/cluster-api-provider-azure/util/reconciler" - "sigs.k8s.io/cluster-api-provider-azure/util/tele" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" "sigs.k8s.io/cluster-api/util" "sigs.k8s.io/cluster-api/util/annotations" @@ -43,6 +37,13 @@ import ( "sigs.k8s.io/controller-runtime/pkg/controller" "sigs.k8s.io/controller-runtime/pkg/handler" "sigs.k8s.io/controller-runtime/pkg/reconcile" + + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" + "sigs.k8s.io/cluster-api-provider-azure/azure/scope" + "sigs.k8s.io/cluster-api-provider-azure/azure/services/identities" + azureutil "sigs.k8s.io/cluster-api-provider-azure/util/azure" + "sigs.k8s.io/cluster-api-provider-azure/util/reconciler" + "sigs.k8s.io/cluster-api-provider-azure/util/tele" ) // AzureJSONTemplateReconciler reconciles Azure json secrets for AzureMachineTemplate objects. diff --git a/controllers/azurejson_machinetemplate_controller_test.go b/controllers/azurejson_machinetemplate_controller_test.go index ca051d971a9..69dd8d6e315 100644 --- a/controllers/azurejson_machinetemplate_controller_test.go +++ b/controllers/azurejson_machinetemplate_controller_test.go @@ -26,10 +26,11 @@ import ( "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/types" "k8s.io/client-go/tools/record" - infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/client/fake" + + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" ) func TestAzureJSONTemplateReconciler(t *testing.T) { diff --git a/controllers/azuremachine_controller.go b/controllers/azuremachine_controller.go index 5c75f9498b8..ff921250ea2 100644 --- a/controllers/azuremachine_controller.go +++ b/controllers/azuremachine_controller.go @@ -24,12 +24,6 @@ import ( corev1 "k8s.io/api/core/v1" apierrors "k8s.io/apimachinery/pkg/api/errors" "k8s.io/client-go/tools/record" - infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" - "sigs.k8s.io/cluster-api-provider-azure/azure" - "sigs.k8s.io/cluster-api-provider-azure/azure/scope" - "sigs.k8s.io/cluster-api-provider-azure/pkg/coalescing" - "sigs.k8s.io/cluster-api-provider-azure/util/reconciler" - "sigs.k8s.io/cluster-api-provider-azure/util/tele" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" capierrors "sigs.k8s.io/cluster-api/errors" "sigs.k8s.io/cluster-api/util" @@ -42,6 +36,13 @@ import ( "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" "sigs.k8s.io/controller-runtime/pkg/handler" "sigs.k8s.io/controller-runtime/pkg/reconcile" + + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" + "sigs.k8s.io/cluster-api-provider-azure/azure" + "sigs.k8s.io/cluster-api-provider-azure/azure/scope" + "sigs.k8s.io/cluster-api-provider-azure/pkg/coalescing" + "sigs.k8s.io/cluster-api-provider-azure/util/reconciler" + "sigs.k8s.io/cluster-api-provider-azure/util/tele" ) // AzureMachineReconciler reconciles an AzureMachine object. @@ -337,7 +338,6 @@ func (amr *AzureMachineReconciler) reconcileNormal(ctx context.Context, machineS return reconcile.Result{}, nil } -//nolint:unparam // Always returns an empty struct for reconcile.Result func (amr *AzureMachineReconciler) reconcilePause(ctx context.Context, machineScope *scope.MachineScope) (reconcile.Result, error) { ctx, log, done := tele.StartSpanWithLogger(ctx, "controllers.AzureMachine.reconcilePause") defer done() diff --git a/controllers/azuremachine_controller_test.go b/controllers/azuremachine_controller_test.go index 301decfa71e..34a1d01e080 100644 --- a/controllers/azuremachine_controller_test.go +++ b/controllers/azuremachine_controller_test.go @@ -29,17 +29,18 @@ import ( "k8s.io/apimachinery/pkg/types" "k8s.io/client-go/tools/record" "k8s.io/utils/ptr" - infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" - "sigs.k8s.io/cluster-api-provider-azure/azure" - "sigs.k8s.io/cluster-api-provider-azure/azure/scope" - "sigs.k8s.io/cluster-api-provider-azure/azure/services/resourceskus" - "sigs.k8s.io/cluster-api-provider-azure/util/reconciler" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" capierrors "sigs.k8s.io/cluster-api/errors" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/client/fake" "sigs.k8s.io/controller-runtime/pkg/reconcile" + + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" + "sigs.k8s.io/cluster-api-provider-azure/azure" + "sigs.k8s.io/cluster-api-provider-azure/azure/scope" + "sigs.k8s.io/cluster-api-provider-azure/azure/services/resourceskus" + "sigs.k8s.io/cluster-api-provider-azure/util/reconciler" ) type TestMachineReconcileInput struct { diff --git a/controllers/azuremachine_reconciler.go b/controllers/azuremachine_reconciler.go index f1a6d2ff8af..544ccc02694 100644 --- a/controllers/azuremachine_reconciler.go +++ b/controllers/azuremachine_reconciler.go @@ -20,6 +20,7 @@ import ( "context" "github.com/pkg/errors" + "sigs.k8s.io/cluster-api-provider-azure/azure" "sigs.k8s.io/cluster-api-provider-azure/azure/scope" "sigs.k8s.io/cluster-api-provider-azure/azure/services/availabilitysets" diff --git a/controllers/azuremachine_reconciler_test.go b/controllers/azuremachine_reconciler_test.go index 01efbe0fcf1..bd4abb8de3e 100644 --- a/controllers/azuremachine_reconciler_test.go +++ b/controllers/azuremachine_reconciler_test.go @@ -24,13 +24,14 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v5" . "github.com/onsi/gomega" "go.uber.org/mock/gomock" + clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" "sigs.k8s.io/cluster-api-provider-azure/azure/mock_azure" "sigs.k8s.io/cluster-api-provider-azure/azure/scope" "sigs.k8s.io/cluster-api-provider-azure/azure/services/resourceskus" gomockinternal "sigs.k8s.io/cluster-api-provider-azure/internal/test/matchers/gomock" - clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" ) func TestAzureMachineServiceReconcile(t *testing.T) { @@ -59,7 +60,6 @@ func TestAzureMachineServiceReconcile(t *testing.T) { } for name, tc := range cases { - tc := tc t.Run(name, func(t *testing.T) { g := NewWithT(t) @@ -135,7 +135,6 @@ func TestAzureMachineServicePause(t *testing.T) { } for name, tc := range cases { - tc := tc t.Run(name, func(t *testing.T) { g := NewWithT(t) @@ -200,7 +199,6 @@ func TestAzureMachineServiceDelete(t *testing.T) { } for name, tc := range cases { - tc := tc t.Run(name, func(t *testing.T) { g := NewWithT(t) diff --git a/controllers/azuremanagedcluster_controller.go b/controllers/azuremanagedcluster_controller.go index b86092966ad..8a08c90f3b8 100644 --- a/controllers/azuremanagedcluster_controller.go +++ b/controllers/azuremanagedcluster_controller.go @@ -23,10 +23,6 @@ import ( apierrors "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/types" "k8s.io/client-go/tools/record" - infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" - "sigs.k8s.io/cluster-api-provider-azure/pkg/coalescing" - "sigs.k8s.io/cluster-api-provider-azure/util/reconciler" - "sigs.k8s.io/cluster-api-provider-azure/util/tele" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" "sigs.k8s.io/cluster-api/util" "sigs.k8s.io/cluster-api/util/annotations" @@ -37,6 +33,11 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/handler" "sigs.k8s.io/controller-runtime/pkg/reconcile" + + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" + "sigs.k8s.io/cluster-api-provider-azure/pkg/coalescing" + "sigs.k8s.io/cluster-api-provider-azure/util/reconciler" + "sigs.k8s.io/cluster-api-provider-azure/util/tele" ) // AzureManagedClusterReconciler reconciles an AzureManagedCluster object. diff --git a/controllers/azuremanagedcluster_controller_test.go b/controllers/azuremanagedcluster_controller_test.go index 572fbd8239d..4f8d81e650c 100644 --- a/controllers/azuremanagedcluster_controller_test.go +++ b/controllers/azuremanagedcluster_controller_test.go @@ -25,13 +25,14 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/types" - infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" - "sigs.k8s.io/cluster-api-provider-azure/util/reconciler" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/client/fake" "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" + + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" + "sigs.k8s.io/cluster-api-provider-azure/util/reconciler" ) func TestAzureManagedClusterController(t *testing.T) { diff --git a/controllers/azuremanagedcontrolplane_controller.go b/controllers/azuremanagedcontrolplane_controller.go index a069fdaac2a..e315fa4406e 100644 --- a/controllers/azuremanagedcontrolplane_controller.go +++ b/controllers/azuremanagedcontrolplane_controller.go @@ -24,12 +24,6 @@ import ( corev1 "k8s.io/api/core/v1" apierrors "k8s.io/apimachinery/pkg/api/errors" "k8s.io/client-go/tools/record" - infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" - "sigs.k8s.io/cluster-api-provider-azure/azure" - "sigs.k8s.io/cluster-api-provider-azure/azure/scope" - "sigs.k8s.io/cluster-api-provider-azure/pkg/coalescing" - "sigs.k8s.io/cluster-api-provider-azure/util/reconciler" - "sigs.k8s.io/cluster-api-provider-azure/util/tele" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" expv1 "sigs.k8s.io/cluster-api/exp/api/v1beta1" capiexputil "sigs.k8s.io/cluster-api/exp/util" @@ -42,6 +36,13 @@ import ( "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" "sigs.k8s.io/controller-runtime/pkg/handler" "sigs.k8s.io/controller-runtime/pkg/reconcile" + + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" + "sigs.k8s.io/cluster-api-provider-azure/azure" + "sigs.k8s.io/cluster-api-provider-azure/azure/scope" + "sigs.k8s.io/cluster-api-provider-azure/pkg/coalescing" + "sigs.k8s.io/cluster-api-provider-azure/util/reconciler" + "sigs.k8s.io/cluster-api-provider-azure/util/tele" ) // AzureManagedControlPlaneReconciler reconciles an AzureManagedControlPlane object. @@ -277,7 +278,6 @@ func (amcpr *AzureManagedControlPlaneReconciler) reconcileNormal(ctx context.Con return reconcile.Result{}, nil } -//nolint:unparam // Always returns an empty struct for reconcile.Result func (amcpr *AzureManagedControlPlaneReconciler) reconcilePause(ctx context.Context, scope *scope.ManagedControlPlaneScope) (reconcile.Result, error) { ctx, log, done := tele.StartSpanWithLogger(ctx, "controllers.AzureManagedControlPlane.reconcilePause") defer done() diff --git a/controllers/azuremanagedcontrolplane_controller_test.go b/controllers/azuremanagedcontrolplane_controller_test.go index c04419ee309..b76af1a3570 100644 --- a/controllers/azuremanagedcontrolplane_controller_test.go +++ b/controllers/azuremanagedcontrolplane_controller_test.go @@ -31,17 +31,18 @@ import ( "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/types" "k8s.io/client-go/tools/record" + clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" + "sigs.k8s.io/cluster-api/util/patch" + ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/client" + "sigs.k8s.io/controller-runtime/pkg/client/fake" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" "sigs.k8s.io/cluster-api-provider-azure/azure/mock_azure" "sigs.k8s.io/cluster-api-provider-azure/azure/scope" "sigs.k8s.io/cluster-api-provider-azure/internal/test" "sigs.k8s.io/cluster-api-provider-azure/util/reconciler" - clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" - "sigs.k8s.io/cluster-api/util/patch" - ctrl "sigs.k8s.io/controller-runtime" - "sigs.k8s.io/controller-runtime/pkg/client" - "sigs.k8s.io/controller-runtime/pkg/client/fake" ) func TestClusterToAzureManagedControlPlane(t *testing.T) { diff --git a/controllers/azuremanagedcontrolplane_reconciler.go b/controllers/azuremanagedcontrolplane_reconciler.go index 783a0ba7e1f..a6367532096 100644 --- a/controllers/azuremanagedcontrolplane_reconciler.go +++ b/controllers/azuremanagedcontrolplane_reconciler.go @@ -22,6 +22,11 @@ import ( "github.com/pkg/errors" "k8s.io/client-go/tools/clientcmd" + clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" + "sigs.k8s.io/cluster-api/util/secret" + "sigs.k8s.io/controller-runtime/pkg/client" + "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" + "sigs.k8s.io/cluster-api-provider-azure/azure" "sigs.k8s.io/cluster-api-provider-azure/azure/scope" "sigs.k8s.io/cluster-api-provider-azure/azure/services/aksextensions" @@ -33,10 +38,6 @@ import ( "sigs.k8s.io/cluster-api-provider-azure/azure/services/subnets" "sigs.k8s.io/cluster-api-provider-azure/azure/services/virtualnetworks" "sigs.k8s.io/cluster-api-provider-azure/util/tele" - clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" - "sigs.k8s.io/cluster-api/util/secret" - "sigs.k8s.io/controller-runtime/pkg/client" - "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" ) // azureManagedControlPlaneService contains the services required by the cluster controller. diff --git a/controllers/azuremanagedcontrolplane_reconciler_test.go b/controllers/azuremanagedcontrolplane_reconciler_test.go index f97d0072ee4..0a551eab721 100644 --- a/controllers/azuremanagedcontrolplane_reconciler_test.go +++ b/controllers/azuremanagedcontrolplane_reconciler_test.go @@ -23,6 +23,7 @@ import ( . "github.com/onsi/gomega" "github.com/pkg/errors" "go.uber.org/mock/gomock" + "sigs.k8s.io/cluster-api-provider-azure/azure" "sigs.k8s.io/cluster-api-provider-azure/azure/mock_azure" gomockinternal "sigs.k8s.io/cluster-api-provider-azure/internal/test/matchers/gomock" @@ -59,7 +60,6 @@ func TestAzureManagedControlPlaneServicePause(t *testing.T) { } for name, tc := range cases { - tc := tc t.Run(name, func(t *testing.T) { g := NewWithT(t) diff --git a/controllers/azuremanagedmachinepool_controller.go b/controllers/azuremanagedmachinepool_controller.go index 046c55b0878..214a7d78452 100644 --- a/controllers/azuremanagedmachinepool_controller.go +++ b/controllers/azuremanagedmachinepool_controller.go @@ -24,12 +24,6 @@ import ( "github.com/pkg/errors" apierrors "k8s.io/apimachinery/pkg/api/errors" "k8s.io/client-go/tools/record" - infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" - "sigs.k8s.io/cluster-api-provider-azure/azure" - "sigs.k8s.io/cluster-api-provider-azure/azure/scope" - "sigs.k8s.io/cluster-api-provider-azure/pkg/coalescing" - "sigs.k8s.io/cluster-api-provider-azure/util/reconciler" - "sigs.k8s.io/cluster-api-provider-azure/util/tele" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" expv1 "sigs.k8s.io/cluster-api/exp/api/v1beta1" "sigs.k8s.io/cluster-api/util" @@ -42,6 +36,13 @@ import ( "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" "sigs.k8s.io/controller-runtime/pkg/handler" "sigs.k8s.io/controller-runtime/pkg/reconcile" + + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" + "sigs.k8s.io/cluster-api-provider-azure/azure" + "sigs.k8s.io/cluster-api-provider-azure/azure/scope" + "sigs.k8s.io/cluster-api-provider-azure/pkg/coalescing" + "sigs.k8s.io/cluster-api-provider-azure/util/reconciler" + "sigs.k8s.io/cluster-api-provider-azure/util/tele" ) // AzureManagedMachinePoolReconciler reconciles an AzureManagedMachinePool object. @@ -294,7 +295,6 @@ func (ammpr *AzureManagedMachinePoolReconciler) reconcileNormal(ctx context.Cont return reconcile.Result{}, nil } -//nolint:unparam // Always returns an empty struct for reconcile.Result func (ammpr *AzureManagedMachinePoolReconciler) reconcilePause(ctx context.Context, scope *scope.ManagedMachinePoolScope) (reconcile.Result, error) { ctx, log, done := tele.StartSpanWithLogger(ctx, "controllers.AzureManagedMachinePool.reconcilePause") defer done() diff --git a/controllers/azuremanagedmachinepool_controller_test.go b/controllers/azuremanagedmachinepool_controller_test.go index 5f1c6d48055..dfcfc7a5236 100644 --- a/controllers/azuremanagedmachinepool_controller_test.go +++ b/controllers/azuremanagedmachinepool_controller_test.go @@ -31,6 +31,11 @@ import ( "k8s.io/apimachinery/pkg/types" "k8s.io/client-go/kubernetes/scheme" "k8s.io/utils/ptr" + clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" + expv1 "sigs.k8s.io/cluster-api/exp/api/v1beta1" + ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/client/fake" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" "sigs.k8s.io/cluster-api-provider-azure/azure/mock_azure" @@ -39,10 +44,6 @@ import ( "sigs.k8s.io/cluster-api-provider-azure/azure/services/agentpools/mock_agentpools" gomock2 "sigs.k8s.io/cluster-api-provider-azure/internal/test/matchers/gomock" reconcilerutils "sigs.k8s.io/cluster-api-provider-azure/util/reconciler" - clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" - expv1 "sigs.k8s.io/cluster-api/exp/api/v1beta1" - ctrl "sigs.k8s.io/controller-runtime" - "sigs.k8s.io/controller-runtime/pkg/client/fake" ) func TestAzureManagedMachinePoolReconcile(t *testing.T) { @@ -130,7 +131,6 @@ func TestAzureManagedMachinePoolReconcile(t *testing.T) { } for _, c := range cases { - c := c t.Run(c.name, func(t *testing.T) { var ( g = NewWithT(t) diff --git a/controllers/azuremanagedmachinepool_reconciler.go b/controllers/azuremanagedmachinepool_reconciler.go index f7039e4bc02..da71c578a8c 100644 --- a/controllers/azuremanagedmachinepool_reconciler.go +++ b/controllers/azuremanagedmachinepool_reconciler.go @@ -26,6 +26,7 @@ import ( asocontainerservicev1preview "github.com/Azure/azure-service-operator/v2/api/containerservice/v1api20231102preview" "github.com/pkg/errors" azprovider "sigs.k8s.io/cloud-provider-azure/pkg/provider" + "sigs.k8s.io/cluster-api-provider-azure/azure" "sigs.k8s.io/cluster-api-provider-azure/azure/scope" "sigs.k8s.io/cluster-api-provider-azure/azure/services/agentpools" @@ -133,7 +134,6 @@ func (s *azureManagedMachinePoolService) Reconcile(ctx context.Context) error { var match *armcompute.VirtualMachineScaleSet for _, ss := range vmss { - ss := ss if ss.Tags["poolName"] != nil && *ss.Tags["poolName"] == agentPoolName { match = &ss break diff --git a/controllers/azuremanagedmachinepool_reconciler_test.go b/controllers/azuremanagedmachinepool_reconciler_test.go index 4696c001b5e..60e000d6a42 100644 --- a/controllers/azuremanagedmachinepool_reconciler_test.go +++ b/controllers/azuremanagedmachinepool_reconciler_test.go @@ -24,6 +24,7 @@ import ( "github.com/pkg/errors" "go.uber.org/mock/gomock" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure/mock_azure" "sigs.k8s.io/cluster-api-provider-azure/azure/scope" @@ -59,7 +60,6 @@ func TestIsAgentPoolVMSSNotFoundError(t *testing.T) { } for _, c := range cases { - c := c t.Run(c.Name, func(t *testing.T) { t.Parallel() g := gomega.NewWithT(t) @@ -97,7 +97,6 @@ func TestAzureManagedMachinePoolServicePause(t *testing.T) { } for name, tc := range cases { - tc := tc t.Run(name, func(t *testing.T) { g := gomega.NewWithT(t) diff --git a/controllers/helpers.go b/controllers/helpers.go index 805afef2cce..9ecd9c3301f 100644 --- a/controllers/helpers.go +++ b/controllers/helpers.go @@ -34,15 +34,6 @@ import ( "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/types" "k8s.io/klog/v2" - infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" - "sigs.k8s.io/cluster-api-provider-azure/azure" - "sigs.k8s.io/cluster-api-provider-azure/azure/scope" - "sigs.k8s.io/cluster-api-provider-azure/azure/services/groups" - infrav1exp "sigs.k8s.io/cluster-api-provider-azure/exp/api/v1beta1" - "sigs.k8s.io/cluster-api-provider-azure/feature" - "sigs.k8s.io/cluster-api-provider-azure/pkg/coalescing" - "sigs.k8s.io/cluster-api-provider-azure/util/reconciler" - "sigs.k8s.io/cluster-api-provider-azure/util/tele" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" clusterctlv1 "sigs.k8s.io/cluster-api/cmd/clusterctl/api/v1alpha3" expv1 "sigs.k8s.io/cluster-api/exp/api/v1beta1" @@ -60,6 +51,16 @@ import ( "sigs.k8s.io/controller-runtime/pkg/handler" "sigs.k8s.io/controller-runtime/pkg/predicate" "sigs.k8s.io/controller-runtime/pkg/reconcile" + + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" + "sigs.k8s.io/cluster-api-provider-azure/azure" + "sigs.k8s.io/cluster-api-provider-azure/azure/scope" + "sigs.k8s.io/cluster-api-provider-azure/azure/services/groups" + infrav1exp "sigs.k8s.io/cluster-api-provider-azure/exp/api/v1beta1" + "sigs.k8s.io/cluster-api-provider-azure/feature" + "sigs.k8s.io/cluster-api-provider-azure/pkg/coalescing" + "sigs.k8s.io/cluster-api-provider-azure/util/reconciler" + "sigs.k8s.io/cluster-api-provider-azure/util/tele" ) const ( @@ -88,7 +89,7 @@ type ( // AzureClusterToAzureMachinesMapper creates a mapping handler to transform AzureClusters into AzureMachines. The transform // requires AzureCluster to map to the owning Cluster, then from the Cluster, collect the Machines belonging to the cluster, // then finally projecting the infrastructure reference to the AzureMachine. -func AzureClusterToAzureMachinesMapper(ctx context.Context, c client.Client, obj runtime.Object, scheme *runtime.Scheme, log logr.Logger) (handler.MapFunc, error) { +func AzureClusterToAzureMachinesMapper(_ context.Context, c client.Client, obj runtime.Object, scheme *runtime.Scheme, log logr.Logger) (handler.MapFunc, error) { gvk, err := apiutil.GVKForObject(obj, scheme) if err != nil { return nil, errors.Wrap(err, "failed to find GVK for AzureMachine") @@ -704,7 +705,7 @@ func RemoveClusterIdentityFinalizer(ctx context.Context, c client.Client, object // MachinePoolToInfrastructureMapFunc returns a handler.MapFunc that watches for // MachinePool events and returns reconciliation requests for an infrastructure provider object. func MachinePoolToInfrastructureMapFunc(gvk schema.GroupVersionKind, log logr.Logger) handler.MapFunc { - return func(ctx context.Context, o client.Object) []reconcile.Request { + return func(_ context.Context, o client.Object) []reconcile.Request { m, ok := o.(*expv1.MachinePool) if !ok { log.V(4).Info("attempt to map incorrect type", "type", fmt.Sprintf("%T", o)) @@ -735,7 +736,7 @@ func MachinePoolToInfrastructureMapFunc(gvk schema.GroupVersionKind, log logr.Lo // AzureManagedMachinePools. The transform requires AzureManagedCluster to map to the owning Cluster, then from the // Cluster, collect the MachinePools belonging to the cluster, then finally projecting the infrastructure reference // to the AzureManagedMachinePools. -func AzureManagedClusterToAzureManagedMachinePoolsMapper(ctx context.Context, c client.Client, scheme *runtime.Scheme, log logr.Logger) (handler.MapFunc, error) { +func AzureManagedClusterToAzureManagedMachinePoolsMapper(_ context.Context, c client.Client, scheme *runtime.Scheme, log logr.Logger) (handler.MapFunc, error) { gvk, err := apiutil.GVKForObject(new(infrav1.AzureManagedMachinePool), scheme) if err != nil { return nil, errors.Wrap(err, "failed to find GVK for AzureManagedMachinePool") @@ -788,7 +789,7 @@ func AzureManagedClusterToAzureManagedMachinePoolsMapper(ctx context.Context, c // AzureManagedMachinePools. The transform requires AzureManagedControlPlane to map to the owning Cluster, then from the // Cluster, collect the MachinePools belonging to the cluster, then finally projecting the infrastructure reference // to the AzureManagedMachinePools. -func AzureManagedControlPlaneToAzureManagedMachinePoolsMapper(ctx context.Context, c client.Client, scheme *runtime.Scheme, log logr.Logger) (handler.MapFunc, error) { +func AzureManagedControlPlaneToAzureManagedMachinePoolsMapper(_ context.Context, c client.Client, scheme *runtime.Scheme, log logr.Logger) (handler.MapFunc, error) { gvk, err := apiutil.GVKForObject(new(infrav1.AzureManagedMachinePool), scheme) if err != nil { return nil, errors.Wrap(err, "failed to find GVK for AzureManagedMachinePool") @@ -840,7 +841,7 @@ func AzureManagedControlPlaneToAzureManagedMachinePoolsMapper(ctx context.Contex // AzureManagedClusterToAzureManagedControlPlaneMapper creates a mapping handler to transform AzureManagedClusters into // AzureManagedControlPlane. The transform requires AzureManagedCluster to map to the owning Cluster, then from the // Cluster, collect the control plane infrastructure reference. -func AzureManagedClusterToAzureManagedControlPlaneMapper(ctx context.Context, c client.Client, log logr.Logger) (handler.MapFunc, error) { +func AzureManagedClusterToAzureManagedControlPlaneMapper(_ context.Context, c client.Client, log logr.Logger) (handler.MapFunc, error) { return func(ctx context.Context, o client.Object) []ctrl.Request { ctx, cancel := context.WithTimeout(ctx, reconciler.DefaultMappingTimeout) defer cancel() @@ -889,7 +890,7 @@ func AzureManagedClusterToAzureManagedControlPlaneMapper(ctx context.Context, c // AzureManagedControlPlaneToAzureManagedClusterMapper creates a mapping handler to transform AzureManagedClusters into // AzureManagedControlPlane. The transform requires AzureManagedCluster to map to the owning Cluster, then from the // Cluster, collect the control plane infrastructure reference. -func AzureManagedControlPlaneToAzureManagedClusterMapper(ctx context.Context, c client.Client, log logr.Logger) (handler.MapFunc, error) { +func AzureManagedControlPlaneToAzureManagedClusterMapper(_ context.Context, c client.Client, log logr.Logger) (handler.MapFunc, error) { return func(ctx context.Context, o client.Object) []ctrl.Request { ctx, cancel := context.WithTimeout(ctx, reconciler.DefaultMappingTimeout) defer cancel() @@ -937,7 +938,7 @@ func AzureManagedControlPlaneToAzureManagedClusterMapper(ctx context.Context, c // MachinePoolToAzureManagedControlPlaneMapFunc returns a handler.MapFunc that watches for // MachinePool events and returns reconciliation requests for a control plane object. -func MachinePoolToAzureManagedControlPlaneMapFunc(ctx context.Context, c client.Client, gvk schema.GroupVersionKind, log logr.Logger) handler.MapFunc { +func MachinePoolToAzureManagedControlPlaneMapFunc(_ context.Context, c client.Client, gvk schema.GroupVersionKind, log logr.Logger) handler.MapFunc { return func(ctx context.Context, o client.Object) []reconcile.Request { ctx, cancel := context.WithTimeout(ctx, reconciler.DefaultMappingTimeout) defer cancel() @@ -1064,9 +1065,9 @@ func ClusterUpdatePauseChange(logger logr.Logger) predicate.Funcs { log.V(6).Info("Cluster paused status remained the same, blocking further processing") return false }, - CreateFunc: func(e event.CreateEvent) bool { return false }, - DeleteFunc: func(e event.DeleteEvent) bool { return false }, - GenericFunc: func(e event.GenericEvent) bool { return false }, + CreateFunc: func(_ event.CreateEvent) bool { return false }, + DeleteFunc: func(_ event.DeleteEvent) bool { return false }, + GenericFunc: func(_ event.GenericEvent) bool { return false }, } } diff --git a/controllers/helpers_test.go b/controllers/helpers_test.go index 3504161e047..2c030a70c4e 100644 --- a/controllers/helpers_test.go +++ b/controllers/helpers_test.go @@ -35,9 +35,6 @@ import ( "k8s.io/apimachinery/pkg/types" clientgoscheme "k8s.io/client-go/kubernetes/scheme" "k8s.io/utils/ptr" - infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" - "sigs.k8s.io/cluster-api-provider-azure/azure/scope" - "sigs.k8s.io/cluster-api-provider-azure/internal/test/mock_log" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" clusterctlv1 "sigs.k8s.io/cluster-api/cmd/clusterctl/api/v1alpha3" expv1 "sigs.k8s.io/cluster-api/exp/api/v1beta1" @@ -45,6 +42,10 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client/fake" "sigs.k8s.io/controller-runtime/pkg/event" "sigs.k8s.io/controller-runtime/pkg/reconcile" + + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" + "sigs.k8s.io/cluster-api-provider-azure/azure/scope" + "sigs.k8s.io/cluster-api-provider-azure/internal/test/mock_log" ) var ( @@ -163,9 +164,9 @@ func TestGetCloudProviderConfig(t *testing.T) { }, } - os.Setenv("AZURE_CLIENT_ID", "fooClient") - os.Setenv("AZURE_CLIENT_SECRET", "fooSecret") - os.Setenv("AZURE_TENANT_ID", "fooTenant") + os.Setenv("AZURE_CLIENT_ID", "fooClient") //nolint:tenv // we want to use os.Setenv here instead of t.Setenv + os.Setenv("AZURE_CLIENT_SECRET", "fooSecret") //nolint:tenv // we want to use os.Setenv here instead of t.Setenv + os.Setenv("AZURE_TENANT_ID", "fooTenant") //nolint:tenv // we want to use os.Setenv here instead of t.Setenv for name, tc := range cases { t.Run(name, func(t *testing.T) { @@ -210,13 +211,13 @@ func TestGetCloudProviderConfig(t *testing.T) { g.Expect(cloudConfig.Data).NotTo(BeNil()) if diff := cmp.Diff(tc.expectedControlPlaneConfig, string(cloudConfig.Data["control-plane-azure.json"])); diff != "" { - t.Errorf(diff) + t.Errorf("%s", diff) } if diff := cmp.Diff(tc.expectedWorkerNodeConfig, string(cloudConfig.Data["worker-node-azure.json"])); diff != "" { - t.Errorf(diff) + t.Errorf("%s", diff) } if diff := cmp.Diff(tc.expectedControlPlaneConfig, string(cloudConfig.Data["azure.json"])); diff != "" { - t.Errorf(diff) + t.Errorf("%s", diff) } }) } @@ -1344,7 +1345,6 @@ func Test_ManagedMachinePoolToInfrastructureMapFunc(t *testing.T) { } for _, c := range cases { - c := c t.Run(c.Name, func(t *testing.T) { g := NewWithT(t) @@ -1555,7 +1555,6 @@ func TestClusterPauseChangeAndInfrastructureReady(t *testing.T) { } for _, test := range tests { - test := test t.Run(test.name, func(t *testing.T) { t.Parallel() p := ClusterPauseChangeAndInfrastructureReady(logr.New(nil)) diff --git a/controllers/managedclusteradopt_controller.go b/controllers/managedclusteradopt_controller.go index 23a67ba1106..e6cb2782e32 100644 --- a/controllers/managedclusteradopt_controller.go +++ b/controllers/managedclusteradopt_controller.go @@ -25,14 +25,15 @@ import ( corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" - infrav1alpha "sigs.k8s.io/cluster-api-provider-azure/api/v1alpha1" - "sigs.k8s.io/cluster-api-provider-azure/util/tele" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/controller" "sigs.k8s.io/controller-runtime/pkg/event" "sigs.k8s.io/controller-runtime/pkg/predicate" + + infrav1alpha "sigs.k8s.io/cluster-api-provider-azure/api/v1alpha1" + "sigs.k8s.io/cluster-api-provider-azure/util/tele" ) const ( @@ -46,7 +47,7 @@ type ManagedClusterAdoptReconciler struct { } // SetupWithManager sets up the controller with the Manager. -func (r *ManagedClusterAdoptReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Manager, options controller.Options) error { +func (r *ManagedClusterAdoptReconciler) SetupWithManager(_ context.Context, mgr ctrl.Manager, options controller.Options) error { _, err := ctrl.NewControllerManagedBy(mgr). WithOptions(options). For(&asocontainerservicev1.ManagedCluster{}). diff --git a/controllers/resource_reconciler.go b/controllers/resource_reconciler.go index 438e5720572..cabfbe7a8b7 100644 --- a/controllers/resource_reconciler.go +++ b/controllers/resource_reconciler.go @@ -28,14 +28,15 @@ import ( "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/klog/v2" - infrav1alpha "sigs.k8s.io/cluster-api-provider-azure/api/v1alpha1" - "sigs.k8s.io/cluster-api-provider-azure/pkg/mutators" - "sigs.k8s.io/cluster-api-provider-azure/util/tele" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" "sigs.k8s.io/controller-runtime/pkg/handler" "sigs.k8s.io/controller-runtime/pkg/predicate" "sigs.k8s.io/controller-runtime/pkg/reconcile" + + infrav1alpha "sigs.k8s.io/cluster-api-provider-azure/api/v1alpha1" + "sigs.k8s.io/cluster-api-provider-azure/pkg/mutators" + "sigs.k8s.io/cluster-api-provider-azure/util/tele" ) // ResourceReconciler reconciles a set of arbitrary ASO resources. @@ -62,7 +63,10 @@ func (r *ResourceReconciler) Reconcile(ctx context.Context) error { defer done() log.V(4).Info("reconciling resources") - var newResourceStatuses []infrav1alpha.ResourceStatus + // TODO (nojnhuh) : is there a functional diff between + // var newResourceStatuses []infrav1alpha.ResourceStatus and newResourceStatuses := make([]infrav1alpha.ResourceStatus,0) + // in the scenario below? + var newResourceStatuses []infrav1alpha.ResourceStatus //nolint:prealloc // leaving it as is for now for _, spec := range r.resources { gvk := spec.GroupVersionKind() diff --git a/controllers/resource_reconciler_test.go b/controllers/resource_reconciler_test.go index 3cc12972f99..2b51f72aeaf 100644 --- a/controllers/resource_reconciler_test.go +++ b/controllers/resource_reconciler_test.go @@ -29,11 +29,12 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "k8s.io/apimachinery/pkg/runtime" - infrav1alpha "sigs.k8s.io/cluster-api-provider-azure/api/v1alpha1" "sigs.k8s.io/controller-runtime/pkg/client" fakeclient "sigs.k8s.io/controller-runtime/pkg/client/fake" "sigs.k8s.io/controller-runtime/pkg/handler" "sigs.k8s.io/controller-runtime/pkg/predicate" + + infrav1alpha "sigs.k8s.io/cluster-api-provider-azure/api/v1alpha1" ) type FakeClient struct { diff --git a/controllers/suite_test.go b/controllers/suite_test.go index e690875f066..96219bc85ac 100644 --- a/controllers/suite_test.go +++ b/controllers/suite_test.go @@ -23,9 +23,10 @@ import ( . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" corev1 "k8s.io/api/core/v1" + "sigs.k8s.io/controller-runtime/pkg/controller" + "sigs.k8s.io/cluster-api-provider-azure/internal/test/env" "sigs.k8s.io/cluster-api-provider-azure/util/reconciler" - "sigs.k8s.io/controller-runtime/pkg/controller" ) // These tests use Ginkgo (BDD-style Go testing framework). Refer to diff --git a/exp/api/v1beta1/azuremachinepool_default.go b/exp/api/v1beta1/azuremachinepool_default.go index aeeddd1f65c..cac19047c0a 100644 --- a/exp/api/v1beta1/azuremachinepool_default.go +++ b/exp/api/v1beta1/azuremachinepool_default.go @@ -24,10 +24,11 @@ import ( "golang.org/x/crypto/ssh" kerrors "k8s.io/apimachinery/pkg/util/errors" "k8s.io/apimachinery/pkg/util/uuid" + "sigs.k8s.io/controller-runtime/pkg/client" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" azureutil "sigs.k8s.io/cluster-api-provider-azure/util/azure" utilSSH "sigs.k8s.io/cluster-api-provider-azure/util/ssh" - "sigs.k8s.io/controller-runtime/pkg/client" ) // SetDefaults sets the default values for an AzureMachinePool. diff --git a/exp/api/v1beta1/azuremachinepool_default_test.go b/exp/api/v1beta1/azuremachinepool_default_test.go index 65adc0be3d8..03fbc4a3fa5 100644 --- a/exp/api/v1beta1/azuremachinepool_default_test.go +++ b/exp/api/v1beta1/azuremachinepool_default_test.go @@ -26,10 +26,11 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/utils/ptr" - infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" expv1 "sigs.k8s.io/cluster-api/exp/api/v1beta1" "sigs.k8s.io/controller-runtime/pkg/client/fake" + + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" ) func TestAzureMachinePool_SetDefaultSSHPublicKey(t *testing.T) { diff --git a/exp/api/v1beta1/azuremachinepool_test.go b/exp/api/v1beta1/azuremachinepool_test.go index 72d4441744f..12bed0d3018 100644 --- a/exp/api/v1beta1/azuremachinepool_test.go +++ b/exp/api/v1beta1/azuremachinepool_test.go @@ -21,6 +21,7 @@ import ( "github.com/onsi/gomega" "k8s.io/utils/ptr" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" infrav1exp "sigs.k8s.io/cluster-api-provider-azure/exp/api/v1beta1" ) @@ -244,7 +245,6 @@ func TestAzureMachinePool_Validate(t *testing.T) { } for _, c := range cases { - c := c t.Run(c.Name, func(t *testing.T) { // Don't add t.Parallel() here or the test will fail. g := gomega.NewGomegaWithT(t) diff --git a/exp/api/v1beta1/azuremachinepool_types.go b/exp/api/v1beta1/azuremachinepool_types.go index 882af9ae389..e1ec02ad7d1 100644 --- a/exp/api/v1beta1/azuremachinepool_types.go +++ b/exp/api/v1beta1/azuremachinepool_types.go @@ -19,9 +19,10 @@ package v1beta1 import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/intstr" - infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" "sigs.k8s.io/cluster-api/errors" + + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" ) const ( diff --git a/exp/api/v1beta1/azuremachinepool_webhook.go b/exp/api/v1beta1/azuremachinepool_webhook.go index ebcb446b78b..a19b3f707f3 100644 --- a/exp/api/v1beta1/azuremachinepool_webhook.go +++ b/exp/api/v1beta1/azuremachinepool_webhook.go @@ -29,13 +29,14 @@ import ( kerrors "k8s.io/apimachinery/pkg/util/errors" "k8s.io/apimachinery/pkg/util/intstr" "k8s.io/apimachinery/pkg/util/validation/field" - infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" - "sigs.k8s.io/cluster-api-provider-azure/feature" - azureutil "sigs.k8s.io/cluster-api-provider-azure/util/azure" capifeature "sigs.k8s.io/cluster-api/feature" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/webhook/admission" + + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" + "sigs.k8s.io/cluster-api-provider-azure/feature" + azureutil "sigs.k8s.io/cluster-api-provider-azure/util/azure" ) // SetupAzureMachinePoolWebhookWithManager sets up and registers the webhook with the manager. @@ -56,7 +57,7 @@ type azureMachinePoolWebhook struct { } // Default implements webhook.Defaulter so a webhook will be registered for the type. -func (ampw *azureMachinePoolWebhook) Default(ctx context.Context, obj runtime.Object) error { +func (ampw *azureMachinePoolWebhook) Default(_ context.Context, obj runtime.Object) error { amp, ok := obj.(*AzureMachinePool) if !ok { return apierrors.NewBadRequest("expected an AzureMachinePool") @@ -67,7 +68,7 @@ func (ampw *azureMachinePoolWebhook) Default(ctx context.Context, obj runtime.Ob // +kubebuilder:webhook:verbs=create;update,path=/validate-infrastructure-cluster-x-k8s-io-v1beta1-azuremachinepool,mutating=false,failurePolicy=fail,groups=infrastructure.cluster.x-k8s.io,resources=azuremachinepools,versions=v1beta1,name=validation.azuremachinepool.infrastructure.cluster.x-k8s.io,sideEffects=None,admissionReviewVersions=v1;v1beta1 // ValidateCreate implements webhook.Validator so a webhook will be registered for the type. -func (ampw *azureMachinePoolWebhook) ValidateCreate(ctx context.Context, obj runtime.Object) (admission.Warnings, error) { +func (ampw *azureMachinePoolWebhook) ValidateCreate(_ context.Context, obj runtime.Object) (admission.Warnings, error) { amp, ok := obj.(*AzureMachinePool) if !ok { return nil, apierrors.NewBadRequest("expected an AzureMachinePool") @@ -84,7 +85,7 @@ func (ampw *azureMachinePoolWebhook) ValidateCreate(ctx context.Context, obj run } // ValidateUpdate implements webhook.Validator so a webhook will be registered for the type. -func (ampw *azureMachinePoolWebhook) ValidateUpdate(ctx context.Context, oldObj, newObj runtime.Object) (admission.Warnings, error) { +func (ampw *azureMachinePoolWebhook) ValidateUpdate(_ context.Context, oldObj, newObj runtime.Object) (admission.Warnings, error) { amp, ok := newObj.(*AzureMachinePool) if !ok { return nil, apierrors.NewBadRequest("expected an AzureMachinePool") @@ -93,7 +94,7 @@ func (ampw *azureMachinePoolWebhook) ValidateUpdate(ctx context.Context, oldObj, } // ValidateDelete implements webhook.Validator so a webhook will be registered for the type. -func (ampw *azureMachinePoolWebhook) ValidateDelete(ctx context.Context, obj runtime.Object) (admission.Warnings, error) { +func (ampw *azureMachinePoolWebhook) ValidateDelete(_ context.Context, _ runtime.Object) (admission.Warnings, error) { return nil, nil } @@ -320,7 +321,7 @@ func (amp *AzureMachinePool) ValidateOrchestrationMode(c client.Client) func() e return errors.Wrap(err, "failed to parse Kubernetes version") } if k8sVersion.LT(semver.MustParse("1.26.0")) { - return errors.New(fmt.Sprintf("specified Kubernetes version %s must be >= 1.26.0 for Flexible orchestration mode", k8sVersion)) + return fmt.Errorf("specified Kubernetes version %s must be >= 1.26.0 for Flexible orchestration mode", k8sVersion) } } diff --git a/exp/api/v1beta1/azuremachinepool_webhook_test.go b/exp/api/v1beta1/azuremachinepool_webhook_test.go index 0fa17be5f58..e1324deee98 100644 --- a/exp/api/v1beta1/azuremachinepool_webhook_test.go +++ b/exp/api/v1beta1/azuremachinepool_webhook_test.go @@ -35,12 +35,13 @@ import ( "k8s.io/apimachinery/pkg/util/uuid" utilfeature "k8s.io/component-base/featuregate/testing" "k8s.io/utils/ptr" - infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" - "sigs.k8s.io/cluster-api-provider-azure/feature" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" expv1 "sigs.k8s.io/cluster-api/exp/api/v1beta1" capifeature "sigs.k8s.io/cluster-api/feature" "sigs.k8s.io/controller-runtime/pkg/client" + + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" + "sigs.k8s.io/cluster-api-provider-azure/feature" ) var ( @@ -624,10 +625,10 @@ func createMachinePoolWithDiagnostics(diagnosticsType infrav1.BootDiagnosticsSto } } -func createMachinePoolWithUserAssignedIdentity(providerIds []string) *AzureMachinePool { - userAssignedIdentities := make([]infrav1.UserAssignedIdentity, len(providerIds)) +func createMachinePoolWithUserAssignedIdentity(providerIDs []string) *AzureMachinePool { + userAssignedIdentities := make([]infrav1.UserAssignedIdentity, len(providerIDs)) - for _, providerID := range providerIds { + for _, providerID := range providerIDs { userAssignedIdentities = append(userAssignedIdentities, infrav1.UserAssignedIdentity{ ProviderID: providerID, }) diff --git a/exp/api/v1beta1/azuremachinepoolmachine_types.go b/exp/api/v1beta1/azuremachinepoolmachine_types.go index 907bf7a81ad..afd32527f13 100644 --- a/exp/api/v1beta1/azuremachinepoolmachine_types.go +++ b/exp/api/v1beta1/azuremachinepoolmachine_types.go @@ -19,9 +19,10 @@ package v1beta1 import ( corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" "sigs.k8s.io/cluster-api/errors" + + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" ) const ( diff --git a/exp/api/v1beta1/azuremachinepoolmachine_webhook.go b/exp/api/v1beta1/azuremachinepoolmachine_webhook.go index b2fef133832..6b9278ee2cd 100644 --- a/exp/api/v1beta1/azuremachinepoolmachine_webhook.go +++ b/exp/api/v1beta1/azuremachinepoolmachine_webhook.go @@ -20,11 +20,12 @@ import ( "github.com/pkg/errors" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/util/validation/field" - "sigs.k8s.io/cluster-api-provider-azure/feature" capifeature "sigs.k8s.io/cluster-api/feature" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/webhook" "sigs.k8s.io/controller-runtime/pkg/webhook/admission" + + "sigs.k8s.io/cluster-api-provider-azure/feature" ) // SetupWebhookWithManager sets up and registers the webhook with the manager. diff --git a/exp/controllers/azuremachinepool_controller.go b/exp/controllers/azuremachinepool_controller.go index 8fd899d7474..042d36b3137 100644 --- a/exp/controllers/azuremachinepool_controller.go +++ b/exp/controllers/azuremachinepool_controller.go @@ -30,14 +30,6 @@ import ( "k8s.io/apimachinery/pkg/runtime/schema" kerrors "k8s.io/apimachinery/pkg/util/errors" "k8s.io/client-go/tools/record" - infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" - "sigs.k8s.io/cluster-api-provider-azure/azure" - "sigs.k8s.io/cluster-api-provider-azure/azure/scope" - infracontroller "sigs.k8s.io/cluster-api-provider-azure/controllers" - infrav1exp "sigs.k8s.io/cluster-api-provider-azure/exp/api/v1beta1" - "sigs.k8s.io/cluster-api-provider-azure/pkg/coalescing" - "sigs.k8s.io/cluster-api-provider-azure/util/reconciler" - "sigs.k8s.io/cluster-api-provider-azure/util/tele" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" kubeadmv1 "sigs.k8s.io/cluster-api/bootstrap/kubeadm/api/v1beta1" capierrors "sigs.k8s.io/cluster-api/errors" @@ -52,6 +44,15 @@ import ( "sigs.k8s.io/controller-runtime/pkg/handler" "sigs.k8s.io/controller-runtime/pkg/predicate" "sigs.k8s.io/controller-runtime/pkg/reconcile" + + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" + "sigs.k8s.io/cluster-api-provider-azure/azure" + "sigs.k8s.io/cluster-api-provider-azure/azure/scope" + infracontroller "sigs.k8s.io/cluster-api-provider-azure/controllers" + infrav1exp "sigs.k8s.io/cluster-api-provider-azure/exp/api/v1beta1" + "sigs.k8s.io/cluster-api-provider-azure/pkg/coalescing" + "sigs.k8s.io/cluster-api-provider-azure/util/reconciler" + "sigs.k8s.io/cluster-api-provider-azure/util/tele" ) type ( @@ -365,7 +366,6 @@ func (ampr *AzureMachinePoolReconciler) reconcileNormal(ctx context.Context, mac return reconcile.Result{}, nil } -//nolint:unparam // Always returns an empty struct for reconcile.Result func (ampr *AzureMachinePoolReconciler) reconcilePause(ctx context.Context, machinePoolScope *scope.MachinePoolScope) (reconcile.Result, error) { ctx, log, done := tele.StartSpanWithLogger(ctx, "controllers.AzureMachinePoolReconciler.reconcilePause") defer done() @@ -385,7 +385,6 @@ func (ampr *AzureMachinePoolReconciler) reconcilePause(ctx context.Context, mach return reconcile.Result{}, nil } -//nolint:unparam // Always returns an empty struct for reconcile.Result func (ampr *AzureMachinePoolReconciler) reconcileDelete(ctx context.Context, machinePoolScope *scope.MachinePoolScope, clusterScope infracontroller.ClusterScoper) (reconcile.Result, error) { ctx, log, done := tele.StartSpanWithLogger(ctx, "controllers.AzureMachinePoolReconciler.reconcileDelete") defer done() diff --git a/exp/controllers/azuremachinepool_controller_test.go b/exp/controllers/azuremachinepool_controller_test.go index d64c9cebb6f..20cd390066e 100644 --- a/exp/controllers/azuremachinepool_controller_test.go +++ b/exp/controllers/azuremachinepool_controller_test.go @@ -26,15 +26,16 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/client-go/tools/record" - infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" - infrav1exp "sigs.k8s.io/cluster-api-provider-azure/exp/api/v1beta1" - "sigs.k8s.io/cluster-api-provider-azure/internal/test" - "sigs.k8s.io/cluster-api-provider-azure/util/reconciler" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" expv1 "sigs.k8s.io/cluster-api/exp/api/v1beta1" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/client/fake" + + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" + infrav1exp "sigs.k8s.io/cluster-api-provider-azure/exp/api/v1beta1" + "sigs.k8s.io/cluster-api-provider-azure/internal/test" + "sigs.k8s.io/cluster-api-provider-azure/util/reconciler" ) var _ = Describe("AzureMachinePoolReconciler", func() { diff --git a/exp/controllers/azuremachinepool_controller_unit_test.go b/exp/controllers/azuremachinepool_controller_unit_test.go index c050ae16c05..f0c1e05248a 100644 --- a/exp/controllers/azuremachinepool_controller_unit_test.go +++ b/exp/controllers/azuremachinepool_controller_unit_test.go @@ -25,12 +25,13 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/utils/ptr" + clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" + expv1 "sigs.k8s.io/cluster-api/exp/api/v1beta1" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure/mock_azure" "sigs.k8s.io/cluster-api-provider-azure/azure/scope" infrav1exp "sigs.k8s.io/cluster-api-provider-azure/exp/api/v1beta1" - clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" - expv1 "sigs.k8s.io/cluster-api/exp/api/v1beta1" ) func Test_newAzureMachinePoolService(t *testing.T) { diff --git a/exp/controllers/azuremachinepool_reconciler.go b/exp/controllers/azuremachinepool_reconciler.go index a51c1123725..8529eed9829 100644 --- a/exp/controllers/azuremachinepool_reconciler.go +++ b/exp/controllers/azuremachinepool_reconciler.go @@ -20,6 +20,7 @@ import ( "context" "github.com/pkg/errors" + "sigs.k8s.io/cluster-api-provider-azure/azure" "sigs.k8s.io/cluster-api-provider-azure/azure/scope" "sigs.k8s.io/cluster-api-provider-azure/azure/services/resourceskus" diff --git a/exp/controllers/azuremachinepool_reconciler_test.go b/exp/controllers/azuremachinepool_reconciler_test.go index 760470bd669..ccd2fdceb21 100644 --- a/exp/controllers/azuremachinepool_reconciler_test.go +++ b/exp/controllers/azuremachinepool_reconciler_test.go @@ -24,6 +24,9 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v5" . "github.com/onsi/gomega" "go.uber.org/mock/gomock" + clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" + expv1 "sigs.k8s.io/cluster-api/exp/api/v1beta1" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" "sigs.k8s.io/cluster-api-provider-azure/azure/mock_azure" @@ -31,8 +34,6 @@ import ( "sigs.k8s.io/cluster-api-provider-azure/azure/services/resourceskus" infrav1exp "sigs.k8s.io/cluster-api-provider-azure/exp/api/v1beta1" gomockinternal "sigs.k8s.io/cluster-api-provider-azure/internal/test/matchers/gomock" - clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" - expv1 "sigs.k8s.io/cluster-api/exp/api/v1beta1" ) func TestAzureMachinePoolServiceReconcile(t *testing.T) { @@ -61,7 +62,6 @@ func TestAzureMachinePoolServiceReconcile(t *testing.T) { } for name, tc := range cases { - tc := tc t.Run(name, func(t *testing.T) { g := NewWithT(t) @@ -139,7 +139,6 @@ func TestAzureMachinePoolServicePause(t *testing.T) { } for name, tc := range cases { - tc := tc t.Run(name, func(t *testing.T) { g := NewWithT(t) @@ -204,7 +203,6 @@ func TestAzureMachinePoolServiceDelete(t *testing.T) { } for name, tc := range cases { - tc := tc t.Run(name, func(t *testing.T) { g := NewWithT(t) diff --git a/exp/controllers/azuremachinepoolmachine_controller.go b/exp/controllers/azuremachinepoolmachine_controller.go index 4401bad6e6b..63e32885bab 100644 --- a/exp/controllers/azuremachinepoolmachine_controller.go +++ b/exp/controllers/azuremachinepoolmachine_controller.go @@ -26,15 +26,6 @@ import ( apierrors "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/runtime" "k8s.io/client-go/tools/record" - infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" - "sigs.k8s.io/cluster-api-provider-azure/azure" - "sigs.k8s.io/cluster-api-provider-azure/azure/scope" - "sigs.k8s.io/cluster-api-provider-azure/azure/services/scalesetvms" - infracontroller "sigs.k8s.io/cluster-api-provider-azure/controllers" - infrav1exp "sigs.k8s.io/cluster-api-provider-azure/exp/api/v1beta1" - "sigs.k8s.io/cluster-api-provider-azure/pkg/coalescing" - "sigs.k8s.io/cluster-api-provider-azure/util/reconciler" - "sigs.k8s.io/cluster-api-provider-azure/util/tele" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" capierrors "sigs.k8s.io/cluster-api/errors" "sigs.k8s.io/cluster-api/util" @@ -47,6 +38,16 @@ import ( "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" "sigs.k8s.io/controller-runtime/pkg/handler" "sigs.k8s.io/controller-runtime/pkg/reconcile" + + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" + "sigs.k8s.io/cluster-api-provider-azure/azure" + "sigs.k8s.io/cluster-api-provider-azure/azure/scope" + "sigs.k8s.io/cluster-api-provider-azure/azure/services/scalesetvms" + infracontroller "sigs.k8s.io/cluster-api-provider-azure/controllers" + infrav1exp "sigs.k8s.io/cluster-api-provider-azure/exp/api/v1beta1" + "sigs.k8s.io/cluster-api-provider-azure/pkg/coalescing" + "sigs.k8s.io/cluster-api-provider-azure/util/reconciler" + "sigs.k8s.io/cluster-api-provider-azure/util/tele" ) type ( diff --git a/exp/controllers/azuremachinepoolmachine_controller_test.go b/exp/controllers/azuremachinepoolmachine_controller_test.go index 4b604261df1..96239ef405e 100644 --- a/exp/controllers/azuremachinepoolmachine_controller_test.go +++ b/exp/controllers/azuremachinepoolmachine_controller_test.go @@ -28,6 +28,12 @@ import ( "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/types" "k8s.io/utils/ptr" + clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" + expv1 "sigs.k8s.io/cluster-api/exp/api/v1beta1" + ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/client" + "sigs.k8s.io/controller-runtime/pkg/client/fake" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" "sigs.k8s.io/cluster-api-provider-azure/azure/mock_azure" @@ -35,11 +41,6 @@ import ( infrav1exp "sigs.k8s.io/cluster-api-provider-azure/exp/api/v1beta1" gomock2 "sigs.k8s.io/cluster-api-provider-azure/internal/test/matchers/gomock" reconcilerutils "sigs.k8s.io/cluster-api-provider-azure/util/reconciler" - clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" - expv1 "sigs.k8s.io/cluster-api/exp/api/v1beta1" - ctrl "sigs.k8s.io/controller-runtime" - "sigs.k8s.io/controller-runtime/pkg/client" - "sigs.k8s.io/controller-runtime/pkg/client/fake" ) func TestAzureMachinePoolMachineReconciler_Reconcile(t *testing.T) { @@ -110,7 +111,6 @@ func TestAzureMachinePoolMachineReconciler_Reconcile(t *testing.T) { } for _, c := range cases { - c := c t.Run(c.Name, func(t *testing.T) { var ( g = NewWithT(t) diff --git a/exp/controllers/helpers.go b/exp/controllers/helpers.go index b8bc0ba3b7c..d95652c94b4 100644 --- a/exp/controllers/helpers.go +++ b/exp/controllers/helpers.go @@ -27,10 +27,6 @@ import ( "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/types" - infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" - "sigs.k8s.io/cluster-api-provider-azure/controllers" - infrav1exp "sigs.k8s.io/cluster-api-provider-azure/exp/api/v1beta1" - "sigs.k8s.io/cluster-api-provider-azure/util/reconciler" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" expv1 "sigs.k8s.io/cluster-api/exp/api/v1beta1" "sigs.k8s.io/cluster-api/util" @@ -41,12 +37,17 @@ import ( "sigs.k8s.io/controller-runtime/pkg/handler" "sigs.k8s.io/controller-runtime/pkg/predicate" "sigs.k8s.io/controller-runtime/pkg/reconcile" + + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" + "sigs.k8s.io/cluster-api-provider-azure/controllers" + infrav1exp "sigs.k8s.io/cluster-api-provider-azure/exp/api/v1beta1" + "sigs.k8s.io/cluster-api-provider-azure/util/reconciler" ) // AzureClusterToAzureMachinePoolsMapper creates a mapping handler to transform AzureClusters into AzureMachinePools. The transform // requires AzureCluster to map to the owning Cluster, then from the Cluster, collect the MachinePools belonging to the cluster, // then finally projecting the infrastructure reference to the AzureMachinePool. -func AzureClusterToAzureMachinePoolsMapper(ctx context.Context, c client.Client, scheme *runtime.Scheme, log logr.Logger) (handler.MapFunc, error) { +func AzureClusterToAzureMachinePoolsMapper(_ context.Context, c client.Client, scheme *runtime.Scheme, log logr.Logger) (handler.MapFunc, error) { gvk, err := apiutil.GVKForObject(new(infrav1exp.AzureMachinePool), scheme) if err != nil { return nil, errors.Wrap(err, "failed to find GVK for AzureMachinePool") @@ -99,7 +100,7 @@ func AzureClusterToAzureMachinePoolsMapper(ctx context.Context, c client.Client, // AzureManagedControlPlaneToAzureMachinePoolsMapper creates a mapping handler to transform AzureManagedControlPlanes into AzureMachinePools. The transform // requires AzureManagedControlPlane to map to the owning Cluster, then from the Cluster, collect the MachinePools belonging to the cluster, // then finally projecting the infrastructure reference to the AzureMachinePool. -func AzureManagedControlPlaneToAzureMachinePoolsMapper(ctx context.Context, c client.Client, scheme *runtime.Scheme, log logr.Logger) (handler.MapFunc, error) { +func AzureManagedControlPlaneToAzureMachinePoolsMapper(_ context.Context, c client.Client, scheme *runtime.Scheme, log logr.Logger) (handler.MapFunc, error) { gvk, err := apiutil.GVKForObject(new(infrav1exp.AzureMachinePool), scheme) if err != nil { return nil, errors.Wrap(err, "failed to find GVK for AzureMachinePool") @@ -151,7 +152,7 @@ func AzureManagedControlPlaneToAzureMachinePoolsMapper(ctx context.Context, c cl // AzureMachinePoolMachineMapper creates a mapping handler to transform AzureMachinePoolMachine to AzureMachinePools. func AzureMachinePoolMachineMapper(scheme *runtime.Scheme, log logr.Logger) handler.MapFunc { - return func(ctx context.Context, o client.Object) []ctrl.Request { + return func(_ context.Context, o client.Object) []ctrl.Request { gvk, err := apiutil.GVKForObject(new(infrav1exp.AzureMachinePool), scheme) if err != nil { log.Error(errors.WithStack(err), "failed to find GVK for AzureMachinePool") @@ -195,7 +196,7 @@ func AzureMachinePoolMachineMapper(scheme *runtime.Scheme, log logr.Logger) hand // MachinePoolToInfrastructureMapFunc returns a handler.MapFunc that watches for // MachinePool events and returns reconciliation requests for an infrastructure provider object. func MachinePoolToInfrastructureMapFunc(gvk schema.GroupVersionKind, log logr.Logger) handler.MapFunc { - return func(ctx context.Context, o client.Object) []reconcile.Request { + return func(_ context.Context, o client.Object) []reconcile.Request { m, ok := o.(*expv1.MachinePool) if !ok { log.V(4).Info("attempt to map incorrect type", "type", fmt.Sprintf("%T", o)) @@ -224,7 +225,7 @@ func MachinePoolToInfrastructureMapFunc(gvk schema.GroupVersionKind, log logr.Lo // AzureClusterToAzureMachinePoolsFunc is a handler.MapFunc to be used to enqueue // requests for reconciliation of AzureMachinePools. -func AzureClusterToAzureMachinePoolsFunc(ctx context.Context, c client.Client, log logr.Logger) handler.MapFunc { +func AzureClusterToAzureMachinePoolsFunc(_ context.Context, c client.Client, log logr.Logger) handler.MapFunc { return func(ctx context.Context, o client.Object) []reconcile.Request { ctx, cancel := context.WithTimeout(ctx, reconciler.DefaultMappingTimeout) defer cancel() @@ -269,7 +270,7 @@ func AzureClusterToAzureMachinePoolsFunc(ctx context.Context, c client.Client, l // AzureMachinePoolToAzureMachinePoolMachines maps an AzureMachinePool to its child AzureMachinePoolMachines through // Cluster and MachinePool labels. -func AzureMachinePoolToAzureMachinePoolMachines(ctx context.Context, c client.Client, log logr.Logger) handler.MapFunc { +func AzureMachinePoolToAzureMachinePoolMachines(_ context.Context, c client.Client, log logr.Logger) handler.MapFunc { return func(ctx context.Context, o client.Object) []reconcile.Request { ctx, cancel := context.WithTimeout(ctx, reconciler.DefaultMappingTimeout) defer cancel() @@ -332,9 +333,9 @@ func MachinePoolModelHasChanged(logger logr.Logger) predicate.Funcs { //} return shouldUpdate }, - CreateFunc: func(e event.CreateEvent) bool { return false }, - DeleteFunc: func(e event.DeleteEvent) bool { return false }, - GenericFunc: func(e event.GenericEvent) bool { return false }, + CreateFunc: func(_ event.CreateEvent) bool { return false }, + DeleteFunc: func(_ event.DeleteEvent) bool { return false }, + GenericFunc: func(_ event.GenericEvent) bool { return false }, } } @@ -365,14 +366,14 @@ func MachinePoolMachineHasStateOrVersionChange(logger logr.Logger) predicate.Fun } return shouldUpdate }, - CreateFunc: func(e event.CreateEvent) bool { return false }, - DeleteFunc: func(e event.DeleteEvent) bool { return false }, - GenericFunc: func(e event.GenericEvent) bool { return false }, + CreateFunc: func(_ event.CreateEvent) bool { return false }, + DeleteFunc: func(_ event.DeleteEvent) bool { return false }, + GenericFunc: func(_ event.GenericEvent) bool { return false }, } } // BootstrapConfigToInfrastructureMapFunc returns a handler.ToRequestsFunc that watches for Config events and returns. -func BootstrapConfigToInfrastructureMapFunc(ctx context.Context, c client.Client, log logr.Logger) handler.MapFunc { +func BootstrapConfigToInfrastructureMapFunc(_ context.Context, c client.Client, log logr.Logger) handler.MapFunc { return func(ctx context.Context, o client.Object) []reconcile.Request { ctx, cancel := context.WithTimeout(ctx, reconciler.DefaultMappingTimeout) defer cancel() diff --git a/exp/controllers/helpers_test.go b/exp/controllers/helpers_test.go index e448dd0e076..92f7d5c7e73 100644 --- a/exp/controllers/helpers_test.go +++ b/exp/controllers/helpers_test.go @@ -26,14 +26,15 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/types" - infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" - infrav1exp "sigs.k8s.io/cluster-api-provider-azure/exp/api/v1beta1" - gomockinternal "sigs.k8s.io/cluster-api-provider-azure/internal/test/matchers/gomock" - "sigs.k8s.io/cluster-api-provider-azure/internal/test/mock_log" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/client/fake" "sigs.k8s.io/controller-runtime/pkg/reconcile" + + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" + infrav1exp "sigs.k8s.io/cluster-api-provider-azure/exp/api/v1beta1" + gomockinternal "sigs.k8s.io/cluster-api-provider-azure/internal/test/matchers/gomock" + "sigs.k8s.io/cluster-api-provider-azure/internal/test/mock_log" ) var ( @@ -133,7 +134,6 @@ func Test_MachinePoolToInfrastructureMapFunc(t *testing.T) { } for _, c := range cases { - c := c t.Run(c.Name, func(t *testing.T) { g := NewWithT(t) @@ -283,7 +283,6 @@ func Test_azureClusterToAzureMachinePoolsFunc(t *testing.T) { } for _, c := range cases { - c := c t.Run(c.Name, func(t *testing.T) { t.Parallel() g := NewGomegaWithT(t) diff --git a/exp/controllers/suite_test.go b/exp/controllers/suite_test.go index 5a2b710485d..6064e99e233 100644 --- a/exp/controllers/suite_test.go +++ b/exp/controllers/suite_test.go @@ -24,11 +24,12 @@ import ( . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" corev1 "k8s.io/api/core/v1" + "sigs.k8s.io/controller-runtime/pkg/controller" + "sigs.k8s.io/controller-runtime/pkg/log" + "sigs.k8s.io/cluster-api-provider-azure/controllers" "sigs.k8s.io/cluster-api-provider-azure/internal/test/env" "sigs.k8s.io/cluster-api-provider-azure/util/reconciler" - "sigs.k8s.io/controller-runtime/pkg/controller" - "sigs.k8s.io/controller-runtime/pkg/log" ) // These tests use Ginkgo (BDD-style Go testing framework). Refer to diff --git a/internal/test/env/env.go b/internal/test/env/env.go index 7a0bea6dd30..b9520458680 100644 --- a/internal/test/env/env.go +++ b/internal/test/env/env.go @@ -35,15 +35,16 @@ import ( "k8s.io/client-go/rest" "k8s.io/klog/v2" "k8s.io/utils/ptr" - infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" - infrav1exp "sigs.k8s.io/cluster-api-provider-azure/exp/api/v1beta1" - "sigs.k8s.io/cluster-api-provider-azure/internal/test/record" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" expv1 "sigs.k8s.io/cluster-api/exp/api/v1beta1" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/envtest" "sigs.k8s.io/controller-runtime/pkg/manager" "sigs.k8s.io/controller-runtime/pkg/metrics/server" + + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" + infrav1exp "sigs.k8s.io/cluster-api-provider-azure/exp/api/v1beta1" + "sigs.k8s.io/cluster-api-provider-azure/internal/test/record" ) var ( @@ -132,7 +133,7 @@ func (t *TestEnvironment) Stop() error { } func getFilePathToCAPICRDs(root string) string { - modBits, err := os.ReadFile(filepath.Join(root, "go.mod")) + modBits, err := os.ReadFile(filepath.Join(root, "go.mod")) //nolint:gosec // Ignore G304: Potential file inclusion via variable linter error. if err != nil { return "" } diff --git a/internal/test/matchers/gomega/matchers.go b/internal/test/matchers/gomega/matchers.go index bb8a6e90c29..22fde117bb5 100644 --- a/internal/test/matchers/gomega/matchers.go +++ b/internal/test/matchers/gomega/matchers.go @@ -23,6 +23,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/onsi/gomega/matchers" "github.com/onsi/gomega/types" + "sigs.k8s.io/cluster-api-provider-azure/internal/test/record" ) diff --git a/internal/test/matchers/gomega/matchers_test.go b/internal/test/matchers/gomega/matchers_test.go index 3f78bf66bad..981b601bcbc 100644 --- a/internal/test/matchers/gomega/matchers_test.go +++ b/internal/test/matchers/gomega/matchers_test.go @@ -20,6 +20,7 @@ import ( "testing" "github.com/onsi/gomega" + "sigs.k8s.io/cluster-api-provider-azure/internal/test/record" ) @@ -78,7 +79,6 @@ func TestLogContains(t *testing.T) { } for _, c := range cases { - c := c t.Run(c.Name, func(t *testing.T) { t.Parallel() g := gomega.NewWithT(t) diff --git a/internal/test/record/logger.go b/internal/test/record/logger.go index 7b7a2b4a3f0..186370be7dc 100644 --- a/internal/test/record/logger.go +++ b/internal/test/record/logger.go @@ -153,12 +153,12 @@ func (l *Logger) Init(info logr.RuntimeInfo) { } // Enabled is always enabled. -func (l *Logger) Enabled(v int) bool { +func (l *Logger) Enabled(_ int) bool { return true } // Info logs a non-error message with the given key/value pairs as context. -func (l *Logger) Info(level int, msg string, kvs ...interface{}) { +func (l *Logger) Info(_ int, msg string, kvs ...interface{}) { values := copySlice(l.values) values = append(values, kvs...) values = append(values, "msg", msg) @@ -183,7 +183,7 @@ func (l *Logger) V(level int) logr.LogSink { // WithName adds a new element to the logger's name. func (l *Logger) WithName(name string) logr.LogSink { nl := l.clone() - if len(l.prefix) > 0 { + if l.prefix != "" { nl.prefix = l.prefix + "/" } nl.prefix += name diff --git a/main.go b/main.go index 8aa08637a4b..85243d554f5 100644 --- a/main.go +++ b/main.go @@ -42,16 +42,6 @@ import ( "k8s.io/client-go/tools/leaderelection/resourcelock" cgrecord "k8s.io/client-go/tools/record" "k8s.io/klog/v2" - infrav1alpha "sigs.k8s.io/cluster-api-provider-azure/api/v1alpha1" - infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" - "sigs.k8s.io/cluster-api-provider-azure/controllers" - infrav1exp "sigs.k8s.io/cluster-api-provider-azure/exp/api/v1beta1" - infrav1controllersexp "sigs.k8s.io/cluster-api-provider-azure/exp/controllers" - "sigs.k8s.io/cluster-api-provider-azure/feature" - "sigs.k8s.io/cluster-api-provider-azure/pkg/coalescing" - "sigs.k8s.io/cluster-api-provider-azure/pkg/ot" - "sigs.k8s.io/cluster-api-provider-azure/util/reconciler" - "sigs.k8s.io/cluster-api-provider-azure/version" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" kubeadmv1 "sigs.k8s.io/cluster-api/bootstrap/kubeadm/api/v1beta1" "sigs.k8s.io/cluster-api/controllers/remote" @@ -65,6 +55,17 @@ import ( "sigs.k8s.io/controller-runtime/pkg/controller" "sigs.k8s.io/controller-runtime/pkg/manager" "sigs.k8s.io/controller-runtime/pkg/webhook" + + infrav1alpha "sigs.k8s.io/cluster-api-provider-azure/api/v1alpha1" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" + "sigs.k8s.io/cluster-api-provider-azure/controllers" + infrav1exp "sigs.k8s.io/cluster-api-provider-azure/exp/api/v1beta1" + infrav1controllersexp "sigs.k8s.io/cluster-api-provider-azure/exp/controllers" + "sigs.k8s.io/cluster-api-provider-azure/feature" + "sigs.k8s.io/cluster-api-provider-azure/pkg/coalescing" + "sigs.k8s.io/cluster-api-provider-azure/pkg/ot" + "sigs.k8s.io/cluster-api-provider-azure/util/reconciler" + "sigs.k8s.io/cluster-api-provider-azure/version" ) var ( diff --git a/pkg/coalescing/reconciler.go b/pkg/coalescing/reconciler.go index 542b21b2f63..549767d5571 100644 --- a/pkg/coalescing/reconciler.go +++ b/pkg/coalescing/reconciler.go @@ -22,9 +22,10 @@ import ( "github.com/go-logr/logr" "github.com/pkg/errors" + "sigs.k8s.io/controller-runtime/pkg/reconcile" + "sigs.k8s.io/cluster-api-provider-azure/util/cache/ttllru" "sigs.k8s.io/cluster-api-provider-azure/util/tele" - "sigs.k8s.io/controller-runtime/pkg/reconcile" ) type ( diff --git a/pkg/coalescing/reconciler_test.go b/pkg/coalescing/reconciler_test.go index 7b178fe7fe8..eb29be77024 100644 --- a/pkg/coalescing/reconciler_test.go +++ b/pkg/coalescing/reconciler_test.go @@ -27,9 +27,10 @@ import ( "github.com/pkg/errors" "go.uber.org/mock/gomock" "k8s.io/apimachinery/pkg/types" - mock_coalescing "sigs.k8s.io/cluster-api-provider-azure/pkg/coalescing/mocks" "sigs.k8s.io/controller-runtime/pkg/log" "sigs.k8s.io/controller-runtime/pkg/reconcile" + + mock_coalescing "sigs.k8s.io/cluster-api-provider-azure/pkg/coalescing/mocks" ) func TestCoalescingReconciler_Reconcile(t *testing.T) { @@ -85,7 +86,6 @@ func TestCoalescingReconciler_Reconcile(t *testing.T) { } for _, c := range cases { - c := c t.Run(c.Name, func(t *testing.T) { g := NewWithT(t) mockCtrl := gomock.NewController(t) diff --git a/pkg/mutators/azureasomanagedcontrolplane.go b/pkg/mutators/azureasomanagedcontrolplane.go index 400fb65987e..8471341820a 100644 --- a/pkg/mutators/azureasomanagedcontrolplane.go +++ b/pkg/mutators/azureasomanagedcontrolplane.go @@ -25,15 +25,16 @@ import ( asocontainerservicev1 "github.com/Azure/azure-service-operator/v2/api/containerservice/v1api20231001" asocontainerservicev1hub "github.com/Azure/azure-service-operator/v2/api/containerservice/v1api20231001/storage" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" - infrav1alpha "sigs.k8s.io/cluster-api-provider-azure/api/v1alpha1" - "sigs.k8s.io/cluster-api-provider-azure/azure" - "sigs.k8s.io/cluster-api-provider-azure/util/tele" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" exputil "sigs.k8s.io/cluster-api/exp/util" "sigs.k8s.io/cluster-api/util/secret" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/conversion" "sigs.k8s.io/controller-runtime/pkg/reconcile" + + infrav1alpha "sigs.k8s.io/cluster-api-provider-azure/api/v1alpha1" + "sigs.k8s.io/cluster-api-provider-azure/azure" + "sigs.k8s.io/cluster-api-provider-azure/util/tele" ) var ( @@ -80,7 +81,7 @@ func SetManagedClusterDefaults(ctrlClient client.Client, asoManagedControlPlane return err } - if err := setManagedClusterCredentials(ctx, cluster, managedClusterPath, managedCluster); err != nil { + if err := setManagedClusterCredentials(ctx, cluster, managedClusterPath, managedCluster); err != nil { //nolint:nolintlint // leave it as is return err } diff --git a/pkg/mutators/azureasomanagedcontrolplane_test.go b/pkg/mutators/azureasomanagedcontrolplane_test.go index ad4e414dffb..d9b4071ee48 100644 --- a/pkg/mutators/azureasomanagedcontrolplane_test.go +++ b/pkg/mutators/azureasomanagedcontrolplane_test.go @@ -30,12 +30,13 @@ import ( "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "k8s.io/apimachinery/pkg/runtime" "k8s.io/utils/ptr" - infrav1alpha "sigs.k8s.io/cluster-api-provider-azure/api/v1alpha1" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" expv1 "sigs.k8s.io/cluster-api/exp/api/v1beta1" "sigs.k8s.io/cluster-api/util/secret" fakeclient "sigs.k8s.io/controller-runtime/pkg/client/fake" "sigs.k8s.io/controller-runtime/pkg/conversion" + + infrav1alpha "sigs.k8s.io/cluster-api-provider-azure/api/v1alpha1" ) func TestSetManagedClusterDefaults(t *testing.T) { diff --git a/pkg/mutators/azureasomanagedmachinepool.go b/pkg/mutators/azureasomanagedmachinepool.go index 9b1b670acd2..d4b89ba040f 100644 --- a/pkg/mutators/azureasomanagedmachinepool.go +++ b/pkg/mutators/azureasomanagedmachinepool.go @@ -23,12 +23,13 @@ import ( asocontainerservicev1 "github.com/Azure/azure-service-operator/v2/api/containerservice/v1api20231001" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" - infrav1alpha "sigs.k8s.io/cluster-api-provider-azure/api/v1alpha1" - "sigs.k8s.io/cluster-api-provider-azure/util/tele" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" expv1 "sigs.k8s.io/cluster-api/exp/api/v1beta1" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/reconcile" + + infrav1alpha "sigs.k8s.io/cluster-api-provider-azure/api/v1alpha1" + "sigs.k8s.io/cluster-api-provider-azure/util/tele" ) // ErrNoManagedClustersAgentPoolDefined describes an AzureASOManagedMachinePool without a ManagedClustersAgentPool. @@ -62,7 +63,7 @@ func SetAgentPoolDefaults(ctrlClient client.Client, machinePool *expv1.MachinePo return err } - if err := setAgentPoolCount(ctx, ctrlClient, machinePool, agentPoolPath, agentPool); err != nil { + if err := setAgentPoolCount(ctx, ctrlClient, machinePool, agentPoolPath, agentPool); err != nil { //nolint:nolintlint // leave it as is return err } diff --git a/pkg/mutators/azureasomanagedmachinepool_test.go b/pkg/mutators/azureasomanagedmachinepool_test.go index 2749e190092..0058fde4dfd 100644 --- a/pkg/mutators/azureasomanagedmachinepool_test.go +++ b/pkg/mutators/azureasomanagedmachinepool_test.go @@ -28,11 +28,12 @@ import ( "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "k8s.io/apimachinery/pkg/runtime" "k8s.io/utils/ptr" - infrav1alpha "sigs.k8s.io/cluster-api-provider-azure/api/v1alpha1" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" expv1 "sigs.k8s.io/cluster-api/exp/api/v1beta1" "sigs.k8s.io/controller-runtime/pkg/client" fakeclient "sigs.k8s.io/controller-runtime/pkg/client/fake" + + infrav1alpha "sigs.k8s.io/cluster-api-provider-azure/api/v1alpha1" ) func TestSetAgentPoolDefaults(t *testing.T) { diff --git a/pkg/mutators/mutator.go b/pkg/mutators/mutator.go index 1c295960893..8a1c58454fb 100644 --- a/pkg/mutators/mutator.go +++ b/pkg/mutators/mutator.go @@ -27,8 +27,9 @@ import ( "github.com/go-logr/logr" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "k8s.io/apimachinery/pkg/runtime" - "sigs.k8s.io/cluster-api-provider-azure/util/tele" "sigs.k8s.io/controller-runtime/pkg/reconcile" + + "sigs.k8s.io/cluster-api-provider-azure/util/tele" ) // ResourcesMutator mutates in-place a slice of ASO resources to be reconciled. These mutations make only the diff --git a/pkg/ot/traces.go b/pkg/ot/traces.go index 70afb19ec84..39015e4c25c 100644 --- a/pkg/ot/traces.go +++ b/pkg/ot/traces.go @@ -29,6 +29,7 @@ import ( "go.opentelemetry.io/otel/sdk/resource" sdktrace "go.opentelemetry.io/otel/sdk/trace" semconv "go.opentelemetry.io/otel/semconv/v1.4.0" + "sigs.k8s.io/cluster-api-provider-azure/version" ) diff --git a/test/e2e/aks.go b/test/e2e/aks.go index 3b76e1c3a53..6b01c0a0235 100644 --- a/test/e2e/aks.go +++ b/test/e2e/aks.go @@ -28,13 +28,14 @@ import ( "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "k8s.io/apimachinery/pkg/types" "k8s.io/utils/ptr" - infrav1alpha "sigs.k8s.io/cluster-api-provider-azure/api/v1alpha1" - infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" expv1 "sigs.k8s.io/cluster-api/exp/api/v1beta1" "sigs.k8s.io/cluster-api/test/framework" "sigs.k8s.io/cluster-api/test/framework/clusterctl" "sigs.k8s.io/controller-runtime/pkg/client" + + infrav1alpha "sigs.k8s.io/cluster-api-provider-azure/api/v1alpha1" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" ) // DiscoverAndWaitForAKSControlPlaneInput contains the fields the required for checking the status of azure managed control plane. diff --git a/test/e2e/aks_adopt.go b/test/e2e/aks_adopt.go index 6834ae7ac07..29382fd49ac 100644 --- a/test/e2e/aks_adopt.go +++ b/test/e2e/aks_adopt.go @@ -25,12 +25,13 @@ import ( . "github.com/onsi/gomega" apierrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" clusterctlv1 "sigs.k8s.io/cluster-api/cmd/clusterctl/api/v1alpha3" expv1 "sigs.k8s.io/cluster-api/exp/api/v1beta1" "sigs.k8s.io/cluster-api/test/framework/clusterctl" "sigs.k8s.io/controller-runtime/pkg/client" + + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" ) type AKSAdoptSpecInput struct { diff --git a/test/e2e/aks_autoscaler.go b/test/e2e/aks_autoscaler.go index 32e5aac0855..32de0dcbabb 100644 --- a/test/e2e/aks_autoscaler.go +++ b/test/e2e/aks_autoscaler.go @@ -28,10 +28,11 @@ import ( . "github.com/onsi/gomega" "k8s.io/apimachinery/pkg/types" "k8s.io/utils/ptr" - infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" expv1 "sigs.k8s.io/cluster-api/exp/api/v1beta1" "sigs.k8s.io/controller-runtime/pkg/client" + + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" ) type AKSAutoscaleSpecInput struct { diff --git a/test/e2e/aks_azure_cluster_autoscaler.go b/test/e2e/aks_azure_cluster_autoscaler.go index 114650d44ea..7073140b39d 100644 --- a/test/e2e/aks_azure_cluster_autoscaler.go +++ b/test/e2e/aks_azure_cluster_autoscaler.go @@ -28,8 +28,9 @@ import ( . "github.com/onsi/gomega" "k8s.io/apimachinery/pkg/types" "k8s.io/utils/ptr" - infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" + + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" ) type AKSAzureClusterAutoscalerSettingsSpecInput struct { diff --git a/test/e2e/aks_byo_node.go b/test/e2e/aks_byo_node.go index ae3e4ea95c0..70ea34ed45b 100644 --- a/test/e2e/aks_byo_node.go +++ b/test/e2e/aks_byo_node.go @@ -28,13 +28,14 @@ import ( corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/utils/ptr" - infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" - infrav1exp "sigs.k8s.io/cluster-api-provider-azure/exp/api/v1beta1" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" bootstrapv1 "sigs.k8s.io/cluster-api/bootstrap/kubeadm/api/v1beta1" expv1 "sigs.k8s.io/cluster-api/exp/api/v1beta1" "sigs.k8s.io/cluster-api/util/conditions" "sigs.k8s.io/controller-runtime/pkg/client" + + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" + infrav1exp "sigs.k8s.io/cluster-api-provider-azure/exp/api/v1beta1" ) type AKSBYONodeSpecInput struct { diff --git a/test/e2e/aks_clusterclass.go b/test/e2e/aks_clusterclass.go index e85e1594375..3bfc745c157 100644 --- a/test/e2e/aks_clusterclass.go +++ b/test/e2e/aks_clusterclass.go @@ -28,10 +28,11 @@ import ( . "github.com/onsi/gomega" "k8s.io/apimachinery/pkg/types" "k8s.io/utils/ptr" - infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" expv1 "sigs.k8s.io/cluster-api/exp/api/v1beta1" "sigs.k8s.io/controller-runtime/pkg/client" + + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" ) type AKSClusterClassInput struct { diff --git a/test/e2e/aks_fleets_member.go b/test/e2e/aks_fleets_member.go index 1af4660028c..09bb20f544e 100644 --- a/test/e2e/aks_fleets_member.go +++ b/test/e2e/aks_fleets_member.go @@ -31,11 +31,12 @@ import ( . "github.com/onsi/gomega" "k8s.io/apimachinery/pkg/types" "k8s.io/utils/ptr" - infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" - "sigs.k8s.io/cluster-api-provider-azure/azure" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" "sigs.k8s.io/cluster-api/util/conditions" "sigs.k8s.io/controller-runtime/pkg/client" + + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" + "sigs.k8s.io/cluster-api-provider-azure/azure" ) type AKSFleetsMemberInput struct { diff --git a/test/e2e/aks_machinepools.go b/test/e2e/aks_machinepools.go index 81313f13556..de2b35e797d 100644 --- a/test/e2e/aks_machinepools.go +++ b/test/e2e/aks_machinepools.go @@ -28,13 +28,14 @@ import ( . "github.com/onsi/gomega" "k8s.io/apimachinery/pkg/types" "k8s.io/utils/ptr" - infrav1alpha "sigs.k8s.io/cluster-api-provider-azure/api/v1alpha1" - infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" - "sigs.k8s.io/cluster-api-provider-azure/pkg/mutators" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" expv1 "sigs.k8s.io/cluster-api/exp/api/v1beta1" "sigs.k8s.io/cluster-api/test/framework" "sigs.k8s.io/controller-runtime/pkg/client" + + infrav1alpha "sigs.k8s.io/cluster-api-provider-azure/api/v1alpha1" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" + "sigs.k8s.io/cluster-api-provider-azure/pkg/mutators" ) type AKSMachinePoolSpecInput struct { diff --git a/test/e2e/aks_marketplace.go b/test/e2e/aks_marketplace.go index d5503729286..f8f35f4b27b 100644 --- a/test/e2e/aks_marketplace.go +++ b/test/e2e/aks_marketplace.go @@ -31,11 +31,12 @@ import ( corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/types" "k8s.io/utils/ptr" - infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" - "sigs.k8s.io/cluster-api-provider-azure/azure" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" "sigs.k8s.io/cluster-api/util/conditions" "sigs.k8s.io/controller-runtime/pkg/client" + + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" + "sigs.k8s.io/cluster-api-provider-azure/azure" ) type AKSMarketplaceExtensionSpecInput struct { diff --git a/test/e2e/aks_node_labels.go b/test/e2e/aks_node_labels.go index 5ac398c734f..ec16be07d31 100644 --- a/test/e2e/aks_node_labels.go +++ b/test/e2e/aks_node_labels.go @@ -29,10 +29,11 @@ import ( . "github.com/onsi/gomega" "k8s.io/apimachinery/pkg/types" "k8s.io/utils/ptr" - infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" expv1 "sigs.k8s.io/cluster-api/exp/api/v1beta1" "sigs.k8s.io/controller-runtime/pkg/client" + + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" ) type AKSNodeLabelsSpecInput struct { diff --git a/test/e2e/aks_node_taints.go b/test/e2e/aks_node_taints.go index eacb010ce5c..69ff71a5d7b 100644 --- a/test/e2e/aks_node_taints.go +++ b/test/e2e/aks_node_taints.go @@ -31,10 +31,11 @@ import ( corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/types" "k8s.io/utils/ptr" - infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" expv1 "sigs.k8s.io/cluster-api/exp/api/v1beta1" "sigs.k8s.io/controller-runtime/pkg/client" + + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" ) type AKSNodeTaintsSpecInput struct { diff --git a/test/e2e/aks_patches.go b/test/e2e/aks_patches.go index f5dcbb22e41..e40001182e5 100644 --- a/test/e2e/aks_patches.go +++ b/test/e2e/aks_patches.go @@ -32,10 +32,11 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" "k8s.io/utils/ptr" - infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" expv1 "sigs.k8s.io/cluster-api/exp/api/v1beta1" "sigs.k8s.io/controller-runtime/pkg/client" + + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" ) type AKSPatchSpecInput struct { diff --git a/test/e2e/aks_public_ip_prefix.go b/test/e2e/aks_public_ip_prefix.go index 5258e4ea83f..606008246d7 100644 --- a/test/e2e/aks_public_ip_prefix.go +++ b/test/e2e/aks_public_ip_prefix.go @@ -31,12 +31,13 @@ import ( apierrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/utils/ptr" - infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" - "sigs.k8s.io/cluster-api-provider-azure/azure" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" expv1 "sigs.k8s.io/cluster-api/exp/api/v1beta1" "sigs.k8s.io/cluster-api/util/conditions" "sigs.k8s.io/controller-runtime/pkg/client" + + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" + "sigs.k8s.io/cluster-api-provider-azure/azure" ) type AKSPublicIPPrefixSpecInput struct { @@ -77,7 +78,7 @@ func AKSPublicIPPrefixSpec(ctx context.Context, inputGetter func() AKSPublicIPPr }, nil) Expect(err).NotTo(HaveOccurred()) var publicIPPrefix armnetwork.PublicIPPrefix - Eventually(func(g Gomega) { + Eventually(func(_ Gomega) { resp, err := poller.PollUntilDone(ctx, nil) Expect(err).NotTo(HaveOccurred()) publicIPPrefix = resp.PublicIPPrefix diff --git a/test/e2e/aks_spot.go b/test/e2e/aks_spot.go index 5f35e561104..eebf129d2fa 100644 --- a/test/e2e/aks_spot.go +++ b/test/e2e/aks_spot.go @@ -30,11 +30,12 @@ import ( "k8s.io/apimachinery/pkg/api/resource" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/utils/ptr" - infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" expv1 "sigs.k8s.io/cluster-api/exp/api/v1beta1" "sigs.k8s.io/cluster-api/util/conditions" "sigs.k8s.io/controller-runtime/pkg/client" + + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" ) type AKSSpotSpecInput struct { diff --git a/test/e2e/aks_tags.go b/test/e2e/aks_tags.go index d91d5f1577e..deac4ddb610 100644 --- a/test/e2e/aks_tags.go +++ b/test/e2e/aks_tags.go @@ -30,11 +30,12 @@ import ( "golang.org/x/exp/maps" "k8s.io/apimachinery/pkg/types" "k8s.io/utils/ptr" - infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" - "sigs.k8s.io/cluster-api-provider-azure/azure/converters" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" expv1 "sigs.k8s.io/cluster-api/exp/api/v1beta1" "sigs.k8s.io/controller-runtime/pkg/client" + + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" + "sigs.k8s.io/cluster-api-provider-azure/azure/converters" ) type AKSAdditionalTagsSpecInput struct { diff --git a/test/e2e/aks_upgrade.go b/test/e2e/aks_upgrade.go index fc6a12fad0d..a907f7ee890 100644 --- a/test/e2e/aks_upgrade.go +++ b/test/e2e/aks_upgrade.go @@ -27,11 +27,12 @@ import ( . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "k8s.io/utils/ptr" - infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" expv1 "sigs.k8s.io/cluster-api/exp/api/v1beta1" "sigs.k8s.io/cluster-api/test/framework" "sigs.k8s.io/controller-runtime/pkg/client" + + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" ) type AKSUpgradeSpecInput struct { diff --git a/test/e2e/aks_versions.go b/test/e2e/aks_versions.go index 562d6f888c7..94a42b963ac 100644 --- a/test/e2e/aks_versions.go +++ b/test/e2e/aks_versions.go @@ -115,7 +115,7 @@ func GetWorkingAKSKubernetesVersion(ctx context.Context, subscriptionID, locatio // This means there is no version supported by AKS for this major.minor if !foundWorkingVersion { - return "", errors.New(fmt.Sprintf("No AKS versions found for %s", semver.MajorMinor(baseVersion))) + return "", fmt.Errorf("no AKS versions found for %s", semver.MajorMinor(baseVersion)) } return maxVersion, nil diff --git a/test/e2e/azure_clusterproxy.go b/test/e2e/azure_clusterproxy.go index c3c138e84ec..646ce32de52 100644 --- a/test/e2e/azure_clusterproxy.go +++ b/test/e2e/azure_clusterproxy.go @@ -46,12 +46,13 @@ import ( "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/kubectl/pkg/describe" "k8s.io/utils/ptr" - infrav1alpha "sigs.k8s.io/cluster-api-provider-azure/api/v1alpha1" - infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" - infrav1exp "sigs.k8s.io/cluster-api-provider-azure/exp/api/v1beta1" expv1 "sigs.k8s.io/cluster-api/exp/api/v1beta1" "sigs.k8s.io/cluster-api/test/framework" "sigs.k8s.io/controller-runtime/pkg/client" + + infrav1alpha "sigs.k8s.io/cluster-api-provider-azure/api/v1alpha1" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" + infrav1exp "sigs.k8s.io/cluster-api-provider-azure/exp/api/v1beta1" ) type ( diff --git a/test/e2e/azure_csidriver.go b/test/e2e/azure_csidriver.go index 59b4ed32ff3..d8a572a6c01 100644 --- a/test/e2e/azure_csidriver.go +++ b/test/e2e/azure_csidriver.go @@ -27,11 +27,12 @@ import ( appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" "k8s.io/client-go/kubernetes" + "sigs.k8s.io/cluster-api/test/framework" + "sigs.k8s.io/cluster-api/util" + deploymentBuilder "sigs.k8s.io/cluster-api-provider-azure/test/e2e/kubernetes/deployment" e2e_pvc "sigs.k8s.io/cluster-api-provider-azure/test/e2e/kubernetes/pvc" e2e_sc "sigs.k8s.io/cluster-api-provider-azure/test/e2e/kubernetes/storageclass" - "sigs.k8s.io/cluster-api/test/framework" - "sigs.k8s.io/cluster-api/util" ) const ( diff --git a/test/e2e/azure_edgezone.go b/test/e2e/azure_edgezone.go index 49c20997b3e..deb3c192acc 100644 --- a/test/e2e/azure_edgezone.go +++ b/test/e2e/azure_edgezone.go @@ -27,12 +27,13 @@ import ( . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" corev1 "k8s.io/api/core/v1" - infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" - azureutil "sigs.k8s.io/cluster-api-provider-azure/util/azure" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" "sigs.k8s.io/cluster-api/test/framework" "sigs.k8s.io/cluster-api/test/framework/clusterctl" "sigs.k8s.io/controller-runtime/pkg/client" + + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" + azureutil "sigs.k8s.io/cluster-api-provider-azure/util/azure" ) // AzureEdgeZoneClusterSpecInput is the input for Azure diff --git a/test/e2e/azure_lb.go b/test/e2e/azure_lb.go index c98a8bf040d..4d8d30cde53 100644 --- a/test/e2e/azure_lb.go +++ b/test/e2e/azure_lb.go @@ -33,12 +33,13 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/client-go/kubernetes" k8snet "k8s.io/utils/net" + "sigs.k8s.io/cluster-api/test/framework" + "sigs.k8s.io/cluster-api/util" + deploymentBuilder "sigs.k8s.io/cluster-api-provider-azure/test/e2e/kubernetes/deployment" "sigs.k8s.io/cluster-api-provider-azure/test/e2e/kubernetes/job" "sigs.k8s.io/cluster-api-provider-azure/test/e2e/kubernetes/node" "sigs.k8s.io/cluster-api-provider-azure/test/e2e/kubernetes/windows" - "sigs.k8s.io/cluster-api/test/framework" - "sigs.k8s.io/cluster-api/util" ) // AzureLBSpecInput is the input for AzureLBSpec. diff --git a/test/e2e/azure_logcollector.go b/test/e2e/azure_logcollector.go index e0909b7f05e..9f0fb5ad681 100644 --- a/test/e2e/azure_logcollector.go +++ b/test/e2e/azure_logcollector.go @@ -32,17 +32,18 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v5" "github.com/pkg/errors" apierrors "k8s.io/apimachinery/pkg/api/errors" - infrav1alpha "sigs.k8s.io/cluster-api-provider-azure/api/v1alpha1" - infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" - "sigs.k8s.io/cluster-api-provider-azure/azure" - infrav1exp "sigs.k8s.io/cluster-api-provider-azure/exp/api/v1beta1" - azureutil "sigs.k8s.io/cluster-api-provider-azure/util/azure" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" expv1 "sigs.k8s.io/cluster-api/exp/api/v1beta1" "sigs.k8s.io/cluster-api/test/framework" "sigs.k8s.io/cluster-api/util" "sigs.k8s.io/controller-runtime/pkg/client" kinderrors "sigs.k8s.io/kind/pkg/errors" + + infrav1alpha "sigs.k8s.io/cluster-api-provider-azure/api/v1alpha1" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" + "sigs.k8s.io/cluster-api-provider-azure/azure" + infrav1exp "sigs.k8s.io/cluster-api-provider-azure/exp/api/v1beta1" + azureutil "sigs.k8s.io/cluster-api-provider-azure/util/azure" ) // AzureLogCollector collects logs from a CAPZ workload cluster. @@ -132,7 +133,7 @@ func (k AzureLogCollector) CollectMachinePoolLog(ctx context.Context, management // CollectInfrastructureLogs collects log from the infrastructure. // This is currently a no-op implementation to satisfy the LogCollector interface. -func (k AzureLogCollector) CollectInfrastructureLogs(ctx context.Context, managementClusterClient client.Client, c *clusterv1.Cluster, outputPath string) error { +func (k AzureLogCollector) CollectInfrastructureLogs(_ context.Context, _ client.Client, _ *clusterv1.Cluster, _ string) error { return nil } @@ -507,7 +508,7 @@ func writeBootLog(bootDiagnostics armcompute.RetrieveBootDiagnosticsDataResult, return errors.Wrap(err, "failed to create HTTP request") } resp, err := http.DefaultClient.Do(req) - if err != nil || resp.StatusCode != 200 { + if err != nil || resp.StatusCode != http.StatusOK { return errors.Wrap(err, "failed to get logs from serial console uri") } defer resp.Body.Close() diff --git a/test/e2e/azure_machinepools.go b/test/e2e/azure_machinepools.go index 6c77c70c652..e60c2ca65c8 100644 --- a/test/e2e/azure_machinepools.go +++ b/test/e2e/azure_machinepools.go @@ -31,13 +31,14 @@ import ( "k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/selection" "k8s.io/utils/ptr" - infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" - infrav1exp "sigs.k8s.io/cluster-api-provider-azure/exp/api/v1beta1" - azureutil "sigs.k8s.io/cluster-api-provider-azure/util/azure" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" expv1 "sigs.k8s.io/cluster-api/exp/api/v1beta1" "sigs.k8s.io/cluster-api/test/framework" "sigs.k8s.io/controller-runtime/pkg/client" + + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" + infrav1exp "sigs.k8s.io/cluster-api-provider-azure/exp/api/v1beta1" + azureutil "sigs.k8s.io/cluster-api-provider-azure/util/azure" ) const ( diff --git a/test/e2e/azure_net_pol.go b/test/e2e/azure_net_pol.go index 18062510861..52ba8dbf572 100644 --- a/test/e2e/azure_net_pol.go +++ b/test/e2e/azure_net_pol.go @@ -31,10 +31,11 @@ import ( corev1 "k8s.io/api/core/v1" "k8s.io/client-go/kubernetes" "k8s.io/client-go/rest" + "sigs.k8s.io/cluster-api/test/framework" + deploymentBuilder "sigs.k8s.io/cluster-api-provider-azure/test/e2e/kubernetes/deployment" e2e_namespace "sigs.k8s.io/cluster-api-provider-azure/test/e2e/kubernetes/namespace" e2e_networkpolicy "sigs.k8s.io/cluster-api-provider-azure/test/e2e/kubernetes/networkpolicy" - "sigs.k8s.io/cluster-api/test/framework" ) const ( diff --git a/test/e2e/azure_privatecluster.go b/test/e2e/azure_privatecluster.go index d9770c9bdcb..bc368287207 100644 --- a/test/e2e/azure_privatecluster.go +++ b/test/e2e/azure_privatecluster.go @@ -31,16 +31,16 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - "github.com/pkg/errors" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/util/wait" "k8s.io/utils/ptr" - azureutil "sigs.k8s.io/cluster-api-provider-azure/util/azure" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" "sigs.k8s.io/cluster-api/test/framework" "sigs.k8s.io/cluster-api/test/framework/clusterctl" "sigs.k8s.io/cluster-api/util" "sigs.k8s.io/controller-runtime/pkg/client" + + azureutil "sigs.k8s.io/cluster-api-provider-azure/util/azure" ) // AzurePrivateClusterSpecInput is the input for AzurePrivateClusterSpec. @@ -195,7 +195,7 @@ func AzurePrivateClusterSpec(ctx context.Context, inputGetter func() AzurePrivat // Wait for operation to complete. return false, nil default: - return false, errors.New(fmt.Sprintf("Azure Bastion provisioning failed with state: %q", ptr.Deref(bastion.Properties.ProvisioningState, "(nil)"))) + return false, fmt.Errorf("azure bastion provisioning failed with state: %q", ptr.Deref(bastion.Properties.ProvisioningState, "(nil)")) } } err = wait.ExponentialBackoff(backoff, retryFn) diff --git a/test/e2e/azure_securitygroups.go b/test/e2e/azure_securitygroups.go index 745a5628df5..257f747e32b 100644 --- a/test/e2e/azure_securitygroups.go +++ b/test/e2e/azure_securitygroups.go @@ -28,10 +28,11 @@ import ( . "github.com/onsi/gomega" corev1 "k8s.io/api/core/v1" "k8s.io/utils/ptr" - infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" "sigs.k8s.io/cluster-api/test/framework" "sigs.k8s.io/controller-runtime/pkg/client" + + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" ) // AzureSecurityGroupsSpecInput is the input for AzureSecurityGroupsSpec. diff --git a/test/e2e/azure_selfhosted.go b/test/e2e/azure_selfhosted.go index 919336fa325..7a51aa5d05c 100644 --- a/test/e2e/azure_selfhosted.go +++ b/test/e2e/azure_selfhosted.go @@ -31,7 +31,6 @@ import ( . "github.com/onsi/gomega" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" clusterctlv1 "sigs.k8s.io/cluster-api/cmd/clusterctl/api/v1alpha3" capi_e2e "sigs.k8s.io/cluster-api/test/e2e" @@ -39,6 +38,8 @@ import ( "sigs.k8s.io/cluster-api/test/framework/clusterctl" "sigs.k8s.io/cluster-api/util" "sigs.k8s.io/controller-runtime/pkg/client" + + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" ) // SelfHostedSpecInput is the input for SelfHostedSpec. diff --git a/test/e2e/azure_vmextensions.go b/test/e2e/azure_vmextensions.go index 54b92421bc3..8a8b94a58bf 100644 --- a/test/e2e/azure_vmextensions.go +++ b/test/e2e/azure_vmextensions.go @@ -27,12 +27,13 @@ import ( . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" corev1 "k8s.io/api/core/v1" - infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" - infrav1exp "sigs.k8s.io/cluster-api-provider-azure/exp/api/v1beta1" - azureutil "sigs.k8s.io/cluster-api-provider-azure/util/azure" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" "sigs.k8s.io/cluster-api/test/framework" "sigs.k8s.io/controller-runtime/pkg/client" + + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" + infrav1exp "sigs.k8s.io/cluster-api-provider-azure/exp/api/v1beta1" + azureutil "sigs.k8s.io/cluster-api-provider-azure/util/azure" ) // AzureVMExtensionsSpecInput is the input for AzureVMExtensionsSpec. diff --git a/test/e2e/cni.go b/test/e2e/cni.go index a0d236256af..e1d64e569ab 100644 --- a/test/e2e/cni.go +++ b/test/e2e/cni.go @@ -52,7 +52,7 @@ func EnsureCNI(ctx context.Context, input clusterctl.ApplyCustomClusterTemplateA } // InstallCNIManifest installs the CNI manifest provided by the user -func InstallCNIManifest(ctx context.Context, input clusterctl.ApplyCustomClusterTemplateAndWaitInput, cidrBlocks []string, hasWindows bool) { +func InstallCNIManifest(ctx context.Context, input clusterctl.ApplyCustomClusterTemplateAndWaitInput, cidrBlocks []string, hasWindows bool) { //nolint:revive // leaving unused cidrBlocks and hasWindows for understanding By("Installing a CNI plugin to the workload cluster") workloadCluster := input.ClusterProxy.GetWorkloadCluster(ctx, input.Namespace, input.ClusterName) diff --git a/test/e2e/common.go b/test/e2e/common.go index b78c40df2cc..4af6db9855f 100644 --- a/test/e2e/common.go +++ b/test/e2e/common.go @@ -38,9 +38,6 @@ import ( "k8s.io/client-go/rest" "k8s.io/client-go/tools/clientcmd" "k8s.io/utils/ptr" - infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" - "sigs.k8s.io/cluster-api-provider-azure/azure" - e2e_namespace "sigs.k8s.io/cluster-api-provider-azure/test/e2e/kubernetes/namespace" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" kubeadmv1 "sigs.k8s.io/cluster-api/controlplane/kubeadm/api/v1beta1" capi_e2e "sigs.k8s.io/cluster-api/test/e2e" @@ -48,6 +45,10 @@ import ( "sigs.k8s.io/cluster-api/test/framework/clusterctl" "sigs.k8s.io/cluster-api/util/kubeconfig" "sigs.k8s.io/controller-runtime/pkg/client" + + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" + "sigs.k8s.io/cluster-api-provider-azure/azure" + e2e_namespace "sigs.k8s.io/cluster-api-provider-azure/test/e2e/kubernetes/namespace" ) // Test suite constants for e2e config variables diff --git a/test/e2e/conformance_test.go b/test/e2e/conformance_test.go index 221cfba06b3..ece89b59ea3 100644 --- a/test/e2e/conformance_test.go +++ b/test/e2e/conformance_test.go @@ -33,11 +33,12 @@ import ( corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" - "sigs.k8s.io/cluster-api-provider-azure/test/e2e/kubernetes/node" capi_e2e "sigs.k8s.io/cluster-api/test/e2e" "sigs.k8s.io/cluster-api/test/framework/clusterctl" "sigs.k8s.io/cluster-api/test/framework/kubetest" "sigs.k8s.io/cluster-api/util" + + "sigs.k8s.io/cluster-api-provider-azure/test/e2e/kubernetes/node" ) var _ = Describe("Conformance Tests", func() { diff --git a/test/e2e/helm.go b/test/e2e/helm.go index 15a0149eed2..761b56cb326 100644 --- a/test/e2e/helm.go +++ b/test/e2e/helm.go @@ -35,11 +35,11 @@ type HelmOptions struct { } // InstallHelmChart takes a Helm repo URL, a chart name, and release name, and creates a Helm release on the E2E workload cluster. -func InstallHelmChart(ctx context.Context, clusterProxy framework.ClusterProxy, namespace, repoURL, chartName, releaseName string, options *HelmOptions, version string) { +func InstallHelmChart(_ context.Context, clusterProxy framework.ClusterProxy, namespace, repoURL, chartName, releaseName string, options *HelmOptions, version string) { // Check that Helm v3 is installed helm, err := exec.LookPath("helm") Expect(err).NotTo(HaveOccurred(), "No helm binary found in PATH") - cmd := exec.Command(helm, "version", "--short") + cmd := exec.Command(helm, "version", "--short") //nolint:gosec // Suppress G204: Subprocess launched with variable warning since this is a test file stdout, err := cmd.Output() Expect(err).NotTo(HaveOccurred()) Logf("Helm version: %s", stdout) @@ -69,7 +69,7 @@ func InstallHelmChart(ctx context.Context, clusterProxy framework.ClusterProxy, // Install the chart and retry if needed Eventually(func() error { - cmd := exec.Command(helm, args...) + cmd := exec.Command(helm, args...) //nolint:gosec // Suppress G204: Subprocess launched with variable warning since this is a test file Logf("Helm command: %s", cmd.String()) output, err := cmd.CombinedOutput() Logf("Helm install output: %s", string(output)) diff --git a/test/e2e/helpers.go b/test/e2e/helpers.go index 14172c7731d..c10105f682a 100644 --- a/test/e2e/helpers.go +++ b/test/e2e/helpers.go @@ -52,14 +52,15 @@ import ( typedappsv1 "k8s.io/client-go/kubernetes/typed/apps/v1" typedbatchv1 "k8s.io/client-go/kubernetes/typed/batch/v1" typedcorev1 "k8s.io/client-go/kubernetes/typed/core/v1" - infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" - "sigs.k8s.io/cluster-api-provider-azure/azure" - infrav1exp "sigs.k8s.io/cluster-api-provider-azure/exp/api/v1beta1" capi_e2e "sigs.k8s.io/cluster-api/test/e2e" "sigs.k8s.io/cluster-api/test/framework" "sigs.k8s.io/cluster-api/test/framework/clusterctl" "sigs.k8s.io/cluster-api/test/framework/kubernetesversions" "sigs.k8s.io/controller-runtime/pkg/client" + + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" + "sigs.k8s.io/cluster-api-provider-azure/azure" + infrav1exp "sigs.k8s.io/cluster-api-provider-azure/exp/api/v1beta1" ) const ( @@ -78,7 +79,7 @@ type deploymentsClientAdapter struct { } // Get fetches the deployment named by the key and updates the provided object. -func (c deploymentsClientAdapter) Get(ctx context.Context, key client.ObjectKey, obj client.Object, opts ...client.GetOption) error { +func (c deploymentsClientAdapter) Get(ctx context.Context, key client.ObjectKey, obj client.Object, _ ...client.GetOption) error { deployment, err := c.client.Get(ctx, key.Name, metav1.GetOptions{}) if deployObj, ok := obj.(*appsv1.Deployment); ok { deployment.DeepCopyInto(deployObj) @@ -148,7 +149,7 @@ type jobsClientAdapter struct { } // Get fetches the job named by the key and updates the provided object. -func (c jobsClientAdapter) Get(ctx context.Context, key client.ObjectKey, obj client.Object, opts ...client.GetOption) error { +func (c jobsClientAdapter) Get(ctx context.Context, key client.ObjectKey, obj client.Object, _ ...client.GetOption) error { job, err := c.client.Get(ctx, key.Name, metav1.GetOptions{}) if jobObj, ok := obj.(*batchv1.Job); ok { job.DeepCopyInto(jobObj) @@ -243,7 +244,7 @@ type servicesClientAdapter struct { } // Get fetches the service named by the key and updates the provided object. -func (c servicesClientAdapter) Get(ctx context.Context, key client.ObjectKey, obj client.Object, opts ...client.GetOption) error { +func (c servicesClientAdapter) Get(ctx context.Context, key client.ObjectKey, obj client.Object, _ ...client.GetOption) error { service, err := c.client.Get(ctx, key.Name, metav1.GetOptions{}) if serviceObj, ok := obj.(*corev1.Service); ok { service.DeepCopyInto(serviceObj) @@ -281,7 +282,7 @@ func WaitForDaemonset(ctx context.Context, input WaitForDaemonsetInput, interval } // WaitForDaemonsets retries during E2E until all daemonsets pods are all Running. -func WaitForDaemonsets(ctx context.Context, clusterProxy framework.ClusterProxy, specName string, intervals ...interface{}) { +func WaitForDaemonsets(ctx context.Context, clusterProxy framework.ClusterProxy, _ string, intervals ...interface{}) { Expect(clusterProxy).NotTo(BeNil()) cl := clusterProxy.GetClient() var dsList = &appsv1.DaemonSetList{} diff --git a/test/e2e/kubernetes/networkpolicy/networkpolicy.go b/test/e2e/kubernetes/networkpolicy/networkpolicy.go index ad9472341a4..2299e28d9b0 100644 --- a/test/e2e/kubernetes/networkpolicy/networkpolicy.go +++ b/test/e2e/kubernetes/networkpolicy/networkpolicy.go @@ -34,6 +34,7 @@ import ( "k8s.io/client-go/kubernetes" restclient "k8s.io/client-go/rest" "k8s.io/kubectl/pkg/scheme" + e2e_pod "sigs.k8s.io/cluster-api-provider-azure/test/e2e/kubernetes/pod" ) @@ -109,7 +110,7 @@ func CheckOutboundConnection(clientset *kubernetes.Clientset, config *restclient Expect(err).NotTo(HaveOccurred()) } -func ApplyNetworkPolicy(ctx context.Context, clientset *kubernetes.Clientset, nwpolicyName string, namespace string, nwpolicyFileName string, policyDir string) { +func ApplyNetworkPolicy(ctx context.Context, clientset *kubernetes.Clientset, _ string, namespace string, nwpolicyFileName string, policyDir string) { err := CreateNetworkPolicyFromFile(ctx, clientset, filepath.Join(policyDir, nwpolicyFileName), namespace) Expect(err).NotTo(HaveOccurred()) } diff --git a/test/e2e/kubernetes/node/node.go b/test/e2e/kubernetes/node/node.go index 64fb1137024..e0329925a4f 100644 --- a/test/e2e/kubernetes/node/node.go +++ b/test/e2e/kubernetes/node/node.go @@ -34,6 +34,7 @@ import ( "k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/util/strategicpatch" "k8s.io/client-go/kubernetes" + "sigs.k8s.io/cluster-api-provider-azure/test/e2e/kubernetes/windows" ) diff --git a/test/e2e/kubernetes/windows/windows.go b/test/e2e/kubernetes/windows/windows.go index 0d0ee46aa3a..620d3e736cf 100644 --- a/test/e2e/kubernetes/windows/windows.go +++ b/test/e2e/kubernetes/windows/windows.go @@ -50,7 +50,7 @@ func (i *WindowsImage) GetImage(version OSVersion) string { return fmt.Sprintf("%s:%s", i.BaseImage, tag) } -func GetWindowsImage(testImage WindowsTestImages, version OSVersion) string { +func GetWindowsImage(_ WindowsTestImages, version OSVersion) string { httpd := WindowsImage{ BaseImage: "registry.k8s.io/e2e-test-images/httpd", Tags: map[OSVersion]string{ diff --git a/test/logger.go b/test/logger.go index 40ea7932e6c..6075e760a73 100644 --- a/test/logger.go +++ b/test/logger.go @@ -29,12 +29,13 @@ import ( . "github.com/onsi/gomega" "k8s.io/klog/v2" - "sigs.k8s.io/cluster-api-provider-azure/test/e2e" "sigs.k8s.io/cluster-api/test/framework" ctrl "sigs.k8s.io/controller-runtime" + + "sigs.k8s.io/cluster-api-provider-azure/test/e2e" ) -func Fail(message string, callerSkip ...int) { +func Fail(message string, _ ...int) { panic(message) } diff --git a/util/cache/ttllru/ttllru_test.go b/util/cache/ttllru/ttllru_test.go index 6e3ed2ad8eb..dd7a7b52dc8 100644 --- a/util/cache/ttllru/ttllru_test.go +++ b/util/cache/ttllru/ttllru_test.go @@ -23,6 +23,7 @@ import ( . "github.com/onsi/gomega" "go.uber.org/mock/gomock" + gomockinternal "sigs.k8s.io/cluster-api-provider-azure/internal/test/matchers/gomock" mockttllru "sigs.k8s.io/cluster-api-provider-azure/util/cache/ttllru/mocks" ) @@ -148,7 +149,6 @@ func TestCache_Get(t *testing.T) { } for _, c := range cases { - c := c t.Run(c.Name, func(t *testing.T) { g := NewWithT(t) mockCtrl := gomock.NewController(t) diff --git a/util/futures/getter.go b/util/futures/getter.go index 3bfc846f746..84e473d6c66 100644 --- a/util/futures/getter.go +++ b/util/futures/getter.go @@ -17,8 +17,9 @@ limitations under the License. package futures import ( - infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/controller-runtime/pkg/client" + + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" ) // Getter interface defines methods that an object should implement in order to diff --git a/util/futures/getter_test.go b/util/futures/getter_test.go index 0330e3cbf91..cef08f727b2 100644 --- a/util/futures/getter_test.go +++ b/util/futures/getter_test.go @@ -20,6 +20,7 @@ import ( "testing" . "github.com/onsi/gomega" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" ) diff --git a/util/futures/setter_test.go b/util/futures/setter_test.go index 7e941f8e8a4..d42a07c3dca 100644 --- a/util/futures/setter_test.go +++ b/util/futures/setter_test.go @@ -20,6 +20,7 @@ import ( "testing" . "github.com/onsi/gomega" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" ) diff --git a/util/reconciler/defaults_test.go b/util/reconciler/defaults_test.go index 2e98931cfbe..8d3c4b41922 100644 --- a/util/reconciler/defaults_test.go +++ b/util/reconciler/defaults_test.go @@ -21,6 +21,7 @@ import ( "time" "github.com/onsi/gomega" + "sigs.k8s.io/cluster-api-provider-azure/util/reconciler" ) @@ -48,7 +49,6 @@ func TestDefaultedLoopTimeout(t *testing.T) { } for _, c := range cases { - c := c t.Run(c.Name, func(t *testing.T) { t.Parallel() g := gomega.NewWithT(t) @@ -84,7 +84,6 @@ func TestDefaultedReconcilerRequeue(t *testing.T) { } for _, c := range cases { - c := c t.Run(c.Name, func(t *testing.T) { t.Parallel() g := gomega.NewWithT(t) @@ -120,7 +119,6 @@ func TestDefaultedAzureCallTimeout(t *testing.T) { } for _, c := range cases { - c := c t.Run(c.Name, func(t *testing.T) { t.Parallel() g := gomega.NewWithT(t) @@ -156,7 +154,6 @@ func TestDefaultedAzureServiceReconcileTimeout(t *testing.T) { } for _, c := range cases { - c := c t.Run(c.Name, func(t *testing.T) { t.Parallel() g := gomega.NewWithT(t) diff --git a/util/system/namespace_test.go b/util/system/namespace_test.go index d8b84bd2130..45618d2fd16 100644 --- a/util/system/namespace_test.go +++ b/util/system/namespace_test.go @@ -42,10 +42,9 @@ func TestGetNamespace(t *testing.T) { } for _, c := range cases { - c := c t.Run(c.Name, func(t *testing.T) { g := gomega.NewWithT(t) - os.Setenv(NamespaceEnvVarName, c.PodNamespace) + os.Setenv(NamespaceEnvVarName, c.PodNamespace) //nolint:tenv // leave it as is defer os.Unsetenv(NamespaceEnvVarName) g.Expect(GetManagerNamespace()).To(gomega.Equal(c.Expected)) }) diff --git a/util/tele/span_logger.go b/util/tele/span_logger.go index b65af5abffc..5cf7b72ba56 100644 --- a/util/tele/span_logger.go +++ b/util/tele/span_logger.go @@ -35,14 +35,14 @@ type spanLogSink struct { vals []interface{} } -func (*spanLogSink) Init(info logr.RuntimeInfo) { +func (*spanLogSink) Init(_ logr.RuntimeInfo) { } func (s *spanLogSink) End(opts ...trace.SpanEndOption) { s.Span.End(opts...) } -func (*spanLogSink) Enabled(v int) bool { +func (*spanLogSink) Enabled(_ int) bool { return true } @@ -70,7 +70,7 @@ func (s *spanLogSink) evtStr(evtType, msg string) string { ) } -func (s *spanLogSink) Info(level int, msg string, keysAndValues ...interface{}) { +func (s *spanLogSink) Info(_ int, msg string, keysAndValues ...interface{}) { attrs := s.kvsToAttrs(keysAndValues...) s.AddEvent( s.evtStr("INFO", msg),