Skip to content

Commit

Permalink
fix lint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
crazy-max committed Dec 22, 2024
1 parent 3c66f80 commit 47b8e7a
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 14 deletions.
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
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

0 comments on commit 47b8e7a

Please sign in to comment.