Browse code

Fix golint warnings for daemon/execdriver/windows

Addresses: #14756

Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>

Qiang Huang authored on 2015/08/03 10:54:02
Showing 12 changed files
... ...
@@ -2,6 +2,7 @@
2 2
 
3 3
 package windows
4 4
 
5
-func (d *driver) Clean(id string) error {
5
+// Clean implements the exec driver Driver interface.
6
+func (d *Driver) Clean(id string) error {
6 7
 	return nil
7 8
 }
... ...
@@ -13,13 +13,14 @@ import (
13 13
 	"github.com/natefinch/npipe"
14 14
 )
15 15
 
16
-func (d *driver) Exec(c *execdriver.Command, processConfig *execdriver.ProcessConfig, pipes *execdriver.Pipes, startCallback execdriver.StartCallback) (int, error) {
16
+// Exec implements the exec driver Driver interface.
17
+func (d *Driver) Exec(c *execdriver.Command, processConfig *execdriver.ProcessConfig, pipes *execdriver.Pipes, startCallback execdriver.StartCallback) (int, error) {
17 18
 
18 19
 	var (
19 20
 		inListen, outListen, errListen     *npipe.PipeListener
20 21
 		term                               execdriver.Terminal
21 22
 		err                                error
22
-		randomID                           string = stringid.GenerateNonCryptoID()
23
+		randomID                           = stringid.GenerateNonCryptoID()
23 24
 		serverPipeFormat, clientPipeFormat string
24 25
 		pid                                uint32
25 26
 		exitCode                           int32
... ...
@@ -4,7 +4,8 @@ package windows
4 4
 
5 5
 import "fmt"
6 6
 
7
-func (d *driver) GetPidsForContainer(id string) ([]int, error) {
7
+// GetPidsForContainer implements the exec driver Driver interface.
8
+func (d *Driver) GetPidsForContainer(id string) ([]int, error) {
8 9
 	// TODO Windows: Implementation required.
9 10
 	return nil, fmt.Errorf("GetPidsForContainer: GetPidsForContainer() not implemented")
10 11
 }
... ...
@@ -9,7 +9,8 @@ type info struct {
9 9
 	driver *driver
10 10
 }
11 11
 
12
-func (d *driver) Info(id string) execdriver.Info {
12
+// Info implements the exec driver Driver interface.
13
+func (d *Driver) Info(id string) execdriver.Info {
13 14
 	return &info{
14 15
 		ID:     id,
15 16
 		driver: d,
... ...
@@ -8,10 +8,12 @@ import (
8 8
 	"github.com/docker/docker/daemon/execdriver"
9 9
 )
10 10
 
11
-func (d *driver) Pause(c *execdriver.Command) error {
11
+// Pause implements the exec driver Driver interface.
12
+func (d *Driver) Pause(c *execdriver.Command) error {
12 13
 	return fmt.Errorf("Windows: Containers cannot be paused")
13 14
 }
14 15
 
15
-func (d *driver) Unpause(c *execdriver.Command) error {
16
+// Unpause implements the exec driver Driver interface.
17
+func (d *Driver) Unpause(c *execdriver.Command) error {
16 18
 	return fmt.Errorf("Windows: Containers cannot be paused")
17 19
 }
... ...
@@ -17,7 +17,7 @@ import (
17 17
 )
18 18
 
19 19
 type layer struct {
20
-	Id   string
20
+	ID   string
21 21
 	Path string
22 22
 }
23 23
 
... ...
@@ -50,7 +50,8 @@ type containerInit struct {
50 50
 	Layers                  []layer
51 51
 }
52 52
 
53
-func (d *driver) Run(c *execdriver.Command, pipes *execdriver.Pipes, startCallback execdriver.StartCallback) (execdriver.ExitStatus, error) {
53
+// Run implements the exec driver Driver interface
54
+func (d *Driver) Run(c *execdriver.Command, pipes *execdriver.Pipes, startCallback execdriver.StartCallback) (execdriver.ExitStatus, error) {
54 55
 
55 56
 	var (
56 57
 		term                           execdriver.Terminal
... ...
@@ -75,7 +76,7 @@ func (d *driver) Run(c *execdriver.Command, pipes *execdriver.Pipes, startCallba
75 75
 
76 76
 	for i := 0; i < len(c.LayerPaths); i++ {
77 77
 		cu.Layers = append(cu.Layers, layer{
78
-			Id:   hcsshim.NewGUID(c.LayerPaths[i]).ToString(),
78
+			ID:   hcsshim.NewGUID(c.LayerPaths[i]).ToString(),
79 79
 			Path: c.LayerPaths[i],
80 80
 		})
81 81
 	}
... ...
@@ -8,6 +8,7 @@ import (
8 8
 	"github.com/docker/docker/daemon/execdriver"
9 9
 )
10 10
 
11
-func (d *driver) Stats(id string) (*execdriver.ResourceStats, error) {
11
+// Stats implements the exec driver Driver interface.
12
+func (d *Driver) Stats(id string) (*execdriver.ResourceStats, error) {
12 13
 	return nil, fmt.Errorf("Windows: Stats not implemented")
13 14
 }
... ...
@@ -6,15 +6,18 @@ package windows
6 6
 type StdConsole struct {
7 7
 }
8 8
 
9
+// NewStdConsole returns a new StdConsole struct.
9 10
 func NewStdConsole() *StdConsole {
10 11
 	return &StdConsole{}
11 12
 }
12 13
 
14
+// Resize implements Resize method of Terminal interface.
13 15
 func (s *StdConsole) Resize(h, w int) error {
14 16
 	// we do not need to resize a non tty
15 17
 	return nil
16 18
 }
17 19
 
20
+// Close implements Close method of Terminal interface.
18 21
 func (s *StdConsole) Close() error {
19 22
 	// nothing to close here
20 23
 	return nil
... ...
@@ -8,12 +8,14 @@ import (
8 8
 	"github.com/microsoft/hcsshim"
9 9
 )
10 10
 
11
-func (d *driver) Terminate(p *execdriver.Command) error {
11
+// Terminate implements the exec driver Driver interface.
12
+func (d *Driver) Terminate(p *execdriver.Command) error {
12 13
 	logrus.Debugf("WindowsExec: Terminate() id=%s", p.ID)
13 14
 	return kill(p.ID, p.ContainerPid)
14 15
 }
15 16
 
16
-func (d *driver) Kill(p *execdriver.Command, sig int) error {
17
+// Kill implements the exec driver Driver interface.
18
+func (d *Driver) Kill(p *execdriver.Command, sig int) error {
17 19
 	logrus.Debugf("WindowsExec: Kill() id=%s sig=%d", p.ID, sig)
18 20
 	return kill(p.ID, p.ContainerPid)
19 21
 }
... ...
@@ -6,12 +6,13 @@ import (
6 6
 	"github.com/microsoft/hcsshim"
7 7
 )
8 8
 
9
-// TtyConsole is for when using a container interactively
9
+// TtyConsole implements the exec driver Terminal interface.
10 10
 type TtyConsole struct {
11 11
 	id        string
12 12
 	processid uint32
13 13
 }
14 14
 
15
+// NewTtyConsole returns a new TtyConsole struct.
15 16
 func NewTtyConsole(id string, processid uint32) *TtyConsole {
16 17
 	tty := &TtyConsole{
17 18
 		id:        id,
... ...
@@ -20,10 +21,12 @@ func NewTtyConsole(id string, processid uint32) *TtyConsole {
20 20
 	return tty
21 21
 }
22 22
 
23
+// Resize implements Resize method of Terminal interface.
23 24
 func (t *TtyConsole) Resize(h, w int) error {
24 25
 	return hcsshim.ResizeConsoleInComputeSystem(t.id, t.processid, h, w)
25 26
 }
26 27
 
28
+// Close implements Close method of Terminal interface.
27 29
 func (t *TtyConsole) Close() error {
28 30
 	return nil
29 31
 }
... ...
@@ -20,6 +20,7 @@ var dummyMode bool
20 20
 // This allows the daemon to terminate containers rather than shutdown
21 21
 var terminateMode bool
22 22
 
23
+// Define name and version for windows
23 24
 var (
24 25
 	DriverName = "Windows 1854"
25 26
 	Version    = dockerversion.VERSION + " " + dockerversion.GITCOMMIT
... ...
@@ -29,18 +30,22 @@ type activeContainer struct {
29 29
 	command *execdriver.Command
30 30
 }
31 31
 
32
-type driver struct {
32
+// Driver contains all information for windows driver,
33
+// it implements execdriver.Driver
34
+type Driver struct {
33 35
 	root             string
34 36
 	initPath         string
35 37
 	activeContainers map[string]*activeContainer
36 38
 	sync.Mutex
37 39
 }
38 40
 
39
-func (d *driver) Name() string {
41
+// Name implements the exec driver Driver interface.
42
+func (d *Driver) Name() string {
40 43
 	return fmt.Sprintf("%s %s", DriverName, Version)
41 44
 }
42 45
 
43
-func NewDriver(root, initPath string, options []string) (*driver, error) {
46
+// NewDriver returns a new windows driver, called from NewDriver of execdriver.
47
+func NewDriver(root, initPath string, options []string) (*Driver, error) {
44 48
 
45 49
 	for _, option := range options {
46 50
 		key, val, err := parsers.ParseKeyValueOpt(option)
... ...
@@ -69,7 +74,7 @@ func NewDriver(root, initPath string, options []string) (*driver, error) {
69 69
 		}
70 70
 	}
71 71
 
72
-	return &driver{
72
+	return &Driver{
73 73
 		root:             root,
74 74
 		initPath:         initPath,
75 75
 		activeContainers: make(map[string]*activeContainer),
... ...
@@ -23,6 +23,7 @@ packages=(
23 23
 	daemon/execdriver/lxc
24 24
 	daemon/execdriver/native
25 25
 	daemon/execdriver/native/template
26
+	daemon/execdriver/windows
26 27
 	daemon/graphdriver/aufs
27 28
 	daemon/graphdriver/devmapper
28 29
 	daemon/logger