Skip to content

Commit 4ce71d7

Browse files
tony-landrethtony-landreth
authored andcommitted
Responds to linter feedback
1 parent 2c45df7 commit 4ce71d7

37 files changed

+163
-159
lines changed

.golangci.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,3 +149,7 @@ formatters:
149149
- third_party$
150150
- builtin$
151151
- examples$
152+
issues:
153+
# Disable max issues limit (default is 50)
154+
max-issues-per-linter: 0
155+
max-same-issues: 0

internal/bridge/client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ func (c *Client) doWithBackoff(
280280
request.Header = headers.Clone()
281281

282282
//nolint:bodyclose // This response is returned to the caller.
283-
response, err = c.Client.Do(request)
283+
response, err = c.Do(request)
284284
}
285285

286286
// An error indicates there was no response from the server, and the

internal/bridge/client_test.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ func TestClientBackoff(t *testing.T) {
3131
client := NewClient("", "")
3232
var total time.Duration
3333

34-
for i := 1; i <= 50 && client.Backoff.Steps > 0; i++ {
35-
step := client.Backoff.Step()
34+
for i := 1; i <= 50 && client.Steps > 0; i++ {
35+
step := client.Step()
3636
total += step
3737

3838
t.Logf("%02d:%20v%20v", i, step, total)
@@ -68,7 +68,7 @@ func TestClientDoWithBackoff(t *testing.T) {
6868

6969
// Client with one attempt, i.e. no backoff.
7070
client := NewClient(server.URL, "xyz")
71-
client.Backoff.Steps = 1
71+
client.Steps = 1
7272
assert.Equal(t, client.BaseURL.String(), server.URL)
7373

7474
ctx := context.Background()
@@ -113,8 +113,8 @@ func TestClientDoWithBackoff(t *testing.T) {
113113

114114
// Client with brief backoff.
115115
client := NewClient(server.URL, "")
116-
client.Backoff.Duration = time.Millisecond
117-
client.Backoff.Steps = 5
116+
client.Duration = time.Millisecond
117+
client.Steps = 5
118118
assert.Equal(t, client.BaseURL.String(), server.URL)
119119

120120
ctx := context.Background()
@@ -170,8 +170,8 @@ func TestClientDoWithBackoff(t *testing.T) {
170170

171171
// Client with brief backoff.
172172
client := NewClient(server.URL, "")
173-
client.Backoff.Duration = time.Millisecond
174-
client.Backoff.Steps = 5
173+
client.Duration = time.Millisecond
174+
client.Steps = 5
175175
assert.Equal(t, client.BaseURL.String(), server.URL)
176176

177177
ctx := context.Background()
@@ -190,8 +190,8 @@ func TestClientDoWithBackoff(t *testing.T) {
190190

191191
// Client with lots of brief backoff.
192192
client := NewClient(server.URL, "")
193-
client.Backoff.Duration = time.Millisecond
194-
client.Backoff.Steps = 100
193+
client.Duration = time.Millisecond
194+
client.Steps = 100
195195
assert.Equal(t, client.BaseURL.String(), server.URL)
196196

197197
ctx, cancel := context.WithTimeout(context.Background(), 50*time.Millisecond)

internal/bridge/crunchybridgecluster/apply.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ func (r *CrunchyBridgeClusterReconciler) patch(
2222
patch client.Patch, options ...client.PatchOption,
2323
) error {
2424
options = append([]client.PatchOption{r.Owner}, options...)
25-
return r.Client.Patch(ctx, object, patch, options...)
25+
return r.Patch(ctx, object, patch, options...)
2626
}
2727

2828
// apply sends an apply patch to object's endpoint in the Kubernetes API and

internal/bridge/crunchybridgecluster/crunchybridgecluster_controller.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ func (r *CrunchyBridgeClusterReconciler) SetupWithManager(
9191
func (r *CrunchyBridgeClusterReconciler) setControllerReference(
9292
owner *v1beta1.CrunchyBridgeCluster, controlled client.Object,
9393
) error {
94-
return controllerutil.SetControllerReference(owner, controlled, r.Client.Scheme())
94+
return controllerutil.SetControllerReference(owner, controlled, r.Scheme())
9595
}
9696

9797
//+kubebuilder:rbac:groups="postgres-operator.crunchydata.com",resources="crunchybridgeclusters",verbs={get,patch,update}
@@ -684,7 +684,7 @@ func (r *CrunchyBridgeClusterReconciler) GetSecretKeys(
684684
}}
685685

686686
err := errors.WithStack(
687-
r.Client.Get(ctx, client.ObjectKeyFromObject(existing), existing))
687+
r.Get(ctx, client.ObjectKeyFromObject(existing), existing))
688688

689689
if err == nil {
690690
if existing.Data["key"] != nil && existing.Data["team"] != nil {
@@ -707,7 +707,7 @@ func (r *CrunchyBridgeClusterReconciler) deleteControlled(
707707
version := object.GetResourceVersion()
708708
exactly := client.Preconditions{UID: &uid, ResourceVersion: &version}
709709

710-
return r.Client.Delete(ctx, object, exactly)
710+
return r.Delete(ctx, object, exactly)
711711
}
712712

713713
return nil

internal/bridge/crunchybridgecluster/delete.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ func (r *CrunchyBridgeClusterReconciler) handleDelete(
2828
log := ctrl.LoggerFrom(ctx)
2929

3030
// If the CrunchyBridgeCluster isn't being deleted, add the finalizer
31-
if crunchybridgecluster.ObjectMeta.DeletionTimestamp.IsZero() {
31+
if crunchybridgecluster.DeletionTimestamp.IsZero() {
3232
if !controllerutil.ContainsFinalizer(crunchybridgecluster, finalizer) {
3333
controllerutil.AddFinalizer(crunchybridgecluster, finalizer)
3434
if err := r.Update(ctx, crunchybridgecluster); err != nil {

internal/bridge/crunchybridgecluster/delete_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ func TestHandleDeleteCluster(t *testing.T) {
6565

6666
// Get cluster from kubernetes and assert that the deletion timestamp was added
6767
assert.NilError(t, tClient.Get(ctx, client.ObjectKeyFromObject(cluster), cluster))
68-
assert.Check(t, !cluster.ObjectMeta.DeletionTimestamp.IsZero())
68+
assert.Check(t, !cluster.DeletionTimestamp.IsZero())
6969

7070
// Note: We must run handleDelete multiple times because we don't want to remove the
7171
// finalizer until we're sure that the cluster has been deleted from Bridge, so we
@@ -107,7 +107,7 @@ func TestHandleDeleteCluster(t *testing.T) {
107107

108108
// Get cluster from kubernetes and assert that the deletion timestamp was added
109109
assert.NilError(t, tClient.Get(ctx, client.ObjectKeyFromObject(cluster), cluster))
110-
assert.Check(t, !cluster.ObjectMeta.DeletionTimestamp.IsZero())
110+
assert.Check(t, !cluster.DeletionTimestamp.IsZero())
111111

112112
// Run handleDelete again to attempt to delete from Bridge, but provide bad api key
113113
cluster.Status.ID = "2345"

internal/bridge/crunchybridgecluster/postgres.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ func (r *CrunchyBridgeClusterReconciler) reconcilePostgresRoleSecrets(
9292
// Make sure that this cluster's role secret names are not being used by any other
9393
// secrets in the namespace
9494
allSecretsInNamespace := &corev1.SecretList{}
95-
err := errors.WithStack(r.Client.List(ctx, allSecretsInNamespace, client.InNamespace(cluster.Namespace)))
95+
err := errors.WithStack(r.List(ctx, allSecretsInNamespace, client.InNamespace(cluster.Namespace)))
9696
if err != nil {
9797
return nil, nil, err
9898
}
@@ -115,7 +115,7 @@ func (r *CrunchyBridgeClusterReconciler) reconcilePostgresRoleSecrets(
115115
selector, err := naming.AsSelector(naming.CrunchyBridgeClusterPostgresRoles(cluster.Name))
116116
if err == nil {
117117
err = errors.WithStack(
118-
r.Client.List(ctx, secrets,
118+
r.List(ctx, secrets,
119119
client.InNamespace(cluster.Namespace),
120120
client.MatchingLabelsSelector{Selector: selector},
121121
))

internal/bridge/installation_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ func TestInstallationReconcile(t *testing.T) {
9999

100100
reconciler.NewClient = func() *Client {
101101
c := NewClient(server.URL, "")
102-
c.Backoff.Steps = 1
102+
c.Steps = 1
103103
assert.Equal(t, c.BaseURL.String(), server.URL)
104104
return c
105105
}
@@ -155,7 +155,7 @@ func TestInstallationReconcile(t *testing.T) {
155155

156156
reconciler.NewClient = func() *Client {
157157
c := NewClient(server.URL, "")
158-
c.Backoff.Steps = 1
158+
c.Steps = 1
159159
assert.Equal(t, c.BaseURL.String(), server.URL)
160160
return c
161161
}
@@ -289,7 +289,7 @@ func TestInstallationReconcile(t *testing.T) {
289289

290290
reconciler.NewClient = func() *Client {
291291
c := NewClient(server.URL, "")
292-
c.Backoff.Steps = 1
292+
c.Steps = 1
293293
assert.Equal(t, c.BaseURL.String(), server.URL)
294294
return c
295295
}
@@ -343,7 +343,7 @@ func TestInstallationReconcile(t *testing.T) {
343343

344344
reconciler.NewClient = func() *Client {
345345
c := NewClient(server.URL, "")
346-
c.Backoff.Steps = 1
346+
c.Steps = 1
347347
assert.Equal(t, c.BaseURL.String(), server.URL)
348348
return c
349349
}
@@ -426,7 +426,7 @@ func TestInstallationReconcile(t *testing.T) {
426426

427427
reconciler.NewClient = func() *Client {
428428
c := NewClient(server.URL, "")
429-
c.Backoff.Steps = 1
429+
c.Steps = 1
430430
assert.Equal(t, c.BaseURL.String(), server.URL)
431431
return c
432432
}

internal/config/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ func VerifyImageValues(cluster *v1beta1.PostgresCluster) error {
173173
}
174174

175175
if len(images) > 0 {
176-
return fmt.Errorf("Missing image(s): %s", images)
176+
return fmt.Errorf("missing image(s): %s", images)
177177
}
178178

179179
return nil

0 commit comments

Comments
 (0)