Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update go to 1.23 #271

Merged
merged 6 commits into from
Dec 22, 2024
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
80 changes: 68 additions & 12 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,42 +4,98 @@ run:
- containers_image_openpgp
- exclude_graphdriver_btrfs
- exclude_graphdriver_devicemapper
# default uses Go version from the go.mod file, fallback on the env var
# `GOVERSION`, fallback on 1.17: https://golangci-lint.run/usage/configuration/#run-configuration
go: "1.23"

linters:
enable:
- bodyclose
- depguard
- forbidigo
- gocritic
- gofmt
- goimports
- revive
- gosec
- gosimple
- govet
- importas
- ineffassign
- makezero
- misspell
- noctx
- nolintlint
- revive
- staticcheck
- testifylint
- typecheck
- errname
- makezero
- whitespace
- unused
- whitespace
disable-all: true

linters-settings:
gocritic:
disabled-checks:
- "ifElseChain"
- "assignOp"
- "appendAssign"
- "singleCaseSwitch"
- "exitAfterDefer" # FIXME
importas:
alias:
- pkg: "github.com/opencontainers/image-spec/specs-go/v1"
alias: "ocispecs"
- pkg: "github.com/opencontainers/go-digest"
alias: "digest"
govet:
enable:
- nilness
- unusedwrite
depguard:
rules:
main:
deny:
# The io/ioutil package has been deprecated.
# https://go.dev/doc/go1.16#ioutil
- pkg: "io/ioutil"
desc: The io/ioutil package has been deprecated.
importas:
no-unaliased: true
forbidigo:
forbid:
- '^fmt\.Errorf(# use errors\.Errorf instead)?$'
- '^platforms\.DefaultString(# use platforms\.Format(platforms\.DefaultSpec()) instead\.)?$'
gosec:
excludes:
- G204 # Audit use of command execution
- G402 # TLS MinVersion too low
- G115 # integer overflow conversion
config:
G306: "0644"
testifylint:
disable:
# disable rules that reduce the test condition
- "empty"
- "bool-compare"
- "len"
- "negative-positive"

issues:
exclude-rules:
- linters:
- revive
text: "stutters"
- linters:
- revive
text: "empty-block"
- linters:
- revive
text: "superfluous-else"
- linters:
- revive
text: "unused-parameter"
- linters:
- revive
text: "redefines-builtin-id"
- linters:
- revive
text: "if-return"

# show all
max-issues-per-linter: 0
max-same-issues: 0
# show all
max-issues-per-linter: 0
max-same-issues: 0
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# syntax=docker/dockerfile:1

ARG GO_VERSION="1.21"
ARG ALPINE_VERSION="3.18"
ARG XX_VERSION="1.3.0"
ARG GO_VERSION="1.23"
ARG ALPINE_VERSION="3.21"
ARG XX_VERSION="1.6.1"
ARG BUILDTAGS="containers_image_openpgp exclude_graphdriver_btrfs exclude_graphdriver_devicemapper"

FROM --platform=$BUILDPLATFORM tonistiigi/xx:${XX_VERSION} AS xx
Expand Down
2 changes: 1 addition & 1 deletion cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func main() {
runtime.GOMAXPROCS(runtime.NumCPU())

meta.Version = version
meta.UserAgent = fmt.Sprintf("%s/%s go/%s %s", meta.ID, meta.Version, runtime.Version()[2:], strings.Title(runtime.GOOS))
meta.UserAgent = fmt.Sprintf("%s/%s go/%s %s", meta.ID, meta.Version, runtime.Version()[2:], strings.Title(runtime.GOOS)) //nolint:staticcheck // ignoring "SA1019: strings.Title is deprecated", as for our use we don't need full unicode support

_ = kong.Parse(&cli,
kong.Name(meta.ID),
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/crazy-max/undock

go 1.21
go 1.23.0

require (
github.com/alecthomas/kong v0.9.0
Expand Down
6 changes: 3 additions & 3 deletions hack/lint.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# syntax=docker/dockerfile:1

ARG GO_VERSION="1.21"
ARG ALPINE_VERSION="3.18"
ARG GOLANGCI_LINT_VERSION="v1.55"
ARG GO_VERSION="1.23"
ARG ALPINE_VERSION="3.21"
ARG GOLANGCI_LINT_VERSION="v1.62"

FROM golang:${GO_VERSION}-alpine${ALPINE_VERSION} AS base
ENV GOFLAGS="-buildvcs=false"
Expand Down
4 changes: 2 additions & 2 deletions hack/vendor.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# syntax=docker/dockerfile:1

ARG GO_VERSION="1.21"
ARG ALPINE_VERSION="3.18"
ARG GO_VERSION="1.23"
ARG ALPINE_VERSION="3.21"
ARG GOMOD_OUTDATED_VERSION="v0.8.0"

FROM golang:${GO_VERSION}-alpine${ALPINE_VERSION} AS base
Expand Down
4 changes: 2 additions & 2 deletions internal/app/undock.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/crazy-max/undock/internal/config"
ximage "github.com/crazy-max/undock/pkg/extractor/image"
"github.com/crazy-max/undock/pkg/image"
specs "github.com/opencontainers/image-spec/specs-go/v1"
ocispecs "github.com/opencontainers/image-spec/specs-go/v1"
"github.com/pkg/errors"
)

Expand All @@ -18,7 +18,7 @@ type Undock struct {
ctx context.Context
meta config.Meta
cli config.Cli
platform specs.Platform
platform ocispecs.Platform
}

// New creates new undock instance
Expand Down
3 changes: 1 addition & 2 deletions pkg/extractor/blob.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package extractor

import (
"context"
"fmt"
"io"
"io/fs"
"os"
Expand Down Expand Up @@ -93,7 +92,7 @@ func ExtractBlob(filename string, dest string, opts ExtractBlobOpts) error {
case f.FileInfo.Mode()&fs.ModeSymlink != 0:
return writeSymlink(ctx, path, f)
default:
return fmt.Errorf("cannot handle file mode: %v", f.FileInfo.Mode())
return errors.Errorf("cannot handle file mode: %v", f.FileInfo.Mode())
}
})
}
Expand Down
10 changes: 5 additions & 5 deletions pkg/extractor/image/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/containerd/containerd/platforms"
"github.com/containers/image/v5/manifest"
"github.com/crazy-max/undock/pkg/extractor"
specs "github.com/opencontainers/image-spec/specs-go/v1"
ocispecs "github.com/opencontainers/image-spec/specs-go/v1"
"github.com/pkg/errors"
"github.com/rs/zerolog"
"github.com/rs/zerolog/log"
Expand All @@ -31,7 +31,7 @@ type Options struct {
// Source image reference
Source string
// Platform to enforce for Source image
Platform specs.Platform
Platform ocispecs.Platform
// Includes a subset of files/dirs from the Source image
Includes []string
// All extracts all architectures if Source image is a manifest list
Expand Down Expand Up @@ -102,14 +102,14 @@ func (c *Client) Extract() error {
}

type manifestEntry struct {
platform specs.Platform
platform ocispecs.Platform
manifest *manifest.OCI1
}

var mans []manifestEntry

mtype := manifest.GuessMIMEType(manblob)
if mtype == specs.MediaTypeImageManifest {
if mtype == ocispecs.MediaTypeImageManifest {
man, err := manifest.OCI1FromManifest(manblob)
if err != nil {
return errors.Wrap(err, "cannot create OCI manifest instance from blob")
Expand All @@ -118,7 +118,7 @@ func (c *Client) Extract() error {
platform: c.opts.Platform,
manifest: man,
})
} else if mtype == specs.MediaTypeImageIndex {
} else if mtype == ocispecs.MediaTypeImageIndex {
ocindex, err := manifest.OCI1IndexFromManifest(manblob)
if err != nil {
return errors.Wrap(err, "cannot create OCI manifest index instance from blob")
Expand Down
6 changes: 2 additions & 4 deletions pkg/image/ref.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,8 @@ func Reference(name string) (reference.Named, error) {
ref, err := reference.ParseNormalizedNamed(name)
if err != nil {
return nil, errors.Wrapf(err, "parsing normalized named %q", name)
}

if _, ok := ref.(reference.Named); !ok {
return nil, fmt.Errorf("%q is not a named reference", name)
} else if ref == nil {
return nil, errors.Errorf("%q is not a named reference", name)
}

if _, hasTag := ref.(reference.NamedTagged); hasTag {
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading