diff --git a/cmd/skopeo/list_tags_test.go b/cmd/skopeo/list_tags_test.go index f0734eb3..2b3cc2d5 100644 --- a/cmd/skopeo/list_tags_test.go +++ b/cmd/skopeo/list_tags_test.go @@ -16,7 +16,6 @@ func TestDockerRepositoryReferenceParser(t *testing.T) { {"docker://somehost.com"}, // Valid default expansion {"docker://nginx"}, // Valid default expansion } { - ref, err := parseDockerRepositoryReference(test[0]) require.NoError(t, err) expected, err := alltransports.ParseImageName(test[0]) @@ -47,7 +46,6 @@ func TestDockerRepositoryReferenceParserDrift(t *testing.T) { {"docker://somehost.com", "docker.io/library/somehost.com"}, // Valid default expansion {"docker://nginx", "docker.io/library/nginx"}, // Valid default expansion } { - ref, err := parseDockerRepositoryReference(test[0]) ref2, err2 := alltransports.ParseImageName(test[0]) diff --git a/cmd/skopeo/proxy.go b/cmd/skopeo/proxy.go index eb819acd..d15f3ee7 100644 --- a/cmd/skopeo/proxy.go +++ b/cmd/skopeo/proxy.go @@ -668,7 +668,7 @@ func (h *proxyHandler) GetLayerInfo(args []any) (replyBuf, error) { layerInfos = img.LayerInfos() } - var layers []convertedLayerInfo + layers := make([]convertedLayerInfo, 0, len(layerInfos)) for _, layer := range layerInfos { layers = append(layers, convertedLayerInfo{layer.Digest, layer.Size, layer.MediaType}) } diff --git a/cmd/skopeo/sync.go b/cmd/skopeo/sync.go index 1c86acf5..392d7696 100644 --- a/cmd/skopeo/sync.go +++ b/cmd/skopeo/sync.go @@ -132,7 +132,7 @@ See skopeo-sync(1) for details. } // UnmarshalYAML is the implementation of the Unmarshaler interface method -// method for the tlsVerifyConfig type. +// for the tlsVerifyConfig type. // It unmarshals the 'tls-verify' YAML key so that, when they key is not // specified, tls verification is enforced. func (tls *tlsVerifyConfig) UnmarshalYAML(value *yaml.Node) error { diff --git a/cmd/skopeo/utils_test.go b/cmd/skopeo/utils_test.go index f5160b22..150e4ec2 100644 --- a/cmd/skopeo/utils_test.go +++ b/cmd/skopeo/utils_test.go @@ -385,7 +385,6 @@ func TestParseManifestFormat(t *testing.T) { // since there is a shared authfile image option and a non-shared (prefixed) one, make sure the override logic // works correctly. func TestImageOptionsAuthfileOverride(t *testing.T) { - for _, testCase := range []struct { flagPrefix string cmdFlags []string diff --git a/integration/check_test.go b/integration/check_test.go index 56f245e4..6b6a9c64 100644 --- a/integration/check_test.go +++ b/integration/check_test.go @@ -39,15 +39,12 @@ func (s *SkopeoSuite) TearDownSuite(c *check.C) { s.regV2.tearDown(c) } if s.regV2WithAuth != nil { - //cmd := exec.Command("docker", "logout", s.regV2WithAuth) - //c.Assert(cmd.Run(), check.IsNil) + // cmd := exec.Command("docker", "logout", s.regV2WithAuth) + // c.Assert(cmd.Run(), check.IsNil) s.regV2WithAuth.tearDown(c) } } -// TODO like dockerCmd but much easier, just out,err -//func skopeoCmd() - func (s *SkopeoSuite) TestVersion(c *check.C) { assertSkopeoSucceeds(c, fmt.Sprintf(".*%s version %s.*", skopeoBinary, version.Version), "--version") diff --git a/integration/copy_test.go b/integration/copy_test.go index ee530b04..39a5cea4 100644 --- a/integration/copy_test.go +++ b/integration/copy_test.go @@ -567,7 +567,7 @@ func matchLayerBlobBinaryType(c *check.C, ociImageDirPath string, contentType st c.Assert(err, check.IsNil) if layerContentType == contentType { - foundCount = foundCount + 1 + foundCount++ } } @@ -576,8 +576,7 @@ func matchLayerBlobBinaryType(c *check.C, ociImageDirPath string, contentType st func getFileContentType(out *os.File) (string, error) { buffer := make([]byte, 512) - _, err := out.Read(buffer) - if err != nil { + if _, err := out.Read(buffer); err != nil { return "", err } contentType := http.DetectContentType(buffer) diff --git a/integration/openshift.go b/integration/openshift.go index 635d010d..c822c560 100644 --- a/integration/openshift.go +++ b/integration/openshift.go @@ -44,7 +44,7 @@ func startOpenshiftCluster(c *check.C) *openshiftCluster { return cluster } -// clusterCmd creates an exec.Cmd in cluster.workingDir with current environment modified by environment +// clusterCmd creates an exec.Cmd in cluster.workingDir with current environment modified by environment. func (cluster *openshiftCluster) clusterCmd(env map[string]string, name string, args ...string) *exec.Cmd { cmd := exec.Command(name, args...) cmd.Dir = cluster.workingDir diff --git a/integration/procutils.go b/integration/procutils.go index c6a59f18..e53f94b5 100644 --- a/integration/procutils.go +++ b/integration/procutils.go @@ -7,6 +7,6 @@ import ( "os/exec" ) -// cmdLifecycleToParentIfPossible tries to exit if the parent process exits (only works on Linux) +// cmdLifecycleToParentIfPossible tries to exit if the parent process exits (only works on Linux). func cmdLifecycleToParentIfPossible(c *exec.Cmd) { } diff --git a/integration/proxy_test.go b/integration/proxy_test.go index 687c6ed4..7fd794b4 100644 --- a/integration/proxy_test.go +++ b/integration/proxy_test.go @@ -11,14 +11,13 @@ import ( "syscall" "time" - "gopkg.in/check.v1" - "github.com/containers/image/v5/manifest" imgspecv1 "github.com/opencontainers/image-spec/specs-go/v1" + "gopkg.in/check.v1" ) // This image is known to be x86_64 only right now -const knownNotManifestListedImage_x8664 = "docker://quay.io/coreos/11bot" +const knownNotManifestListedImageX8664 = "docker://quay.io/coreos/11bot" // knownNotExtantImage would be very surprising if it did exist const knownNotExtantImage = "docker://quay.io/centos/centos:opensusewindowsubuntu" @@ -81,7 +80,7 @@ func (p *proxy) call(method string, args []any) (rval any, fd *pipefd, err error replybuf := make([]byte, maxMsgSize) n, oobn, _, _, err := p.c.ReadMsgUnix(replybuf, oob) if err != nil { - err = fmt.Errorf("reading reply: %v", err) + err = fmt.Errorf("reading reply: %w", err) return } var reply reply @@ -99,7 +98,7 @@ func (p *proxy) call(method string, args []any) (rval any, fd *pipefd, err error var scms []syscall.SocketControlMessage scms, err = syscall.ParseSocketControlMessage(oob[:oobn]) if err != nil { - err = fmt.Errorf("failed to parse control message: %v", err) + err = fmt.Errorf("failed to parse control message: %w", err) return } if len(scms) != 1 { @@ -109,7 +108,7 @@ func (p *proxy) call(method string, args []any) (rval any, fd *pipefd, err error var fds []int fds, err = syscall.ParseUnixRights(&scms[0]) if err != nil { - err = fmt.Errorf("failed to parse unix rights: %v", err) + err = fmt.Errorf("failed to parse unix rights: %w", err) return } fd = &pipefd{ @@ -233,7 +232,7 @@ type byteFetch struct { } func runTestGetManifestAndConfig(p *proxy, img string) error { - v, err := p.callNoFd("OpenImage", []any{knownNotManifestListedImage_x8664}) + v, err := p.callNoFd("OpenImage", []any{knownNotManifestListedImageX8664}) if err != nil { return err } @@ -248,7 +247,7 @@ func runTestGetManifestAndConfig(p *proxy, img string) error { } // Also verify the optional path - v, err = p.callNoFd("OpenImageOptional", []any{knownNotManifestListedImage_x8664}) + v, err = p.callNoFd("OpenImageOptional", []any{knownNotManifestListedImageX8664}) if err != nil { return err } @@ -339,9 +338,9 @@ func (s *ProxySuite) TestProxy(c *check.C) { p, err := newProxy() c.Assert(err, check.IsNil) - err = runTestGetManifestAndConfig(p, knownNotManifestListedImage_x8664) + err = runTestGetManifestAndConfig(p, knownNotManifestListedImageX8664) if err != nil { - err = fmt.Errorf("Testing image %s: %v", knownNotManifestListedImage_x8664, err) + err = fmt.Errorf("Testing image %s: %v", knownNotManifestListedImageX8664, err) } c.Assert(err, check.IsNil) diff --git a/integration/utils.go b/integration/utils.go index b1b7f7b9..b1e049c4 100644 --- a/integration/utils.go +++ b/integration/utils.go @@ -42,7 +42,7 @@ func consumeAndLogOutputStream(c *check.C, id string, f io.ReadCloser, err error }() } -// consumeAndLogOutputs causes all output to stdout and stderr from an *exec.Cmd to be logged to c +// consumeAndLogOutputs causes all output to stdout and stderr from an *exec.Cmd to be logged to c. func consumeAndLogOutputs(c *check.C, id string, cmd *exec.Cmd) { stdout, err := cmd.StdoutPipe() consumeAndLogOutputStream(c, id+" stdout", stdout, err)