Skip to content

Commit f25b064

Browse files
authored
Update to Go 1.24.2, golangci-lint 2.x (#459)
* Update new image tag for KKP owned images Signed-off-by: archups <[email protected]> * Changes related to golangci-lint migration Signed-off-by: archups <[email protected]> * Update build image tag version Signed-off-by: archups <[email protected]> * Add empty line between boilerplate and actual content Signed-off-by: archups <[email protected]> --------- Signed-off-by: archups <[email protected]>
1 parent 4b62a12 commit f25b064

File tree

11 files changed

+110
-62
lines changed

11 files changed

+110
-62
lines changed

.golangci.yml

Lines changed: 75 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,16 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14+
15+
version: "2"
1416
run:
15-
timeout: 20m
17+
# concurrency=1 lowers memory usage a bit
18+
concurrency: 1
19+
modules-download-mode: readonly
1620
issues-exit-code: 1
1721

1822
linters:
23+
default: none
1924
enable:
2025
- asasalint
2126
- asciicheck
@@ -29,8 +34,6 @@ linters:
2934
- goconst
3035
- gocritic
3136
- gocyclo
32-
- gofmt
33-
- gosimple
3437
- govet
3538
- importas
3639
- ineffassign
@@ -42,36 +45,81 @@ linters:
4245
- nosprintfhostport
4346
- predeclared
4447
- promlinter
45-
- revive
4648
- staticcheck
47-
- tenv
48-
- typecheck
4949
- unconvert
5050
- unused
5151
- wastedassign
5252
- whitespace
53-
disable-all: true
5453

55-
linters-settings:
56-
goimports:
57-
local-prefixes: k8c.io/operating-system-manager
58-
tagliatelle:
59-
case:
54+
settings:
55+
goimports:
56+
local-prefixes: k8c.io/operating-system-manager
57+
tagliatelle:
58+
case:
59+
rules:
60+
json: goCamel
61+
yaml: goCamel
62+
depguard:
6063
rules:
61-
json: goCamel
62-
yaml: goCamel
63-
depguard:
64-
rules:
65-
main:
66-
deny:
67-
- { pkg: io/ioutil, desc: https://go.dev/doc/go1.16#ioutil }
68-
govet:
69-
enable:
70-
- nilness # find tautologies / impossible conditions
64+
main:
65+
deny:
66+
- { pkg: io/ioutil, desc: https://go.dev/doc/go1.16#ioutil }
67+
govet:
68+
enable:
69+
- nilness # find tautologies / impossible conditions
70+
importas:
71+
alias:
72+
# Operating System Manager
73+
- pkg: k8c.io/operating-system-manager/pkg/crd/osm/v1alpha1
74+
alias: osmv1alpha1
75+
- pkg: k8c.io/operating-system-manager/pkg/test/util
76+
alias: testUtil
77+
# Machine Controller
78+
- pkg: k8c.io/machine-controller/sdk/apis/(\w+)/(v[\w\d]+)
79+
alias: $1$2
80+
- pkg: k8c.io/machine-controller/sdk/bootstrap
81+
alias: mcbootstrap
82+
- pkg: k8c.io/machine-controller/sdk/net
83+
alias: mcnet
84+
- pkg: k8c.io/machine-controller/pkg/controller/util
85+
alias: machinecontrollerutil
86+
# Kubernetes
87+
- pkg: k8s.io/api/(\w+)/(v[\w\d]+)
88+
alias: $1$2
89+
- pkg: k8s.io/api/core/v1
90+
alias: corev1
91+
- pkg: k8s.io/apimachinery/pkg/apis/meta/v1
92+
alias: metav1
93+
- pkg: k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1
94+
alias: apiextensionsv1
95+
- pkg: k8s.io/apimachinery/pkg/api/errors
96+
alias: kerrors
97+
# Controller Runtime
98+
- pkg: sigs.k8s.io/controller-runtime/pkg/client
99+
alias: ctrlruntimeclient
100+
- pkg: sigs.k8s.io/controller-runtime/pkg/client/fake
101+
alias: ctrlruntimefakeclient
102+
staticcheck:
103+
checks:
104+
- all
105+
- '-ST1000'
106+
- '-QF1008'
107+
- '-ST1020'
108+
exclusions:
109+
presets:
110+
- comments
111+
- std-error-handling
112+
- common-false-positives
113+
- legacy
114+
paths:
115+
- zz_generated.*.go
71116

72117
issues:
73-
exclude-dirs:
74-
- hack
75-
- vendor
76-
exclude-files:
77-
- zz_generated.*.go
118+
max-same-issues: 0
119+
120+
formatters:
121+
enable:
122+
- gofmt
123+
exclusions:
124+
paths:
125+
- zz_generated.*.go

.prow/postsubmits.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ postsubmits:
2626
preset-goproxy: "true"
2727
spec:
2828
containers:
29-
- image: quay.io/kubermatic/build:go-1.23-node-20-kind-0.26-10
29+
- image: quay.io/kubermatic/build:go-1.24-node-20-kind-0.27-5
3030
command:
3131
- /bin/bash
3232
- -c
@@ -53,7 +53,7 @@ postsubmits:
5353
preset-goproxy: "true"
5454
spec:
5555
containers:
56-
- image: quay.io/kubermatic/build:go-1.23-node-20-kind-0.26-10
56+
- image: quay.io/kubermatic/build:go-1.24-node-20-kind-0.27-5
5757
command:
5858
- "./hack/ci/upload-gocache.sh"
5959
resources:

.prow/verify.yaml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ presubmits:
2121
preset-goproxy: "true"
2222
spec:
2323
containers:
24-
- image: quay.io/kubermatic/build:go-1.23-node-20-10
24+
- image: quay.io/kubermatic/build:go-1.24-node-20-5
2525
command:
2626
- make
2727
args:
@@ -36,7 +36,7 @@ presubmits:
3636
preset-goproxy: "true"
3737
spec:
3838
containers:
39-
- image: quay.io/kubermatic/build:go-1.23-node-20-10
39+
- image: quay.io/kubermatic/build:go-1.24-node-20-5
4040
command:
4141
- make
4242
args:
@@ -58,7 +58,7 @@ presubmits:
5858
preset-goproxy: "true"
5959
spec:
6060
containers:
61-
- image: quay.io/kubermatic/build:go-1.23-node-20-10
61+
- image: quay.io/kubermatic/build:go-1.24-node-20-5
6262
command:
6363
- make
6464
args:
@@ -79,7 +79,7 @@ presubmits:
7979
preset-goproxy: "true"
8080
spec:
8181
containers:
82-
- image: quay.io/kubermatic/build:go-1.23-node-20-10
82+
- image: quay.io/kubermatic/build:go-1.24-node-20-5
8383
command:
8484
- ./hack/verify-licenses.sh
8585
resources:
@@ -95,7 +95,7 @@ presubmits:
9595
preset-goproxy: "true"
9696
spec:
9797
containers:
98-
- image: quay.io/kubermatic/build:go-1.23-node-20-10
98+
- image: quay.io/kubermatic/build:go-1.24-node-20-5
9999
command:
100100
- make
101101
args:
@@ -115,7 +115,7 @@ presubmits:
115115
preset-goproxy: "true"
116116
spec:
117117
containers:
118-
- image: quay.io/kubermatic/build:go-1.23-node-20-10
118+
- image: quay.io/kubermatic/build:go-1.24-node-20-5
119119
command:
120120
- make
121121
args:
@@ -130,7 +130,7 @@ presubmits:
130130
clone_uri: "ssh://[email protected]/kubermatic/operating-system-manager.git"
131131
spec:
132132
containers:
133-
- image: quay.io/kubermatic/build:go-1.23-node-20-10
133+
- image: quay.io/kubermatic/build:go-1.24-node-20-5
134134
command:
135135
- shfmt
136136
args:
@@ -161,7 +161,7 @@ presubmits:
161161
preset-goproxy: "true"
162162
spec:
163163
containers:
164-
- image: quay.io/kubermatic/build:go-1.23-node-20-10
164+
- image: quay.io/kubermatic/build:go-1.24-node-20-5
165165
command:
166166
- make
167167
args:
@@ -182,7 +182,7 @@ presubmits:
182182
preset-goproxy: "true"
183183
spec:
184184
containers:
185-
- image: quay.io/kubermatic/build:go-1.23-node-20-kind-0.26-10
185+
- image: quay.io/kubermatic/build:go-1.24-node-20-kind-0.27-5
186186
command:
187187
- "./hack/ci/run-e2e-tests.sh"
188188
resources:

hack/lib.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ is_containerized() {
109109

110110
containerize() {
111111
local cmd="$1"
112-
local image="${CONTAINERIZE_IMAGE:-quay.io/kubermatic/util:2.0.0}"
112+
local image="${CONTAINERIZE_IMAGE:-quay.io/kubermatic/util:2.6.0}"
113113
local gocache="${CONTAINERIZE_GOCACHE:-/tmp/.gocache}"
114114
local gomodcache="${CONTAINERIZE_GOMODCACHE:-/tmp/.gomodcache}"
115115
local skip="${NO_CONTAINERIZE:-}"

hack/update-codegen.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ set -euo pipefail
1919
cd $(dirname $0)/..
2020
source hack/lib.sh
2121

22-
CONTAINERIZE_IMAGE=quay.io/kubermatic/build:go-1.23-node-20-10 containerize ./hack/update-codegen.sh
22+
CONTAINERIZE_IMAGE=quay.io/kubermatic/build:go-1.24-node-20-5 containerize ./hack/update-codegen.sh
2323
SCRIPT_ROOT=$(dirname "${BASH_SOURCE}")
2424

2525
sed="sed"

hack/update-crds-openapi.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ set -euo pipefail
1919
cd $(dirname $0)/..
2020
source hack/lib.sh
2121

22-
CONTAINERIZE_IMAGE=quay.io/kubermatic/build:go-1.23-node-20-10 containerize ./hack/update-crds-openapi.sh
22+
CONTAINERIZE_IMAGE=quay.io/kubermatic/build:go-1.24-node-20-5 containerize ./hack/update-crds-openapi.sh
2323
SCRIPT_ROOT=$(dirname "${BASH_SOURCE}")
2424

2525
echodate "Creating vendor directory"

hack/verify-licenses.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ set -euo pipefail
1919
cd $(dirname $0)/..
2020
source hack/lib.sh
2121

22-
CONTAINERIZE_IMAGE=quay.io/kubermatic/build:go-1.23-node-20-10 containerize ./hack/verify-licenses.sh
22+
CONTAINERIZE_IMAGE=quay.io/kubermatic/build:go-1.24-node-20-5 containerize ./hack/verify-licenses.sh
2323

2424
go mod vendor
2525

pkg/bootstrap/kubeconfig_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import (
2626
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2727
"k8s.io/apimachinery/pkg/types"
2828
"k8s.io/client-go/kubernetes/scheme"
29-
ctrlruntimefake "sigs.k8s.io/controller-runtime/pkg/client/fake"
29+
ctrlruntimefakeclient "sigs.k8s.io/controller-runtime/pkg/client/fake"
3030
)
3131

3232
func TestUpdateSecretExpirationAndGetToken(t *testing.T) {
@@ -60,7 +60,7 @@ func TestUpdateSecretExpirationAndGetToken(t *testing.T) {
6060
data[tokenIDKey] = []byte("tokenID")
6161
data[expirationKey] = []byte(testCase.initialExpirationTime.Format(time.RFC3339))
6262
secret.Data = data
63-
b.client = ctrlruntimefake.
63+
b.client = ctrlruntimefakeclient.
6464
NewClientBuilder().
6565
WithScheme(scheme.Scheme).
6666
WithObjects(secret).

pkg/clusterinfo/configmap.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import (
2929
"k8s.io/client-go/tools/clientcmd"
3030
clientcmdapi "k8s.io/client-go/tools/clientcmd/api"
3131
"k8s.io/klog/v2"
32-
controllerruntimeclient "sigs.k8s.io/controller-runtime/pkg/client"
32+
ctrlruntimeclient "sigs.k8s.io/controller-runtime/pkg/client"
3333
)
3434

3535
const (
@@ -38,7 +38,7 @@ const (
3838
securePortName = "https"
3939
)
4040

41-
func New(client controllerruntimeclient.Client, caCert string) *KubeconfigProvider {
41+
func New(client ctrlruntimeclient.Client, caCert string) *KubeconfigProvider {
4242
return &KubeconfigProvider{
4343
client: client,
4444
caCert: caCert,
@@ -47,7 +47,7 @@ func New(client controllerruntimeclient.Client, caCert string) *KubeconfigProvid
4747

4848
type KubeconfigProvider struct {
4949
caCert string
50-
client controllerruntimeclient.Client
50+
client ctrlruntimeclient.Client
5151
}
5252

5353
func (p *KubeconfigProvider) GetKubeconfig(ctx context.Context) (*clientcmdapi.Config, error) {

pkg/clusterinfo/configmap_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ import (
2828
"k8s.io/client-go/kubernetes/scheme"
2929
"k8s.io/client-go/rest"
3030
"k8s.io/client-go/tools/clientcmd"
31-
controllerruntimeclient "sigs.k8s.io/controller-runtime/pkg/client"
32-
ctrlruntimefake "sigs.k8s.io/controller-runtime/pkg/client/fake"
31+
ctrlruntimeclient "sigs.k8s.io/controller-runtime/pkg/client"
32+
ctrlruntimefakeclient "sigs.k8s.io/controller-runtime/pkg/client/fake"
3333
)
3434

3535
const (
@@ -62,14 +62,14 @@ users: null
6262
func TestKubeconfigProvider_GetKubeconfig(t *testing.T) {
6363
tests := []struct {
6464
name string
65-
objects []controllerruntimeclient.Object
65+
objects []ctrlruntimeclient.Object
6666
clientConfig *rest.Config
6767
err error
6868
resConfig string
6969
}{
7070
{
7171
name: "successful from configmap",
72-
objects: []controllerruntimeclient.Object{&corev1.ConfigMap{
72+
objects: []ctrlruntimeclient.Object{&corev1.ConfigMap{
7373
ObjectMeta: metav1.ObjectMeta{
7474
Name: "cluster-info",
7575
Namespace: "kube-public",
@@ -82,7 +82,7 @@ func TestKubeconfigProvider_GetKubeconfig(t *testing.T) {
8282
},
8383
{
8484
name: "successful from in-cluster via endpoints - clusterIP",
85-
objects: []controllerruntimeclient.Object{&corev1.Endpoints{
85+
objects: []ctrlruntimeclient.Object{&corev1.Endpoints{
8686
ObjectMeta: metav1.ObjectMeta{
8787
Name: "kubernetes",
8888
Namespace: "default",
@@ -118,7 +118,7 @@ func TestKubeconfigProvider_GetKubeconfig(t *testing.T) {
118118
for _, test := range tests {
119119
t.Run(test.name, func(t *testing.T) {
120120
ctx := context.Background()
121-
client := ctrlruntimefake.
121+
client := ctrlruntimefakeclient.
122122
NewClientBuilder().
123123
WithScheme(scheme.Scheme).
124124
WithObjects(test.objects...).

0 commit comments

Comments
 (0)