Skip to content

Commit 3d2b399

Browse files
authored
Migrate to golangci lint v2 and satisfy new warnings (#19)
1 parent 1085750 commit 3d2b399

File tree

9 files changed

+97
-89
lines changed

9 files changed

+97
-89
lines changed

.github/workflows/docker.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ jobs:
3737
go-version: '1.24'
3838

3939
- name: Lint
40-
uses: golangci/golangci-lint-action@v6
40+
uses: golangci/golangci-lint-action@v7
4141
with:
42-
args: --build-tags integration -p bugs -p unused --timeout=3m
42+
args: --build-tags integration --timeout=3m
4343

4444
- name: Make tag
4545
run: |

cmd/internal/determine-sync-images/lister.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -141,11 +141,7 @@ func (s *SyncLister) DetermineImageSyncList() ([]api.OS, error) {
141141

142142
api.SortOSImagesByName(syncImages)
143143

144-
for {
145-
if sizeCount < s.config.MaxCacheSize {
146-
break
147-
}
148-
144+
for sizeCount < s.config.MaxCacheSize {
149145
syncImages, sizeCount, err = s.reduce(syncImages, sizeCount)
150146
if err != nil {
151147
s.logger.Warn("cannot reduce anymore images (all at minimum size), exceeding maximum cache size")
@@ -281,7 +277,9 @@ func retrieveContentLength(ctx context.Context, c *http.Client, url string) (int
281277
if err != nil {
282278
return 0, err
283279
}
284-
defer resp.Body.Close()
280+
defer func() {
281+
_ = resp.Body.Close()
282+
}()
285283

286284
if resp.StatusCode != http.StatusOK {
287285
return 0, fmt.Errorf("head request to url did not return OK: %s", url)

cmd/internal/sync/syncer.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,10 @@ func (s *Syncer) fileMD5(filePath string) (string, error) {
190190
if err != nil {
191191
return "", err
192192
}
193-
defer file.Close()
193+
defer func() {
194+
_ = file.Close()
195+
}()
196+
194197
hash := md5.New() // nolint
195198
if _, err := io.Copy(hash, file); err != nil {
196199
return "", err
@@ -222,7 +225,6 @@ func (s *Syncer) download(rootPath string, e api.CacheEntity) error {
222225
if err != nil {
223226
return fmt.Errorf("error opening file path %s: %w", targetPath, err)
224227
}
225-
defer f.Close()
226228

227229
s.logger.Info("downloading file", "id", e.GetName(), "key", e.GetSubPath(), "size", e.GetSize(), "to", tmpTargetPath)
228230
n, err := e.Download(s.stop, f, s.httpClient, s.s3)
@@ -231,6 +233,7 @@ func (s *Syncer) download(rootPath string, e api.CacheEntity) error {
231233
}
232234
defer func() {
233235
_ = s.fs.Remove(tmpTargetPath)
236+
_ = f.Close()
234237
}()
235238

236239
switch ent := e.(type) {
@@ -257,7 +260,9 @@ func (s *Syncer) download(rootPath string, e api.CacheEntity) error {
257260
if err != nil {
258261
return fmt.Errorf("error opening file path %s: %w", md5TargetPath, err)
259262
}
260-
defer f.Close()
263+
defer func() {
264+
_ = f.Close()
265+
}()
261266

262267
s.logger.Info("downloading md5 checksum", "id", e.GetName(), "key", e.GetSubPath(), "to", md5TargetPath)
263268
_, err = e.DownloadMD5(s.stop, &f, s.httpClient, s.s3)

cmd/internal/sync/syncer_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,9 @@ func createTestFile(t *testing.T, fs afero.Fs, p string) {
9898
createTestDir(t, fs, path.Base(p))
9999
f, err := fs.Create(p)
100100
require.NoError(t, err)
101-
defer f.Close()
101+
defer func() {
102+
_ = f.Close()
103+
}()
102104
_, err = f.WriteString("Test")
103105
require.NoError(t, err)
104106
}

go.mod

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -7,34 +7,34 @@ require (
77
github.com/aws/aws-sdk-go v1.55.6
88
github.com/docker/go-units v0.5.0
99
github.com/go-openapi/strfmt v0.23.0
10-
github.com/go-playground/validator/v10 v10.25.0
10+
github.com/go-playground/validator/v10 v10.26.0
1111
github.com/google/go-cmp v0.7.0
12-
github.com/metal-stack/metal-go v0.40.4
12+
github.com/metal-stack/metal-go v0.41.1
1313
github.com/metal-stack/v v1.0.3
1414
github.com/olekukonko/tablewriter v0.0.5
15-
github.com/prometheus/client_golang v1.21.1
15+
github.com/prometheus/client_golang v1.22.0
1616
github.com/robfig/cron/v3 v3.0.1
1717
github.com/spf13/afero v1.14.0
1818
github.com/spf13/cobra v1.9.1
19-
github.com/spf13/viper v1.20.0
19+
github.com/spf13/viper v1.20.1
2020
github.com/stretchr/testify v1.10.0
21-
sigs.k8s.io/controller-runtime v0.20.3
21+
sigs.k8s.io/controller-runtime v0.20.4
2222
)
2323

2424
require (
2525
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 // indirect
2626
github.com/beorn7/perks v1.0.1 // indirect
2727
github.com/cespare/xxhash/v2 v2.3.0 // indirect
28-
github.com/coreos/go-oidc/v3 v3.13.0 // indirect
28+
github.com/coreos/go-oidc/v3 v3.14.1 // indirect
2929
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
3030
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.4.0 // indirect
31-
github.com/fsnotify/fsnotify v1.8.0 // indirect
31+
github.com/fsnotify/fsnotify v1.9.0 // indirect
3232
github.com/gabriel-vasile/mimetype v1.4.8 // indirect
33-
github.com/go-jose/go-jose/v4 v4.0.5 // indirect
33+
github.com/go-jose/go-jose/v4 v4.1.0 // indirect
3434
github.com/go-logr/logr v1.4.2 // indirect
3535
github.com/go-logr/stdr v1.2.2 // indirect
3636
github.com/go-openapi/analysis v0.23.0 // indirect
37-
github.com/go-openapi/errors v0.22.0 // indirect
37+
github.com/go-openapi/errors v0.22.1 // indirect
3838
github.com/go-openapi/jsonpointer v0.21.1 // indirect
3939
github.com/go-openapi/jsonreference v0.21.0 // indirect
4040
github.com/go-openapi/loads v0.22.0 // indirect
@@ -46,13 +46,12 @@ require (
4646
github.com/go-playground/universal-translator v0.18.1 // indirect
4747
github.com/go-viper/mapstructure/v2 v2.2.1 // indirect
4848
github.com/goccy/go-json v0.10.5 // indirect
49-
github.com/golang-jwt/jwt/v5 v5.2.1 // indirect
49+
github.com/golang-jwt/jwt/v5 v5.2.2 // indirect
5050
github.com/google/uuid v1.6.0 // indirect
5151
github.com/gorilla/mux v1.8.1 // indirect
5252
github.com/inconshreveable/mousetrap v1.1.0 // indirect
5353
github.com/jmespath/go-jmespath v0.4.0 // indirect
5454
github.com/josharian/intern v1.0.0 // indirect
55-
github.com/klauspost/compress v1.18.0 // indirect
5655
github.com/leodido/go-urn v1.4.0 // indirect
5756
github.com/lestrrat-go/blackmagic v1.0.2 // indirect
5857
github.com/lestrrat-go/httpcc v1.0.1 // indirect
@@ -62,19 +61,19 @@ require (
6261
github.com/lestrrat-go/option v1.0.1 // indirect
6362
github.com/mailru/easyjson v0.9.0 // indirect
6463
github.com/mattn/go-runewidth v0.0.16 // indirect
65-
github.com/metal-stack/metal-lib v0.20.2 // indirect
64+
github.com/metal-stack/metal-lib v0.21.0 // indirect
6665
github.com/metal-stack/security v0.9.3 // indirect
6766
github.com/mitchellh/mapstructure v1.5.0 // indirect
6867
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
6968
github.com/oklog/ulid v1.3.1 // indirect
7069
github.com/opentracing/opentracing-go v1.2.0 // indirect
71-
github.com/pelletier/go-toml/v2 v2.2.3 // indirect
70+
github.com/pelletier/go-toml/v2 v2.2.4 // indirect
7271
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
73-
github.com/prometheus/client_model v0.6.1 // indirect
72+
github.com/prometheus/client_model v0.6.2 // indirect
7473
github.com/prometheus/common v0.63.0 // indirect
75-
github.com/prometheus/procfs v0.15.1 // indirect
74+
github.com/prometheus/procfs v0.16.0 // indirect
7675
github.com/rivo/uniseg v0.4.7 // indirect
77-
github.com/sagikazarmark/locafero v0.8.0 // indirect
76+
github.com/sagikazarmark/locafero v0.9.0 // indirect
7877
github.com/segmentio/asm v1.2.0 // indirect
7978
github.com/sourcegraph/conc v0.3.0 // indirect
8079
github.com/spf13/cast v1.7.1 // indirect
@@ -86,13 +85,12 @@ require (
8685
go.opentelemetry.io/otel/metric v1.35.0 // indirect
8786
go.opentelemetry.io/otel/trace v1.35.0 // indirect
8887
go.uber.org/multierr v1.11.0 // indirect
89-
golang.org/x/crypto v0.36.0 // indirect
90-
golang.org/x/net v0.37.0 // indirect
91-
golang.org/x/oauth2 v0.28.0 // indirect
92-
golang.org/x/sync v0.12.0 // indirect
93-
golang.org/x/sys v0.31.0 // indirect
94-
golang.org/x/text v0.23.0 // indirect
95-
golang.org/x/tools v0.30.0 // indirect
96-
google.golang.org/protobuf v1.36.5 // indirect
88+
golang.org/x/crypto v0.37.0 // indirect
89+
golang.org/x/net v0.39.0 // indirect
90+
golang.org/x/oauth2 v0.29.0 // indirect
91+
golang.org/x/sync v0.13.0 // indirect
92+
golang.org/x/sys v0.32.0 // indirect
93+
golang.org/x/text v0.24.0 // indirect
94+
google.golang.org/protobuf v1.36.6 // indirect
9795
gopkg.in/yaml.v3 v3.0.1 // indirect
9896
)

0 commit comments

Comments
 (0)