mirror of
				https://github.com/moby/moby.git
				synced 2022-11-09 12:21:53 -05:00 
			
		
		
		
	Fix golint errors.
Signed-off-by: Daniel Nephin <dnephin@docker.com>
This commit is contained in:
		
							parent
							
								
									d7e2c4ce77
								
							
						
					
					
						commit
						9b47b7b151
					
				
					 29 changed files with 51 additions and 47 deletions
				
			
		| 
						 | 
				
			
			@ -53,6 +53,7 @@ func (v VersionMiddleware) WrapHandler(handler func(ctx context.Context, w http.
 | 
			
		|||
		w.Header().Set("Server", header)
 | 
			
		||||
		w.Header().Set("API-Version", v.defaultVersion)
 | 
			
		||||
		w.Header().Set("OSType", runtime.GOOS)
 | 
			
		||||
		// nolint: golint
 | 
			
		||||
		ctx = context.WithValue(ctx, "api-version", apiVersion)
 | 
			
		||||
		return handler(ctx, w, r, vars)
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -19,7 +19,7 @@ import (
 | 
			
		|||
)
 | 
			
		||||
 | 
			
		||||
var (
 | 
			
		||||
	errDockerfileNotStringArray = errors.New("When using JSON array syntax, arrays must be comprised of strings only.")
 | 
			
		||||
	errDockerfileNotStringArray = errors.New("when using JSON array syntax, arrays must be comprised of strings only")
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
const (
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -453,7 +453,7 @@ func loadDaemonCliConfig(opts *daemonOptions) (*config.Config, error) {
 | 
			
		|||
		c, err := config.MergeDaemonConfigurations(conf, flags, opts.configFile)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			if flags.Changed("config-file") || !os.IsNotExist(err) {
 | 
			
		||||
				return nil, fmt.Errorf("unable to configure the Docker daemon with file %s: %v\n", opts.configFile, err)
 | 
			
		||||
				return nil, fmt.Errorf("unable to configure the Docker daemon with file %s: %v", opts.configFile, err)
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		// the merged configuration can be nil if the config file didn't exist.
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -31,11 +31,11 @@ func (daemon *Daemon) ContainerAttach(prefixOrName string, c *backend.ContainerA
 | 
			
		|||
		return err
 | 
			
		||||
	}
 | 
			
		||||
	if container.IsPaused() {
 | 
			
		||||
		err := fmt.Errorf("Container %s is paused, unpause the container before attach.", prefixOrName)
 | 
			
		||||
		err := fmt.Errorf("container %s is paused, unpause the container before attach", prefixOrName)
 | 
			
		||||
		return stateConflictError{err}
 | 
			
		||||
	}
 | 
			
		||||
	if container.IsRestarting() {
 | 
			
		||||
		err := fmt.Errorf("Container %s is restarting, wait until the container is running.", prefixOrName)
 | 
			
		||||
		err := fmt.Errorf("container %s is restarting, wait until the container is running", prefixOrName)
 | 
			
		||||
		return stateConflictError{err}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -66,7 +66,7 @@ var (
 | 
			
		|||
	// containerd if none is specified
 | 
			
		||||
	DefaultRuntimeBinary = "docker-runc"
 | 
			
		||||
 | 
			
		||||
	errSystemNotSupported = errors.New("The Docker daemon is not supported on this platform.")
 | 
			
		||||
	errSystemNotSupported = errors.New("the Docker daemon is not supported on this platform")
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type daemonStore struct {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -557,13 +557,13 @@ func verifyPlatformContainerSettings(daemon *Daemon, hostConfig *containertypes.
 | 
			
		|||
	// check for various conflicting options with user namespaces
 | 
			
		||||
	if daemon.configStore.RemappedRoot != "" && hostConfig.UsernsMode.IsPrivate() {
 | 
			
		||||
		if hostConfig.Privileged {
 | 
			
		||||
			return warnings, fmt.Errorf("Privileged mode is incompatible with user namespaces.  You must run the container in the host namespace when running privileged mode.")
 | 
			
		||||
			return warnings, fmt.Errorf("privileged mode is incompatible with user namespaces.  You must run the container in the host namespace when running privileged mode")
 | 
			
		||||
		}
 | 
			
		||||
		if hostConfig.NetworkMode.IsHost() && !hostConfig.UsernsMode.IsHost() {
 | 
			
		||||
			return warnings, fmt.Errorf("Cannot share the host's network namespace when user namespaces are enabled")
 | 
			
		||||
			return warnings, fmt.Errorf("cannot share the host's network namespace when user namespaces are enabled")
 | 
			
		||||
		}
 | 
			
		||||
		if hostConfig.PidMode.IsHost() && !hostConfig.UsernsMode.IsHost() {
 | 
			
		||||
			return warnings, fmt.Errorf("Cannot share the host PID namespace when user namespaces are enabled")
 | 
			
		||||
			return warnings, fmt.Errorf("cannot share the host PID namespace when user namespaces are enabled")
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	if hostConfig.CgroupParent != "" && UsingSystemd(daemon.configStore) {
 | 
			
		||||
| 
						 | 
				
			
			@ -1125,7 +1125,7 @@ func setupDaemonRoot(config *config.Config, rootDir string, rootIDs idtools.IDPa
 | 
			
		|||
				break
 | 
			
		||||
			}
 | 
			
		||||
			if !idtools.CanAccess(dirPath, rootIDs) {
 | 
			
		||||
				return fmt.Errorf("A subdirectory in your graphroot path (%s) restricts access to the remapped root uid/gid; please fix by allowing 'o+x' permissions on existing directories.", config.Root)
 | 
			
		||||
				return fmt.Errorf("a subdirectory in your graphroot path (%s) restricts access to the remapped root uid/gid; please fix by allowing 'o+x' permissions on existing directories", config.Root)
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -2664,7 +2664,7 @@ func NewDeviceSet(root string, doInit bool, options []string, uidMaps, gidMaps [
 | 
			
		|||
			devices.metaDataLoopbackSize = size
 | 
			
		||||
		case "dm.fs":
 | 
			
		||||
			if val != "ext4" && val != "xfs" {
 | 
			
		||||
				return nil, fmt.Errorf("devmapper: Unsupported filesystem %s\n", val)
 | 
			
		||||
				return nil, fmt.Errorf("devmapper: Unsupported filesystem %s", val)
 | 
			
		||||
			}
 | 
			
		||||
			devices.filesystem = val
 | 
			
		||||
		case "dm.mkfsarg":
 | 
			
		||||
| 
						 | 
				
			
			@ -2786,7 +2786,7 @@ func NewDeviceSet(root string, doInit bool, options []string, uidMaps, gidMaps [
 | 
			
		|||
				Level: int(level),
 | 
			
		||||
			})
 | 
			
		||||
		default:
 | 
			
		||||
			return nil, fmt.Errorf("devmapper: Unknown option %s\n", key)
 | 
			
		||||
			return nil, fmt.Errorf("devmapper: Unknown option %s", key)
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -121,7 +121,7 @@ func copyDir(srcDir, dstDir string, flags copyFlags) error {
 | 
			
		|||
			}
 | 
			
		||||
 | 
			
		||||
		default:
 | 
			
		||||
			return fmt.Errorf("Unknown file type for %s\n", srcPath)
 | 
			
		||||
			return fmt.Errorf("unknown file type for %s", srcPath)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		// Everything below is copying metadata from src to dst. All this metadata
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -101,7 +101,7 @@ func (p *cmdProbe) run(ctx context.Context, d *Daemon, cntr *container.Container
 | 
			
		|||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
	if info.ExitCode == nil {
 | 
			
		||||
		return nil, fmt.Errorf("Healthcheck for container %s has no exit code!", cntr.ID)
 | 
			
		||||
		return nil, fmt.Errorf("healthcheck for container %s has no exit code", cntr.ID)
 | 
			
		||||
	}
 | 
			
		||||
	// Note: Go's json package will handle invalid UTF-8 for us
 | 
			
		||||
	out := output.String()
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -162,7 +162,7 @@ func TestCreateError(t *testing.T) {
 | 
			
		|||
		client: mockClient,
 | 
			
		||||
	}
 | 
			
		||||
	mockClient.createLogStreamResult <- &createLogStreamResult{
 | 
			
		||||
		errorResult: errors.New("Error!"),
 | 
			
		||||
		errorResult: errors.New("Error"),
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	err := stream.create()
 | 
			
		||||
| 
						 | 
				
			
			@ -243,7 +243,7 @@ func TestPublishBatchError(t *testing.T) {
 | 
			
		|||
		sequenceToken: aws.String(sequenceToken),
 | 
			
		||||
	}
 | 
			
		||||
	mockClient.putLogEventsResult <- &putLogEventsResult{
 | 
			
		||||
		errorResult: errors.New("Error!"),
 | 
			
		||||
		errorResult: errors.New("Error"),
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	events := []wrappedEvent{
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -203,7 +203,7 @@ func New(info logger.Info) (logger.Logger, error) {
 | 
			
		|||
		}
 | 
			
		||||
		gzipCompressionLevel = int(gzipCompressionLevel64)
 | 
			
		||||
		if gzipCompressionLevel < gzip.DefaultCompression || gzipCompressionLevel > gzip.BestCompression {
 | 
			
		||||
			err := fmt.Errorf("Not supported level '%s' for %s (supported values between %d and %d).",
 | 
			
		||||
			err := fmt.Errorf("not supported level '%s' for %s (supported values between %d and %d)",
 | 
			
		||||
				gzipCompressionLevelStr, splunkGzipCompressionLevelKey, gzip.DefaultCompression, gzip.BestCompression)
 | 
			
		||||
			return nil, err
 | 
			
		||||
		}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -36,7 +36,7 @@ func (daemon *Daemon) StateChanged(id string, e libcontainerd.StateInfo) error {
 | 
			
		|||
	case libcontainerd.StateOOM:
 | 
			
		||||
		// StateOOM is Linux specific and should never be hit on Windows
 | 
			
		||||
		if runtime.GOOS == "windows" {
 | 
			
		||||
			return errors.New("Received StateOOM from libcontainerd on Windows. This should never happen.")
 | 
			
		||||
			return errors.New("received StateOOM from libcontainerd on Windows. This should never happen")
 | 
			
		||||
		}
 | 
			
		||||
		daemon.updateHealthMonitor(c)
 | 
			
		||||
		if err := c.CheckpointTo(daemon.containersReplica); err != nil {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -348,6 +348,7 @@ func (daemon *Daemon) createNetwork(create types.NetworkCreateRequest, id string
 | 
			
		|||
	n, err := c.NewNetwork(driver, create.Name, id, nwOptions...)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		if _, ok := err.(libnetwork.ErrDataStoreNotInitialized); ok {
 | 
			
		||||
			// nolint: golint
 | 
			
		||||
			return nil, errors.New("This node is not a swarm manager. Use \"docker swarm init\" or \"docker swarm join\" to connect this node to swarm and try again.")
 | 
			
		||||
		}
 | 
			
		||||
		return nil, err
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -438,7 +438,7 @@ func ensureShared(path string) error {
 | 
			
		|||
	}
 | 
			
		||||
 | 
			
		||||
	if !sharedMount {
 | 
			
		||||
		return fmt.Errorf("Path %s is mounted on %s but it is not a shared mount.", path, sourceMount)
 | 
			
		||||
		return fmt.Errorf("path %s is mounted on %s but it is not a shared mount", path, sourceMount)
 | 
			
		||||
	}
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -465,7 +465,7 @@ func ensureSharedOrSlave(path string) error {
 | 
			
		|||
	}
 | 
			
		||||
 | 
			
		||||
	if !sharedMount && !slaveMount {
 | 
			
		||||
		return fmt.Errorf("Path %s is mounted on %s but it is not a shared or slave mount.", path, sourceMount)
 | 
			
		||||
		return fmt.Errorf("path %s is mounted on %s but it is not a shared or slave mount", path, sourceMount)
 | 
			
		||||
	}
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -27,7 +27,7 @@ func (daemon *Daemon) ContainerStart(name string, hostConfig *containertypes.Hos
 | 
			
		|||
		defer container.Unlock()
 | 
			
		||||
 | 
			
		||||
		if container.Paused {
 | 
			
		||||
			return stateConflictError{errors.New("Cannot start a paused container, try unpause instead.")}
 | 
			
		||||
			return stateConflictError{errors.New("cannot start a paused container, try unpause instead")}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if container.Running {
 | 
			
		||||
| 
						 | 
				
			
			@ -35,7 +35,7 @@ func (daemon *Daemon) ContainerStart(name string, hostConfig *containertypes.Hos
 | 
			
		|||
		}
 | 
			
		||||
 | 
			
		||||
		if container.RemovalInProgress || container.Dead {
 | 
			
		||||
			return stateConflictError{errors.New("Container is marked for removal and cannot be started.")}
 | 
			
		||||
			return stateConflictError{errors.New("container is marked for removal and cannot be started")}
 | 
			
		||||
		}
 | 
			
		||||
		return nil
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			@ -110,7 +110,7 @@ func (daemon *Daemon) containerStart(container *container.Container, checkpoint
 | 
			
		|||
	}
 | 
			
		||||
 | 
			
		||||
	if container.RemovalInProgress || container.Dead {
 | 
			
		||||
		return stateConflictError{errors.New("Container is marked for removal and cannot be started.")}
 | 
			
		||||
		return stateConflictError{errors.New("container is marked for removal and cannot be started")}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// if we encounter an error during start we need to ensure that any other
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -50,7 +50,7 @@ func (daemon *Daemon) update(name string, hostConfig *container.HostConfig) erro
 | 
			
		|||
	}()
 | 
			
		||||
 | 
			
		||||
	if container.RemovalInProgress || container.Dead {
 | 
			
		||||
		return errCannotUpdate(container.ID, fmt.Errorf("Container is marked for removal and cannot be \"update\"."))
 | 
			
		||||
		return errCannotUpdate(container.ID, fmt.Errorf("container is marked for removal and cannot be \"update\""))
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	container.Lock()
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -908,7 +908,7 @@ func fixManifestLayers(m *schema1.Manifest) error {
 | 
			
		|||
			m.FSLayers = append(m.FSLayers[:i], m.FSLayers[i+1:]...)
 | 
			
		||||
			m.History = append(m.History[:i], m.History[i+1:]...)
 | 
			
		||||
		} else if imgs[i].Parent != imgs[i+1].ID {
 | 
			
		||||
			return fmt.Errorf("Invalid parent ID. Expected %v, got %v.", imgs[i+1].ID, imgs[i].Parent)
 | 
			
		||||
			return fmt.Errorf("invalid parent ID. Expected %v, got %v", imgs[i+1].ID, imgs[i].Parent)
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -10,6 +10,7 @@ import (
 | 
			
		|||
 | 
			
		||||
	"github.com/docker/distribution/manifest/schema1"
 | 
			
		||||
	"github.com/docker/distribution/reference"
 | 
			
		||||
	"github.com/docker/docker/pkg/testutil"
 | 
			
		||||
	"github.com/opencontainers/go-digest"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -102,9 +103,8 @@ func TestFixManifestLayersBadParent(t *testing.T) {
 | 
			
		|||
		},
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if err := fixManifestLayers(&duplicateLayerManifest); err == nil || !strings.Contains(err.Error(), "Invalid parent ID.") {
 | 
			
		||||
		t.Fatalf("expected an invalid parent ID error from fixManifestLayers")
 | 
			
		||||
	}
 | 
			
		||||
	err := fixManifestLayers(&duplicateLayerManifest)
 | 
			
		||||
	testutil.ErrorContains(t, err, "invalid parent ID")
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// TestValidateManifest verifies the validateManifest function
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -2,7 +2,12 @@
 | 
			
		|||
  "Vendor": true,
 | 
			
		||||
  "Deadline": "2m",
 | 
			
		||||
  "Sort": ["linter", "severity", "path"],
 | 
			
		||||
  "Exclude": [".*\\.pb\\.go"],
 | 
			
		||||
  "Exclude": [
 | 
			
		||||
    ".*\\.pb\\.go",
 | 
			
		||||
    "dockerversion/version_autogen.go",
 | 
			
		||||
    "api/types/container/container_.*",
 | 
			
		||||
    "integration-cli/"
 | 
			
		||||
  ],
 | 
			
		||||
 | 
			
		||||
  "Enable": [
 | 
			
		||||
    "gofmt",
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -103,7 +103,7 @@ func (s *DockerSuite) TestStartPausedContainer(c *check.C) {
 | 
			
		|||
	// an error should have been shown that you cannot start paused container
 | 
			
		||||
	c.Assert(err, checker.NotNil, check.Commentf("out: %s", out))
 | 
			
		||||
	// an error should have been shown that you cannot start paused container
 | 
			
		||||
	c.Assert(out, checker.Contains, "Cannot start a paused container, try unpause instead.")
 | 
			
		||||
	c.Assert(out, checker.Contains, "cannot start a paused container, try unpause instead")
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (s *DockerSuite) TestStartMultipleContainers(c *check.C) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -595,7 +595,7 @@ func createTarFile(path, extractDir string, hdr *tar.Header, reader io.Reader, L
 | 
			
		|||
		return nil
 | 
			
		||||
 | 
			
		||||
	default:
 | 
			
		||||
		return fmt.Errorf("Unhandled tar header type %d\n", hdr.Typeflag)
 | 
			
		||||
		return fmt.Errorf("unhandled tar header type %d", hdr.Typeflag)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// Lchown is not supported on Windows.
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -7,6 +7,7 @@ import (
 | 
			
		|||
	"testing"
 | 
			
		||||
	"time"
 | 
			
		||||
 | 
			
		||||
	"github.com/stretchr/testify/assert"
 | 
			
		||||
	"golang.org/x/net/context"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -14,7 +15,7 @@ import (
 | 
			
		|||
type errorReader struct{}
 | 
			
		||||
 | 
			
		||||
func (r *errorReader) Read(p []byte) (int, error) {
 | 
			
		||||
	return 0, fmt.Errorf("Error reader always fail.")
 | 
			
		||||
	return 0, fmt.Errorf("error reader always fail")
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func TestReadCloserWrapperClose(t *testing.T) {
 | 
			
		||||
| 
						 | 
				
			
			@ -35,9 +36,7 @@ func TestReaderErrWrapperReadOnError(t *testing.T) {
 | 
			
		|||
		called = true
 | 
			
		||||
	})
 | 
			
		||||
	_, err := wrapper.Read([]byte{})
 | 
			
		||||
	if err == nil || !strings.Contains(err.Error(), "Error reader always fail.") {
 | 
			
		||||
		t.Fatalf("readErrWrapper should returned an error")
 | 
			
		||||
	}
 | 
			
		||||
	assert.EqualError(t, err, "error reader always fail")
 | 
			
		||||
	if !called {
 | 
			
		||||
		t.Fatalf("readErrWrapper should have call the anonymous function on failure")
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -8,11 +8,10 @@ import (
 | 
			
		|||
	"strings"
 | 
			
		||||
	"time"
 | 
			
		||||
 | 
			
		||||
	"github.com/Nvveen/Gotty"
 | 
			
		||||
 | 
			
		||||
	gotty "github.com/Nvveen/Gotty"
 | 
			
		||||
	"github.com/docker/docker/pkg/jsonlog"
 | 
			
		||||
	"github.com/docker/docker/pkg/term"
 | 
			
		||||
	"github.com/docker/go-units"
 | 
			
		||||
	units "github.com/docker/go-units"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// JSONError wraps a concrete Code and Message, `Code` is
 | 
			
		||||
| 
						 | 
				
			
			@ -187,7 +186,7 @@ func cursorDown(out io.Writer, ti termInfo, l int) {
 | 
			
		|||
func (jm *JSONMessage) Display(out io.Writer, termInfo termInfo) error {
 | 
			
		||||
	if jm.Error != nil {
 | 
			
		||||
		if jm.Error.Code == 401 {
 | 
			
		||||
			return fmt.Errorf("Authentication is required.")
 | 
			
		||||
			return fmt.Errorf("authentication is required")
 | 
			
		||||
		}
 | 
			
		||||
		return jm.Error
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -10,6 +10,7 @@ import (
 | 
			
		|||
 | 
			
		||||
	"github.com/docker/docker/pkg/jsonlog"
 | 
			
		||||
	"github.com/docker/docker/pkg/term"
 | 
			
		||||
	"github.com/stretchr/testify/assert"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
func TestError(t *testing.T) {
 | 
			
		||||
| 
						 | 
				
			
			@ -198,9 +199,7 @@ func TestJSONMessageDisplayWithJSONError(t *testing.T) {
 | 
			
		|||
 | 
			
		||||
	jsonMessage = JSONMessage{Error: &JSONError{401, "Anything"}}
 | 
			
		||||
	err = jsonMessage.Display(data, &noTermInfo{})
 | 
			
		||||
	if err == nil || err.Error() != "Authentication is required." {
 | 
			
		||||
		t.Fatalf("Expected an error \"Authentication is required.\", got %q", err)
 | 
			
		||||
	}
 | 
			
		||||
	assert.EqualError(t, err, "authentication is required")
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func TestDisplayJSONMessagesStreamInvalidJSON(t *testing.T) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -61,7 +61,7 @@ func (r *Result) Assert(t testingT, exp Expected) *Result {
 | 
			
		|||
	}
 | 
			
		||||
	_, file, line, ok := runtime.Caller(1)
 | 
			
		||||
	if ok {
 | 
			
		||||
		t.Fatalf("at %s:%d - %s", filepath.Base(file), line, err.Error())
 | 
			
		||||
		t.Fatalf("at %s:%d - %s\n", filepath.Base(file), line, err.Error())
 | 
			
		||||
	} else {
 | 
			
		||||
		t.Fatalf("(no file/line info) - %s", err.Error())
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			@ -108,7 +108,7 @@ func (r *Result) Compare(exp Expected) error {
 | 
			
		|||
	if len(errors) == 0 {
 | 
			
		||||
		return nil
 | 
			
		||||
	}
 | 
			
		||||
	return fmt.Errorf("%s\nFailures:\n%s\n", r, strings.Join(errors, "\n"))
 | 
			
		||||
	return fmt.Errorf("%s\nFailures:\n%s", r, strings.Join(errors, "\n"))
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func matchOutput(expected string, actual string) bool {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -29,7 +29,7 @@ func loginV1(authConfig *types.AuthConfig, apiEndpoint APIEndpoint, userAgent st
 | 
			
		|||
	logrus.Debugf("attempting v1 login to registry endpoint %s", serverAddress)
 | 
			
		||||
 | 
			
		||||
	if serverAddress == "" {
 | 
			
		||||
		return "", "", systemError{errors.New("Server Error: Server Address not set.")}
 | 
			
		||||
		return "", "", systemError{errors.New("server Error: Server Address not set")}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	req, err := http.NewRequest("GET", serverAddress+"users/", nil)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -354,7 +354,7 @@ func ValidateIndexName(val string) (string, error) {
 | 
			
		|||
		val = "docker.io"
 | 
			
		||||
	}
 | 
			
		||||
	if strings.HasPrefix(val, "-") || strings.HasSuffix(val, "-") {
 | 
			
		||||
		return "", fmt.Errorf("Invalid index name (%s). Cannot begin or end with a hyphen.", val)
 | 
			
		||||
		return "", fmt.Errorf("invalid index name (%s). Cannot begin or end with a hyphen", val)
 | 
			
		||||
	}
 | 
			
		||||
	return val, nil
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -81,7 +81,7 @@ func ReadCertsDirectory(tlsConfig *tls.Config, directory string) error {
 | 
			
		|||
			keyName := certName[:len(certName)-5] + ".key"
 | 
			
		||||
			logrus.Debugf("cert: %s", filepath.Join(directory, f.Name()))
 | 
			
		||||
			if !hasFile(fs, keyName) {
 | 
			
		||||
				return fmt.Errorf("Missing key %s for client certificate %s. Note that CA certificates should use the extension .crt.", keyName, certName)
 | 
			
		||||
				return fmt.Errorf("missing key %s for client certificate %s. Note that CA certificates should use the extension .crt", keyName, certName)
 | 
			
		||||
			}
 | 
			
		||||
			cert, err := tls.LoadX509KeyPair(filepath.Join(directory, certName), filepath.Join(directory, keyName))
 | 
			
		||||
			if err != nil {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -434,7 +434,7 @@ func (r *Session) GetRepositoryData(name reference.Named) (*RepositoryData, erro
 | 
			
		|||
		// "Get https://index.docker.io/v1/repositories/library/busybox/images: i/o timeout"
 | 
			
		||||
		// was a top search on the docker user forum
 | 
			
		||||
		if isTimeout(err) {
 | 
			
		||||
			return nil, fmt.Errorf("Network timed out while trying to connect to %s. You may want to check your internet connection or if you are behind a proxy.", repositoryTarget)
 | 
			
		||||
			return nil, fmt.Errorf("network timed out while trying to connect to %s. You may want to check your internet connection or if you are behind a proxy", repositoryTarget)
 | 
			
		||||
		}
 | 
			
		||||
		return nil, fmt.Errorf("Error while pulling image: %v", err)
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue