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

View file

@ -119,6 +119,8 @@ func loadRestConfig() (cfg *rest.Config, err error) {
return clientcmd.BuildConfigFromFlags("", kubeconfig) 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 { func lookupEnvOr[T any](envKey string, fallback T, parse func(envVal string) (T, error)) T {
envVal := os.Getenv(envKey) envVal := os.Getenv(envKey)
if envVal == "" { 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) { func identity[T any](in T) (T, error) {
return in, nil return in, nil
} }

View file

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