Skip to content

Commit b3d3ed9

Browse files
authored
Merge pull request #394 from kubernetes-sigs/dependabot/github_actions/golangci/golangci-lint-action-8.0.0
🌱 Bump golangci/golangci-lint-action from 6.5.2 to 8.0.0
2 parents ca418e9 + 4f51122 commit b3d3ed9

File tree

6 files changed

+109
-110
lines changed

6 files changed

+109
-110
lines changed

.github/workflows/golangci-lint.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ jobs:
2525
with:
2626
go-version: ${{ steps.vars.outputs.go_version }}
2727
- name: golangci-lint
28-
uses: golangci/golangci-lint-action@55c2c1448f86e01eaae002a5a3a9624417608d84 # tag=v6.5.2
28+
uses: golangci/golangci-lint-action@4afd733a84b1f43292c63897423277bb7f4313a9 # tag=v8.0.0
2929
with:
30-
version: v1.64.8
30+
version: v2.1.6
3131
working-directory: ${{matrix.working-directory}}
3232
args: --timeout=5m

.golangci.yaml

Lines changed: 87 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,10 @@
1+
version: "2"
12
run:
2-
timeout: 5m
33
go: "1.22"
44
allow-parallel-runners: true
5-
65
linters:
7-
disable-all: true
8-
# Enable specific linter
9-
# https://golangci-lint.run/usage/linters/#enabled-by-default-linters
6+
default: none
107
enable:
11-
# Default linters
12-
- errcheck
13-
- gosimple
14-
- govet
15-
- ineffassign
16-
- staticcheck
17-
- typecheck
18-
- unused
19-
# Additional linters
208
- asasalint
219
- asciicheck
2210
- bidichk
@@ -26,23 +14,22 @@ linters:
2614
- copyloopvar
2715
- dogsled
2816
- durationcheck
17+
- errcheck
2918
- errchkjson
3019
- errname
3120
- errorlint
3221
- exhaustive
3322
- forcetypeassert
34-
- gci
3523
- ginkgolinter
3624
- goconst
3725
- gocritic
3826
- gocyclo
3927
- godot
40-
- gofmt
41-
- gofumpt
4228
- goheader
43-
- goimports
4429
- goprintffuncname
30+
- govet
4531
- importas
32+
- ineffassign
4633
- makezero
4734
- misspell
4835
- nakedret
@@ -56,85 +43,97 @@ linters:
5643
- reassign
5744
- rowserrcheck
5845
- sqlclosecheck
59-
- stylecheck
46+
- staticcheck
6047
- testableexamples
6148
- thelper
6249
- tparallel
6350
- unconvert
6451
- unparam
52+
- unused
6553
- usestdlibvars
6654
- usetesting
6755
- wastedassign
6856
- whitespace
57+
settings:
58+
goheader:
59+
values:
60+
regexp:
61+
license-year: (202[0-9]|20[3-9][0-9])
62+
template: |-
63+
Copyright {{license-year}} The Kubernetes Authors.
6964
70-
linters-settings:
71-
goheader:
72-
values:
73-
regexp:
74-
license-year: (202[0-9]|20[3-9][0-9])
75-
template: |-
76-
Copyright {{license-year}} The Kubernetes Authors.
77-
78-
Licensed under the Apache License, Version 2.0 (the "License");
79-
you may not use this file except in compliance with the License.
80-
You may obtain a copy of the License at
65+
Licensed under the Apache License, Version 2.0 (the "License");
66+
you may not use this file except in compliance with the License.
67+
You may obtain a copy of the License at
8168
82-
http://www.apache.org/licenses/LICENSE-2.0
69+
http://www.apache.org/licenses/LICENSE-2.0
8370
84-
Unless required by applicable law or agreed to in writing, software
85-
distributed under the License is distributed on an "AS IS" BASIS,
86-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
87-
See the License for the specific language governing permissions and
88-
limitations under the License.
89-
nlreturn:
90-
block-size: 2
91-
stylecheck:
92-
# https://staticcheck.io/docs/options#checks
93-
checks: ["all", "-ST1000", "-ST1003", "-ST1016"]
94-
dot-import-whitelist:
95-
- "github.com/onsi/gomega"
96-
importas:
97-
no-unaliased: true
98-
alias:
99-
# Kubernetes
100-
- pkg: k8s.io/api/core/v1
101-
alias: corev1
102-
- pkg: k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1
103-
alias: apiextensionsv1
104-
- pkg: k8s.io/apimachinery/pkg/apis/meta/v1
105-
alias: metav1
106-
- pkg: k8s.io/apimachinery/pkg/api/errors
107-
alias: apierrors
108-
- pkg: k8s.io/apimachinery/pkg/util/errors
109-
alias: kerrors
110-
- pkg: k8s.io/apimachinery/pkg/util/runtime
111-
alias: utilruntime
112-
# Controller Runtime
113-
- pkg: sigs.k8s.io/controller-runtime
114-
alias: ctrl
115-
# CAPI
116-
- pkg: sigs.k8s.io/cluster-api/api/v1beta1
117-
alias: clusterv1
118-
- pkg: sigs.k8s.io/cluster-api/cmd/clusterctl/api/v1alpha3
119-
alias: clusterctlv1
120-
- pkg: sigs.k8s.io/cluster-api/cmd/clusterctl/client/config
121-
alias: configclient
122-
# CAPI Add-on Provider Helm
123-
- pkg: sigs.k8s.io/cluster-api-addon-provider-helm
124-
alias: addonsv1alpha1
125-
issues:
126-
exclude:
127-
# Not all platforms are supported by this provider, those which aren't
128-
# supported will be caught by the default case in the switches.
129-
- "missing cases in switch of type v1.PlatformType: (\\.*)"
130-
exclude-use-default: false
131-
exclude-files:
132-
- "zz_generated.*\\.go$"
133-
exclude-rules:
134-
# Exclude some linters from running on tests files.
135-
- path: _test\.go
136-
linters:
137-
- gosec
138-
- path: hack/boilerplate
139-
linters:
140-
- goheader
71+
Unless required by applicable law or agreed to in writing, software
72+
distributed under the License is distributed on an "AS IS" BASIS,
73+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
74+
See the License for the specific language governing permissions and
75+
limitations under the License.
76+
importas:
77+
alias:
78+
- pkg: k8s.io/api/core/v1
79+
alias: corev1
80+
- pkg: k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1
81+
alias: apiextensionsv1
82+
- pkg: k8s.io/apimachinery/pkg/apis/meta/v1
83+
alias: metav1
84+
- pkg: k8s.io/apimachinery/pkg/api/errors
85+
alias: apierrors
86+
- pkg: k8s.io/apimachinery/pkg/util/errors
87+
alias: kerrors
88+
- pkg: k8s.io/apimachinery/pkg/util/runtime
89+
alias: utilruntime
90+
- pkg: sigs.k8s.io/controller-runtime
91+
alias: ctrl
92+
- pkg: sigs.k8s.io/cluster-api/api/v1beta1
93+
alias: clusterv1
94+
- pkg: sigs.k8s.io/cluster-api/cmd/clusterctl/api/v1alpha3
95+
alias: clusterctlv1
96+
- pkg: sigs.k8s.io/cluster-api/cmd/clusterctl/client/config
97+
alias: configclient
98+
- pkg: sigs.k8s.io/cluster-api-addon-provider-helm
99+
alias: addonsv1alpha1
100+
no-unaliased: true
101+
nlreturn:
102+
block-size: 2
103+
staticcheck:
104+
checks:
105+
- all
106+
- -ST1000
107+
- -ST1003
108+
- -ST1016
109+
dot-import-whitelist:
110+
- github.com/onsi/gomega
111+
exclusions:
112+
generated: lax
113+
rules:
114+
- linters:
115+
- gosec
116+
path: _test\.go
117+
- linters:
118+
- goheader
119+
path: hack/boilerplate
120+
- path: (.+)\.go$
121+
text: 'missing cases in switch of type v1.PlatformType: (\.*)'
122+
paths:
123+
- zz_generated.*\.go$
124+
- third_party$
125+
- builtin$
126+
- examples$
127+
formatters:
128+
enable:
129+
- gci
130+
- gofmt
131+
- gofumpt
132+
- goimports
133+
exclusions:
134+
generated: lax
135+
paths:
136+
- zz_generated.*\.go$
137+
- third_party$
138+
- builtin$
139+
- examples$

controllers/helmchartproxy/helmchartproxy_controller.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ func (r *HelmChartProxyReconciler) Reconcile(ctx context.Context, req ctrl.Reque
8282

8383
// Fetch the HelmChartProxy instance.
8484
helmChartProxy := &addonsv1alpha1.HelmChartProxy{}
85-
if err := r.Client.Get(ctx, req.NamespacedName, helmChartProxy); err != nil {
85+
if err := r.Get(ctx, req.NamespacedName, helmChartProxy); err != nil {
8686
if apierrors.IsNotFound(err) {
8787
log.V(2).Info("HelmChartProxy resource not found, skipping reconciliation", "helmChartProxy", req.NamespacedName)
8888
return ctrl.Result{}, nil
@@ -133,7 +133,7 @@ func (r *HelmChartProxyReconciler) Reconcile(ctx context.Context, req ctrl.Reque
133133
}
134134

135135
// examine DeletionTimestamp to determine if object is under deletion
136-
if helmChartProxy.ObjectMeta.DeletionTimestamp.IsZero() {
136+
if helmChartProxy.DeletionTimestamp.IsZero() {
137137
// The object is not being deleted, so if it does not have our finalizer,
138138
// then lets add the finalizer and update the object. This is equivalent
139139
// registering our finalizer.
@@ -190,7 +190,7 @@ func (r *HelmChartProxyReconciler) reconcileNormal(ctx context.Context, helmChar
190190
log.V(2).Info("Starting reconcileNormal for chart proxy", "name", helmChartProxy.Name, "strategy", helmChartProxy.Spec.ReconcileStrategy)
191191

192192
// If Reconcile strategy is not InstallOnce, delete orphaned HelmReleaseProxies
193-
if !(helmChartProxy.Spec.ReconcileStrategy == string(addonsv1alpha1.ReconcileStrategyInstallOnce)) {
193+
if helmChartProxy.Spec.ReconcileStrategy != string(addonsv1alpha1.ReconcileStrategyInstallOnce) {
194194
err := r.deleteOrphanedHelmReleaseProxies(ctx, helmChartProxy, clusters, helmReleaseProxies)
195195
if err != nil {
196196
return err
@@ -199,7 +199,7 @@ func (r *HelmChartProxyReconciler) reconcileNormal(ctx context.Context, helmChar
199199

200200
for _, cluster := range clusters {
201201
// Don't reconcile if the Cluster is being deleted
202-
if !cluster.ObjectMeta.DeletionTimestamp.IsZero() {
202+
if !cluster.DeletionTimestamp.IsZero() {
203203
continue
204204
}
205205

@@ -258,7 +258,7 @@ func (r *HelmChartProxyReconciler) listClustersWithLabels(ctx context.Context, n
258258
return nil, err
259259
}
260260

261-
if err := r.Client.List(ctx, clusterList, client.InNamespace(namespace), client.MatchingLabelsSelector{Selector: labelselector}); err != nil {
261+
if err := r.List(ctx, clusterList, client.InNamespace(namespace), client.MatchingLabelsSelector{Selector: labelselector}); err != nil {
262262
return nil, err
263263
}
264264

@@ -270,7 +270,7 @@ func (r *HelmChartProxyReconciler) listInstalledReleases(ctx context.Context, na
270270
releaseList := &addonsv1alpha1.HelmReleaseProxyList{}
271271

272272
// TODO: should we use client.MatchingLabels or try to use the labelSelector itself?
273-
if err := r.Client.List(ctx, releaseList, client.InNamespace(namespace), client.MatchingLabels(labels)); err != nil {
273+
if err := r.List(ctx, releaseList, client.InNamespace(namespace), client.MatchingLabels(labels)); err != nil {
274274
return nil, err
275275
}
276276

@@ -352,7 +352,7 @@ func (r *HelmChartProxyReconciler) ClusterToHelmChartProxiesMapper(ctx context.C
352352

353353
// TODO: Figure out if we want this search to be cross-namespaces.
354354

355-
if err := r.Client.List(ctx, helmChartProxies, client.InNamespace(cluster.Namespace)); err != nil {
355+
if err := r.List(ctx, helmChartProxies, client.InNamespace(cluster.Namespace)); err != nil {
356356
return nil
357357
}
358358

@@ -390,7 +390,7 @@ func HelmReleaseProxyToHelmChartProxyMapper(ctx context.Context, o client.Object
390390

391391
// Check if the controller reference is already set and
392392
// return an empty result when one is found.
393-
for _, ref := range helmReleaseProxy.ObjectMeta.OwnerReferences {
393+
for _, ref := range helmReleaseProxy.OwnerReferences {
394394
if ref.Controller != nil && *ref.Controller {
395395
name := client.ObjectKey{
396396
Namespace: helmReleaseProxy.GetNamespace(),

controllers/helmchartproxy/helmchartproxy_controller_phases.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ func (r *HelmChartProxyReconciler) getExistingHelmReleaseProxy(ctx context.Conte
135135
// TODO: Figure out if we want this search to be cross-namespaces.
136136

137137
log.V(2).Info("Attempting to fetch existing HelmReleaseProxy with Cluster and HelmChartProxy labels", "cluster", cluster.Name, "helmChartProxy", helmChartProxy.Name)
138-
if err := r.Client.List(ctx, helmReleaseProxyList, listOpts...); err != nil {
138+
if err := r.List(ctx, helmReleaseProxyList, listOpts...); err != nil {
139139
return nil, err
140140
}
141141

@@ -161,12 +161,12 @@ func (r *HelmChartProxyReconciler) createOrUpdateHelmReleaseProxy(ctx context.Co
161161
return nil
162162
}
163163
if existing == nil {
164-
if err := r.Client.Create(ctx, helmReleaseProxy); err != nil {
164+
if err := r.Create(ctx, helmReleaseProxy); err != nil {
165165
return errors.Wrapf(err, "failed to create HelmReleaseProxy '%s' for cluster: %s/%s", helmReleaseProxy.Name, cluster.Namespace, cluster.Name)
166166
}
167167
} else {
168168
// TODO: should this use patchHelmReleaseProxy() instead of Update() in case there's a race condition?
169-
if err := r.Client.Update(ctx, helmReleaseProxy); err != nil {
169+
if err := r.Update(ctx, helmReleaseProxy); err != nil {
170170
return errors.Wrapf(err, "failed to update HelmReleaseProxy '%s' for cluster: %s/%s", helmReleaseProxy.Name, cluster.Namespace, cluster.Name)
171171
}
172172
}
@@ -178,7 +178,7 @@ func (r *HelmChartProxyReconciler) createOrUpdateHelmReleaseProxy(ctx context.Co
178178
func (r *HelmChartProxyReconciler) deleteHelmReleaseProxy(ctx context.Context, helmReleaseProxy *addonsv1alpha1.HelmReleaseProxy) error {
179179
log := ctrl.LoggerFrom(ctx)
180180

181-
if err := r.Client.Delete(ctx, helmReleaseProxy); err != nil {
181+
if err := r.Delete(ctx, helmReleaseProxy); err != nil {
182182
if apierrors.IsNotFound(err) {
183183
log.V(2).Info("HelmReleaseProxy already deleted, nothing to do", "helmReleaseProxy", helmReleaseProxy.Name)
184184
return nil

controllers/helmreleaseproxy/helmreleaseproxy_controller.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ func (r *HelmReleaseProxyReconciler) Reconcile(ctx context.Context, req ctrl.Req
101101

102102
// Fetch the HelmReleaseProxy instance.
103103
helmReleaseProxy := &addonsv1alpha1.HelmReleaseProxy{}
104-
if err := r.Client.Get(ctx, req.NamespacedName, helmReleaseProxy); err != nil {
104+
if err := r.Get(ctx, req.NamespacedName, helmReleaseProxy); err != nil {
105105
if apierrors.IsNotFound(err) {
106106
log.V(2).Info("HelmReleaseProxy resource not found, skipping reconciliation", "helmReleaseProxy", req.NamespacedName)
107107
return ctrl.Result{}, nil
@@ -136,7 +136,7 @@ func (r *HelmReleaseProxyReconciler) Reconcile(ctx context.Context, req ctrl.Req
136136
}
137137

138138
// examine DeletionTimestamp to determine if object is under deletion
139-
if helmReleaseProxy.ObjectMeta.DeletionTimestamp.IsZero() {
139+
if helmReleaseProxy.DeletionTimestamp.IsZero() {
140140
// The object is not being deleted, so if it does not have our finalizer,
141141
// then lets add the finalizer and update the object. This is equivalent
142142
// registering our finalizer.
@@ -151,7 +151,7 @@ func (r *HelmReleaseProxyReconciler) Reconcile(ctx context.Context, req ctrl.Req
151151
// The object is being deleted
152152
if controllerutil.ContainsFinalizer(helmReleaseProxy, addonsv1alpha1.HelmReleaseProxyFinalizer) {
153153
// our finalizer is present, so lets handle any external dependency
154-
if err := r.Client.Get(ctx, clusterKey, cluster); err == nil {
154+
if err := r.Get(ctx, clusterKey, cluster); err == nil {
155155
log.V(2).Info("Getting kubeconfig for cluster", "cluster", cluster.Name)
156156
restConfig, err := remote.RESTConfig(ctx, "caaph", r.Client, clusterKey)
157157
if err != nil {
@@ -190,7 +190,7 @@ func (r *HelmReleaseProxyReconciler) Reconcile(ctx context.Context, req ctrl.Req
190190
return ctrl.Result{}, nil
191191
}
192192

193-
if err := r.Client.Get(ctx, clusterKey, cluster); err != nil {
193+
if err := r.Get(ctx, clusterKey, cluster); err != nil {
194194
// TODO: add check to tell if Cluster is deleted so we can remove the HelmReleaseProxy.
195195
wrappedErr := errors.Wrapf(err, "failed to get cluster %s/%s", clusterKey.Namespace, clusterKey.Name)
196196
conditions.MarkFalse(helmReleaseProxy, addonsv1alpha1.ClusterAvailableCondition, addonsv1alpha1.GetClusterFailedReason, clusterv1.ConditionSeverityError, "%s", wrappedErr.Error())
@@ -446,7 +446,7 @@ func (r *HelmReleaseProxyReconciler) getCAFile(ctx context.Context, helmReleaseP
446446
// getCredentialsFromSecret returns the OCI credentials from a Secret.
447447
func (r *HelmReleaseProxyReconciler) getCredentialsFromSecret(ctx context.Context, name, namespace, key string) ([]byte, error) {
448448
secret := &corev1.Secret{}
449-
if err := r.Client.Get(ctx, types.NamespacedName{Name: name, Namespace: namespace}, secret); err != nil {
449+
if err := r.Get(ctx, types.NamespacedName{Name: name, Namespace: namespace}, secret); err != nil {
450450
return nil, err
451451
}
452452

@@ -477,7 +477,7 @@ func writeCredentialsToFile(ctx context.Context, credentials []byte) (string, er
477477
// getCredentialsFromSecret returns the OCI credentials from a Secret.
478478
func (r *HelmReleaseProxyReconciler) getCACertificateFromSecret(ctx context.Context, name, namespace string) ([]byte, error) {
479479
secret := &corev1.Secret{}
480-
if err := r.Client.Get(ctx, types.NamespacedName{Name: name, Namespace: namespace}, secret); err != nil {
480+
if err := r.Get(ctx, types.NamespacedName{Name: name, Namespace: namespace}, secret); err != nil {
481481
return nil, err
482482
}
483483

0 commit comments

Comments
 (0)