Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🌱 Bump golangci-lint to v1.56.2 #1503

Merged
merged 1 commit into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@ jobs:
- name: golangci-lint-${{matrix.working-directory}}
uses: golangci/golangci-lint-action@3cfe3a4abbb849e10058ce4af15d205b6da42804 # v4.0.0
with:
version: v1.54.2
version: v1.56.2
working-directory: ${{matrix.working-directory}}
1 change: 1 addition & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ issues:
linters:
- unused
- unparam
- goconst
# Specific exclude rules for deprecated fields that are still part of the codebase.
# These should be removed as the referenced deprecated item is removed from the project.
- linters:
Expand Down
16 changes: 9 additions & 7 deletions baremetal/metal3data_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,13 @@ import (
)

const (
m3machine = "metal3machine"
host = "baremetalhost"
capimachine = "machine"
DataLabelName = "infrastructure.cluster.x-k8s.io/data-name"
PoolLabelName = "infrastructure.cluster.x-k8s.io/pool-name"
m3machine = "metal3machine"
host = "baremetalhost"
capimachine = "machine"
DataLabelName = "infrastructure.cluster.x-k8s.io/data-name"
PoolLabelName = "infrastructure.cluster.x-k8s.io/pool-name"
networkDataSuffix = "-networdata"
metaDataSuffix = "-metadata"
)

var (
Expand Down Expand Up @@ -162,7 +164,7 @@ func (m *DataManager) createSecrets(ctx context.Context) error {
// If the secret name is unset, set it
if m.Data.Spec.MetaData == nil || m.Data.Spec.MetaData.Name == "" {
m.Data.Spec.MetaData = &corev1.SecretReference{
Name: m3m.Name + "-metadata",
Name: m3m.Name + metaDataSuffix,
Namespace: m.Data.Namespace,
}
}
Expand All @@ -188,7 +190,7 @@ func (m *DataManager) createSecrets(ctx context.Context) error {
// If the secret name is unset, set it
if m.Data.Spec.NetworkData == nil || m.Data.Spec.NetworkData.Name == "" {
m.Data.Spec.NetworkData = &corev1.SecretReference{
Name: m3m.Name + "-networkdata",
Name: m3m.Name + networkDataSuffix,
Namespace: m.Data.Namespace,
}
}
Expand Down
8 changes: 4 additions & 4 deletions baremetal/metal3data_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ var _ = Describe("Metal3Data manager", func() {
tmpSecret := corev1.Secret{}
err = fakeClient.Get(context.TODO(),
client.ObjectKey{
Name: metal3machineName + "-metadata",
Name: metal3machineName + metaDataSuffix,
Namespace: namespaceName,
},
&tmpSecret,
Expand All @@ -224,7 +224,7 @@ var _ = Describe("Metal3Data manager", func() {
tmpSecret := corev1.Secret{}
err = fakeClient.Get(context.TODO(),
client.ObjectKey{
Name: metal3machineName + "-networkdata",
Name: metal3machineName + networkDataSuffix,
Namespace: namespaceName,
},
&tmpSecret,
Expand Down Expand Up @@ -370,13 +370,13 @@ var _ = Describe("Metal3Data manager", func() {
Spec: infrav1.Metal3DataClaimSpec{},
},
metadataSecret: &corev1.Secret{
ObjectMeta: testObjectMeta(metal3machineName+"-metadata", namespaceName, ""),
ObjectMeta: testObjectMeta(metal3machineName+metaDataSuffix, namespaceName, ""),
Data: map[string][]byte{
"metaData": []byte("Hello"),
},
},
networkdataSecret: &corev1.Secret{
ObjectMeta: testObjectMeta(metal3machineName+"-networkdata", namespaceName, ""),
ObjectMeta: testObjectMeta(metal3machineName+networkDataSuffix, namespaceName, ""),
Data: map[string][]byte{
"networkData": []byte("Bye"),
},
Expand Down
4 changes: 2 additions & 2 deletions baremetal/metal3machine_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2550,7 +2550,7 @@ var _ = Describe("Metal3Machine manager", func() {
BMHHost := newBareMetalHost(baremetalhostName, nil, bmov1alpha1.StateNone, nil, false, "metadata", false, tc.HostID)
fakeClient := fake.NewClientBuilder().WithScheme(s).WithObjects(BMHHost).Build()
corev1Client := clientfake.NewSimpleClientset(tc.TargetObjects...).CoreV1()
m := func(ctx context.Context, client client.Client, cluster *clusterv1.Cluster) (
m := func(_ context.Context, _ client.Client, _ *clusterv1.Cluster) (
clientcorev1.CoreV1Interface, error,
) {
return corev1Client, nil
Expand Down Expand Up @@ -2667,7 +2667,7 @@ var _ = Describe("Metal3Machine manager", func() {
BMHHost := newBareMetalHost(baremetalhostName, nil, bmov1alpha1.StateNone, nil, false, "metadata", false, tc.HostID)
fakeClient := fake.NewClientBuilder().WithScheme(s).WithObjects(BMHHost).Build()
corev1Client := clientfake.NewSimpleClientset(tc.TargetObjects...).CoreV1()
m := func(ctx context.Context, client client.Client, cluster *clusterv1.Cluster) (
m := func(_ context.Context, _ client.Client, _ *clusterv1.Cluster) (
clientcorev1.CoreV1Interface, error,
) {
return corev1Client, nil
Expand Down
2 changes: 1 addition & 1 deletion baremetal/metal3remediation_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -953,7 +953,7 @@ var _ = Describe("Metal3Remediation manager", func() {
corev1Client := clientfake.NewSimpleClientset(&corev1.Node{ObjectMeta: metav1.ObjectMeta{
Name: node.Name,
}}).CoreV1()
clientGetter := func(ctx context.Context, client client.Client, cluster *clusterv1.Cluster) (clientcorev1.CoreV1Interface, error) {
clientGetter := func(_ context.Context, _ client.Client, _ *clusterv1.Cluster) (clientcorev1.CoreV1Interface, error) {
return corev1Client, nil
}
remediationMgr, err := NewRemediationManager(fakeClient, clientGetter, m3Remediation, nil, capiMachine,
Expand Down
4 changes: 2 additions & 2 deletions controllers/metal3labelsync_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ var _ = Describe("Metal3LabelSync controller", func() {
Client: fakeClient,
ManagerFactory: baremetal.NewManagerFactory(fakeClient),
Log: logr.Discard(),
CapiClientGetter: func(ctx context.Context, client client.Client, cluster *clusterv1.Cluster) (
CapiClientGetter: func(_ context.Context, _ client.Client, _ *clusterv1.Cluster) (
clientcorev1.CoreV1Interface, error,
) {
return corev1Client, nil
Expand Down Expand Up @@ -540,7 +540,7 @@ var _ = Describe("Metal3LabelSync controller", func() {
Client: fakeClient,
ManagerFactory: baremetal.NewManagerFactory(fakeClient),
Log: logr.Discard(),
CapiClientGetter: func(ctx context.Context, client client.Client, cluster *clusterv1.Cluster) (
CapiClientGetter: func(_ context.Context, _ client.Client, _ *clusterv1.Cluster) (
clientcorev1.CoreV1Interface, error,
) {
return corev1Client, nil
Expand Down
2 changes: 1 addition & 1 deletion controllers/metal3machine_controller_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ var _ = Describe("Reconcile metal3machine", func() {
oldProviderID := testBMmachine.Spec.ProviderID

fakeClient := fake.NewClientBuilder().WithScheme(setupScheme()).WithObjects(tc.Objects...).WithStatusSubresource(tc.Objects...).Build()
mockCapiClientGetter := func(ctx context.Context, c client.Client, cluster *clusterv1.Cluster) (
mockCapiClientGetter := func(_ context.Context, _ client.Client, _ *clusterv1.Cluster) (
clientcorev1.CoreV1Interface, error,
) {
return clientfake.NewSimpleClientset(tc.TargetObjects...).CoreV1(), nil
Expand Down
4 changes: 2 additions & 2 deletions controllers/metal3remediation_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ func (r *Metal3RemediationReconciler) restoreNode(ctx context.Context, remediati
}

// set annotations
if len(annotations) > 0 {
if annotations != "" {
nodeAnnotations, err := unmarshal(annotations)
if err != nil {
r.Log.Error(err, "failed to unmarshal node annotations", "node", node.Name, "annotations", annotations)
Expand All @@ -389,7 +389,7 @@ func (r *Metal3RemediationReconciler) restoreNode(ctx context.Context, remediati
}

// set labels
if len(labels) > 0 {
if labels != "" {
nodeLabels, err := unmarshal(labels)
if err != nil {
r.Log.Error(err, "failed to unmarshal node labels", "node", node.Name, "labels", labels)
Expand Down
6 changes: 3 additions & 3 deletions hack/ensure-golangci-lint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ download_and_install_golangci_lint()
KERNEL_OS="$(uname | tr '[:upper:]' '[:lower:]')"
ARCH="$(uname -m | sed -e 's/x86_64/amd64/' -e 's/\(arm\)\(64\)\?.*/\1\2/' -e 's/aarch64$/arm64/')"
GOLANGCI_LINT="golangci-lint"
GOLANGCI_VERSION="1.54.2"
GOLANGCI_VERSION="1.56.2"
case "${KERNEL_OS}-${ARCH}" in
darwin-arm64) GOLANGCI_SHA256="7b33fb1be2f26b7e3d1f3c10ce9b2b5ce6d13bb1d8468a4b2ba794f05b4445e1" ;;
linux-amd64) GOLANGCI_SHA256="17c9ca05253efe833d47f38caf670aad2202b5e6515879a99873fabd4c7452b3" ;;
darwin-arm64) GOLANGCI_SHA256="5f9ecda712c7ae08fbf872336fae3db866720e5865903d4c53903184b2a2c2dc" ;;
linux-amd64) GOLANGCI_SHA256="e1c313fb5fc85a33890fdee5dbb1777d1f5829c84d655a47a55688f3aad5e501" ;;
*)
echo >&2 "error:${KERNEL_OS}-${ARCH} not supported. Please obtain the binary and calculate sha256 manually."
exit 1
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/cert_rotation.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func certRotation(ctx context.Context, inputGetter func() CertRotationInput) {
mariadbEnabled := input.E2EConfig.GetVariable(ironicMariadb) == "true"
By("Check if Ironic pod is running")
ironicNamespace := input.E2EConfig.GetVariable("NAMEPREFIX") + "-system"
ironicDeploymentName := input.E2EConfig.GetVariable("NAMEPREFIX") + "-ironic"
ironicDeploymentName := input.E2EConfig.GetVariable("NAMEPREFIX") + ironicSuffix
ironicDeployment, err := getDeployment(ctx, clusterClient, ironicDeploymentName, ironicNamespace)
Eventually(func() error {
ironicPod, err := getPodFromDeployment(ctx, clientSet, ironicDeployment, ironicNamespace)
Expand Down
3 changes: 2 additions & 1 deletion test/e2e/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ const (
ironicImageDir = "/opt/metal3-dev-env/ironic/html/images"
osTypeCentos = "centos"
osTypeUbuntu = "ubuntu"
ironicSuffix = "-ironic"
)

func Byf(format string, a ...interface{}) {
Expand Down Expand Up @@ -651,7 +652,7 @@ func runCommand(logFolder, filename, machineIP, user, command string) error {
Auth: []ssh.AuthMethod{
ssh.PublicKeys(signer),
},
HostKeyCallback: func(hostname string, remote net.Addr, key ssh.PublicKey) error { return nil },
HostKeyCallback: func(_ string, _ net.Addr, _ ssh.PublicKey) error { return nil },
Timeout: 60 * time.Second,
}
client, err := ssh.Dial("tcp", fmt.Sprintf("%s:22", machineIP), cfg)
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/pivoting.go
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ func installIronicBMO(ctx context.Context, inputGetter func() installIronicBMOIn
Expect(er).ToNot(HaveOccurred(), "Failed to deploy Ironic")
deploymentNameList := []string{}
if input.deployIronic {
deploymentNameList = append(deploymentNameList, "-ironic")
deploymentNameList = append(deploymentNameList, ironicSuffix)
}
if input.deployBMO {
deploymentNameList = append(deploymentNameList, "-controller-manager")
Expand All @@ -345,7 +345,7 @@ type RemoveIronicInput struct {
func removeIronic(ctx context.Context, inputGetter func() RemoveIronicInput) {
input := inputGetter()
if input.IsDeployment {
deploymentName := input.NamePrefix + "-ironic"
deploymentName := input.NamePrefix + ironicSuffix
RemoveDeployment(ctx, func() RemoveDeploymentInput {
return RemoveDeploymentInput{
ManagementCluster: input.ManagementCluster,
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/upgrade_clusterctl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ func preWaitForCluster(clusterProxy framework.ClusterProxy, clusterNamespace str
}

// Create the BMHs needed in the hosting namespace.
createBMH := func(clusterProxy framework.ClusterProxy, clusterNamespace string, clusterName string) {
createBMH := func(clusterProxy framework.ClusterProxy, clusterNamespace string, _ string) {
installSplitYAML()
splitFiles := splitYAMLFile("bmhosts_crs.yaml", workDir)
// Check which from which cluster creation this call is coming
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/upgrade_ironic.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func upgradeIronic(ctx context.Context, inputGetter func() upgradeIronicInput) {
clientSet = input.ManagementCluster.GetClientSet()
namePrefix = input.E2EConfig.GetVariable("NAMEPREFIX")
ironicNamespace = input.E2EConfig.GetVariable("IRONIC_NAMESPACE")
ironicDeployName = namePrefix + "-ironic"
ironicDeployName = namePrefix + ironicSuffix
containerRegistry = input.E2EConfig.GetVariable("CONTAINER_REGISTRY")
ironicImageTag = input.E2EConfig.GetVariable("IRONIC_IMAGE_TAG")
)
Expand Down