diff --git a/Makefile b/Makefile index b1fbde760f..56411388ed 100644 --- a/Makefile +++ b/Makefile @@ -387,11 +387,11 @@ ifeq ($(EXPORT_RESULT), true) $(GOINSTALL) github.com/jstemmer/go-junit-report/v2@latest $(eval OUTPUT_OPTIONS = | go-junit-report -set-exit-code > junit-report.xml) endif - KUBEBUILDER_ASSETS="$(shell $(SETUP_ENVTEST) use $(ENVTEST_K8S_VERSION) --arch=amd64 -p path)" $(GOTEST) ./... $(OUTPUT_OPTIONS) + KUBEBUILDER_ASSETS="$(shell $(SETUP_ENVTEST) use $(ENVTEST_K8S_VERSION) --arch=amd64 -p path)" $(GOTEST) $(GOTESTPKGS) $(OUTPUT_OPTIONS) .PHONY: coverage coverage: setup-envtest ## Run the tests of the project and export the coverage - KUBEBUILDER_ASSETS="$(shell $(SETUP_ENVTEST) use $(ENVTEST_K8S_VERSION) --arch=amd64 -p path)" $(GOTEST) -cover -covermode=count -coverprofile=profile.cov -coverpkg=./... ./... + KUBEBUILDER_ASSETS="$(shell $(SETUP_ENVTEST) use $(ENVTEST_K8S_VERSION) --arch=amd64 -p path)" $(GOTEST) -cover -covermode=count -coverprofile=profile.cov $(GOTESTPKGS) $(GOTOOL) cover -func profile.cov ifeq ($(EXPORT_RESULT), true) $(GOINSTALL) github.com/AlekSi/gocov-xml@latest diff --git a/api/v1alpha4/nutanixcluster_conversion.go b/api/v1alpha4/nutanixcluster_conversion.go index dbb1437258..6f81d2cbd7 100644 --- a/api/v1alpha4/nutanixcluster_conversion.go +++ b/api/v1alpha4/nutanixcluster_conversion.go @@ -18,7 +18,7 @@ package v1alpha4 import ( apiconversion "k8s.io/apimachinery/pkg/conversion" - capiv1alpha4 "sigs.k8s.io/cluster-api/api/v1alpha4" //nolint:staticcheck // we know v1alpha4 is deprecated: release-v1.3 branch is not an active development branch + capiv1alpha4 "sigs.k8s.io/cluster-api/api/v1alpha4" //nolint:staticcheck // Ignoring v1alpha4 deprecation linter warnings due to inactive dev branch capiv1beta1 "sigs.k8s.io/cluster-api/api/v1beta1" "sigs.k8s.io/controller-runtime/pkg/conversion" diff --git a/api/v1alpha4/nutanixcluster_types.go b/api/v1alpha4/nutanixcluster_types.go index 00cff41ff1..f5926dc780 100644 --- a/api/v1alpha4/nutanixcluster_types.go +++ b/api/v1alpha4/nutanixcluster_types.go @@ -19,7 +19,7 @@ package v1alpha4 import ( credentialTypes "github.com/nutanix-cloud-native/prism-go-client/environment/credentials" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - capiv1 "sigs.k8s.io/cluster-api/api/v1alpha4" //nolint:staticcheck // we know v1alpha4 is deprecated: release-v1.3 branch is not an active development branch + capiv1 "sigs.k8s.io/cluster-api/api/v1alpha4" //nolint:staticcheck // Ignoring v1alpha4 deprecation linter warnings due to inactive dev branch "sigs.k8s.io/cluster-api/errors" ) diff --git a/api/v1alpha4/nutanixmachine_types.go b/api/v1alpha4/nutanixmachine_types.go index f0723bf207..c0c4b05584 100644 --- a/api/v1alpha4/nutanixmachine_types.go +++ b/api/v1alpha4/nutanixmachine_types.go @@ -20,7 +20,7 @@ import ( corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/resource" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - capiv1 "sigs.k8s.io/cluster-api/api/v1alpha4" //nolint:staticcheck // we know v1alpha4 is deprecated: release-v1.3 branch is not an active development branch + capiv1 "sigs.k8s.io/cluster-api/api/v1alpha4" //nolint:staticcheck // Ignoring v1alpha4 deprecation linter warnings due to inactive dev branch "sigs.k8s.io/cluster-api/errors" ) diff --git a/api/v1alpha4/nutanixmachinetemplate_conversion.go b/api/v1alpha4/nutanixmachinetemplate_conversion.go index 3e5b43977f..36aa97e0f8 100644 --- a/api/v1alpha4/nutanixmachinetemplate_conversion.go +++ b/api/v1alpha4/nutanixmachinetemplate_conversion.go @@ -18,7 +18,7 @@ package v1alpha4 import ( apiconversion "k8s.io/apimachinery/pkg/conversion" - capiv1alpha4 "sigs.k8s.io/cluster-api/api/v1alpha4" //nolint:staticcheck // we know v1alpha4 is deprecated: release-v1.3 branch is not an active development branch + capiv1alpha4 "sigs.k8s.io/cluster-api/api/v1alpha4" //nolint:staticcheck // Ignoring v1alpha4 deprecation linter warnings due to inactive dev branch capiv1beta1 "sigs.k8s.io/cluster-api/api/v1beta1" utilconversion "sigs.k8s.io/cluster-api/util/conversion" "sigs.k8s.io/controller-runtime/pkg/conversion" diff --git a/api/v1alpha4/nutanixmachinetemplate_types.go b/api/v1alpha4/nutanixmachinetemplate_types.go index 211a3409e5..9330dbd449 100644 --- a/api/v1alpha4/nutanixmachinetemplate_types.go +++ b/api/v1alpha4/nutanixmachinetemplate_types.go @@ -18,7 +18,7 @@ package v1alpha4 import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - capiv1 "sigs.k8s.io/cluster-api/api/v1alpha4" //nolint:staticcheck // we know v1alpha4 is deprecated: release-v1.3 branch is not an active development branch + capiv1 "sigs.k8s.io/cluster-api/api/v1alpha4" //nolint:staticcheck // Ignoring v1alpha4 deprecation linter warnings due to inactive dev branch ) // NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized. diff --git a/api/v1alpha4/v1alpha4_test.go b/api/v1alpha4/v1alpha4_test.go index df299db994..1e3b5f551b 100644 --- a/api/v1alpha4/v1alpha4_test.go +++ b/api/v1alpha4/v1alpha4_test.go @@ -6,7 +6,7 @@ import ( "github.com/nutanix-cloud-native/prism-go-client/environment/credentials" "github.com/nutanix-cloud-native/prism-go-client/utils" "github.com/stretchr/testify/assert" - "sigs.k8s.io/cluster-api/api/v1alpha4" //nolint:staticcheck // we know v1alpha4 is deprecated: release-v1.3 branch is not an active development branch + "sigs.k8s.io/cluster-api/api/v1alpha4" //nolint:staticcheck // Ignoring v1alpha4 deprecation linter warnings due to inactive dev branch ) func TestNutanixCluster(t *testing.T) { diff --git a/config/crd/bases/infrastructure.cluster.x-k8s.io_nutanixmachines.yaml b/config/crd/bases/infrastructure.cluster.x-k8s.io_nutanixmachines.yaml index f042bcc276..f6cacb29a3 100644 --- a/config/crd/bases/infrastructure.cluster.x-k8s.io_nutanixmachines.yaml +++ b/config/crd/bases/infrastructure.cluster.x-k8s.io_nutanixmachines.yaml @@ -645,8 +645,8 @@ spec: description: The machine address. type: string type: - description: Machine address type, one of Hostname, ExternalIP - or InternalIP. + description: Machine address type, one of Hostname, ExternalIP, + InternalIP, ExternalDNS or InternalDNS. type: string required: - address diff --git a/test/e2e/cluster_upgrade_test.go b/test/e2e/cluster_upgrade_test.go index a2f0ef511e..40be60eb56 100644 --- a/test/e2e/cluster_upgrade_test.go +++ b/test/e2e/cluster_upgrade_test.go @@ -21,8 +21,7 @@ package e2e import ( . "github.com/onsi/ginkgo/v2" - "k8s.io/utils/pointer" - + "k8s.io/utils/ptr" capi_e2e "sigs.k8s.io/cluster-api/test/e2e" ) @@ -46,7 +45,7 @@ var _ = Describe("When upgrading a workload cluster and testing K8S conformance" // BootstrapClusterProxy: bootstrapClusterProxy, // ArtifactFolder: artifactFolder, // SkipCleanup: skipCleanup, -// Flavor: pointer.String("topology"), +// Flavor: ptr.To("topology"), // // This test is run in CI in parallel with other tests. To keep the test duration reasonable // // the conformance tests are skipped. // SkipConformanceTests: true, @@ -65,8 +64,8 @@ var _ = Describe("When upgrading a workload cluster with a single control plane // This test is run in CI in parallel with other tests. To keep the test duration reasonable // the conformance tests are skipped. SkipConformanceTests: true, - ControlPlaneMachineCount: pointer.Int64(1), - WorkerMachineCount: pointer.Int64(1), + ControlPlaneMachineCount: ptr.To(int64(1)), + WorkerMachineCount: ptr.To(int64(1)), } }) }) @@ -82,8 +81,8 @@ var _ = Describe("When upgrading a workload cluster with a HA control plane", La // This test is run in CI in parallel with other tests. To keep the test duration reasonable // the conformance tests are skipped. SkipConformanceTests: true, - ControlPlaneMachineCount: pointer.Int64(3), - WorkerMachineCount: pointer.Int64(1), + ControlPlaneMachineCount: ptr.To(int64(3)), + WorkerMachineCount: ptr.To(int64(1)), } }) }) @@ -99,9 +98,9 @@ var _ = Describe("When upgrading a workload cluster with a HA control plane usin // This test is run in CI in parallel with other tests. To keep the test duration reasonable // the conformance tests are skipped. SkipConformanceTests: true, - ControlPlaneMachineCount: pointer.Int64(3), - WorkerMachineCount: pointer.Int64(1), - Flavor: pointer.String("kcp-scale-in"), + ControlPlaneMachineCount: ptr.To(int64(3)), + WorkerMachineCount: ptr.To(int64(1)), + Flavor: ptr.To("kcp-scale-in"), } }) }) diff --git a/test/e2e/clusterctl_upgrade_test.go b/test/e2e/clusterctl_upgrade_test.go index 42b2d3706e..a55b8977ef 100644 --- a/test/e2e/clusterctl_upgrade_test.go +++ b/test/e2e/clusterctl_upgrade_test.go @@ -22,7 +22,6 @@ import ( "bytes" "context" "fmt" - "io/ioutil" "os" "path/filepath" "time" @@ -132,7 +131,7 @@ func createPreWaitForClusterFunc(testInputFunc func() capi_e2e.ClusterctlUpgrade Byf("Replacing image in %s", latestVersionComponentsYamlFile) // load the components.yaml file - componentsYaml, err := ioutil.ReadFile(latestVersionComponentsYamlFile) + componentsYaml, err := os.ReadFile(latestVersionComponentsYamlFile) Expect(err).NotTo(HaveOccurred()) gitCommitHash := os.Getenv("GIT_COMMIT") @@ -146,7 +145,7 @@ func createPreWaitForClusterFunc(testInputFunc func() capi_e2e.ClusterctlUpgrade ) // write the file back - err = ioutil.WriteFile(latestVersionComponentsYamlFile, componentsYaml, 0o644) + err = os.WriteFile(latestVersionComponentsYamlFile, componentsYaml, 0o644) Expect(err).NotTo(HaveOccurred()) Byf("Successfully replaced image in components.yaml with the image from the current commit: %s", currentCommitImage) diff --git a/test/e2e/md_scale_test.go b/test/e2e/md_scale_test.go index c4428c2f23..c6dc1def59 100644 --- a/test/e2e/md_scale_test.go +++ b/test/e2e/md_scale_test.go @@ -27,7 +27,7 @@ import ( . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" corev1 "k8s.io/api/core/v1" - "k8s.io/utils/pointer" + "k8s.io/utils/ptr" capi_e2e "sigs.k8s.io/cluster-api/test/e2e" "sigs.k8s.io/cluster-api/test/framework" "sigs.k8s.io/cluster-api/test/framework/clusterctl" @@ -96,8 +96,8 @@ var _ = Describe("When testing MachineDeployment scale up/down from 10 replicas Namespace: namespace.Name, ClusterName: fmt.Sprintf("%s-%s", specName, util.RandomString(6)), KubernetesVersion: input.E2EConfig.GetVariable(KubernetesVersion), - ControlPlaneMachineCount: pointer.Int64Ptr(1), - WorkerMachineCount: pointer.Int64Ptr(10), + ControlPlaneMachineCount: ptr.To(int64(1)), + WorkerMachineCount: ptr.To(int64(10)), }, ControlPlaneWaiters: input.ControlPlaneWaiters, WaitForClusterIntervals: input.E2EConfig.GetIntervals(specName, "wait-cluster"), @@ -105,7 +105,7 @@ var _ = Describe("When testing MachineDeployment scale up/down from 10 replicas WaitForMachineDeployments: input.E2EConfig.GetIntervals(specName, "wait-worker-nodes"), }, clusterResources) - Expect(clusterResources.MachineDeployments[0].Spec.Replicas).To(Equal(pointer.Int32Ptr(10))) + Expect(clusterResources.MachineDeployments[0].Spec.Replicas).To(Equal(ptr.To(int32(10)))) By("Scaling the MachineDeployment out to 20") framework.ScaleAndWaitMachineDeployment(ctx, framework.ScaleAndWaitMachineDeploymentInput{ diff --git a/test/e2e/projects_test.go b/test/e2e/projects_test.go index 5a06659710..2ab3d7a356 100644 --- a/test/e2e/projects_test.go +++ b/test/e2e/projects_test.go @@ -24,7 +24,7 @@ import ( . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" corev1 "k8s.io/api/core/v1" - "k8s.io/utils/pointer" + "k8s.io/utils/ptr" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" "sigs.k8s.io/cluster-api/test/framework/clusterctl" @@ -68,7 +68,7 @@ var _ = Describe("Nutanix projects", Label("capx-feature-test", "projects", "slo invalidProjectNMT := testHelper.createDefaultNMT(clusterName, namespace.Name) invalidProjectNMT.Spec.Template.Spec.Project = &infrav1.NutanixResourceIdentifier{ Type: "name", - Name: pointer.StringPtr(nonExistingProjectName), + Name: ptr.To(nonExistingProjectName), } testHelper.createCapiObject(ctx, createCapiObjectParams{ creator: bootstrapClusterProxy.GetClient(), diff --git a/test/e2e/test_helpers.go b/test/e2e/test_helpers.go index ec178e3023..e37e55d006 100644 --- a/test/e2e/test_helpers.go +++ b/test/e2e/test_helpers.go @@ -35,7 +35,7 @@ import ( corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/resource" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/utils/pointer" + "k8s.io/utils/ptr" capiv1 "sigs.k8s.io/cluster-api/api/v1beta1" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" "sigs.k8s.io/cluster-api/test/framework" @@ -254,16 +254,16 @@ func (t testHelper) createUUIDNMT(ctx context.Context, clusterName, namespace st MemorySize: resource.MustParse(defaultMemorySize), Image: infrav1.NutanixResourceIdentifier{ Type: infrav1.NutanixIdentifierUUID, - UUID: pointer.StringPtr(imageUUID), + UUID: ptr.To(imageUUID), }, Cluster: infrav1.NutanixResourceIdentifier{ Type: infrav1.NutanixIdentifierUUID, - UUID: pointer.StringPtr(clusterUUID), + UUID: ptr.To(clusterUUID), }, Subnets: []infrav1.NutanixResourceIdentifier{ { Type: infrav1.NutanixIdentifierUUID, - UUID: pointer.StringPtr(subnetUUID), + UUID: ptr.To(subnetUUID), }, }, SystemDiskSize: resource.MustParse(defaultSystemDiskSize), @@ -426,8 +426,8 @@ func (t testHelper) deployCluster(params deployClusterParams, clusterResources * Namespace: params.namespace.Name, ClusterName: params.clusterName, KubernetesVersion: t.e2eConfig.GetVariable(KubernetesVersion), - ControlPlaneMachineCount: pointer.Int64Ptr(1), - WorkerMachineCount: pointer.Int64Ptr(1), + ControlPlaneMachineCount: ptr.To(int64(1)), + WorkerMachineCount: ptr.To(int64(1)), } t.createClusterFromConfig(ctx, clusterctl.ApplyClusterTemplateAndWaitInput{ @@ -449,8 +449,8 @@ func (t testHelper) deployClusterAndWait(params deployClusterParams, clusterReso Namespace: params.namespace.Name, ClusterName: params.clusterName, KubernetesVersion: t.e2eConfig.GetVariable(KubernetesVersion), - ControlPlaneMachineCount: pointer.Int64Ptr(1), - WorkerMachineCount: pointer.Int64Ptr(1), + ControlPlaneMachineCount: ptr.To(int64(1)), + WorkerMachineCount: ptr.To(int64(1)), } clusterctl.ApplyClusterTemplateAndWait(ctx, clusterctl.ApplyClusterTemplateAndWaitInput{ @@ -537,7 +537,7 @@ func (t testHelper) getNutanixResourceIdentifierFromEnv(envVarKey string) infrav Expect(envVarValue).ToNot(BeEmpty(), "expected environment variable %s to be set", envVarKey) return infrav1.NutanixResourceIdentifier{ Type: nameType, - Name: pointer.StringPtr(envVarValue), + Name: ptr.To(envVarValue), } } @@ -545,7 +545,7 @@ func (t testHelper) getNutanixResourceIdentifierFromE2eConfig(variableKey string variableValue := t.getVariableFromE2eConfig(variableKey) return infrav1.NutanixResourceIdentifier{ Type: nameType, - Name: pointer.StringPtr(variableValue), + Name: ptr.To(variableValue), } }