Skip to content

Commit 13471c8

Browse files
Merge pull request #820 from dmage/linter
Add config for golangci-lint and fix errors
2 parents 70e8400 + f146a97 commit 13471c8

36 files changed

+84
-91
lines changed

.golangci.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
linters:
2+
enable:
3+
- contextcheck
4+
- errcheck
5+
- exhaustive
6+
- gofumpt
7+
- gosimple
8+
- govet
9+
- ineffassign
10+
- misspell
11+
- staticcheck
12+
- typecheck
13+
- unused

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ PROG := cluster-image-registry-operator
44

55
GOLANGCI_LINT = _output/tools/golangci-lint
66
GOLANGCI_LINT_CACHE = $(PWD)/_output/golangci-lint-cache
7-
GOLANGCI_LINT_VERSION = v1.50.0
7+
GOLANGCI_LINT_VERSION = v1.50.1
88

99
GO_REQUIRED_MIN_VERSION = 1.16
1010

cmd/cluster-image-registry-operator/main.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,7 @@ import (
2626

2727
const metricsPort = 60000
2828

29-
var (
30-
filesToWatch []string
31-
)
29+
var filesToWatch []string
3230

3331
func printVersion() {
3432
klog.Infof("Cluster Image Registry Operator Version: %s", version.Version)

pkg/client/operatorclient.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ func (c *ConfigOperatorClient) UpdateOperatorStatus(ctx context.Context, oldReso
7777

7878
config.Status.OperatorStatus = *in
7979

80-
updatedConfig, err := c.client.UpdateStatus(context.TODO(), config, metav1.UpdateOptions{})
80+
updatedConfig, err := c.client.UpdateStatus(ctx, config, metav1.UpdateOptions{})
8181
if err != nil {
8282
return nil, err
8383
}

pkg/metrics/server_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,10 +197,8 @@ func TestImagePrunerInstallStatus(t *testing.T) {
197197
t.Errorf("expected metric %s to be 2, got %f", metricName, m.Gauge.GetValue())
198198
}
199199
}
200-
201200
})
202201
}
203-
204202
}
205203

206204
func findMetricsByCounter(buf io.ReadCloser, name string) []*io_prometheus_client.Metric {

pkg/operator/metrics.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ func NewMetricsController(informer imageinformers.ImageStreamInformer) *MetricsC
3232
}
3333
}
3434

35-
// report gathers all metrics reported by this operator and calls approprate function in the
35+
// report gathers all metrics reported by this operator and calls appropriate function in the
3636
// metrics package to report the current values.
3737
func (m *MetricsController) report(_ context.Context) {
3838
imgstreams, err := m.lister.List(labels.Everything())

pkg/operator/starter.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ func RunOperator(ctx context.Context, kubeconfig *restclient.Config) error {
6262

6363
// library-go just logs a warning and continues
6464
// https://github.com/openshift/library-go/blob/4362aa519714a4b62b00ab8318197ba2bba51cb7/pkg/controller/controllercmd/builder.go#L230
65-
controllerRef, err := events.GetControllerReferenceForCurrentPod(context.TODO(), kubeClient, defaults.ImageRegistryOperatorNamespace, nil)
65+
controllerRef, err := events.GetControllerReferenceForCurrentPod(ctx, kubeClient, defaults.ImageRegistryOperatorNamespace, nil)
6666
if err != nil {
6767
klog.Warningf("unable to get owner reference (falling back to namespace): %v", err)
6868
}

pkg/resource/dependencies.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ func (d dependencies) Checksum(configMapLister corelisters.ConfigMapNamespaceLis
4343
cm, err := configMapLister.Get(name)
4444
if errors.IsNotFound(err) {
4545
// We may have optional dependencies.
46-
klog.Infof("missing the deployment depencency: ConfigMap %s: %s", name, err)
46+
klog.Infof("missing the deployment dependency: ConfigMap %s: %s", name, err)
4747
continue
4848
} else if err != nil {
4949
return "", err

pkg/resource/deployment_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ func TestChecksum(t *testing.T) {
6161

6262
for _, test := range tests {
6363
t.Run(test.name, func(t *testing.T) {
64-
6564
ctx, cancel := context.WithCancel(context.Background())
6665
defer cancel()
6766

pkg/resource/podtemplatespec_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,8 @@ func TestMakePodTemplateSpecWithTopologySpread(t *testing.T) {
133133
MatchLabels: map[string]string{"registry": "abc"},
134134
},
135135
},
136-
}},
136+
},
137+
},
137138
expected: []corev1.TopologySpreadConstraint{
138139
{
139140
MaxSkew: 2,

0 commit comments

Comments
 (0)