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.55.2 #216

Merged
merged 7 commits into from
Jan 30, 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
4 changes: 2 additions & 2 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ jobs:
- name: golangci-lint
uses: golangci/golangci-lint-action@07db5389c99593f11ad7b44463c2d4233066a9b1 # [email protected]
with:
version: v1.54.2
args: --verbose --timeout 5m
version: v1.55.2
args: --verbose --timeout 10m
12 changes: 11 additions & 1 deletion .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,20 @@ run:
- "zz_generated.*"
linters:
enable:
- gochecksumtype
- goimports
- perfsprint
- protogetter
- revive
- whitespace
- wsl
- goimports
linters-settings:
goimports:
local-prefixes: github.com/gardener/terminal-controller-manager
issues:
exclude-rules:
# Allow dot imports for ginkgo and gomega
- source: ginkgo|gomega
linters:
- revive
text: "should not use dot imports"
4 changes: 2 additions & 2 deletions controllers/terminal_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -735,9 +735,9 @@ func clusterNameForCredential(cred extensionsv1alpha1.ClusterCredentials) (strin
return cred.SecretRef.Name, nil
} else if cred.ServiceAccountRef != nil {
return cred.ServiceAccountRef.Name, nil
} else {
return "", errors.New("no cluster credentials provided")
}

return "", errors.New("no cluster credentials provided")
}

func createOrUpdateKubeconfigSecret(ctx context.Context, targetClientSet *gardenclient.ClientSet, hostClientSet *gardenclient.ClientSet, t *extensionsv1alpha1.Terminal, labelSet *labels.Set, annotationSet *utils.Set) (*corev1.Secret, error) {
Expand Down
2 changes: 1 addition & 1 deletion hack/golangci-lint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ if [ -z "$SOURCE_PATH" ]; then
fi
export SOURCE_PATH="$(readlink -f "$SOURCE_PATH")"

GOLANGCI_LINT_VERSION=${GOLANGCI_LINT_VERSION:-v1.54.2}
GOLANGCI_LINT_VERSION=${GOLANGCI_LINT_VERSION:-v1.55.2}
GOLANGCI_LINT_ADDITIONAL_FLAGS=${GOLANGCI_LINT_ADDITIONAL_FLAGS:-""}

# Install golangci-lint (linting tool)
Expand Down
4 changes: 2 additions & 2 deletions internal/gardenclient/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,9 @@ func NewClientSetFromClusterCredentials(ctx context.Context, cs *ClientSet, cred
return NewClientSetFromSecretRef(ctx, cs, credentials.SecretRef, scheme)
} else if pointer.BoolDeref(honourServiceAccountRef, false) && credentials.ServiceAccountRef != nil {
return NewClientSetFromServiceAccountRef(ctx, cs, credentials.ServiceAccountRef, expirationSeconds, scheme)
} else {
return nil, errors.New("no cluster credentials provided")
}

return nil, errors.New("no cluster credentials provided")
}

func NewClientSetFromServiceAccountRef(ctx context.Context, cs *ClientSet, ref *corev1.ObjectReference, expirationSeconds *int64, scheme *runtime.Scheme) (*ClientSet, error) {
Expand Down
4 changes: 2 additions & 2 deletions internal/utils/miscellaneous.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ SPDX-License-Identifier: Apache-2.0
package utils

import (
"fmt"
"hash/fnv"
"os"
"strconv"
)

// Set is a map of label:value. It implements Labels.
Expand All @@ -23,7 +23,7 @@ func ToFnvHash(value string) (string, error) {
return "", err
}

return fmt.Sprint(fnvHash.Sum64()), nil
return strconv.FormatUint(fnvHash.Sum64(), 10), nil
}

// MergeStringMap combines given maps, and does not check for any conflicts
Expand Down
38 changes: 38 additions & 0 deletions internal/utils/miscellaneous_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
SPDX-FileCopyrightText: 2023 SAP SE or an SAP affiliate company and Gardener contributors

SPDX-License-Identifier: Apache-2.0
*/

package utils_test

import (
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"

"github.com/gardener/terminal-controller-manager/internal/utils"
)

var _ = Describe("miscellaneous", func() {
Describe("ToFnvHash", func() {
Context("When a string is passed", func() {
It("should return hash without error", func() {
value := "test string"
hash, err := utils.ToFnvHash(value)

Expect(err).NotTo(HaveOccurred())
Expect(hash).To(Equal("10983430520173899754"))
})
})

Context("When an empty string is passed", func() {
It("should return hash without error", func() {
value := ""
hash, err := utils.ToFnvHash(value)

Expect(err).NotTo(HaveOccurred())
Expect(hash).To(Equal("14695981039346656037"))
})
})
})
})
22 changes: 22 additions & 0 deletions internal/utils/utils_suite_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
SPDX-FileCopyrightText: 2023 SAP SE or an SAP affiliate company and Gardener contributors

SPDX-License-Identifier: Apache-2.0
*/

package utils_test

import (
"testing"
"time"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)

func TestAPIs(t *testing.T) {
RegisterFailHandler(Fail)

SetDefaultEventuallyTimeout(5 * time.Second)
RunSpecs(t, "Utils Suite")
}
Loading