Skip to content

Commit 5ca92bd

Browse files
authored
MGMT-18518: Linter fixes & renovate config for linter and golang (#1147)
1 parent 903b1d6 commit 5ca92bd

File tree

4 files changed

+112
-30
lines changed

4 files changed

+112
-30
lines changed

.golangci.yml

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -15,53 +15,52 @@ run:
1515
# include test files or not, default is true
1616
tests: true
1717

18-
# which dirs to skip: issues from them won't be reported;
19-
# can use regexp here: generated.*, regexp is applied on full path;
20-
# default value is empty list, but default dirs are skipped independently
21-
# from this option's value (see skip-dirs-use-default).
22-
skip-dirs:
23-
- build
24-
- client
25-
- docs
26-
- models
27-
- restapi
28-
2918
# output configuration options
3019
output:
31-
# colored-line-number|line-number|json|tab|checkstyle|code-climate, default is "colored-line-number"
32-
format: colored-line-number
33-
3420
# print lines of code with issue, default is true
3521
print-issued-lines: true
3622

3723
# print linter name in the end of issue text, default is true
3824
print-linter-name: true
3925

40-
# make issues output unique by line, default is true
41-
uniq-by-line: true
42-
4326
issues:
27+
# which dirs to skip: issues from them won't be reported;
28+
# can use regexp here: generated.*, regexp is applied on full path;
29+
# default value is empty list, but default dirs are skipped independently
30+
# from this option's value (see skip-dirs-use-default).
31+
exclude-dirs:
32+
- build
33+
- client
34+
- docs
35+
- models
36+
- restapi
37+
4438
# List of regexps of issue texts to exclude, empty list by default.
4539
# But independently from this option we use default exclude patterns,
4640
# it can be disabled by `exclude-use-default: false`. To list all
4741
# excluded by default patterns execute `golangci-lint run --help`
4842
exclude:
4943
- G107
44+
45+
# make issues output unique by line, default is true
46+
uniq-by-line: true
5047

5148
linters:
5249
enable:
53-
- megacheck
50+
- gosimple
51+
- staticcheck
52+
- unused
5453
- govet
5554
- gocyclo
5655
- gofmt
5756
- gosec
58-
- megacheck
5957
- unconvert
6058
- goimports
6159

6260
linters-settings:
6361
govet:
64-
check-shadowing: true
62+
enable:
63+
- shadow
6564
settings:
6665
printf:
6766
funcs:

Dockerfile.assisted-installer-build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ FROM registry.access.redhat.com/ubi9/go-toolset:1.21 AS golang
22

33
ENV GOFLAGS=""
44

5-
RUN curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.54.0 && \
5+
RUN curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.64.7 && \
66
go install golang.org/x/tools/cmd/goimports@v0.1.0 && \
77
go install github.com/onsi/ginkgo/ginkgo@v1.16.1 && \
88
go install go.uber.org/mock/mockgen@v0.4.0 && \

renovate.json

Lines changed: 82 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,85 @@
11
{
2-
"schedule": ["on Saturday"],
3-
"groupName": "Konflux build pipeline",
4-
"includePaths": [".tekton/*"],
2+
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
3+
4+
55
"commitMessagePrefix": "NO-ISSUE: ",
6-
"labels": ["lgtm", "approved", "konflux"]
6+
"labels": ["lgtm", "approved"],
7+
8+
"prHourlyLimit": 0,
9+
"prConcurrentLimit": 0,
10+
11+
"enabledManagers": [
12+
"custom.regex",
13+
"tekton"
14+
],
15+
16+
"tekton": {
17+
"fileMatch": ["^.tekton/*"]
18+
},
19+
20+
"customManagers": [
21+
{
22+
"customType": "regex",
23+
"fileMatch": [
24+
"^Dockerfile.assisted-installer-build$"
25+
],
26+
"matchStrings": [
27+
"RUN curl .*https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- .* (?<currentValue>.*?) && .*"
28+
],
29+
"depNameTemplate": "github.com/golangci/golangci-lint",
30+
"datasourceTemplate": "go"
31+
},
32+
{
33+
"customType": "regex",
34+
"fileMatch": [
35+
"^Dockerfile.assisted-installer$",
36+
"^Dockerfile.assisted-installer-build$",
37+
"^Dockerfile.assisted-installer-controller$",
38+
"^Dockerfile.assisted-installer-controller-downstream$",
39+
"^Dockerfile.assisted-installer-controller-mce$",
40+
"^Dockerfile.assisted-installer-downstream$",
41+
"^Dockerfile.assisted-installer-mce$"
42+
],
43+
"matchStrings": [
44+
"FROM registry.access.redhat.com/ubi9/go-toolset:(?<currentValue>.*?) AS .*\\n",
45+
"FROM --platform=\\$BUILDPLATFORM registry.access.redhat.com/ubi9/go-toolset:(?<currentValue>.*?) AS builder\\n"
46+
],
47+
"depNameTemplate": "registry.access.redhat.com/ubi9/go-toolset",
48+
"datasourceTemplate": "docker"
49+
}
50+
],
51+
52+
"packageRules": [
53+
{
54+
"groupName": "Go Builder",
55+
"addLabels": ["golang"],
56+
"matchDatasources": ["docker"],
57+
"matchPackageNames": ["registry.access.redhat.com/ubi9/go-toolset"],
58+
"allowedVersions": "/^[0-9]+\\.[0-9]+$/"
59+
},
60+
{
61+
"matchUpdateTypes": ["major"],
62+
"matchDatasources": ["docker"],
63+
"matchPackageNames": ["registry.access.redhat.com/ubi9/go-toolset"],
64+
"enabled": false
65+
},
66+
{
67+
"groupName": "Linter",
68+
"addLabels": ["linter"],
69+
"matchDatasources": ["go"],
70+
"matchPackageNames": ["github.com/golangci/golangci-lint"]
71+
},
72+
{
73+
"matchUpdateTypes": ["major"],
74+
"matchDatasources": ["go"],
75+
"matchPackageNames": ["github.com/golangci/golangci-lint"],
76+
"enabled": false
77+
},
78+
{
79+
"groupName": "Konflux build pipeline",
80+
"addLabels": ["konflux"],
81+
"schedule": ["on Saturday"],
82+
"matchManagers": ["tekton"]
83+
}
84+
]
785
}

src/assisted_installer_controller/assisted_installer_controller_test.go

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,8 @@ var _ = Describe("installer HostRoleMaster role", func() {
354354
configuringSuccess()
355355
listNodes()
356356

357-
for name, value := range inventoryNamesIds {
357+
for name, v := range inventoryNamesIds {
358+
value := v
358359
mockRebootsNotifier.EXPECT().Start(gomock.Any(), name, value.Host.ID, &value.Host.InfraEnvID, gomock.Any()).Times(1)
359360
}
360361
exit := assistedController.waitAndUpdateNodesStatus(false)
@@ -493,7 +494,8 @@ var _ = Describe("installer HostRoleMaster role", func() {
493494
mockk8sclient.EXPECT().ListNodes().Return(nodes, nil).Times(1)
494495
updateProgressSuccess(done, hosts)
495496
configuringSuccess()
496-
for name, value := range inventoryNamesIds {
497+
for name, v := range inventoryNamesIds {
498+
value := v
497499
mockRebootsNotifier.EXPECT().Start(gomock.Any(), name, value.Host.ID, &value.Host.InfraEnvID, gomock.Any()).Times(1)
498500
}
499501
exit := assistedController.waitAndUpdateNodesStatus(false)
@@ -548,7 +550,8 @@ var _ = Describe("installer HostRoleMaster role", func() {
548550
"node2": "57df89ee-3546-48a5-859a-0f1459485a66"}
549551
})
550552
It("WaitAndUpdateNodesStatus one by one", func() {
551-
for name, value := range inventoryNamesIds {
553+
for name, v := range inventoryNamesIds {
554+
value := v
552555
mockRebootsNotifier.EXPECT().Start(gomock.Any(), name, value.Host.ID, &value.Host.InfraEnvID, gomock.Any()).Times(1)
553556
}
554557
listNodesOneByOne := func() {
@@ -590,7 +593,8 @@ var _ = Describe("installer HostRoleMaster role", func() {
590593

591594
Context("UpdateStatusFails and then succeeds", func() {
592595
It("UpdateStatus fails and then succeeds, list nodes failed ", func() {
593-
for name, value := range inventoryNamesIds {
596+
for name, v := range inventoryNamesIds {
597+
value := v
594598
mockRebootsNotifier.EXPECT().Start(gomock.Any(), name, value.Host.ID, &value.Host.InfraEnvID, gomock.Any()).Times(1)
595599
}
596600
updateProgressSuccessFailureTest := func(stages []models.HostStage, inventoryNamesIds map[string]inventory_client.HostData) {
@@ -641,7 +645,8 @@ var _ = Describe("installer HostRoleMaster role", func() {
641645
configuringSuccess()
642646

643647
mockk8sclient.EXPECT().ListCsrs().Return(nil, fmt.Errorf("no matter what")).AnyTimes()
644-
for name, value := range inventoryNamesIds {
648+
for name, v := range inventoryNamesIds {
649+
value := v
645650
mockRebootsNotifier.EXPECT().Start(gomock.Any(), name, value.Host.ID, &value.Host.InfraEnvID, gomock.Any()).Times(1)
646651
}
647652

0 commit comments

Comments
 (0)