mirror of https://github.com/docker/cli.git
				
				
				
			Add line length linter
Signed-off-by: Daniel Nephin <dnephin@docker.com>
This commit is contained in:
		
							parent
							
								
									37ccc00d0e
								
							
						
					
					
						commit
						c31d25653f
					
				| 
						 | 
				
			
			@ -165,7 +165,9 @@ func TestParseRunVolumes(t *testing.T) {
 | 
			
		|||
 | 
			
		||||
	// Two bind-mounts, first read-only, second read-write.
 | 
			
		||||
	// TODO Windows: The Windows version uses read-write as that's the only mode it supports. Can change this post TP4
 | 
			
		||||
	arr, tryit = setupPlatformVolume([]string{`/hostTmp:/containerTmp:ro`, `/hostVar:/containerVar:rw`}, []string{os.Getenv("TEMP") + `:c:\containerTmp:rw`, os.Getenv("ProgramData") + `:c:\ContainerPD:rw`})
 | 
			
		||||
	arr, tryit = setupPlatformVolume(
 | 
			
		||||
		[]string{`/hostTmp:/containerTmp:ro`, `/hostVar:/containerVar:rw`},
 | 
			
		||||
		[]string{os.Getenv("TEMP") + `:c:\containerTmp:rw`, os.Getenv("ProgramData") + `:c:\ContainerPD:rw`})
 | 
			
		||||
	if _, hostConfig := mustParse(t, tryit); hostConfig.Binds == nil || compareRandomizedStrings(hostConfig.Binds[0], hostConfig.Binds[1], arr[0], arr[1]) != nil {
 | 
			
		||||
		t.Fatalf("Error parsing volume flags, `%s and %s` did not mount-bind correctly. Received %v", arr[0], arr[1], hostConfig.Binds)
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -8,7 +8,12 @@ import (
 | 
			
		|||
 | 
			
		||||
func TestCalculateBlockIO(t *testing.T) {
 | 
			
		||||
	blkio := types.BlkioStats{
 | 
			
		||||
		IoServiceBytesRecursive: []types.BlkioStatEntry{{Major: 8, Minor: 0, Op: "read", Value: 1234}, {Major: 8, Minor: 1, Op: "read", Value: 4567}, {Major: 8, Minor: 0, Op: "write", Value: 123}, {Major: 8, Minor: 1, Op: "write", Value: 456}},
 | 
			
		||||
		IoServiceBytesRecursive: []types.BlkioStatEntry{
 | 
			
		||||
			{Major: 8, Minor: 0, Op: "read", Value: 1234},
 | 
			
		||||
			{Major: 8, Minor: 1, Op: "read", Value: 4567},
 | 
			
		||||
			{Major: 8, Minor: 0, Op: "write", Value: 123},
 | 
			
		||||
			{Major: 8, Minor: 1, Op: "write", Value: 456},
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
	blkRead, blkWrite := calculateBlockIO(blkio)
 | 
			
		||||
	if blkRead != 5801 {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -320,8 +320,36 @@ func TestContainerContextWriteJSON(t *testing.T) {
 | 
			
		|||
	}
 | 
			
		||||
	expectedCreated := time.Unix(unix, 0).String()
 | 
			
		||||
	expectedJSONs := []map[string]interface{}{
 | 
			
		||||
		{"Command": "\"\"", "CreatedAt": expectedCreated, "ID": "containerID1", "Image": "ubuntu", "Labels": "", "LocalVolumes": "0", "Mounts": "", "Names": "foobar_baz", "Networks": "", "Ports": "", "RunningFor": "About a minute ago", "Size": "0B", "Status": ""},
 | 
			
		||||
		{"Command": "\"\"", "CreatedAt": expectedCreated, "ID": "containerID2", "Image": "ubuntu", "Labels": "", "LocalVolumes": "0", "Mounts": "", "Names": "foobar_bar", "Networks": "", "Ports": "", "RunningFor": "About a minute ago", "Size": "0B", "Status": ""},
 | 
			
		||||
		{
 | 
			
		||||
			"Command":      "\"\"",
 | 
			
		||||
			"CreatedAt":    expectedCreated,
 | 
			
		||||
			"ID":           "containerID1",
 | 
			
		||||
			"Image":        "ubuntu",
 | 
			
		||||
			"Labels":       "",
 | 
			
		||||
			"LocalVolumes": "0",
 | 
			
		||||
			"Mounts":       "",
 | 
			
		||||
			"Names":        "foobar_baz",
 | 
			
		||||
			"Networks":     "",
 | 
			
		||||
			"Ports":        "",
 | 
			
		||||
			"RunningFor":   "About a minute ago",
 | 
			
		||||
			"Size":         "0B",
 | 
			
		||||
			"Status":       "",
 | 
			
		||||
		},
 | 
			
		||||
		{
 | 
			
		||||
			"Command":      "\"\"",
 | 
			
		||||
			"CreatedAt":    expectedCreated,
 | 
			
		||||
			"ID":           "containerID2",
 | 
			
		||||
			"Image":        "ubuntu",
 | 
			
		||||
			"Labels":       "",
 | 
			
		||||
			"LocalVolumes": "0",
 | 
			
		||||
			"Mounts":       "",
 | 
			
		||||
			"Names":        "foobar_bar",
 | 
			
		||||
			"Networks":     "",
 | 
			
		||||
			"Ports":        "",
 | 
			
		||||
			"RunningFor":   "About a minute ago",
 | 
			
		||||
			"Size":         "0B",
 | 
			
		||||
			"Status":       "",
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
	out := bytes.NewBufferString("")
 | 
			
		||||
	err := ContainerWrite(Context{Format: "{{json .}}", Output: out}, containers)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -77,8 +77,8 @@ func TestHistoryContext_CreatedSince(t *testing.T) {
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
func TestHistoryContext_CreatedBy(t *testing.T) {
 | 
			
		||||
	withTabs := `/bin/sh -c apt-key adv --keyserver hkp://pgp.mit.edu:80	--recv-keys 573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62	&& echo "deb http://nginx.org/packages/mainline/debian/ jessie nginx" >> /etc/apt/sources.list  && apt-get update  && apt-get install --no-install-recommends --no-install-suggests -y       ca-certificates       nginx=${NGINX_VERSION}       nginx-module-xslt       nginx-module-geoip       nginx-module-image-filter       nginx-module-perl       nginx-module-njs       gettext-base  && rm -rf /var/lib/apt/lists/*`
 | 
			
		||||
	expected := `/bin/sh -c apt-key adv --keyserver hkp://pgp.mit.edu:80 --recv-keys 573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62 && echo "deb http://nginx.org/packages/mainline/debian/ jessie nginx" >> /etc/apt/sources.list  && apt-get update  && apt-get install --no-install-recommends --no-install-suggests -y       ca-certificates       nginx=${NGINX_VERSION}       nginx-module-xslt       nginx-module-geoip       nginx-module-image-filter       nginx-module-perl       nginx-module-njs       gettext-base  && rm -rf /var/lib/apt/lists/*`
 | 
			
		||||
	withTabs := `/bin/sh -c apt-key adv --keyserver hkp://pgp.mit.edu:80	--recv-keys 573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62	&& echo "deb http://nginx.org/packages/mainline/debian/ jessie nginx" >> /etc/apt/sources.list  && apt-get update  && apt-get install --no-install-recommends --no-install-suggests -y       ca-certificates       nginx=${NGINX_VERSION}       nginx-module-xslt       nginx-module-geoip       nginx-module-image-filter       nginx-module-perl       nginx-module-njs       gettext-base  && rm -rf /var/lib/apt/lists/*` // nolint: lll
 | 
			
		||||
	expected := `/bin/sh -c apt-key adv --keyserver hkp://pgp.mit.edu:80 --recv-keys 573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62 && echo "deb http://nginx.org/packages/mainline/debian/ jessie nginx" >> /etc/apt/sources.list  && apt-get update  && apt-get install --no-install-recommends --no-install-suggests -y       ca-certificates       nginx=${NGINX_VERSION}       nginx-module-xslt       nginx-module-geoip       nginx-module-image-filter       nginx-module-perl       nginx-module-njs       gettext-base  && rm -rf /var/lib/apt/lists/*` // nolint: lll
 | 
			
		||||
 | 
			
		||||
	var ctx historyContext
 | 
			
		||||
	cases := []historyCase{
 | 
			
		||||
| 
						 | 
				
			
			@ -167,11 +167,19 @@ func TestHistoryContext_Table(t *testing.T) {
 | 
			
		|||
	out := bytes.NewBufferString("")
 | 
			
		||||
	unixTime := time.Now().AddDate(0, 0, -1).Unix()
 | 
			
		||||
	histories := []image.HistoryResponseItem{
 | 
			
		||||
		{ID: "imageID1", Created: unixTime, CreatedBy: "/bin/bash ls && npm i && npm run test && karma -c karma.conf.js start && npm start && more commands here && the list goes on", Size: int64(182964289), Comment: "Hi", Tags: []string{"image:tag2"}},
 | 
			
		||||
		{
 | 
			
		||||
			ID:        "imageID1",
 | 
			
		||||
			Created:   unixTime,
 | 
			
		||||
			CreatedBy: "/bin/bash ls && npm i && npm run test && karma -c karma.conf.js start && npm start && more commands here && the list goes on",
 | 
			
		||||
			Size:      int64(182964289),
 | 
			
		||||
			Comment:   "Hi",
 | 
			
		||||
			Tags:      []string{"image:tag2"},
 | 
			
		||||
		},
 | 
			
		||||
		{ID: "imageID2", Created: unixTime, CreatedBy: "/bin/bash echo", Size: int64(182964289), Comment: "Hi", Tags: []string{"image:tag2"}},
 | 
			
		||||
		{ID: "imageID3", Created: unixTime, CreatedBy: "/bin/bash ls", Size: int64(182964289), Comment: "Hi", Tags: []string{"image:tag2"}},
 | 
			
		||||
		{ID: "imageID4", Created: unixTime, CreatedBy: "/bin/bash grep", Size: int64(182964289), Comment: "Hi", Tags: []string{"image:tag2"}},
 | 
			
		||||
	}
 | 
			
		||||
	// nolint: lll
 | 
			
		||||
	expectedNoTrunc := `IMAGE               CREATED             CREATED BY                                                                                                                     SIZE                COMMENT
 | 
			
		||||
imageID1            24 hours ago        /bin/bash ls && npm i && npm run test && karma -c karma.conf.js start && npm start && more commands here && the list goes on   183MB               Hi
 | 
			
		||||
imageID2            24 hours ago        /bin/bash echo                                                                                                                 183MB               Hi
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -128,8 +128,23 @@ foobar_bar
 | 
			
		|||
 | 
			
		||||
	for _, testcase := range cases {
 | 
			
		||||
		nodes := []swarm.Node{
 | 
			
		||||
			{ID: "nodeID1", Description: swarm.NodeDescription{Hostname: "foobar_baz"}, Status: swarm.NodeStatus{State: swarm.NodeState("foo")}, Spec: swarm.NodeSpec{Availability: swarm.NodeAvailability("drain")}, ManagerStatus: &swarm.ManagerStatus{Leader: true}},
 | 
			
		||||
			{ID: "nodeID2", Description: swarm.NodeDescription{Hostname: "foobar_bar"}, Status: swarm.NodeStatus{State: swarm.NodeState("bar")}, Spec: swarm.NodeSpec{Availability: swarm.NodeAvailability("active")}, ManagerStatus: &swarm.ManagerStatus{Leader: false, Reachability: swarm.Reachability("Reachable")}},
 | 
			
		||||
			{
 | 
			
		||||
				ID:            "nodeID1",
 | 
			
		||||
				Description:   swarm.NodeDescription{Hostname: "foobar_baz"},
 | 
			
		||||
				Status:        swarm.NodeStatus{State: swarm.NodeState("foo")},
 | 
			
		||||
				Spec:          swarm.NodeSpec{Availability: swarm.NodeAvailability("drain")},
 | 
			
		||||
				ManagerStatus: &swarm.ManagerStatus{Leader: true},
 | 
			
		||||
			},
 | 
			
		||||
			{
 | 
			
		||||
				ID:          "nodeID2",
 | 
			
		||||
				Description: swarm.NodeDescription{Hostname: "foobar_bar"},
 | 
			
		||||
				Status:      swarm.NodeStatus{State: swarm.NodeState("bar")},
 | 
			
		||||
				Spec:        swarm.NodeSpec{Availability: swarm.NodeAvailability("active")},
 | 
			
		||||
				ManagerStatus: &swarm.ManagerStatus{
 | 
			
		||||
					Leader:       false,
 | 
			
		||||
					Reachability: swarm.Reachability("Reachable"),
 | 
			
		||||
				},
 | 
			
		||||
			},
 | 
			
		||||
		}
 | 
			
		||||
		out := bytes.NewBufferString("")
 | 
			
		||||
		testcase.context.Output = out
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -780,7 +780,8 @@ func addServiceFlags(flags *pflag.FlagSet, opts *serviceOptions, defaultFlagValu
 | 
			
		|||
	flags.StringVar(&opts.update.order, flagUpdateOrder, "", flagDesc(flagUpdateOrder, `Update order ("start-first"|"stop-first")`))
 | 
			
		||||
	flags.SetAnnotation(flagUpdateOrder, "version", []string{"1.29"})
 | 
			
		||||
 | 
			
		||||
	flags.Uint64Var(&opts.rollback.parallelism, flagRollbackParallelism, defaultFlagValues.getUint64(flagRollbackParallelism), "Maximum number of tasks rolled back simultaneously (0 to roll back all at once)")
 | 
			
		||||
	flags.Uint64Var(&opts.rollback.parallelism, flagRollbackParallelism, defaultFlagValues.getUint64(flagRollbackParallelism),
 | 
			
		||||
		"Maximum number of tasks rolled back simultaneously (0 to roll back all at once)")
 | 
			
		||||
	flags.SetAnnotation(flagRollbackParallelism, "version", []string{"1.28"})
 | 
			
		||||
	flags.DurationVar(&opts.rollback.delay, flagRollbackDelay, 0, flagDesc(flagRollbackDelay, "Delay between task rollbacks (ns|us|ms|s|m|h)"))
 | 
			
		||||
	flags.SetAnnotation(flagRollbackDelay, "version", []string{"1.28"})
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -80,7 +80,10 @@ func runUnlockKey(dockerCli command.Cli, opts unlockKeyOptions) error {
 | 
			
		|||
 | 
			
		||||
func printUnlockCommand(ctx context.Context, dockerCli command.Cli, unlockKey string) {
 | 
			
		||||
	if len(unlockKey) > 0 {
 | 
			
		||||
		fmt.Fprintf(dockerCli.Out(), "To unlock a swarm manager after it restarts, run the `docker swarm unlock`\ncommand and provide the following key:\n\n    %s\n\nPlease remember to store this key in a password manager, since without it you\nwill not be able to restart the manager.\n", unlockKey)
 | 
			
		||||
		fmt.Fprintf(dockerCli.Out(), "To unlock a swarm manager after it restarts, "+
 | 
			
		||||
			"run the `docker swarm unlock`\ncommand and provide the following key:\n\n    %s\n\n"+
 | 
			
		||||
			"Please remember to store this key in a password manager, since without it you\n"+
 | 
			
		||||
			"will not be able to restart the manager.\n", unlockKey)
 | 
			
		||||
	}
 | 
			
		||||
	return
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -330,7 +330,9 @@ func printStorageDriverWarnings(dockerCli *command.DockerCli, info types.Info) {
 | 
			
		|||
 | 
			
		||||
	for _, pair := range info.DriverStatus {
 | 
			
		||||
		if pair[0] == "Data loop file" {
 | 
			
		||||
			fmt.Fprintf(dockerCli.Err(), "WARNING: %s: usage of loopback devices is strongly discouraged for production use.\n         Use `--storage-opt dm.thinpooldev` to specify a custom block storage device.\n", info.Driver)
 | 
			
		||||
			fmt.Fprintf(dockerCli.Err(), "WARNING: %s: usage of loopback devices is "+
 | 
			
		||||
				"strongly discouraged for production use.\n         "+
 | 
			
		||||
				"Use `--storage-opt dm.thinpooldev` to specify a custom block storage device.\n", info.Driver)
 | 
			
		||||
		}
 | 
			
		||||
		if pair[0] == "Supports d_type" && pair[1] == "false" {
 | 
			
		||||
			backingFs := getBackingFs(info)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,6 @@
 | 
			
		|||
{
 | 
			
		||||
  "Vendor": true,
 | 
			
		||||
  "Deadline": "2m",
 | 
			
		||||
  "Sort": ["linter", "severity", "path"],
 | 
			
		||||
  "Exclude": ["cli/compose/schema/bindata.go"],
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -12,8 +13,10 @@
 | 
			
		|||
    "golint",
 | 
			
		||||
    "ineffassign",
 | 
			
		||||
    "interfacer",
 | 
			
		||||
    "lll",
 | 
			
		||||
    "vet"
 | 
			
		||||
  ],
 | 
			
		||||
 | 
			
		||||
  "Cyclo": 19
 | 
			
		||||
  "Cyclo": 19,
 | 
			
		||||
  "LineLength": 200
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -19,7 +19,13 @@ type configWrapper struct {
 | 
			
		|||
 | 
			
		||||
// ContainerCreate creates a new container based in the given configuration.
 | 
			
		||||
// It can be associated with a name, but it's not mandatory.
 | 
			
		||||
func (cli *Client) ContainerCreate(ctx context.Context, config *container.Config, hostConfig *container.HostConfig, networkingConfig *network.NetworkingConfig, containerName string) (container.ContainerCreateCreatedBody, error) {
 | 
			
		||||
func (cli *Client) ContainerCreate(
 | 
			
		||||
	ctx context.Context,
 | 
			
		||||
	config *container.Config,
 | 
			
		||||
	hostConfig *container.HostConfig,
 | 
			
		||||
	networkingConfig *network.NetworkingConfig,
 | 
			
		||||
	containerName string,
 | 
			
		||||
) (container.ContainerCreateCreatedBody, error) {
 | 
			
		||||
	var response container.ContainerCreateCreatedBody
 | 
			
		||||
 | 
			
		||||
	if err := cli.NewVersionError("1.25", "stop timeout"); config != nil && config.StopTimeout != nil && err != nil {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -37,7 +37,12 @@ type CommonAPIClient interface {
 | 
			
		|||
type ContainerAPIClient interface {
 | 
			
		||||
	ContainerAttach(ctx context.Context, container string, options types.ContainerAttachOptions) (types.HijackedResponse, error)
 | 
			
		||||
	ContainerCommit(ctx context.Context, container string, options types.ContainerCommitOptions) (types.IDResponse, error)
 | 
			
		||||
	ContainerCreate(ctx context.Context, config *container.Config, hostConfig *container.HostConfig, networkingConfig *network.NetworkingConfig, containerName string) (container.ContainerCreateCreatedBody, error)
 | 
			
		||||
	ContainerCreate(
 | 
			
		||||
		ctx context.Context,
 | 
			
		||||
		config *container.Config,
 | 
			
		||||
		hostConfig *container.HostConfig,
 | 
			
		||||
		networkingConfig *network.NetworkingConfig,
 | 
			
		||||
		containerName string) (container.ContainerCreateCreatedBody, error)
 | 
			
		||||
	ContainerDiff(ctx context.Context, container string) ([]container.ContainerChangeResponseItem, error)
 | 
			
		||||
	ContainerExecAttach(ctx context.Context, execID string, config types.ExecConfig) (types.HijackedResponse, error)
 | 
			
		||||
	ContainerExecCreate(ctx context.Context, container string, config types.ExecConfig) (types.IDResponse, error)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -171,7 +171,9 @@ func (cli *Client) doRequest(ctx context.Context, req *http.Request) (serverResp
 | 
			
		|||
		// this is localised - for example in French the error would be
 | 
			
		||||
		// `open //./pipe/docker_engine: Le fichier spécifié est introuvable.`
 | 
			
		||||
		if strings.Contains(err.Error(), `open //./pipe/docker_engine`) {
 | 
			
		||||
			err = errors.New(err.Error() + " In the default daemon configuration on Windows, the docker client must be run elevated to connect. This error may also indicate that the docker daemon is not running.")
 | 
			
		||||
			err = errors.Wrap(err, " In the default daemon configuration on Windows, "+
 | 
			
		||||
				"the docker client must be run elevated to connect. This error "+
 | 
			
		||||
				"may also indicate that the docker daemon is not running.")
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		return serverResp, errors.Wrap(err, "error during connect")
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue