Skip to content

chore(deps): update dependency golangci/golangci-lint to v2 #673

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
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
111 changes: 67 additions & 44 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,56 +1,79 @@
linters-settings:
dupl:
threshold: 100
goconst:
min-len: 2
min-occurrences: 2
cyclop:
max-complexity: 27
gocognit:
min-complexity: 50
gci:
sections:
- standard
- default
- prefix(github.com/projectcapsule/capsule-proxy)
gofumpt:
module-path: github.com/projectcapsule/capsule-proxy
extra-rules: false
inamedparam:
# Skips check for interface methods with only a single parameter.
# Default: false
skip-single-param: true
nakedret:
# Make an issue if func has more lines of code than this setting, and it has naked returns.
max-func-lines: 50
version: "2"
run:
tests: false
allow-parallel-runners: true
linters:
enable-all: true
default: all
disable:
- err113
- depguard
- perfsprint
- err113
- exhaustruct
- funlen
- gochecknoglobals
- gochecknoinits
- ireturn
- lll
- gochecknoglobals
- mnd
- nilnil
- recvcheck
- unparam
- nonamedreturns
- paralleltest
- ireturn
- perfsprint
- recvcheck
- testpackage
- unparam
- varnamelen
- wrapcheck
- exhaustruct
- nonamedreturns
issues:
exclude-files:
- "zz_.*\\.go$"
- ".+\\.generated.go"
- ".+_test.go"
- ".+_test_.+.go"
run:
timeout: 3m
allow-parallel-runners: true
tests: false
settings:
cyclop:
max-complexity: 27
dupl:
threshold: 100
gocognit:
min-complexity: 50
goconst:
min-len: 2
min-occurrences: 2
inamedparam:
skip-single-param: true
nakedret:
max-func-lines: 50
exclusions:
generated: lax
presets:
- comments
- common-false-positives
- legacy
- std-error-handling
paths:
- zz_.*\.go$
- .+\.generated.go
- .+_test.go
- .+_test_.+.go
- third_party$
- builtin$
- examples$
formatters:
enable:
- gci
- gofmt
- gofumpt
- goimports
settings:
gci:
sections:
- standard
- default
- prefix(github.com/projectcapsule/capsule-proxy)
gofumpt:
module-path: github.com/projectcapsule/capsule-proxy
extra-rules: false
exclusions:
generated: lax
paths:
- zz_.*\.go$
- .+\.generated.go
- .+_test.go
- .+_test_.+.go
- third_party$
- builtin$
- examples$
46 changes: 23 additions & 23 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ release:

- `ghcr.io/projectcapsule/charts/{{ .ProjectName }}:{{ .Version }}`

**Kubernetes compatibility**

> [!IMPORTANT]
> **Kubernetes compatibility**
>
> Note that the Capsule project offers support only for the latest minor version of Kubernetes.
> Backwards compatibility with older versions of Kubernetes and OpenShift is [offered by supporters](https://projectcapsule.dev/support/).
>
Expand All @@ -63,34 +63,34 @@ changelog:
filters:
exclude:
- '^test:'
- '^chore'
- '^rebase:'
- 'merge conflict'
- Merge pull request
- Merge remote-tracking branch
- Merge branch
groups:
# https://github.com/conventional-changelog/commitlint/tree/master/%40commitlint/config-conventional
- title: '🛠 Dependency updates'
regexp: '^.*?(feat|fix)\(deps\)!?:.+$'
order: 300
- title: '✨ New Features'
regexp: '^.*?feat(\([[:word:]]+\))??!?:.+$'
order: 100
- title: '🐛 Bug fixes'
regexp: '^.*?fix(\([[:word:]]+\))??!?:.+$'
order: 200
- title: '📖 Documentation updates'
regexp: ^.*?docs(\([[:word:]]+\))??!?:.+$
order: 400
- title: '🛡️ Security updates'
regexp: ^.*?(sec)(\([[:word:]]+\))??!?:.+$
order: 500
- title: '🚀 Build process updates'
regexp: ^.*?(build|ci)(\([[:word:]]+\))??!?:.+$
order: 600
- title: '📦 Other work'
order: 9999
- title: '🛠 Dependency updates'
regexp: '^fix\(deps\):|^feat\(deps\):'
order: 300
- title: '✨ New Features'
regexp: '^feat(\([^)]*\))?:'
order: 100
- title: '🐛 Bug fixes'
regexp: '^fix(\([^)]*\))?:'
order: 200
- title: '📖 Documentation updates'
regexp: '^docs(\([^)]*\))?:'
order: 400
- title: '🛡️ Security updates'
regexp: '^sec(\([^)]*\))?:'
order: 500
- title: '🚀 Build process updates'
regexp: '^(build|ci)(\([^)]*\))?:'
order: 600
- title: '📦 Other work'
regexp: '^chore(\([^)]*\))?:|^chore:'
order: 9999
sboms:
- artifacts: archive
signs:
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -341,11 +341,11 @@ ko:
$(call go-install-tool,$(KO),github.com/$(KO_LOOKUP)@$(KO_VERSION))

GOLANGCI_LINT := $(LOCALBIN)/golangci-lint
GOLANGCI_LINT_VERSION := v1.64.8
GOLANGCI_LINT_VERSION := v2.1.6
GOLANGCI_LINT_LOOKUP := golangci/golangci-lint
golangci-lint: ## Download golangci-lint locally if necessary.
@test -s $(GOLANGCI_LINT) && $(GOLANGCI_LINT) -h | grep -q $(GOLANGCI_LINT_VERSION) || \
$(call go-install-tool,$(GOLANGCI_LINT),github.com/$(GOLANGCI_LINT_LOOKUP)/cmd/golangci-lint@$(GOLANGCI_LINT_VERSION))
$(call go-install-tool,$(GOLANGCI_LINT),github.com/$(GOLANGCI_LINT_LOOKUP)/v2/cmd/golangci-lint@$(GOLANGCI_LINT_VERSION))

# go-install-tool will 'go install' any package $2 and install it to $1.
PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST))))
Expand Down
90 changes: 45 additions & 45 deletions internal/controllers/watchdog/crds_watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,50 +35,6 @@ type CRDWatcher struct {
requeue chan event.GenericEvent
}

func (c *CRDWatcher) keyFunction(group, kind string) string {
return fmt.Sprintf("%s-%s", group, kind)
}

func (c *CRDWatcher) register(ctx context.Context, group string, versions []string, kind string) error {
mgr, _ := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{
Scheme: c.Client.Scheme(),
Metrics: metricsserver.Options{
BindAddress: "0",
},
})

watchedVersions := sets.New[string]()

for _, v := range versions {
watchedVersions.Insert(v)

gvk := metav1.GroupVersionKind{
Group: group,
Version: v,
Kind: kind,
}
//nolint:contextcheck
if err := (&NamespacedWatcher{Client: c.Client}).SetupWithManager(mgr, gvk); err != nil {
return err
}
}

scopedCtx, scopedCancelFn := context.WithCancel(ctx)

go func() {
if err := mgr.Start(scopedCtx); err != nil {
scopedCancelFn()
}
}()

c.watchMap[c.keyFunction(group, kind)] = resourceManager{
cancelFn: scopedCancelFn,
watchedVersions: watchedVersions,
}

return nil
}

func (c *CRDWatcher) Reconcile(ctx context.Context, request reconcile.Request) (reconcile.Result, error) {
crd := apiextensionsv1.CustomResourceDefinition{}
if err := c.Client.Get(ctx, request.NamespacedName, &crd); err != nil {
Expand Down Expand Up @@ -156,7 +112,7 @@ func (c *CRDWatcher) SetupWithManager(ctx context.Context, mgr manager.Manager)
apiGroup, apiKind := parts[0], parts[1]

if registerErr := c.register(ctx, apiGroup, versions.UnsortedList(), apiKind); registerErr != nil {
return errors.Wrap(err, "cannot register watcher prior to start-up")
return errors.Wrap(registerErr, "cannot register watcher prior to start-up")
}
}

Expand All @@ -170,3 +126,47 @@ func (c *CRDWatcher) SetupWithManager(ctx context.Context, mgr manager.Manager)
}))).
Complete(c)
}

func (c *CRDWatcher) keyFunction(group, kind string) string {
return fmt.Sprintf("%s-%s", group, kind)
}

func (c *CRDWatcher) register(ctx context.Context, group string, versions []string, kind string) error {
mgr, _ := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{
Scheme: c.Client.Scheme(),
Metrics: metricsserver.Options{
BindAddress: "0",
},
})

watchedVersions := sets.New[string]()

for _, v := range versions {
watchedVersions.Insert(v)

gvk := metav1.GroupVersionKind{
Group: group,
Version: v,
Kind: kind,
}
//nolint:contextcheck
if err := (&NamespacedWatcher{Client: c.Client}).SetupWithManager(mgr, gvk); err != nil {
return err
}
}

scopedCtx, scopedCancelFn := context.WithCancel(ctx)

go func() {
if err := mgr.Start(scopedCtx); err != nil {
scopedCancelFn()
}
}()

c.watchMap[c.keyFunction(group, kind)] = resourceManager{
cancelFn: scopedCancelFn,
watchedVersions: watchedVersions,
}

return nil
}
8 changes: 4 additions & 4 deletions internal/modules/ingressclass/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,19 @@ func getIngressClasses(request *http.Request, proxyTenants []*tenant.ProxyTenant
continue
}

if len(ic.SelectorAllowedListSpec.Exact) > 0 {
exact = append(exact, ic.SelectorAllowedListSpec.Exact...)
if len(ic.Exact) > 0 {
exact = append(exact, ic.Exact...)
}

if len(ic.Default) > 0 {
exact = append(exact, ic.Default)
}

if r := ic.SelectorAllowedListSpec.Regex; len(r) > 0 {
if r := ic.Regex; len(r) > 0 {
regex = append(regex, regexp.MustCompile(r))
}

selector, err := metav1.LabelSelectorAsSelector(&ic.SelectorAllowedListSpec.LabelSelector)
selector, err := metav1.LabelSelectorAsSelector(&ic.LabelSelector)
if err != nil {
continue
}
Expand Down
8 changes: 4 additions & 4 deletions internal/modules/priorityclass/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,19 @@ func getPriorityClass(req *http.Request, proxyTenants []*tenant.ProxyTenant) (al
continue
}

if len(pc.SelectorAllowedListSpec.Exact) > 0 {
exact = append(exact, pc.SelectorAllowedListSpec.Exact...)
if len(pc.Exact) > 0 {
exact = append(exact, pc.Exact...)
}

if len(pc.Default) > 0 {
exact = append(exact, pc.Default)
}

if r := pc.SelectorAllowedListSpec.Regex; len(r) > 0 {
if r := pc.Regex; len(r) > 0 {
regex = append(regex, regexp.MustCompile(r))
}

selector, err := metav1.LabelSelectorAsSelector(&pc.SelectorAllowedListSpec.LabelSelector)
selector, err := metav1.LabelSelectorAsSelector(&pc.LabelSelector)
if err != nil {
continue
}
Expand Down
8 changes: 4 additions & 4 deletions internal/modules/storageclass/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,19 @@ func getStorageClasses(req *http.Request, proxyTenants []*tenant.ProxyTenant) (a
continue
}

if len(sc.SelectorAllowedListSpec.Exact) > 0 {
exact = append(exact, sc.SelectorAllowedListSpec.Exact...)
if len(sc.Exact) > 0 {
exact = append(exact, sc.Exact...)
}

if len(sc.Default) > 0 {
exact = append(exact, sc.Default)
}

if r := sc.SelectorAllowedListSpec.Regex; len(r) > 0 {
if r := sc.Regex; len(r) > 0 {
regex = append(regex, regexp.MustCompile(r))
}

selector, err := metav1.LabelSelectorAsSelector(&sc.SelectorAllowedListSpec.LabelSelector)
selector, err := metav1.LabelSelectorAsSelector(&sc.LabelSelector)
if err != nil {
continue
}
Expand Down
Loading
Loading