Skip to content

Commit 705f36c

Browse files
authored
chore: Bump go, linter & action (#366)
<!-- Thank you for your contribution. Before you submit the pull request: 1. Follow contributing guidelines, templates, the recommended Git workflow, and any related documentation. 2. Read and submit the required Contributor License Agreements (https://github.com/kyma-project/community/blob/main/CONTRIBUTING.md#agreements-and-licenses). 3. Test your changes and attach their results to the pull request. 4. Update the relevant documentation. If the pull request requires a decision, follow the [decision-making process](https://github.com/kyma-project/community/blob/main/governance.md) and replace the PR template with the [decision record template](https://github.com/kyma-project/community/blob/main/.github/ISSUE_TEMPLATE/decision-record.md). --> **Description** Changes proposed in this pull request: - Bump go to 1.24.3 - Bump linter to 2.1.6 - Bump linter action to 8.0.0 **Related issue(s)** <!-- If you refer to a particular issue, provide its number. For example, `Resolves #123`, `Fixes #43`, or `See also #33`. -->
1 parent 2e2de55 commit 705f36c

File tree

5 files changed

+128
-108
lines changed

5 files changed

+128
-108
lines changed

.github/workflows/lint-golangci.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ jobs:
1717
go-version-file: 'go.mod'
1818
cache: false
1919
- name: golangci-lint
20-
uses: golangci/golangci-lint-action@55c2c1448f86e01eaae002a5a3a9624417608d84 # v6.5.0
20+
uses: golangci/golangci-lint-action@4afd733a84b1f43292c63897423277bb7f4313a9 # v8.0.0
2121
with:
22-
version: v1.64.7
22+
version: v2.1.6
2323
args: --verbose
2424
- name: golangci-lint for api module
25-
uses: golangci/golangci-lint-action@55c2c1448f86e01eaae002a5a3a9624417608d84 # v6.5.0
25+
uses: golangci/golangci-lint-action@4afd733a84b1f43292c63897423277bb7f4313a9 # v8.0.0
2626
with:
27-
version: v1.64.7
27+
version: v2.1.6
2828
args: --verbose
2929
working-directory: ./api

.golangci.yaml

Lines changed: 116 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -1,103 +1,123 @@
1+
version: "2"
12
linters:
2-
enable-all: true
3+
default: all
34
disable:
4-
- contextcheck # too many false positives
5-
- depguard # checks if package imports are whitelisted
6-
- exhaustruct # too subjective and harms code readability
5+
- contextcheck
6+
- depguard
7+
- exhaustruct
78
- lll
8-
- nlreturn # too strict and mostly code is not more readable
9-
- sqlclosecheck # not needed for this project
10-
- paralleltest # should be enabled consciously for long-running tests
11-
- tenv # deprecated (since v1.64.0) and replaced by usetesting
12-
- wsl # too strict and mostly code is not more readable
13-
linters-settings:
14-
gomoddirectives:
15-
replace-local: true
16-
replace-allow-list:
17-
- github.com/kyma-project/template-operator/api
18-
stylecheck:
19-
dot-import-whitelist:
20-
- github.com/onsi/ginkgo/v2
21-
- github.com/onsi/gomega
22-
revive:
23-
severity: error
9+
- nlreturn
10+
- paralleltest
11+
- sqlclosecheck
12+
- wsl
13+
settings:
14+
cyclop:
15+
max-complexity: 20
16+
exhaustruct:
17+
exclude:
18+
- gdfs
19+
funlen:
20+
lines: 80
21+
gomoddirectives:
22+
replace-allow-list:
23+
- github.com/kyma-project/template-operator/api
24+
replace-local: true
25+
ireturn:
26+
allow:
27+
- anon
28+
- error
29+
- empty
30+
- stdlib
31+
- Client
32+
- record.EventRecorder
33+
- client.Object
34+
- schema.ObjectKind
35+
- runtime.Object
36+
- meta.RESTMapper
37+
- client.SubResourceWriter
38+
- openapi.Resources
39+
- validation.Schema
40+
- discovery.CachedDiscoveryInterface
41+
- machineryruntime.Object
42+
- v1.Layer
43+
- authn.Keychain
44+
- ratelimiter.RateLimiter
45+
nestif:
46+
min-complexity: 6
47+
nolintlint:
48+
require-explanation: true
49+
revive:
50+
severity: error
51+
rules:
52+
- name: comment-spacings
53+
disabled: true
54+
- name: dot-imports
55+
severity: warning
56+
disabled: true
57+
- name: line-length-limit
58+
arguments:
59+
- 120
60+
severity: warning
61+
disabled: true
62+
staticcheck:
63+
dot-import-whitelist:
64+
- github.com/onsi/ginkgo/v2
65+
- github.com/onsi/gomega
66+
varnamelen:
67+
ignore-names:
68+
- ok
69+
ignore-type-assert-ok: true
70+
ignore-map-index-ok: true
71+
ignore-chan-recv-ok: true
72+
exclusions:
73+
generated: lax
74+
presets:
75+
- comments
76+
- common-false-positives
77+
- legacy
78+
- std-error-handling
2479
rules:
25-
- name: comment-spacings
26-
disabled: true
27-
- name: dot-imports
28-
severity: warning
29-
disabled: true
30-
- name: line-length-limit
31-
severity: warning
32-
disabled: true
33-
arguments: [ 120 ]
34-
funlen:
35-
lines: 80
36-
cyclop:
37-
max-complexity: 20
38-
nestif:
39-
min-complexity: 6
40-
gci:
41-
sections:
42-
- standard # Standard packages.
43-
- default # Imports that could not be matched to another section type.
44-
- prefix(github.com/kyma-project/template-operator) # Imports with the specified prefix.
45-
- blank # Blank imports.
46-
- dot # Dot imports.
47-
custom-order: true
48-
skip-generated: true
49-
nolintlint:
50-
require-explanation: true
51-
ireturn:
52-
allow:
53-
- anon
54-
- error
55-
- empty
56-
- stdlib
57-
- Client
58-
- record.EventRecorder
59-
- client.Object
60-
- schema.ObjectKind #api/v1beta2/moduletemplate_types.go
61-
- runtime.Object #api/v1beta2/moduletemplate_types.go
62-
- meta.RESTMapper #internal/declarative/v2/client_proxy.go, internal/declarative/v2/rest_getter_proxy.go
63-
- client.SubResourceWriter #internal/declarative/v2/client_proxy.go
64-
- openapi.Resources #internal/declarative/v2/kube_factory_proxy.go
65-
- validation.Schema #internal/declarative/v2/kube_factory_proxy.go
66-
- discovery.CachedDiscoveryInterface #internal/declarative/v2/rest_getter_proxy.go
67-
- machineryruntime.Object #internal/declarative/v2/ssa.go
68-
- v1.Layer #internal/manifest/parse.go, tests/integration/controller/manifest/manifest.go
69-
- authn.Keychain #internal/manifest/spec_resolver.go, pkg/ocmextensions/cred.go
70-
- ratelimiter.RateLimiter #internal/rate_limiter.go
71-
varnamelen:
72-
ignore-names:
73-
- ok
74-
ignore-type-assert-ok: true
75-
ignore-map-index-ok: true
76-
ignore-chan-recv-ok: true
77-
exhaustruct:
78-
exclude:
79-
- gdfs
80+
- linters:
81+
- err113
82+
- fatcontext
83+
- funlen
84+
- gochecknoglobals
85+
- maintidx
86+
- wrapcheck
87+
path: _test\.go
88+
- linters:
89+
- lll
90+
source: '^// +kubebuilder: '
91+
- linters:
92+
- lll
93+
source: '^// http '
94+
paths:
95+
- zz_generated.deepcopy.go
96+
- third_party$
97+
- builtin$
98+
- examples$
8099
issues:
81-
exclude-files:
82-
- zz_generated.deepcopy.go
83-
exclude-rules:
84-
- path: "_test\\.go"
85-
linters:
86-
- wrapcheck # Errors do not need to be wrapped in unit and integration tests
87-
- err113 # Dynamic error creation in unit and integration tests is ok
88-
- gochecknoglobals # Does not apply to unit and integration tests
89-
- fatcontext # Tests will use fatcontext for convenience
90-
- funlen # Table driven unit and integration tests exceed function length by design
91-
- maintidx # Table driven unit and integration tests exceed maintainability index by design
92-
- linters:
93-
- lll
94-
source: "^// +kubebuilder: " # Exclude lll issues for long lines starting with kubebuilder marker prefix
95-
- linters:
96-
- lll # Exclude lll issues for long lines starting with an url
97-
source: "^// http "
98100
max-issues-per-linter: 0
99101
max-same-issues: 0
100-
output:
101-
sort-results: true
102-
run:
103-
timeout: 15m
102+
formatters:
103+
enable:
104+
- gci
105+
- gofmt
106+
- gofumpt
107+
- goimports
108+
settings:
109+
gci:
110+
sections:
111+
- standard
112+
- default
113+
- prefix(github.com/kyma-project/template-operator)
114+
- blank
115+
- dot
116+
custom-order: true
117+
exclusions:
118+
generated: lax
119+
paths:
120+
- zz_generated.deepcopy.go
121+
- third_party$
122+
- builtin$
123+
- examples$

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,10 +161,10 @@ vet: ## Run go vet against code.
161161
go vet ./...
162162

163163
GOLANG_CI_LINT = $(LOCALBIN)/golangci-lint
164-
GOLANG_CI_LINT_VERSION ?= v1.64.7
164+
GOLANG_CI_LINT_VERSION ?= v2.1.6
165165
.PHONY: lint
166166
lint: ## Download & Build & Run golangci-lint against code.
167-
GOBIN=$(LOCALBIN) go install github.com/golangci/golangci-lint/cmd/golangci-lint@$(GOLANG_CI_LINT_VERSION)
167+
GOBIN=$(LOCALBIN) go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@$(GOLANG_CI_LINT_VERSION)
168168
$(LOCALBIN)/golangci-lint run --verbose -c .golangci.yaml
169169
cd api && $(LOCALBIN)/golangci-lint run --verbose -c ../.golangci.yaml
170170

controllers/sample_controller_rendered_resources.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,11 +107,11 @@ func (r *SampleReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctr
107107

108108
objectInstance := v1alpha1.Sample{}
109109

110-
if err := r.Client.Get(ctx, req.NamespacedName, &objectInstance); err != nil {
110+
if err := r.Get(ctx, req.NamespacedName, &objectInstance); err != nil {
111111
// we'll ignore not-found errors, since they can't be fixed by an immediate
112112
// requeue (we'll need to wait for a new notification), and we can get them
113113
// on deleted requests.
114-
logger.Info(req.NamespacedName.String() + " got deleted!")
114+
logger.Info(req.String() + " got deleted!")
115115
if client.IgnoreNotFound(err) != nil {
116116
return ctrl.Result{}, fmt.Errorf("error while getting object: %w", err)
117117
}
@@ -207,7 +207,7 @@ func (r *SampleReconciler) HandleDeletingState(ctx context.Context, objectInstan
207207
resourceObjs, err := getResourcesFromLocalPath(objectInstance.Spec.ResourceFilePath, logger)
208208
if err != nil && controllerutil.RemoveFinalizer(objectInstance, finalizer) {
209209
// if error is encountered simply remove the finalizer and delete the reconciled resource
210-
if err := r.Client.Update(ctx, objectInstance); err != nil {
210+
if err := r.Update(ctx, objectInstance); err != nil {
211211
return fmt.Errorf("error while removing finalizer: %w", err)
212212
}
213213
return nil
@@ -217,7 +217,7 @@ func (r *SampleReconciler) HandleDeletingState(ctx context.Context, objectInstan
217217
// the resources to be installed are unstructured,
218218
// so please make sure the types are available on the target cluster
219219
for _, obj := range resourceObjs.Items {
220-
if err = r.Client.Delete(ctx, obj); err != nil && !errors2.IsNotFound(err) {
220+
if err = r.Delete(ctx, obj); err != nil && !errors2.IsNotFound(err) {
221221
// stay in Deleting state if FinalDeletionState is set to Deleting
222222
if !objectInstance.GetDeletionTimestamp().IsZero() && r.FinalDeletionState == v1alpha1.StateDeleting {
223223
return nil
@@ -233,7 +233,7 @@ func (r *SampleReconciler) HandleDeletingState(ctx context.Context, objectInstan
233233

234234
// if resources are ready to be deleted, remove finalizer
235235
if controllerutil.RemoveFinalizer(objectInstance, finalizer) {
236-
if err := r.Client.Update(ctx, objectInstance); err != nil {
236+
if err := r.Update(ctx, objectInstance); err != nil {
237237
return fmt.Errorf("error while removing finalizer: %w", err)
238238
}
239239
return nil

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/kyma-project/template-operator
22

3-
go 1.24.2
3+
go 1.24.3
44

55
replace github.com/kyma-project/template-operator/api => ./api
66

0 commit comments

Comments
 (0)