Skip to content

Commit

Permalink
First part of go-1.22 migration, zap to come
Browse files Browse the repository at this point in the history
  • Loading branch information
majst01 committed Feb 19, 2024
1 parent 6eb6b52 commit bbaa8be
Show file tree
Hide file tree
Showing 5 changed files with 235 additions and 758 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ jobs:
password: ${{ secrets.DOCKER_REGISTRY_TOKEN }}

- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set up Go 1.20
uses: actions/setup-go@v4
- name: Set up Go 1.22
uses: actions/setup-go@v5
with:
go-version: '1.20'
go-version: '1.22'

- name: Lint
uses: golangci/golangci-lint-action@v3
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM ghcr.io/metal-stack/builder:latest as builder

FROM alpine:3.17
FROM alpine:3.19
RUN apk add --no-cache tini ca-certificates
COPY --from=builder /work/bin/metal-image-cache-sync /metal-image-cache-sync
CMD ["/metal-image-cache-sync"]
30 changes: 15 additions & 15 deletions cmd/internal/sync/syncer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func Test_currentFileIndex(t *testing.T) {
tt := tt
t.Run(tt.name, func(t *testing.T) {
fs := afero.NewMemMapFs()
require.Nil(t, fs.MkdirAll(cacheRoot, 0755))
require.NoError(t, fs.MkdirAll(cacheRoot, 0755))
if tt.fsModFunc != nil {
tt.fsModFunc(t, fs)
}
Expand All @@ -97,14 +97,14 @@ func Test_currentFileIndex(t *testing.T) {
func createTestFile(t *testing.T, fs afero.Fs, p string) {
createTestDir(t, fs, path.Base(p))
f, err := fs.Create(p)
require.Nil(t, err)
require.NoError(t, err)
defer f.Close()
_, err = f.WriteString("Test")
require.Nil(t, err)
require.NoError(t, err)
}

func createTestDir(t *testing.T, fs afero.Fs, p string) {
require.Nil(t, fs.MkdirAll(p, 0755))
require.NoError(t, fs.MkdirAll(p, 0755))
}

func dlLoggingSvc(data []byte) (*s3.S3, *[]string, *[]string) {
Expand Down Expand Up @@ -311,7 +311,7 @@ func TestSyncer_defineImageDiff(t *testing.T) {
tt := tt
t.Run(tt.name, func(t *testing.T) {
fs := afero.NewMemMapFs()
require.Nil(t, fs.MkdirAll(cacheRoot, 0755))
require.NoError(t, fs.MkdirAll(cacheRoot, 0755))
if tt.fsModFunc != nil {
tt.fsModFunc(t, fs)
}
Expand Down Expand Up @@ -371,7 +371,7 @@ func Test_cleanEmptyDirs(t *testing.T) {
},
fsCheckFunc: func(t *testing.T, fs afero.Fs) {
exists, err := afero.Exists(fs, cacheRoot+"/ubuntu")
assert.NoError(t, err)
require.NoError(t, err)
assert.False(t, exists, "dir still exists")
},
wantErr: nil,
Expand All @@ -383,15 +383,15 @@ func Test_cleanEmptyDirs(t *testing.T) {
},
fsCheckFunc: func(t *testing.T, fs afero.Fs) {
exists, err := afero.Exists(fs, cacheRoot+"/ubuntu/20.10/20201027")
assert.NoError(t, err)
require.NoError(t, err)
assert.False(t, exists, "dir still exists")

exists, err = afero.Exists(fs, cacheRoot+"/ubuntu/20.10")
assert.NoError(t, err)
require.NoError(t, err)
assert.False(t, exists, "dir still exists")

exists, err = afero.Exists(fs, cacheRoot+"/ubuntu")
assert.NoError(t, err)
require.NoError(t, err)
assert.False(t, exists, "dir still exists")
},
wantErr: nil,
Expand All @@ -404,15 +404,15 @@ func Test_cleanEmptyDirs(t *testing.T) {
},
fsCheckFunc: func(t *testing.T, fs afero.Fs) {
exists, err := afero.Exists(fs, cacheRoot+"/ubuntu/20.10/20201027")
assert.NoError(t, err)
require.NoError(t, err)
assert.False(t, exists, "dir still exists")

exists, err = afero.Exists(fs, cacheRoot+"/ubuntu/20.10")
assert.NoError(t, err)
require.NoError(t, err)
assert.False(t, exists, "dir still exists")

exists, err = afero.Exists(fs, cacheRoot+"/ubuntu")
assert.NoError(t, err)
require.NoError(t, err)
assert.True(t, exists, "dir was deleted")
},
wantErr: nil,
Expand All @@ -438,7 +438,7 @@ func Test_cleanEmptyDirs(t *testing.T) {
"/firewall/2.0.20210207",
} {
exists, err := afero.Exists(fs, cacheRoot+subPath)
assert.NoError(t, err)
require.NoError(t, err)
assert.False(t, exists, "dir still exists")
}

Expand All @@ -451,7 +451,7 @@ func Test_cleanEmptyDirs(t *testing.T) {
"/firewall/2.0/20210304/img.tar.lz4.md5",
} {
exists, err := afero.Exists(fs, cacheRoot+subPath)
assert.NoError(t, err)
require.NoError(t, err)
assert.True(t, exists, "dir was deleted")
}
},
Expand All @@ -462,7 +462,7 @@ func Test_cleanEmptyDirs(t *testing.T) {
tt := tt
t.Run(tt.name, func(t *testing.T) {
fs := afero.NewMemMapFs()
require.Nil(t, fs.MkdirAll(cacheRoot, 0755))
require.NoError(t, fs.MkdirAll(cacheRoot, 0755))
if tt.fsModFunc != nil {
tt.fsModFunc(t, fs)
}
Expand Down
127 changes: 64 additions & 63 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,100 +1,101 @@
module github.com/metal-stack/metal-image-cache-sync

go 1.20
go 1.22

require (
github.com/Masterminds/semver/v3 v3.2.0
github.com/aws/aws-sdk-go v1.44.232
github.com/Masterminds/semver/v3 v3.2.1
github.com/aws/aws-sdk-go v1.50.20
github.com/docker/go-units v0.5.0
github.com/go-openapi/strfmt v0.21.7
github.com/go-playground/validator/v10 v10.12.0
github.com/google/go-cmp v0.5.9
github.com/metal-stack/metal-go v0.22.3
github.com/go-openapi/strfmt v0.22.0
github.com/go-playground/validator/v10 v10.18.0
github.com/google/go-cmp v0.6.0
github.com/metal-stack/metal-go v0.28.0
github.com/metal-stack/v v1.0.3
github.com/olekukonko/tablewriter v0.0.5
github.com/prometheus/client_golang v1.14.0
github.com/prometheus/client_golang v1.18.0
github.com/robfig/cron/v3 v3.0.1
github.com/spf13/afero v1.9.5
github.com/spf13/cobra v1.6.1
github.com/spf13/viper v1.15.0
github.com/stretchr/testify v1.8.2
go.uber.org/zap v1.24.0
sigs.k8s.io/controller-runtime v0.14.6
github.com/spf13/afero v1.11.0
github.com/spf13/cobra v1.8.0
github.com/spf13/viper v1.18.2
github.com/stretchr/testify v1.8.4
go.uber.org/zap v1.26.0
sigs.k8s.io/controller-runtime v0.17.2
)

require (
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 // indirect
github.com/benbjohnson/clock v1.3.0 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/coreos/go-oidc/v3 v3.5.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.1.0 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/go-jose/go-jose/v3 v3.0.0 // indirect
github.com/go-logr/logr v1.2.3 // indirect
github.com/coreos/go-oidc/v3 v3.9.0 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/gabriel-vasile/mimetype v1.4.3 // indirect
github.com/go-jose/go-jose/v3 v3.0.1 // indirect
github.com/go-logr/logr v1.4.1 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-openapi/analysis v0.21.4 // indirect
github.com/go-openapi/errors v0.20.3 // indirect
github.com/go-openapi/jsonpointer v0.19.6 // indirect
github.com/go-openapi/jsonreference v0.20.2 // indirect
github.com/go-openapi/loads v0.21.2 // indirect
github.com/go-openapi/runtime v0.25.0 // indirect
github.com/go-openapi/spec v0.20.8 // indirect
github.com/go-openapi/swag v0.22.3 // indirect
github.com/go-openapi/validate v0.22.1 // indirect
github.com/go-openapi/analysis v0.22.2 // indirect
github.com/go-openapi/errors v0.21.0 // indirect
github.com/go-openapi/jsonpointer v0.20.2 // indirect
github.com/go-openapi/jsonreference v0.20.4 // indirect
github.com/go-openapi/loads v0.21.5 // indirect
github.com/go-openapi/runtime v0.27.1 // indirect
github.com/go-openapi/spec v0.20.14 // indirect
github.com/go-openapi/swag v0.22.9 // indirect
github.com/go-openapi/validate v0.23.0 // indirect
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/goccy/go-json v0.10.2 // indirect
github.com/golang-jwt/jwt/v4 v4.5.0 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/gorilla/mux v1.8.0 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/gorilla/mux v1.8.1 // indirect
github.com/hashicorp/hcl v1.0.0 // 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/leodido/go-urn v1.2.2 // indirect
github.com/lestrrat-go/backoff/v2 v2.0.8 // indirect
github.com/lestrrat-go/blackmagic v1.0.1 // 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
github.com/lestrrat-go/httprc v1.0.4 // indirect
github.com/lestrrat-go/iter v1.0.2 // indirect
github.com/lestrrat-go/jwx v1.2.25 // indirect
github.com/lestrrat-go/jwx/v2 v2.0.19 // indirect
github.com/lestrrat-go/option v1.0.1 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-runewidth v0.0.14 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
github.com/metal-stack/metal-lib v0.11.6 // indirect
github.com/metal-stack/security v0.6.6 // indirect
github.com/mattn/go-runewidth v0.0.15 // indirect
github.com/metal-stack/metal-lib v0.14.4 // indirect
github.com/metal-stack/security v0.7.2 // indirect
github.com/mitchellh/mapstructure v1.5.0 // 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.0.7 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_model v0.3.0 // indirect
github.com/prometheus/common v0.42.0 // indirect
github.com/prometheus/procfs v0.9.0 // indirect
github.com/rivo/uniseg v0.4.4 // indirect
github.com/spf13/cast v1.5.0 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/pelletier/go-toml/v2 v2.1.1 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/prometheus/client_model v0.6.0 // indirect
github.com/prometheus/common v0.47.0 // indirect
github.com/prometheus/procfs v0.12.0 // indirect
github.com/rivo/uniseg v0.4.7 // indirect
github.com/sagikazarmark/locafero v0.4.0 // indirect
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
github.com/segmentio/asm v1.2.0 // indirect
github.com/sourcegraph/conc v0.3.0 // indirect
github.com/spf13/cast v1.6.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/subosito/gotenv v1.4.2 // indirect
go.mongodb.org/mongo-driver v1.11.3 // indirect
go.opentelemetry.io/otel v1.11.1 // indirect
go.opentelemetry.io/otel/trace v1.11.1 // indirect
go.uber.org/atomic v1.10.0 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
go.mongodb.org/mongo-driver v1.14.0 // indirect
go.opentelemetry.io/otel v1.23.1 // indirect
go.opentelemetry.io/otel/metric v1.23.1 // indirect
go.opentelemetry.io/otel/trace v1.23.1 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/crypto v0.7.0 // indirect
golang.org/x/net v0.8.0 // indirect
golang.org/x/oauth2 v0.6.0 // indirect
golang.org/x/sys v0.6.0 // indirect
golang.org/x/text v0.8.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/protobuf v1.30.0 // indirect
golang.org/x/crypto v0.19.0 // indirect
golang.org/x/exp v0.0.0-20240119083558-1b970713d09a // indirect
golang.org/x/net v0.21.0 // indirect
golang.org/x/oauth2 v0.17.0 // indirect
golang.org/x/sync v0.6.0 // indirect
golang.org/x/sys v0.17.0 // indirect
golang.org/x/text v0.14.0 // indirect
google.golang.org/appengine v1.6.8 // indirect
google.golang.org/protobuf v1.32.0 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/square/go-jose.v2 v2.6.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading

0 comments on commit bbaa8be

Please sign in to comment.