Skip to content

Commit 4730771

Browse files
Merge pull request #118 from pheckenlWork/boilerplate-update-1-6c37c92165ab2c46308a1c6a5b11d3cffd8a373d
Boilerplate update 1 6c37c92165ab2c46308a1c6a5b11d3cffd8a373d
2 parents e590a4c + a7f4445 commit 4730771

File tree

12 files changed

+99
-15
lines changed

12 files changed

+99
-15
lines changed

.golangci.yaml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
linters:
2+
enable:
3+
- errcheck
4+
- govet
5+
- staticcheck
6+
- gosec
7+
- bodyclose
8+
- sqlclosecheck
9+
- gofmt
10+
- goimports
11+
- revive
12+
- ineffassign
13+
- unconvert
14+
- unparam
15+
- prealloc
16+
- nolintlint
17+
- misspell
18+
- gocritic
19+
- gocyclo
20+
- dupl
21+
- gosimple
22+
- unused
23+
24+
linters-settings:
25+
revive:
26+
rules:
27+
# Disable package comment requirement
28+
- name: package-comments
29+
disabled: true
30+
errcheck:
31+
# Report type assertions that don't check for errors
32+
check-type-assertions: true
33+
# Allow assignment to blank identifier: _ = resp.Body.Close()
34+
check-blank: false
35+
# Disable the built-in exclude list to catch Close() errors
36+
disable-default-exclusions: true
37+
38+
run:
39+
# Timeout for analysis
40+
timeout: 5m
41+
42+
issues:
43+
# Which dirs to exclude: issues from them won't be reported
44+
exclude-dirs:
45+
- vendor
46+
# Don't use default exclude patterns
47+
exclude-use-default: false
48+
49+
# Output configuration options
50+
output:
51+
# Format: colored-line-number|line-number|json|tab|checkstyle|code-climate
52+
formats:
53+
- format: colored-line-number

OWNERS_ALIASES

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
aliases:
66
srep-functional-team-aurora:
77
- abyrne55
8+
- AlexSmithGH
89
- dakotalongRH
10+
- eth1030
911
- joshbranham
1012
- luis-falcon
1113
- reedcort
@@ -65,7 +67,6 @@ aliases:
6567
- feichashao
6668
- samanthajayasinghe
6769
- xiaoyu74
68-
- Dee-6777
6970
- Tessg22
7071
- smarthall
7172
srep-infra-cicd:
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
d7285a904eda6cf842ddff8c648dedb223934a75
1+
6c37c92165ab2c46308a1c6a5b11d3cffd8a373d

boilerplate/_lib/container-make

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ if [[ "$1" == "-h"* ]] || [[ "$1" == "--h"* ]]; then
44
echo "Usage: $0 {arguments to the real 'make'}"
55
echo "Runs 'make' in the boilerplate backing container."
66
echo "If the command fails, starts a shell in the container so you can debug."
7+
echo "Set NONINTERACTIVE=true (or TRUE) to skip the debug shell and exit with the make return code."
78
exit -1
89
fi
910

@@ -40,12 +41,20 @@ banner "Running: make $@"
4041
$CONTAINER_ENGINE $args make "$@"
4142
rc=$?
4243

43-
# If it failed, drop into the container in a shell
44+
# If it failed, check if we should drop into a shell or exit
4445
if [[ $rc -ne 0 ]]; then
45-
banner "The 'make' command failed! Starting a shell in the container for debugging. Just 'exit' when done."
46-
$CONTAINER_ENGINE $args /bin/bash
46+
# Case-insensitive check for NONINTERACTIVE (true, TRUE, True all work)
47+
if [[ "${NONINTERACTIVE,,}" == "true" ]]; then
48+
banner "The 'make' command failed with exit code $rc. Skipping debug shell (NONINTERACTIVE=${NONINTERACTIVE})."
49+
else
50+
banner "The 'make' command failed! Starting a shell in the container for debugging. Just 'exit' when done."
51+
$CONTAINER_ENGINE $args /bin/bash
52+
fi
4753
fi
4854

4955
# Finally, remove the container
5056
banner "Cleaning up the container"
5157
$CONTAINER_ENGINE rm -f $container_id >/dev/null
58+
59+
# Exit with the return code from make
60+
exit $rc

boilerplate/openshift/golang-osd-operator/OWNERS_ALIASES

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
aliases:
66
srep-functional-team-aurora:
77
- abyrne55
8+
- AlexSmithGH
89
- dakotalongRH
10+
- eth1030
911
- joshbranham
1012
- luis-falcon
1113
- reedcort
@@ -65,7 +67,6 @@ aliases:
6567
- feichashao
6668
- samanthajayasinghe
6769
- xiaoyu74
68-
- Dee-6777
6970
- Tessg22
7071
- smarthall
7172
srep-infra-cicd:

boilerplate/openshift/golang-osd-operator/standard.mk

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,7 @@ endif
364364
# Boilerplate container-make targets.
365365
# Runs 'make' in the boilerplate backing container.
366366
# If the command fails, starts a shell in the container so you can debug.
367+
# Set NONINTERACTIVE=true to skip the debug shell for CI/automation.
367368
.PHONY: container-test
368369
container-test:
369370
${BOILERPLATE_CONTAINER_MAKE} test
@@ -384,6 +385,11 @@ container-validate:
384385
container-coverage:
385386
${BOILERPLATE_CONTAINER_MAKE} coverage
386387

388+
# Run all container-* validation targets in sequence.
389+
# Set NONINTERACTIVE=true to skip debug shells and fail fast for CI/automation.
390+
.PHONY: container-all
391+
container-all: container-lint container-generate container-coverage container-test container-validate
392+
387393
.PHONY: rvmo-bundle
388394
rvmo-bundle:
389395
RELEASE_BRANCH=$(RELEASE_BRANCH) \

build/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ COPY . .
88
RUN make go-build
99

1010
####
11-
FROM registry.access.redhat.com/ubi9/ubi-minimal:9.6-1760515502
11+
FROM registry.access.redhat.com/ubi9/ubi-minimal:9.7-1763362218
1212

1313
ENV USER_UID=1001 \
1414
USER_NAME=configure-goalert-operator

build/Dockerfile.olm-registry

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ COPY ${SAAS_OPERATOR_DIR} manifests
44
RUN initializer --permissive
55

66
# ubi-micro does not work for clusters with fips enabled unless we make OpenSSL available
7-
FROM registry.access.redhat.com/ubi9/ubi-minimal:9.6-1760515502
7+
FROM registry.access.redhat.com/ubi9/ubi-minimal:9.7-1763362218
88

99
COPY --from=builder /bin/registry-server /bin/registry-server
1010
COPY --from=builder /bin/grpc_health_probe /bin/grpc_health_probe

controllers/goalertintegration/clusterdeployment_created.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@ package goalertintegration
33
//goland:noinspection SpellCheckingInspection
44
import (
55
"context"
6-
"github.com/openshift/configure-goalert-operator/pkg/localmetrics"
76
"strings"
87

8+
"github.com/openshift/configure-goalert-operator/pkg/localmetrics"
9+
910
goalertv1alpha1 "github.com/openshift/configure-goalert-operator/api/v1alpha1"
1011
"github.com/openshift/configure-goalert-operator/config"
1112
"github.com/openshift/configure-goalert-operator/pkg/goalert"
@@ -130,10 +131,10 @@ func (r *GoalertIntegrationReconciler) handleCreate(ctx context.Context, gclient
130131
}
131132
}
132133

133-
//add secret part
134+
// add secret part
134135
secret := kube.GenerateGoalertSecret(cd.Namespace, secretName, highIntKey, lowIntKey, heartbeatMonitorKey)
135136
r.reqLogger.Info("creating goalert secret", "ClusterDeployment.Namespace", cd.Namespace)
136-
//add reference
137+
// add reference
137138
if err := controllerutil.SetControllerReference(cd, secret, r.Scheme); err != nil {
138139
r.reqLogger.Error(err, "Error setting controller reference on secret", "ClusterDeployment.Namespace", cd.Namespace)
139140
return err

controllers/goalertintegration/goalertintegration_controller.go

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ var log = logf.Log.WithName("controller_goalertintegration")
7878
//
7979
// For more details, check Reconcile and its Result here:
8080
// - https://pkg.go.dev/sigs.k8s.io/[email protected]/pkg/reconcile
81+
82+
//nolint:gocyclo // This is a marker that we should think about a refactor here.
8183
func (r *GoalertIntegrationReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
8284
start := time.Now()
8385

@@ -142,6 +144,11 @@ func (r *GoalertIntegrationReconciler) Reconcile(ctx context.Context, req ctrl.R
142144
if err != nil {
143145
r.reqLogger.Error(err, "Failed to auth to Goalert")
144146
}
147+
defer func() {
148+
if err := authenticateGoalert.Body.Close(); err != nil {
149+
r.reqLogger.Error(err, "Error closing http.Response Body")
150+
}
151+
}()
145152

146153
// Read session cookie from authentication response headers
147154
sessionCookie, err := r.fetchSessionCookie(authenticateGoalert)
@@ -163,7 +170,7 @@ func (r *GoalertIntegrationReconciler) Reconcile(ctx context.Context, req ctrl.R
163170
}
164171
}
165172

166-
//If the GI is being deleted, clean up all ClusterDeployments with matching finalizers
173+
// If the GI is being deleted, clean up all ClusterDeployments with matching finalizers
167174
if gi.DeletionTimestamp != nil {
168175
if controllerutil.ContainsFinalizer(gi, goalertFinalizer) {
169176
for i := range matchingClusterDeployments.Items {
@@ -185,7 +192,7 @@ func (r *GoalertIntegrationReconciler) Reconcile(ctx context.Context, req ctrl.R
185192
return r.doNotRequeue()
186193
}
187194

188-
//Make sure there's a finalizer on the GoalertIntegration
195+
// Make sure there's a finalizer on the GoalertIntegration
189196
if !controllerutil.ContainsFinalizer(gi, goalertFinalizer) {
190197
if !controllerutil.AddFinalizer(gi, goalertFinalizer) {
191198
if err := r.Update(ctx, gi); err != nil {
@@ -266,8 +273,12 @@ func (r *GoalertIntegrationReconciler) authGoalert(ctx context.Context, username
266273
if err != nil {
267274
r.reqLogger.Error(err, "Error sending HTTP request")
268275
}
276+
defer func() {
277+
if err := authResp.Body.Close(); err != nil {
278+
r.reqLogger.Error(err, "Error closing http.Response Body")
279+
}
280+
}()
269281

270-
defer authResp.Body.Close()
271282
return authResp.Request.Response, nil
272283
}
273284

0 commit comments

Comments
 (0)