Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ jobs:
go-version: '1.24'

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

- name: Make tag
run: |
Expand Down
10 changes: 4 additions & 6 deletions cmd/internal/determine-sync-images/lister.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,7 @@ func (s *SyncLister) DetermineImageSyncList() ([]api.OS, error) {

api.SortOSImagesByName(syncImages)

for {
if sizeCount < s.config.MaxCacheSize {
break
}

for sizeCount < s.config.MaxCacheSize {
syncImages, sizeCount, err = s.reduce(syncImages, sizeCount)
if err != nil {
s.logger.Warn("cannot reduce anymore images (all at minimum size), exceeding maximum cache size")
Expand Down Expand Up @@ -281,7 +277,9 @@ func retrieveContentLength(ctx context.Context, c *http.Client, url string) (int
if err != nil {
return 0, err
}
defer resp.Body.Close()
defer func() {
_ = resp.Body.Close()
}()

if resp.StatusCode != http.StatusOK {
return 0, fmt.Errorf("head request to url did not return OK: %s", url)
Expand Down
11 changes: 8 additions & 3 deletions cmd/internal/sync/syncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,10 @@ func (s *Syncer) fileMD5(filePath string) (string, error) {
if err != nil {
return "", err
}
defer file.Close()
defer func() {
_ = file.Close()
}()

hash := md5.New() // nolint
if _, err := io.Copy(hash, file); err != nil {
return "", err
Expand Down Expand Up @@ -222,7 +225,6 @@ func (s *Syncer) download(rootPath string, e api.CacheEntity) error {
if err != nil {
return fmt.Errorf("error opening file path %s: %w", targetPath, err)
}
defer f.Close()

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

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

s.logger.Info("downloading md5 checksum", "id", e.GetName(), "key", e.GetSubPath(), "to", md5TargetPath)
_, err = e.DownloadMD5(s.stop, &f, s.httpClient, s.s3)
Expand Down
4 changes: 3 additions & 1 deletion cmd/internal/sync/syncer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,9 @@ func createTestFile(t *testing.T, fs afero.Fs, p string) {
createTestDir(t, fs, path.Base(p))
f, err := fs.Create(p)
require.NoError(t, err)
defer f.Close()
defer func() {
_ = f.Close()
}()
_, err = f.WriteString("Test")
require.NoError(t, err)
}
Expand Down
46 changes: 22 additions & 24 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,34 +7,34 @@ require (
github.com/aws/aws-sdk-go v1.55.6
github.com/docker/go-units v0.5.0
github.com/go-openapi/strfmt v0.23.0
github.com/go-playground/validator/v10 v10.25.0
github.com/go-playground/validator/v10 v10.26.0
github.com/google/go-cmp v0.7.0
github.com/metal-stack/metal-go v0.40.4
github.com/metal-stack/metal-go v0.41.1
github.com/metal-stack/v v1.0.3
github.com/olekukonko/tablewriter v0.0.5
github.com/prometheus/client_golang v1.21.1
github.com/prometheus/client_golang v1.22.0
github.com/robfig/cron/v3 v3.0.1
github.com/spf13/afero v1.14.0
github.com/spf13/cobra v1.9.1
github.com/spf13/viper v1.20.0
github.com/spf13/viper v1.20.1
github.com/stretchr/testify v1.10.0
sigs.k8s.io/controller-runtime v0.20.3
sigs.k8s.io/controller-runtime v0.20.4
)

require (
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/coreos/go-oidc/v3 v3.13.0 // indirect
github.com/coreos/go-oidc/v3 v3.14.1 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.4.0 // indirect
github.com/fsnotify/fsnotify v1.8.0 // indirect
github.com/fsnotify/fsnotify v1.9.0 // indirect
github.com/gabriel-vasile/mimetype v1.4.8 // indirect
github.com/go-jose/go-jose/v4 v4.0.5 // indirect
github.com/go-jose/go-jose/v4 v4.1.0 // indirect
github.com/go-logr/logr v1.4.2 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-openapi/analysis v0.23.0 // indirect
github.com/go-openapi/errors v0.22.0 // indirect
github.com/go-openapi/errors v0.22.1 // indirect
github.com/go-openapi/jsonpointer v0.21.1 // indirect
github.com/go-openapi/jsonreference v0.21.0 // indirect
github.com/go-openapi/loads v0.22.0 // indirect
Expand All @@ -46,13 +46,12 @@ require (
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/go-viper/mapstructure/v2 v2.2.1 // indirect
github.com/goccy/go-json v0.10.5 // indirect
github.com/golang-jwt/jwt/v5 v5.2.1 // indirect
github.com/golang-jwt/jwt/v5 v5.2.2 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/gorilla/mux v1.8.1 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/klauspost/compress v1.18.0 // indirect
github.com/leodido/go-urn v1.4.0 // indirect
github.com/lestrrat-go/blackmagic v1.0.2 // indirect
github.com/lestrrat-go/httpcc v1.0.1 // indirect
Expand All @@ -62,19 +61,19 @@ require (
github.com/lestrrat-go/option v1.0.1 // indirect
github.com/mailru/easyjson v0.9.0 // indirect
github.com/mattn/go-runewidth v0.0.16 // indirect
github.com/metal-stack/metal-lib v0.20.2 // indirect
github.com/metal-stack/metal-lib v0.21.0 // indirect
github.com/metal-stack/security v0.9.3 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/oklog/ulid v1.3.1 // indirect
github.com/opentracing/opentracing-go v1.2.0 // indirect
github.com/pelletier/go-toml/v2 v2.2.3 // indirect
github.com/pelletier/go-toml/v2 v2.2.4 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/client_model v0.6.2 // indirect
github.com/prometheus/common v0.63.0 // indirect
github.com/prometheus/procfs v0.15.1 // indirect
github.com/prometheus/procfs v0.16.0 // indirect
github.com/rivo/uniseg v0.4.7 // indirect
github.com/sagikazarmark/locafero v0.8.0 // indirect
github.com/sagikazarmark/locafero v0.9.0 // indirect
github.com/segmentio/asm v1.2.0 // indirect
github.com/sourcegraph/conc v0.3.0 // indirect
github.com/spf13/cast v1.7.1 // indirect
Expand All @@ -86,13 +85,12 @@ require (
go.opentelemetry.io/otel/metric v1.35.0 // indirect
go.opentelemetry.io/otel/trace v1.35.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/crypto v0.36.0 // indirect
golang.org/x/net v0.37.0 // indirect
golang.org/x/oauth2 v0.28.0 // indirect
golang.org/x/sync v0.12.0 // indirect
golang.org/x/sys v0.31.0 // indirect
golang.org/x/text v0.23.0 // indirect
golang.org/x/tools v0.30.0 // indirect
google.golang.org/protobuf v1.36.5 // indirect
golang.org/x/crypto v0.37.0 // indirect
golang.org/x/net v0.39.0 // indirect
golang.org/x/oauth2 v0.29.0 // indirect
golang.org/x/sync v0.13.0 // indirect
golang.org/x/sys v0.32.0 // indirect
golang.org/x/text v0.24.0 // indirect
google.golang.org/protobuf v1.36.6 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading