Fix linter issue

This commit is contained in:
Peter 2022-05-13 16:16:28 +02:00
parent d5a87e481d
commit 8cad908cbd
Signed by: prskr
GPG key ID: C1DB5D2E8DB512F9
3 changed files with 13 additions and 7 deletions

View file

@ -61,8 +61,6 @@ linters-settings:
alias:
- pkg: (k8s.io/api|k8s.io/apimachinery/pkg/apis)/([A-z0-9]+)/([A-z0-9]+)
alias: $2$3
staticcheck:
go: "1.18"
lll:
line-length: 140
misspell:
@ -89,7 +87,7 @@ linters:
- funlen
- gocognit
- goconst
# - gocritic
- gocritic
- gocyclo
- godox
- gofumpt
@ -97,12 +95,12 @@ linters:
- gomoddirectives
- gomnd
- gosec
- gosimple
# - gosimple
- govet
- ifshort
- importas
- ineffassign
# - ireturn - enable later
- ireturn
- lll
- misspell
- nakedret
@ -110,13 +108,14 @@ linters:
- nilnil
- noctx
- nolintlint
- nosprintfhostport
- paralleltest
- prealloc
- predeclared
- promlinter
- staticcheck
# - staticcheck
- structcheck
- stylecheck
# - stylecheck
- tenv
- testpackage
- thelper
@ -143,6 +142,7 @@ issues:
- deadcode
run:
go: "1.18"
skip-files:
- ".*.mock.\\.go$"
modules-download-mode: readonly

View file

@ -119,6 +119,8 @@ func loadRestConfig() (cfg *rest.Config, err error) {
return clientcmd.BuildConfigFromFlags("", kubeconfig)
}
//nolint:nolintlint // false postivie
//nolint:ireturn // false positive
func lookupEnvOr[T any](envKey string, fallback T, parse func(envVal string) (T, error)) T {
envVal := os.Getenv(envKey)
if envVal == "" {
@ -132,6 +134,8 @@ func lookupEnvOr[T any](envKey string, fallback T, parse func(envVal string) (T,
}
}
//nolint:nolintlint // false postivie
//nolint:ireturn // false positive
func identity[T any](in T) (T, error) {
return in, nil
}

View file

@ -23,6 +23,8 @@ func ParseTarget(val string) (Target, error) {
type Target string
//nolint:nolintlint // false postivie
//nolint:ireturn // no over option due to upstream library
func (t Target) Selector() (labels.Selector, error) {
s := string(t)
if s == "" {