Skip to content

Commit 6ce0bd5

Browse files
NO-ISSUE: bumping to to 1.25 in the backplane-2.8 branch
1 parent be59a47 commit 6ce0bd5

16 files changed

Lines changed: 138 additions & 26 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.21 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

Dockerfile.konflux

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM brew.registry.redhat.io/rh-osbs/openshift-golang-builder:v1.24 as builder
1+
FROM brew.registry.redhat.io/rh-osbs/openshift-golang-builder:v1.25 as builder
22
ARG TARGETOS
33
ARG TARGETARCH
44

Makefile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ else
6060
GOBIN=$(shell go env GOBIN)
6161
endif
6262

63+
TEST ?= $(shell go list -f '{{if or .TestGoFiles .XTestGoFiles}}{{.ImportPath}}{{end}}' ./...)
64+
6365
PROJECT_DIR := $(shell dirname $(abspath $(firstword $(MAKEFILE_LIST))))
6466

6567
# Setting SHELL to bash allows bash commands to be executed by recipes.
@@ -113,7 +115,7 @@ golangci-lint: ## Run golangci-lint against code.
113115

114116
.PHONY: test
115117
test: manifests generate fmt vet ## Run tests.
116-
go test ./... -coverprofile cover.out
118+
go test $(TEST) -coverprofile cover.out
117119

118120
.PHONY: deploy-integration-test
119121
deploy-integration-test:
@@ -185,7 +187,7 @@ CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen
185187

186188
## Tool Versions
187189
KUSTOMIZE_VERSION ?= v5.4.3
188-
CONTROLLER_TOOLS_VERSION ?= v0.16.2
190+
CONTROLLER_TOOLS_VERSION ?= v0.17.0
189191

190192
KUSTOMIZE_INSTALL_SCRIPT ?= "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh"
191193
.PHONY: kustomize

cmd/manager/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import (
2020
"flag"
2121
"fmt"
2222
"net/http"
23-
_ "net/http/pprof"
23+
_ "net/http/pprof" //nolint:gosec // G108: pprof only enabled via --start-pprof and bound to localhost:6060
2424
"net/url"
2525
"os"
2626
"time"

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: 31 additions & 5 deletions
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
@@ -150,8 +150,27 @@ spec:
150150
during installation and used for tagging/naming resources in
151151
cloud providers.
152152
type: string
153+
metadataJSONSecretRef:
154+
description: |-
155+
MetadataJSONSecretRef references the secret containing the metadata.json emitted by the
156+
installer, potentially scrubbed for sensitive data.
157+
properties:
158+
name:
159+
default: ""
160+
description: |-
161+
Name of the referent.
162+
This field is effectively required, but due to backwards compatibility is
163+
allowed to be empty. Instances of this type with an empty value here are
164+
almost certainly wrong.
165+
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
166+
type: string
167+
type: object
168+
x-kubernetes-map-type: atomic
153169
platform:
154-
description: Platform holds platform-specific cluster metadata
170+
description: |-
171+
Platform holds platform-specific cluster metadata.
172+
Deprecated. Use the Secret referenced by MetadataJSONSecretRef instead. We may stop
173+
populating this section in the future.
155174
properties:
156175
aws:
157176
description: AWS holds AWS-specific cluster metadata
@@ -160,14 +179,18 @@ spec:
160179
description: |-
161180
HostedZoneRole is the role to assume when performing operations
162181
on a hosted zone owned by another account.
182+
Deprecated. Use the Secret referenced by ClusterMetadata.MetadataJSONSecretRef instead. We
183+
may stop populating this section in the future.
163184
type: string
164185
type: object
165186
azure:
166187
description: Azure holds azure-specific cluster metadata
167188
properties:
168189
resourceGroupName:
169-
description: ResourceGroupName is the name of the resource
170-
group in which the cluster resources were created.
190+
description: |-
191+
ResourceGroupName is the name of the resource group in which the cluster resources were created.
192+
Deprecated. Use the Secret referenced by ClusterMetadata.MetadataJSONSecretRef instead. We
193+
may stop populating this section in the future.
171194
type: string
172195
required:
173196
- resourceGroupName
@@ -176,7 +199,10 @@ spec:
176199
description: GCP holds GCP-specific cluster metadata
177200
properties:
178201
networkProjectID:
179-
description: NetworkProjectID is used for shared VPC setups
202+
description: |-
203+
NetworkProjectID is used for shared VPC setups
204+
Deprecated. Use the Secret referenced by ClusterMetadata.MetadataJSONSecretRef instead. We
205+
may stop populating this section in the future.
180206
type: string
181207
type: object
182208
type: object

controllers/imageclusterinstall_controller.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package controllers
1919
import (
2020
"bytes"
2121
"context"
22+
2223
// These are required for image parsing to work correctly with digest-based pull specs
2324
// See: https://github.com/opencontainers/go-digest/blob/v1.0.0/README.md#usage
2425
_ "crypto/sha256"
@@ -510,7 +511,7 @@ func (r *ImageClusterInstallReconciler) updateBMHProvisioningState(ctx context.C
510511
if bmh.Status.Provisioning.State != bmh_v1alpha1.StateAvailable && bmh.Status.Provisioning.State != bmh_v1alpha1.StateExternallyProvisioned {
511512
return nil
512513
}
513-
log.Infof("Updating BareMetalHost %s/%s provisioning state, current PoweredOn status is: %s", bmh.Namespace, bmh.Name, bmh.Status.PoweredOn)
514+
log.Infof("Updating BareMetalHost %s/%s provisioning state, current PoweredOn status is: %t", bmh.Namespace, bmh.Name, bmh.Status.PoweredOn)
514515
if bmh.Status.Provisioning.State == bmh_v1alpha1.StateAvailable {
515516
if !bmh.Spec.ExternallyProvisioned {
516517
log.Infof("Setting BareMetalHost (%s/%s) ExternallyProvisioned spec", bmh.Namespace, bmh.Name)
@@ -934,7 +935,9 @@ func (r *ImageClusterInstallReconciler) writeImageBaseConfig(ctx context.Context
934935
return err
935936
}
936937
releaseRegistry, err := r.imageSetRegistry(ctx, ici)
937-
938+
if err != nil {
939+
return err
940+
}
938941
return installer.WriteImageBaseConfig(ctx, ici, releaseRegistry, nmstate, file)
939942
}
940943

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
168168
)
169169

170170
BeforeEach(func() {
@@ -1807,7 +1807,7 @@ var _ = Describe("Reconcile with DataImageCoolDownPeriod set to 1 second", func(
18071807
clusterDeployment *hivev1.ClusterDeployment
18081808
pullSecret *corev1.Secret
18091809
installerMock *installer.MockInstaller
1810-
testPullSecretVal = `{"auths":{"cloud.openshift.com":{"auth":"dXNlcjpwYXNzd29yZAo=","email":"r@r.com"}}}`
1810+
testPullSecretVal = `{"auths":{"cloud.openshift.com":{"auth":"dXNlcjpwYXNzd29yZAo=","email":"r@r.com"}}}` //nolint:gosec
18111811
)
18121812

18131813
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() {

0 commit comments

Comments
 (0)