Skip to content

Commit 061c055

Browse files
authored
bump boilerplate to v7.0.0 (#401)
* bump boilerplate to v7.0.0 * bump go version to 1.23 * Update golangci-lint to v2, migrate config, fix lint issues * Explicitly set GOROOT on lint, see golangci-lint/issues/3107 golangci/golangci-lint#3107 * lint error string
1 parent 5929e4c commit 061c055

File tree

18 files changed

+134
-159
lines changed

18 files changed

+134
-159
lines changed

.ci-operator.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
build_root_image:
22
name: boilerplate
33
namespace: openshift
4-
tag: image-v6.0.1
4+
tag: image-v7.0.0

.github/dependabot.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ updates:
1616
schedule:
1717
interval: "weekly"
1818
ignore:
19-
- dependency-name: "app-sre/boilerplate"
19+
- dependency-name: "redhat-services-prod/openshift/boilerplate"
2020
# don't upgrade boilerplate via these means
2121
- dependency-name: "openshift4/ose-operator-registry"
2222
# don't upgrade ose-operator-registry via these means

.golangci.yml

+80-100
Original file line numberDiff line numberDiff line change
@@ -1,106 +1,86 @@
1+
version: "2"
12
run:
2-
# Our CI expects a vendor directory, hence we have to use -mod=readonly here as well.
33
modules-download-mode: readonly
4-
# Timeout for analysis, e.g. 30s, 5m.
5-
# Default: 1m
6-
timeout: 15m
7-
8-
issues:
9-
# on default, golangci-lint excludes gosec. Hence, we have to
10-
# explicitly disable the exclude-use-default: https://github.com/golangci/golangci-lint/issues/1504
11-
exclude-use-default: false
12-
13-
# output configuration options
144
output:
15-
# colored-line-number|line-number|json|tab|checkstyle|code-climate|junit-xml|github-actions
16-
# default is "colored-line-number"
17-
18-
# print lines of code with issue, default is true
19-
print-issued-lines: true
20-
21-
# print linter name in the end of issue text, default is true
22-
print-linter-name: true
23-
24-
# make issues output unique by line, default is true
25-
uniq-by-line: true
26-
27-
# add a prefix to the output file references; default is no prefix
285
path-prefix: ""
29-
30-
# sorts results by: filepath, line and column
31-
sort-results: false
32-
33-
# default linters are enabled `golangci-lint help linters`
346
linters:
35-
disable-all: true
7+
default: none
368
enable:
37-
## enabled by default
38-
- errcheck # checking for unchecked errors, these unchecked errors can be critical bugs in some cases
39-
- gosimple # specializes in simplifying a code
40-
- govet # reports suspicious constructs, such as Printf calls whose arguments do not align with the format string
41-
- ineffassign # detects when assignments to existing variables are not used
42-
- staticcheck # is a go vet on steroids, applying a ton of static analysis checks
43-
- typecheck # like the front-end of a Go compiler, parses and type-checks Go code
44-
- unused # checks for unused constants, variables, functions and types
45-
46-
## disabled by default
47-
- asasalint # Check for pass []any as any in variadic func(...any)
48-
- asciicheck # Simple linter to check that your code does not contain non-ASCII identifiers
49-
- bidichk # Checks for dangerous unicode character sequences
50-
- bodyclose # Checks whether HTTP response body is closed successfully
51-
- decorder # Check declaration order and count of types, constants, variables and functions
52-
- dupword # Checks for duplicate words in the source code
53-
- durationcheck # Check for two durations multiplied together
54-
- errchkjson # Checks types passed to the json encoding functions. Reports unsupported types and optionally reports occasions, where the check for the returned error can be omitted.
55-
- errname # Checks that sentinel errors are prefixed with the Err and error types are suffixed with the Error.
56-
- errorlint # Errorlint is a linter for that can be used to find code that will cause problems with the error wrapping scheme introduced in Go 1.13.
57-
- exportloopref # Checks for pointers to enclosing loop variables
58-
- ginkgolinter # Enforces standards of using ginkgo and gomega
59-
- gocheckcompilerdirectives # Checks that go compiler directive comments (//go:) are valid.
60-
- goconst # Finds repeated strings that could be replaced by a constant
61-
- gocritic # Provides diagnostics that check for bugs, performance and style issues.
62-
- gocyclo # Computes and checks the cyclomatic complexity of functions
63-
- gofmt # Gofmt checks whether code was gofmt-ed. By default this tool runs with -s option to check for code simplification
64-
- gofumpt # Gofumpt checks whether code was gofumpt-ed.
65-
- goheader # Checks is file header matches to pattern
66-
- goimports # Check import statements are formatted according to the 'goimport' command. Reformat imports in autofix mode.
67-
- gomodguard # Allow and block list linter for direct Go module dependencies. This is different from depguard where there are different block types for example version constraints and module recommendations.
68-
- gosec # Inspects source code for security problems
69-
- grouper # An analyzer to analyze expression groups.
70-
- importas # Enforces consistent import aliases
71-
- loggercheck # Checks key value pairs for common logger libraries (kitlog,klog,logr,zap).
72-
- maintidx # Maintidx measures the maintainability index of each function.
73-
- makezero # Finds slice declarations with non-zero initial length
74-
- misspell # Finds commonly misspelled English words in comments
75-
- nestif # Reports deeply nested if statements
76-
- nilerr # Finds the code that returns nil even if it checks that the error is not nil.
77-
- nilnil # Checks that there is no simultaneous return of nil error and an invalid value.
78-
- noctx # Noctx finds sending http request without context.Context
79-
- nolintlint # Reports ill-formed or insufficient nolint directives
80-
- nosprintfhostport # Checks for misuse of Sprintf to construct a host with port in a URL.
81-
- prealloc # Finds slice declarations that could potentially be pre-allocated
82-
- predeclared # Find code that shadows one of Go's predeclared identifiers
83-
- promlinter # Check Prometheus metrics naming via promlint
84-
- reassign # Checks that package variables are not reassigned
85-
- revive # Fast, configurable, extensible, flexible, and beautiful linter for Go. Drop-in replacement of golint.
86-
- rowserrcheck # Checks whether Err of rows is checked successfully
87-
- tenv # Tenv is analyzer that detects using os.Setenv instead of t.Setenv since Go1.17
88-
- thelper # Thelper detects Go test helpers without t.Helper() call and checks the consistency of test helpers
89-
- tparallel # Tparallel detects inappropriate usage of t.Parallel() method in your Go test codes
90-
- unconvert # Remove unnecessary type conversions
91-
- usestdlibvars # A linter that detect the possibility to use variables/constants from the Go standard library.
92-
- wastedassign # Finds wasted assignment statements.
93-
- whitespace # Tool for detection of leading and trailing whitespace
94-
95-
linters-settings:
96-
nestif:
97-
min-complexity: 10
98-
revive:
99-
rules:
100-
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#dot-imports
101-
- name: dot-imports
102-
severity: warning
103-
disabled: false
104-
exclude: [""]
105-
arguments:
106-
- allowedPackages: [github.com/onsi/ginkgo/v2, github.com/onsi/gomega]
9+
- asasalint
10+
- asciicheck
11+
- bidichk
12+
- bodyclose
13+
- decorder
14+
- dupword
15+
- durationcheck
16+
- errcheck
17+
- errchkjson
18+
- errname
19+
- errorlint
20+
- ginkgolinter
21+
- gocheckcompilerdirectives
22+
- goconst
23+
- gocritic
24+
- gocyclo
25+
- goheader
26+
- gomodguard
27+
- gosec
28+
- govet
29+
- grouper
30+
- importas
31+
- ineffassign
32+
- loggercheck
33+
- maintidx
34+
- makezero
35+
- misspell
36+
- nestif
37+
- nilerr
38+
- nilnil
39+
- noctx
40+
- nolintlint
41+
- nosprintfhostport
42+
- prealloc
43+
- predeclared
44+
- promlinter
45+
- reassign
46+
- revive
47+
- rowserrcheck
48+
- staticcheck
49+
- thelper
50+
- tparallel
51+
- unconvert
52+
- unused
53+
- usestdlibvars
54+
- wastedassign
55+
- whitespace
56+
settings:
57+
nestif:
58+
min-complexity: 10
59+
revive:
60+
rules:
61+
- name: dot-imports
62+
arguments:
63+
- allowedPackages:
64+
- github.com/onsi/ginkgo/v2
65+
- github.com/onsi/gomega
66+
severity: warning
67+
disabled: false
68+
exclude:
69+
- ""
70+
exclusions:
71+
generated: lax
72+
paths:
73+
- third_party$
74+
- builtin$
75+
- examples$
76+
formatters:
77+
enable:
78+
- gofmt
79+
- gofumpt
80+
- goimports
81+
exclusions:
82+
generated: lax
83+
paths:
84+
- third_party$
85+
- builtin$
86+
- examples$

Makefile

+7-4
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ endef
88

99
include boilerplate/generated-includes.mk
1010

11-
GOLANGCI_LINT_VERSION=v1.59.1
11+
GOLANGCI_LINT_VERSION=v2.0.2
1212
MOCKGEN_VERSION=v0.5.0
1313

1414
.DEFAULT_GOAL := all
@@ -47,7 +47,8 @@ build-cadctl: check-go121-install ## Build the cadctl binary
4747
lint-cadctl: install-linter ## Lint cadctl subproject
4848
@echo
4949
@echo "Linting cadctl..."
50-
GOLANGCI_LINT_CACHE=$$(mktemp -d) $(GOPATH)/bin/golangci-lint run -c .golangci.yml
50+
# Explicitly set GOROOT, see https://github.com/golangci/golangci-lint/issues/3107
51+
GOROOT=/usr/lib/golang GOLANGCI_LINT_CACHE=$$(mktemp -d) $(GOPATH)/bin/golangci-lint run -c .golangci.yml
5152

5253
.PHONY: test-cadctl
5354
test-cadctl: check-go121-install ## Run automated tests for cadctl
@@ -69,7 +70,8 @@ build-interceptor: check-go121-install ## Build the interceptor binary
6970
lint-interceptor: install-linter ## Lint interceptor subproject
7071
@echo
7172
@echo "Linting interceptor..."
72-
cd interceptor && GOLANGCI_LINT_CACHE=$$(mktemp -d) $(GOPATH)/bin/golangci-lint run -c ../.golangci.yml
73+
# Explicitly set GOROOT, see https://github.com/golangci/golangci-lint/issues/3107
74+
cd interceptor && GOROOT=/usr/lib/golang GOLANGCI_LINT_CACHE=$$(mktemp -d) $(GOPATH)/bin/golangci-lint run -c ../.golangci.yml
7375

7476
.PHONY: test-interceptor
7577
test-interceptor: check-go121-install check-jq-install build-interceptor ## Run unit tests for interceptor
@@ -102,7 +104,8 @@ build-template-updater: ## Build the template-updater binary
102104
lint-template-updater: install-linter ## Lint template-updater subproject
103105
@echo
104106
@echo "Linting template-updater..."
105-
cd hack/update-template && GOLANGCI_LINT_CACHE=$$(mktemp -d) $(GOPATH)/bin/golangci-lint run -c ../../.golangci.yml
107+
# Explicitly set GOROOT, see https://github.com/golangci/golangci-lint/issues/3107
108+
cd hack/update-template && GOROOT=/usr/lib/golang GOLANGCI_LINT_CACHE=$$(mktemp -d) $(GOPATH)/bin/golangci-lint run -c ../../.golangci.yml
106109

107110
.PHONY: boilerplate-update
108111
boilerplate-update: ## Update boilerplate version

OWNERS_ALIASES

+1-2
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@ aliases:
1414
- theautoroboto
1515
- rhdedgar
1616
- katherinelc321
17-
- robotmaxtron
1817
- rojasreinold
19-
- hbhushan3
2018
- fsferraz-rh
2119
srep-functional-team-hulk:
2220
- a7vicky
@@ -52,6 +50,7 @@ aliases:
5250
- npecka
5351
- pshickeydev
5452
- casey-williams-rh
53+
- boranx
5554
srep-functional-team-thor:
5655
- bmeng
5756
- MitaliBhalla

boilerplate/_data/backing-image-tag

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
image-v6.0.1
1+
image-v7.0.0
+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
70a51ed11e104b317f9f6996a9f4491bbc34391a
1+
8eb2484eb85908aa8a6036e2474a2815780114b4

boilerplate/openshift/osd-container-image/OWNERS_ALIASES

+1-2
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@ aliases:
1414
- theautoroboto
1515
- rhdedgar
1616
- katherinelc321
17-
- robotmaxtron
1817
- rojasreinold
19-
- hbhushan3
2018
- fsferraz-rh
2119
srep-functional-team-hulk:
2220
- a7vicky
@@ -52,6 +50,7 @@ aliases:
5250
- npecka
5351
- pshickeydev
5452
- casey-williams-rh
53+
- boranx
5554
srep-functional-team-thor:
5655
- bmeng
5756
- MitaliBhalla

boilerplate/openshift/osd-container-image/dependabot.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ updates:
88
schedule:
99
interval: "weekly"
1010
ignore:
11-
- dependency-name: "app-sre/boilerplate"
11+
- dependency-name: "redhat-services-prod/openshift/boilerplate"
1212
# don't upgrade boilerplate via these means
1313
- dependency-name: "openshift4/ose-operator-registry"
1414
# don't upgrade ose-operator-registry via these means

build/Dockerfile

+18-18
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM quay.io/redhat-services-prod/openshift/boilerplate:image-v6.0.1 as builder
1+
FROM quay.io/redhat-services-prod/openshift/boilerplate:image-v7.0.0 as builder
22

33
ADD . /opt
44
WORKDIR /opt
@@ -18,23 +18,23 @@ ARG VCS_REF
1818
ARG DOCKERFILE_PATH
1919

2020
LABEL vendor="RedHat" \
21-
name="openshift/configuration-anomaly-detection" \
22-
description="a CLI tool to detect and mitigate configuration mishaps" \
23-
io.k8s.display-name="openshift/configuration-anomaly-detection" \
24-
io.k8s.description="a CLI tool to detect and mitigate configuration mishaps" \
25-
maintainer="RedHat <>" \
26-
version="$VERSION" \
27-
org.label-schema.build-date=$BUILD_DATE \
28-
org.label-schema.description="a CLI tool to detect and mitigate configuration mishaps" \
29-
org.label-schema.docker.cmd="docker run --rm openshift/configuration-anomaly-detection" \
30-
org.label-schema.docker.dockerfile=$DOCKERFILE_PATH \
31-
org.label-schema.name="openshift/configuration-anomaly-detection" \
32-
org.label-schema.schema-version="0.1.0" \
33-
org.label-schema.vcs-branch=$VCS_BRANCH \
34-
org.label-schema.vcs-ref=$VCS_REF \
35-
org.label-schema.vcs-url="https://github.com/openshift/configuration-anomaly-detection" \
36-
org.label-schema.vendor="openshift/configuration-anomaly-detection" \
37-
org.label-schema.version=$VERSION
21+
name="openshift/configuration-anomaly-detection" \
22+
description="a CLI tool to detect and mitigate configuration mishaps" \
23+
io.k8s.display-name="openshift/configuration-anomaly-detection" \
24+
io.k8s.description="a CLI tool to detect and mitigate configuration mishaps" \
25+
maintainer="RedHat <>" \
26+
version="$VERSION" \
27+
org.label-schema.build-date=$BUILD_DATE \
28+
org.label-schema.description="a CLI tool to detect and mitigate configuration mishaps" \
29+
org.label-schema.docker.cmd="docker run --rm openshift/configuration-anomaly-detection" \
30+
org.label-schema.docker.dockerfile=$DOCKERFILE_PATH \
31+
org.label-schema.name="openshift/configuration-anomaly-detection" \
32+
org.label-schema.schema-version="0.1.0" \
33+
org.label-schema.vcs-branch=$VCS_BRANCH \
34+
org.label-schema.vcs-ref=$VCS_REF \
35+
org.label-schema.vcs-url="https://github.com/openshift/configuration-anomaly-detection" \
36+
org.label-schema.vendor="openshift/configuration-anomaly-detection" \
37+
org.label-schema.version=$VERSION
3838

3939
RUN microdnf install jq
4040

go.mod

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
module github.com/openshift/configuration-anomaly-detection
22

3-
go 1.22.7
4-
5-
toolchain go1.22.12
3+
go 1.23.0
64

75
require (
86
github.com/PagerDuty/go-pagerduty v1.8.0

interceptor/go.mod

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
module github.com/openshift/configuration-anomaly-detection/interceptor
22

3-
go 1.22.7
4-
5-
toolchain go1.22.12
3+
go 1.23.0
64

75
require (
86
github.com/PagerDuty/go-pagerduty v1.8.0

pkg/aws/aws.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -203,8 +203,8 @@ func (c *SdkClient) PollInstanceStopEventsFor(instances []ec2v2types.Instance, r
203203
idToCloudtrailEvent := make(map[string]cloudtrailv2types.Event)
204204

205205
var executionError error
206-
var stoppedInstanceEvents []cloudtrailv2types.Event = make([]cloudtrailv2types.Event, 0)
207-
var terminatedInstanceEvents []cloudtrailv2types.Event = make([]cloudtrailv2types.Event, 0)
206+
stoppedInstanceEvents := make([]cloudtrailv2types.Event, 0)
207+
terminatedInstanceEvents := make([]cloudtrailv2types.Event, 0)
208208
err = wait.ExponentialBackoff(backoffOptions, func() (bool, error) {
209209
executionError = nil
210210

@@ -483,7 +483,7 @@ func (c *SdkClient) listAllInstancesAttribute(att cloudtrailv2types.LookupAttrib
483483
// exhaust 90 days of events might take *very* long in big accounts
484484
// otherwise.
485485
maxNumberEvents := 1000
486-
var events []cloudtrailv2types.Event = make([]cloudtrailv2types.Event, 0)
486+
events := make([]cloudtrailv2types.Event, 0)
487487
in := &cloudtrailv2.LookupEventsInput{
488488
LookupAttributes: []cloudtrailv2types.LookupAttribute{att},
489489
StartTime: &since,
@@ -600,7 +600,7 @@ func eventContainsInstances(instances []ec2v2types.Instance, event cloudtrailv2t
600600

601601
func getTime(rawReason string) (time.Time, error) {
602602
subMatches := stopInstanceDateRegex.FindStringSubmatch(rawReason)
603-
if subMatches == nil || len(subMatches) < 2 {
603+
if len(subMatches) < 2 {
604604
return time.Time{}, fmt.Errorf("did not find matches: raw data %s", rawReason)
605605
}
606606
if len(subMatches) != 2 {

pkg/investigations/ccam/ccam.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ func (c *Investigation) Run(r *investigation.Resources) (investigation.Investiga
2828
pdClient := r.PdClient
2929
bpError, ok := r.AdditionalResources["error"].(error)
3030
if !ok {
31-
return result, fmt.Errorf("Missing required Investigation field 'error'")
31+
return result, fmt.Errorf("missing required Investigation field 'error'")
3232
}
3333
logging.Info("Investigating possible missing cloud credentials...")
3434

0 commit comments

Comments
 (0)