Browse code

fix a few golint errors

Signed-off-by: Victor Vieux <victorvieux@gmail.com>

Victor Vieux authored on 2016/11/19 08:57:11
Showing 12 changed files
... ...
@@ -3,6 +3,7 @@ package v1p24
3 3
 
4 4
 import "github.com/docker/docker/api/types"
5 5
 
6
+// Info is a backcompatibility struct for the API 1.24
6 7
 type Info struct {
7 8
 	*types.InfoBase
8 9
 	ExecutionDriver string
... ...
@@ -81,7 +81,7 @@ func noArgs(cmd *cobra.Command, args []string) error {
81 81
 		return nil
82 82
 	}
83 83
 	return fmt.Errorf(
84
-		"docker: '%s' is not a docker command.\nSee 'docker --help'.", args[0])
84
+		"docker: '%s' is not a docker command.\nSee 'docker --help'", args[0])
85 85
 }
86 86
 
87 87
 func main() {
... ...
@@ -1052,10 +1052,9 @@ func (c *Cluster) imageWithDigestString(ctx context.Context, image string, authC
1052 1052
 			return "", err
1053 1053
 		}
1054 1054
 		return namedDigestedRef.String(), nil
1055
-	} else {
1056
-		// reference already contains a digest, so just return it
1057
-		return ref.String(), nil
1058 1055
 	}
1056
+	// reference already contains a digest, so just return it
1057
+	return ref.String(), nil
1059 1058
 }
1060 1059
 
1061 1060
 // CreateService creates a new service in a managed swarm cluster.
... ...
@@ -165,18 +165,16 @@ func (d *Driver) Exists(id string) bool {
165 165
 func (d *Driver) CreateReadWrite(id, parent string, opts *graphdriver.CreateOpts) error {
166 166
 	if opts != nil {
167 167
 		return d.create(id, parent, opts.MountLabel, false, opts.StorageOpt)
168
-	} else {
169
-		return d.create(id, parent, "", false, nil)
170 168
 	}
169
+	return d.create(id, parent, "", false, nil)
171 170
 }
172 171
 
173 172
 // Create creates a new read-only layer with the given id.
174 173
 func (d *Driver) Create(id, parent string, opts *graphdriver.CreateOpts) error {
175 174
 	if opts != nil {
176 175
 		return d.create(id, parent, opts.MountLabel, true, opts.StorageOpt)
177
-	} else {
178
-		return d.create(id, parent, "", true, nil)
179 176
 	}
177
+	return d.create(id, parent, "", true, nil)
180 178
 }
181 179
 
182 180
 func (d *Driver) create(id, parent, mountLabel string, readOnly bool, storageOpt map[string]string) error {
... ...
@@ -106,6 +106,7 @@ func (daemon *Daemon) pullImageWithReference(ctx context.Context, ref reference.
106 106
 	return err
107 107
 }
108 108
 
109
+// GetRepository returns a repository from the registry.
109 110
 func (daemon *Daemon) GetRepository(ctx context.Context, ref reference.NamedTagged, authConfig *types.AuthConfig) (dist.Repository, bool, error) {
110 111
 	// get repository info
111 112
 	repoInfo, err := daemon.RegistryService.ResolveRepository(ref)
... ...
@@ -13,6 +13,7 @@ import (
13 13
 	"github.com/docker/docker/pkg/sysinfo"
14 14
 )
15 15
 
16
+// FillPlatformInfo fills the platform related info.
16 17
 func (daemon *Daemon) FillPlatformInfo(v *types.InfoBase, sysInfo *sysinfo.SysInfo) {
17 18
 	v.MemoryLimit = sysInfo.MemoryLimit
18 19
 	v.SwapLimit = sysInfo.SwapLimit
... ...
@@ -5,5 +5,6 @@ import (
5 5
 	"github.com/docker/docker/pkg/sysinfo"
6 6
 )
7 7
 
8
+// FillPlatformInfo fills the platform related info.
8 9
 func (daemon *Daemon) FillPlatformInfo(v *types.InfoBase, sysInfo *sysinfo.SysInfo) {
9 10
 }
... ...
@@ -196,7 +196,7 @@ func (s *DockerSuite) TestHelpExitCodesHelpOutput(c *check.C) {
196 196
 	stdout, stderr, _, err = runCommandWithStdoutStderr(cmd)
197 197
 	c.Assert(err, checker.NotNil)
198 198
 	c.Assert(stdout, checker.Equals, "")
199
-	c.Assert(stderr, checker.Equals, "docker: 'BadCmd' is not a docker command.\nSee 'docker --help'.\n", check.Commentf("Unexcepted output for 'docker badCmd'\n"))
199
+	c.Assert(stderr, checker.Equals, "docker: 'BadCmd' is not a docker command.\nSee 'docker --help'\n", check.Commentf("Unexcepted output for 'docker badCmd'\n"))
200 200
 }
201 201
 
202 202
 func testCommand(cmd string, newEnvs []string, scanForHome bool, home string) error {
... ...
@@ -16,6 +16,7 @@ const (
16 16
 	portOptMode          = "mode"
17 17
 )
18 18
 
19
+// PortOpt represents a port config in swarm mode.
19 20
 type PortOpt struct {
20 21
 	ports []swarm.PortConfig
21 22
 }
... ...
@@ -2,7 +2,7 @@
2 2
 
3 3
 package devicemapper
4 4
 
5
-// LibraryDeferredRemovalsupport is not supported when statically linked.
5
+// LibraryDeferredRemovalSupport is not supported when statically linked.
6 6
 const LibraryDeferredRemovalSupport = false
7 7
 
8 8
 func dmTaskDeferredRemoveFct(task *cdmTask) int {
... ...
@@ -11,50 +11,50 @@ import (
11 11
 	"golang.org/x/net/context"
12 12
 )
13 13
 
14
-var ErrNotSupported = errors.New("plugins are not supported on this platform")
14
+var errNotSupported = errors.New("plugins are not supported on this platform")
15 15
 
16 16
 // Disable deactivates a plugin, which implies that they cannot be used by containers.
17 17
 func (pm *Manager) Disable(name string) error {
18
-	return ErrNotSupported
18
+	return errNotSupported
19 19
 }
20 20
 
21 21
 // Enable activates a plugin, which implies that they are ready to be used by containers.
22 22
 func (pm *Manager) Enable(name string) error {
23
-	return ErrNotSupported
23
+	return errNotSupported
24 24
 }
25 25
 
26 26
 // Inspect examines a plugin config
27 27
 func (pm *Manager) Inspect(name string) (tp types.Plugin, err error) {
28
-	return tp, ErrNotSupported
28
+	return tp, errNotSupported
29 29
 }
30 30
 
31 31
 // Pull pulls a plugin and computes the privileges required to install it.
32 32
 func (pm *Manager) Pull(name string, metaHeader http.Header, authConfig *types.AuthConfig) (types.PluginPrivileges, error) {
33
-	return nil, ErrNotSupported
33
+	return nil, errNotSupported
34 34
 }
35 35
 
36 36
 // List displays the list of plugins and associated metadata.
37 37
 func (pm *Manager) List() ([]types.Plugin, error) {
38
-	return nil, ErrNotSupported
38
+	return nil, errNotSupported
39 39
 }
40 40
 
41 41
 // Push pushes a plugin to the store.
42 42
 func (pm *Manager) Push(name string, metaHeader http.Header, authConfig *types.AuthConfig) error {
43
-	return ErrNotSupported
43
+	return errNotSupported
44 44
 }
45 45
 
46 46
 // Remove deletes plugin's root directory.
47 47
 func (pm *Manager) Remove(name string, config *types.PluginRmConfig) error {
48
-	return ErrNotSupported
48
+	return errNotSupported
49 49
 }
50 50
 
51 51
 // Set sets plugin args
52 52
 func (pm *Manager) Set(name string, args []string) error {
53
-	return ErrNotSupported
53
+	return errNotSupported
54 54
 }
55 55
 
56 56
 // CreateFromContext creates a plugin from the given pluginDir which contains
57 57
 // both the rootfs and the config.json and a repoName with optional tag.
58 58
 func (pm *Manager) CreateFromContext(ctx context.Context, tarCtx io.Reader, options *types.PluginCreateOptions) error {
59
-	return ErrNotSupported
59
+	return errNotSupported
60 60
 }
... ...
@@ -269,7 +269,7 @@ func (r *Root) validateName(name string) error {
269 269
 		return validationError{fmt.Errorf("volume name is too short, names should be at least two alphanumeric characters")}
270 270
 	}
271 271
 	if !volumeNameRegex.MatchString(name) {
272
-		return validationError{fmt.Errorf("%q includes invalid characters for a local volume name, only %q are allowed. If you intented to pass a host directory, use absolute path.", name, utils.RestrictedNameChars)}
272
+		return validationError{fmt.Errorf("%q includes invalid characters for a local volume name, only %q are allowed. If you intented to pass a host directory, use absolute path", name, utils.RestrictedNameChars)}
273 273
 	}
274 274
 	return nil
275 275
 }