Skip to content

Commit

Permalink
Build fixes to keep the build passing
Browse files Browse the repository at this point in the history
Changes to fix linting issues and version dependencies to keep the
build passing
  • Loading branch information
thunderboltsid committed May 14, 2024
1 parent 612584e commit 4e6a653
Show file tree
Hide file tree
Showing 13 changed files with 37 additions and 39 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion api/v1alpha4/nutanixcluster_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
2 changes: 1 addition & 1 deletion api/v1alpha4/nutanixcluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down
2 changes: 1 addition & 1 deletion api/v1alpha4/nutanixmachine_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down
2 changes: 1 addition & 1 deletion api/v1alpha4/nutanixmachinetemplate_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion api/v1alpha4/nutanixmachinetemplate_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion api/v1alpha4/v1alpha4_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 9 additions & 10 deletions test/e2e/cluster_upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand All @@ -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,
Expand All @@ -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)),
}
})
})
Expand All @@ -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)),
}
})
})
Expand All @@ -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"),
}
})
})
5 changes: 2 additions & 3 deletions test/e2e/clusterctl_upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
"bytes"
"context"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"time"
Expand Down Expand Up @@ -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")
Expand All @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions test/e2e/md_scale_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -96,16 +96,16 @@ 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"),
WaitForControlPlaneIntervals: input.E2EConfig.GetIntervals(specName, "wait-control-plane"),
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{
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/projects_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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(),
Expand Down
20 changes: 10 additions & 10 deletions test/e2e/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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{
Expand All @@ -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{
Expand Down Expand Up @@ -537,15 +537,15 @@ 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),
}
}

func (t testHelper) getNutanixResourceIdentifierFromE2eConfig(variableKey string) infrav1.NutanixResourceIdentifier {
variableValue := t.getVariableFromE2eConfig(variableKey)
return infrav1.NutanixResourceIdentifier{
Type: nameType,
Name: pointer.StringPtr(variableValue),
Name: ptr.To(variableValue),
}
}

Expand Down

0 comments on commit 4e6a653

Please sign in to comment.