mirror of
https://github.com/containers/skopeo.git
synced 2025-09-16 23:09:01 +00:00
Merge pull request #1893 from mtrmac/golangci-lint
Fix some golangci-lint-reported nits
This commit is contained in:
@@ -16,7 +16,6 @@ func TestDockerRepositoryReferenceParser(t *testing.T) {
|
|||||||
{"docker://somehost.com"}, // Valid default expansion
|
{"docker://somehost.com"}, // Valid default expansion
|
||||||
{"docker://nginx"}, // Valid default expansion
|
{"docker://nginx"}, // Valid default expansion
|
||||||
} {
|
} {
|
||||||
|
|
||||||
ref, err := parseDockerRepositoryReference(test[0])
|
ref, err := parseDockerRepositoryReference(test[0])
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
expected, err := alltransports.ParseImageName(test[0])
|
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://somehost.com", "docker.io/library/somehost.com"}, // Valid default expansion
|
||||||
{"docker://nginx", "docker.io/library/nginx"}, // Valid default expansion
|
{"docker://nginx", "docker.io/library/nginx"}, // Valid default expansion
|
||||||
} {
|
} {
|
||||||
|
|
||||||
ref, err := parseDockerRepositoryReference(test[0])
|
ref, err := parseDockerRepositoryReference(test[0])
|
||||||
ref2, err2 := alltransports.ParseImageName(test[0])
|
ref2, err2 := alltransports.ParseImageName(test[0])
|
||||||
|
|
||||||
|
@@ -668,7 +668,7 @@ func (h *proxyHandler) GetLayerInfo(args []any) (replyBuf, error) {
|
|||||||
layerInfos = img.LayerInfos()
|
layerInfos = img.LayerInfos()
|
||||||
}
|
}
|
||||||
|
|
||||||
var layers []convertedLayerInfo
|
layers := make([]convertedLayerInfo, 0, len(layerInfos))
|
||||||
for _, layer := range layerInfos {
|
for _, layer := range layerInfos {
|
||||||
layers = append(layers, convertedLayerInfo{layer.Digest, layer.Size, layer.MediaType})
|
layers = append(layers, convertedLayerInfo{layer.Digest, layer.Size, layer.MediaType})
|
||||||
}
|
}
|
||||||
|
@@ -132,7 +132,7 @@ See skopeo-sync(1) for details.
|
|||||||
}
|
}
|
||||||
|
|
||||||
// UnmarshalYAML is the implementation of the Unmarshaler interface method
|
// 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
|
// It unmarshals the 'tls-verify' YAML key so that, when they key is not
|
||||||
// specified, tls verification is enforced.
|
// specified, tls verification is enforced.
|
||||||
func (tls *tlsVerifyConfig) UnmarshalYAML(value *yaml.Node) error {
|
func (tls *tlsVerifyConfig) UnmarshalYAML(value *yaml.Node) error {
|
||||||
|
@@ -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
|
// since there is a shared authfile image option and a non-shared (prefixed) one, make sure the override logic
|
||||||
// works correctly.
|
// works correctly.
|
||||||
func TestImageOptionsAuthfileOverride(t *testing.T) {
|
func TestImageOptionsAuthfileOverride(t *testing.T) {
|
||||||
|
|
||||||
for _, testCase := range []struct {
|
for _, testCase := range []struct {
|
||||||
flagPrefix string
|
flagPrefix string
|
||||||
cmdFlags []string
|
cmdFlags []string
|
||||||
|
@@ -39,15 +39,12 @@ func (s *SkopeoSuite) TearDownSuite(c *check.C) {
|
|||||||
s.regV2.tearDown(c)
|
s.regV2.tearDown(c)
|
||||||
}
|
}
|
||||||
if s.regV2WithAuth != nil {
|
if s.regV2WithAuth != nil {
|
||||||
//cmd := exec.Command("docker", "logout", s.regV2WithAuth)
|
// cmd := exec.Command("docker", "logout", s.regV2WithAuth)
|
||||||
//c.Assert(cmd.Run(), check.IsNil)
|
// c.Assert(cmd.Run(), check.IsNil)
|
||||||
s.regV2WithAuth.tearDown(c)
|
s.regV2WithAuth.tearDown(c)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO like dockerCmd but much easier, just out,err
|
|
||||||
//func skopeoCmd()
|
|
||||||
|
|
||||||
func (s *SkopeoSuite) TestVersion(c *check.C) {
|
func (s *SkopeoSuite) TestVersion(c *check.C) {
|
||||||
assertSkopeoSucceeds(c, fmt.Sprintf(".*%s version %s.*", skopeoBinary, version.Version),
|
assertSkopeoSucceeds(c, fmt.Sprintf(".*%s version %s.*", skopeoBinary, version.Version),
|
||||||
"--version")
|
"--version")
|
||||||
|
@@ -567,7 +567,7 @@ func matchLayerBlobBinaryType(c *check.C, ociImageDirPath string, contentType st
|
|||||||
c.Assert(err, check.IsNil)
|
c.Assert(err, check.IsNil)
|
||||||
|
|
||||||
if layerContentType == contentType {
|
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) {
|
func getFileContentType(out *os.File) (string, error) {
|
||||||
buffer := make([]byte, 512)
|
buffer := make([]byte, 512)
|
||||||
_, err := out.Read(buffer)
|
if _, err := out.Read(buffer); err != nil {
|
||||||
if err != nil {
|
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
contentType := http.DetectContentType(buffer)
|
contentType := http.DetectContentType(buffer)
|
||||||
|
@@ -44,7 +44,7 @@ func startOpenshiftCluster(c *check.C) *openshiftCluster {
|
|||||||
return cluster
|
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 {
|
func (cluster *openshiftCluster) clusterCmd(env map[string]string, name string, args ...string) *exec.Cmd {
|
||||||
cmd := exec.Command(name, args...)
|
cmd := exec.Command(name, args...)
|
||||||
cmd.Dir = cluster.workingDir
|
cmd.Dir = cluster.workingDir
|
||||||
|
@@ -7,6 +7,6 @@ import (
|
|||||||
"os/exec"
|
"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) {
|
func cmdLifecycleToParentIfPossible(c *exec.Cmd) {
|
||||||
}
|
}
|
||||||
|
@@ -11,14 +11,13 @@ import (
|
|||||||
"syscall"
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"gopkg.in/check.v1"
|
|
||||||
|
|
||||||
"github.com/containers/image/v5/manifest"
|
"github.com/containers/image/v5/manifest"
|
||||||
imgspecv1 "github.com/opencontainers/image-spec/specs-go/v1"
|
imgspecv1 "github.com/opencontainers/image-spec/specs-go/v1"
|
||||||
|
"gopkg.in/check.v1"
|
||||||
)
|
)
|
||||||
|
|
||||||
// This image is known to be x86_64 only right now
|
// 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
|
// knownNotExtantImage would be very surprising if it did exist
|
||||||
const knownNotExtantImage = "docker://quay.io/centos/centos:opensusewindowsubuntu"
|
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)
|
replybuf := make([]byte, maxMsgSize)
|
||||||
n, oobn, _, _, err := p.c.ReadMsgUnix(replybuf, oob)
|
n, oobn, _, _, err := p.c.ReadMsgUnix(replybuf, oob)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = fmt.Errorf("reading reply: %v", err)
|
err = fmt.Errorf("reading reply: %w", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
var reply reply
|
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
|
var scms []syscall.SocketControlMessage
|
||||||
scms, err = syscall.ParseSocketControlMessage(oob[:oobn])
|
scms, err = syscall.ParseSocketControlMessage(oob[:oobn])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = fmt.Errorf("failed to parse control message: %v", err)
|
err = fmt.Errorf("failed to parse control message: %w", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if len(scms) != 1 {
|
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
|
var fds []int
|
||||||
fds, err = syscall.ParseUnixRights(&scms[0])
|
fds, err = syscall.ParseUnixRights(&scms[0])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = fmt.Errorf("failed to parse unix rights: %v", err)
|
err = fmt.Errorf("failed to parse unix rights: %w", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
fd = &pipefd{
|
fd = &pipefd{
|
||||||
@@ -233,7 +232,7 @@ type byteFetch struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func runTestGetManifestAndConfig(p *proxy, img string) error {
|
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 {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -248,7 +247,7 @@ func runTestGetManifestAndConfig(p *proxy, img string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Also verify the optional path
|
// Also verify the optional path
|
||||||
v, err = p.callNoFd("OpenImageOptional", []any{knownNotManifestListedImage_x8664})
|
v, err = p.callNoFd("OpenImageOptional", []any{knownNotManifestListedImageX8664})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -339,9 +338,9 @@ func (s *ProxySuite) TestProxy(c *check.C) {
|
|||||||
p, err := newProxy()
|
p, err := newProxy()
|
||||||
c.Assert(err, check.IsNil)
|
c.Assert(err, check.IsNil)
|
||||||
|
|
||||||
err = runTestGetManifestAndConfig(p, knownNotManifestListedImage_x8664)
|
err = runTestGetManifestAndConfig(p, knownNotManifestListedImageX8664)
|
||||||
if err != nil {
|
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)
|
c.Assert(err, check.IsNil)
|
||||||
|
|
||||||
|
@@ -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) {
|
func consumeAndLogOutputs(c *check.C, id string, cmd *exec.Cmd) {
|
||||||
stdout, err := cmd.StdoutPipe()
|
stdout, err := cmd.StdoutPipe()
|
||||||
consumeAndLogOutputStream(c, id+" stdout", stdout, err)
|
consumeAndLogOutputStream(c, id+" stdout", stdout, err)
|
||||||
|
Reference in New Issue
Block a user