Skip to content

Commit 1aebf3d

Browse files
NO-ISSUE: bumping to to 1.25 in the main branch
1 parent 392da90 commit 1aebf3d

16 files changed

Lines changed: 116 additions & 29 deletions

.golangci.yml

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
version: "2"
2+
run:
3+
concurrency: 4
4+
timeout: 5m
5+
issues-exit-code: 1
6+
tests: true
7+
output:
8+
print-issued-lines: true
9+
print-linter-name: true
10+
linters:
11+
enable:
12+
- staticcheck
13+
- unused
14+
- govet
15+
- gocyclo
16+
- gosec
17+
- unconvert
18+
settings:
19+
govet:
20+
enable:
21+
- shadow
22+
settings:
23+
printf:
24+
funcs:
25+
- Infof
26+
- Warnf
27+
- Errorf
28+
- Fatalf
29+
gosec:
30+
excludes:
31+
- G107
32+
- G115
33+
- G401
34+
- G402
35+
- G501
36+
staticcheck:
37+
checks:
38+
- "all"
39+
- "-ST1001"
40+
- "-ST1003"
41+
- "-ST1005"
42+
- "-ST1008"
43+
- "-ST1016"
44+
- "-ST1019"
45+
- "-ST1023"
46+
- "-QF1001"
47+
- "-QF1003"
48+
- "-QF1011"
49+
exclusions:
50+
rules:
51+
- linters:
52+
- staticcheck
53+
text: 'QF1008: could remove embedded field'
54+
- linters:
55+
- gosec
56+
text: 'G306: Expect WriteFile permissions to be 0600 or less'
57+
generated: lax
58+
presets:
59+
- comments
60+
- common-false-positives
61+
- legacy
62+
- std-error-handling
63+
paths:
64+
- third_party$
65+
- builtin$
66+
- examples$
67+
issues:
68+
uniq-by-line: true
69+
formatters:
70+
enable:
71+
- gofmt
72+
- goimports
73+
exclusions:
74+
generated: lax
75+
paths:
76+
- third_party$
77+
- builtin$
78+
- examples$

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM registry.ci.openshift.org/ocp/builder:rhel-9-golang-1.24-openshift-4.20 as builder
1+
FROM registry.ci.openshift.org/ocp/builder:rhel-9-golang-1.25-openshift-4.21 as builder
22
ARG TARGETOS
33
ARG TARGETARCH
44

Makefile

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ endif
6262

6363
PROJECT_DIR := $(shell dirname $(abspath $(firstword $(MAKEFILE_LIST))))
6464

65+
# Get the list of packages which have test files
66+
TEST ?= $(shell go list -f '{{if or .TestGoFiles .XTestGoFiles}}{{.ImportPath}}{{end}}' ./...)
67+
6568
# Setting SHELL to bash allows bash commands to be executed by recipes.
6669
# Options are set to exit when a recipe line exits non-zero or a piped command fails.
6770
SHELL = /usr/bin/env bash -o pipefail
@@ -113,7 +116,7 @@ golangci-lint: ## Run golangci-lint against code.
113116

114117
.PHONY: test
115118
test: manifests generate fmt vet ## Run tests.
116-
go test ./... -coverprofile cover.out
119+
go test $(TEST) -coverprofile cover.out
117120

118121
.PHONY: deploy-integration-test
119122
deploy-integration-test:
@@ -185,7 +188,7 @@ CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen
185188

186189
## Tool Versions
187190
KUSTOMIZE_VERSION ?= v5.4.3
188-
CONTROLLER_TOOLS_VERSION ?= v0.16.2
191+
CONTROLLER_TOOLS_VERSION ?= v0.17.0
189192

190193
KUSTOMIZE_INSTALL_SCRIPT ?= "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh"
191194
.PHONY: kustomize
@@ -208,7 +211,6 @@ mock-gen: ## Download mockgen locally if necessary.
208211
test -s $(MOCK_GEN) || \
209212
GOBIN=$(LOCALBIN) GOFLAGS="" go install go.uber.org/mock/mockgen@v0.4.0
210213

211-
212214
.PHONY: operator-sdk
213215
OPERATOR_SDK ?= $(LOCALBIN)/operator-sdk
214216
operator-sdk: ## Download operator-sdk locally if necessary.

cmd/manager/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import (
2121
"flag"
2222
"fmt"
2323
"net/http"
24-
_ "net/http/pprof"
24+
_ "net/http/pprof" //nolint:gosec // G108: pprof only enabled via --start-pprof and bound to localhost:6060
2525
"net/url"
2626
"os"
2727
"time"
@@ -137,7 +137,7 @@ func main() {
137137
}
138138

139139
controllerOptions := &controllers.ImageClusterInstallReconcilerOptions{}
140-
if err := envconfig.Process("image-based-install-operator", controllerOptions); err != nil {
140+
if err := envconfig.Process("image-based-install-operator", controllerOptions); err != nil { //nolint:govet // shadow: err in if scope
141141
setupLog.Error(err, "unable to process envconfig")
142142
os.Exit(1)
143143
}

cmd/server/main.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"os/signal"
99
"path/filepath"
1010
"syscall"
11+
"time"
1112

1213
"github.com/kelseyhightower/envconfig"
1314
"github.com/openshift/image-based-install-operator/internal/imageserver"
@@ -42,7 +43,8 @@ func main() {
4243
}
4344
http.Handle("/images/", s)
4445
server := &http.Server{
45-
Addr: fmt.Sprintf(":%s", Options.Port),
46+
Addr: fmt.Sprintf(":%s", Options.Port),
47+
ReadHeaderTimeout: 5 * time.Second,
4648
}
4749

4850
go func() {

config/crd/bases/extensions.hive.openshift.io_imageclusterinstalls.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
33
kind: CustomResourceDefinition
44
metadata:
55
annotations:
6-
controller-gen.kubebuilder.io/version: v0.16.2
6+
controller-gen.kubebuilder.io/version: v0.17.0
77
name: imageclusterinstalls.extensions.hive.openshift.io
88
spec:
99
group: extensions.hive.openshift.io

controllers/imageclusterinstall_controller.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ func (r *ImageClusterInstallReconciler) Reconcile(ctx context.Context, req ctrl.
226226
return res, err
227227
}
228228

229-
if err := r.setClusterInstallMetadata(ctx, log, ici, cd); err != nil {
229+
if err := r.setClusterInstallMetadata(ctx, log, ici, cd); err != nil { //nolint:govet // shadow: err in if scope
230230
cond.Message = "failed to set ClusterMetaData in ImageClusterInstall"
231231
log.Error(err)
232232
return ctrl.Result{}, err
@@ -730,7 +730,7 @@ func (r *ImageClusterInstallReconciler) updateBMHProvisioningState(ctx context.C
730730
if bmh.Status.Provisioning.State != bmh_v1alpha1.StateAvailable && bmh.Status.Provisioning.State != bmh_v1alpha1.StateExternallyProvisioned {
731731
return nil
732732
}
733-
log.Infof("BareMetalHost %s/%s PoweredOn status is: %s", bmh.Namespace, bmh.Name, bmh.Status.PoweredOn)
733+
log.Infof("BareMetalHost %s/%s PoweredOn status is: %t", bmh.Namespace, bmh.Name, bmh.Status.PoweredOn)
734734
if !bmh.Spec.Online {
735735
bmh.Spec.Online = true
736736
log.Infof("Setting BareMetalHost (%s/%s) spec.Online to true", bmh.Namespace, bmh.Name)
@@ -1208,7 +1208,9 @@ func (r *ImageClusterInstallReconciler) writeImageBaseConfig(ctx context.Context
12081208
return err
12091209
}
12101210
releaseRegistry, err := r.imageSetRegistry(ctx, ici)
1211-
1211+
if err != nil {
1212+
return err
1213+
}
12121214
return installer.WriteImageBaseConfig(ctx, ici, releaseRegistry, nmstate, file)
12131215
}
12141216

controllers/imageclusterinstall_controller_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ var _ = Describe("Reconcile", func() {
164164
clusterDeployment *hivev1.ClusterDeployment
165165
pullSecret *corev1.Secret
166166
installerMock *installer.MockInstaller
167-
testPullSecretVal = `{"auths":{"cloud.openshift.com":{"auth":"dXNlcjpwYXNzd29yZAo=","email":"r@r.com"}}}`
167+
testPullSecretVal = `{"auths":{"cloud.openshift.com":{"auth":"dXNlcjpwYXNzd29yZAo=","email":"r@r.com"}}}` //nolint:gosec // fake credentials for testing
168168
)
169169

170170
BeforeEach(func() {
@@ -2431,7 +2431,7 @@ var _ = Describe("Reconcile with DataImageCoolDownPeriod set to 1 second", func(
24312431
clusterDeployment *hivev1.ClusterDeployment
24322432
pullSecret *corev1.Secret
24332433
installerMock *installer.MockInstaller
2434-
testPullSecretVal = `{"auths":{"cloud.openshift.com":{"auth":"dXNlcjpwYXNzd29yZAo=","email":"r@r.com"}}}`
2434+
testPullSecretVal = `{"auths":{"cloud.openshift.com":{"auth":"dXNlcjpwYXNzd29yZAo=","email":"r@r.com"}}}` //nolint:gosec // fake credentials for testing
24352435
)
24362436

24372437
installerSuccess := func() {

controllers/imageclusterinstall_monitor_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ var _ = Describe("Monitor", func() {
3939
clusterDeployment *hivev1.ClusterDeployment
4040
bmh *bmh_v1alpha1.BareMetalHost
4141
pullSecret *corev1.Secret
42-
testPullSecretVal = `{"auths":{"cloud.openshift.com":{"auth":"dXNlcjpwYXNzd29yZAo=","email":"r@r.com"}}}`
42+
testPullSecretVal = `{"auths":{"cloud.openshift.com":{"auth":"dXNlcjpwYXNzd29yZAo=","email":"r@r.com"}}}` //nolint:gosec // fake credentials for testing
4343
)
4444

4545
BeforeEach(func() {

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
module github.com/openshift/image-based-install-operator
22

3-
go 1.24.0
3+
go 1.25.0
44

5-
toolchain go1.24.5
5+
toolchain go1.25.5
66

77
require (
88
github.com/containers/image/v5 v5.31.0

0 commit comments

Comments
 (0)