Skip to content

Commit 5e1cac3

Browse files
authored
Merge pull request #1000 from alexander-demicev/maintenance
✨ Multiple changes to improve code quality
2 parents a73c5cd + 1cf520c commit 5e1cac3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+1332
-1004
lines changed

.github/workflows/golangci-lint.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ jobs:
2323
- name: golangci-lint
2424
uses: golangci/golangci-lint-action@1e7e51e771db61008b38414a730f564565cf7c20 # tag=v9.2.0
2525
with:
26-
version: v2.5.0
26+
version: v2.10.1
2727
args: --timeout 15m
2828
- name: golangci-lint-test
2929
uses: golangci/golangci-lint-action@1e7e51e771db61008b38414a730f564565cf7c20 # tag=v9.2.0
3030
with:
31-
version: v2.5.0
31+
version: v2.10.1
3232
args: --build-tags e2e --timeout 15m
3333
working-directory: test

.github/workflows/govulncheck.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: govulncheck
2+
on:
3+
pull_request:
4+
types: [opened, edited, synchronize, reopened]
5+
schedule:
6+
# Run weekly on Monday at 07:00 UTC
7+
- cron: "0 7 * * 1"
8+
jobs:
9+
govulncheck:
10+
name: govulncheck
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@0c366fd6a839edf440554fa01a7085ccba70ac98 # tag=v4.2.2
14+
- name: Calculate go version
15+
id: vars
16+
run: echo "go_version=$(make go-version)" >> $GITHUB_OUTPUT
17+
- name: Set up Go
18+
uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # tag=v6.0.0
19+
with:
20+
go-version: ${{ steps.vars.outputs.go_version }}
21+
- name: Install govulncheck
22+
run: go install golang.org/x/vuln/cmd/govulncheck@latest
23+
- name: Run govulncheck
24+
run: govulncheck ./...

.github/workflows/trivy.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: trivy
2+
on:
3+
pull_request:
4+
types: [opened, edited, synchronize, reopened]
5+
paths:
6+
- "Dockerfile"
7+
- "go.mod"
8+
- "go.sum"
9+
schedule:
10+
# Run weekly on Monday at 08:00 UTC
11+
- cron: "0 8 * * 1"
12+
jobs:
13+
trivy-scan:
14+
name: trivy image scan
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@0c366fd6a839edf440554fa01a7085ccba70ac98 # tag=v4.2.2
18+
- name: Calculate go version
19+
id: vars
20+
run: echo "go_version=$(make go-version)" >> $GITHUB_OUTPUT
21+
- name: Set up Go
22+
uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # tag=v6.0.0
23+
with:
24+
go-version: ${{ steps.vars.outputs.go_version }}
25+
- name: Build image
26+
run: |
27+
make docker-build CONTROLLER_IMG_TAG=cluster-api-operator:ci
28+
- name: Run Trivy vulnerability scanner
29+
uses: aquasecurity/trivy-action@97e0b3872f55f89b95b2f65b3dbab56962816478 # tag=0.34.2
30+
with:
31+
image-ref: "cluster-api-operator:ci"
32+
format: "table"
33+
exit-code: "1"
34+
severity: "CRITICAL,HIGH"
35+
ignore-unfixed: true

.golangci.yaml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
version: "2"
22
run:
3-
go: "1.24"
3+
go: "1.25.7"
44
allow-parallel-runners: true
55
linters:
66
default: none
@@ -55,8 +55,12 @@ linters:
5555
- usestdlibvars
5656
- wastedassign
5757
- whitespace
58-
- wsl
58+
- wsl_v5
5959
settings:
60+
wsl_v5:
61+
allow-first-in-block: true
62+
allow-whole-block: false
63+
branch-max-lines: 2
6064
goheader:
6165
values:
6266
regexp:
@@ -153,7 +157,7 @@ linters:
153157
- linters:
154158
- dogsled
155159
- gosec
156-
- wsl
160+
- wsl_v5
157161
path: internal/envtest/environment.go
158162
# Not all platforms are supported by this operator, those which aren't
159163
# supported will be caught by the default case in the switches.

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ ROOT:=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
2323

2424
.DEFAULT_GOAL:=help
2525

26-
GO_VERSION ?= 1.24.4
26+
GO_VERSION ?= 1.25.7
2727
GO_BASE_CONTAINER ?= docker.io/library/golang
2828
GO_CONTAINER_IMAGE = $(GO_BASE_CONTAINER):$(GO_VERSION)
2929

@@ -83,7 +83,7 @@ CONTROLLER_GEN_VER := v0.19.0
8383
CONTROLLER_GEN_BIN := controller-gen
8484
CONTROLLER_GEN := $(TOOLS_BIN_DIR)/$(CONTROLLER_GEN_BIN)-$(CONTROLLER_GEN_VER)
8585

86-
GOLANGCI_LINT_VER := v2.5.0
86+
GOLANGCI_LINT_VER := v2.10.1
8787
GOLANGCI_LINT_BIN := golangci-lint
8888
GOLANGCI_LINT := $(TOOLS_BIN_DIR)/$(GOLANGCI_LINT_BIN)-$(GOLANGCI_LINT_VER)
8989

api/v1alpha2/addonprovider_wrapper.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ func (b *AddonProvider) ProviderName() string {
5555
}
5656

5757
func (b *AddonProviderList) GetItems() []GenericProvider {
58-
providers := []GenericProvider{}
58+
providers := make([]GenericProvider, 0, len(b.Items))
5959

6060
for index := range b.Items {
6161
providers = append(providers, &b.Items[index])

api/v1alpha2/bootstrapprovider_wrapper.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ func (b *BootstrapProvider) ProviderName() string {
5555
}
5656

5757
func (b *BootstrapProviderList) GetItems() []GenericProvider {
58-
providers := []GenericProvider{}
58+
providers := make([]GenericProvider, 0, len(b.Items))
5959

6060
for index := range b.Items {
6161
providers = append(providers, &b.Items[index])

api/v1alpha2/ipamprovider_wrapper.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ func (p *IPAMProvider) ProviderName() string {
5555
}
5656

5757
func (p *IPAMProviderList) GetItems() []GenericProvider {
58-
providers := []GenericProvider{}
58+
providers := make([]GenericProvider, 0, len(p.Items))
5959

6060
for index := range p.Items {
6161
providers = append(providers, &p.Items[index])

api/v1alpha2/runtimeextensionprovider_wrapper.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ func (p *RuntimeExtensionProvider) ProviderName() string {
5555
}
5656

5757
func (p *RuntimeExtensionProviderList) GetItems() []GenericProvider {
58-
providers := []GenericProvider{}
58+
providers := make([]GenericProvider, 0, len(p.Items))
5959

6060
for index := range p.Items {
6161
providers = append(providers, &p.Items[index])

cmd/main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ func main() {
142142
pflag.Parse()
143143

144144
ctrl.SetLogger(textlogger.NewLogger(textlogger.NewConfig()))
145+
145146
restConfig := ctrl.GetConfigOrDie()
146147

147148
tlsOptions, metricsOptions, err := flags.GetManagerOptions(managerOptions)

0 commit comments

Comments
 (0)