From f9b5eb0cacf87b9e1c5b2aaea30c9774cf60897a Mon Sep 17 00:00:00 2001 From: Qiang Huang Date: Mon, 3 Aug 2015 09:54:02 +0800 Subject: [PATCH] Fix golint warnings for daemon/execdriver/windows Addresses: #14756 Signed-off-by: Qiang Huang --- daemon/execdriver/windows/clean.go | 3 ++- daemon/execdriver/windows/exec.go | 5 +++-- daemon/execdriver/windows/getpids.go | 3 ++- daemon/execdriver/windows/info.go | 3 ++- daemon/execdriver/windows/pauseunpause.go | 6 ++++-- daemon/execdriver/windows/run.go | 7 ++++--- daemon/execdriver/windows/stats.go | 3 ++- daemon/execdriver/windows/stdconsole.go | 3 +++ daemon/execdriver/windows/terminatekill.go | 6 ++++-- daemon/execdriver/windows/ttyconsole.go | 5 ++++- daemon/execdriver/windows/windows.go | 13 +++++++++---- hack/make/validate-lint | 1 + 12 files changed, 40 insertions(+), 18 deletions(-) diff --git a/daemon/execdriver/windows/clean.go b/daemon/execdriver/windows/clean.go index 29ae6f1481250..3a99cf86aa474 100644 --- a/daemon/execdriver/windows/clean.go +++ b/daemon/execdriver/windows/clean.go @@ -2,6 +2,7 @@ package windows -func (d *driver) Clean(id string) error { +// Clean implements the exec driver Driver interface. +func (d *Driver) Clean(id string) error { return nil } diff --git a/daemon/execdriver/windows/exec.go b/daemon/execdriver/windows/exec.go index f16908e6b9e32..6d64eac329b28 100644 --- a/daemon/execdriver/windows/exec.go +++ b/daemon/execdriver/windows/exec.go @@ -13,13 +13,14 @@ import ( "github.com/natefinch/npipe" ) -func (d *driver) Exec(c *execdriver.Command, processConfig *execdriver.ProcessConfig, pipes *execdriver.Pipes, startCallback execdriver.StartCallback) (int, error) { +// Exec implements the exec driver Driver interface. +func (d *Driver) Exec(c *execdriver.Command, processConfig *execdriver.ProcessConfig, pipes *execdriver.Pipes, startCallback execdriver.StartCallback) (int, error) { var ( inListen, outListen, errListen *npipe.PipeListener term execdriver.Terminal err error - randomID string = stringid.GenerateNonCryptoID() + randomID = stringid.GenerateNonCryptoID() serverPipeFormat, clientPipeFormat string pid uint32 exitCode int32 diff --git a/daemon/execdriver/windows/getpids.go b/daemon/execdriver/windows/getpids.go index b8f9c6f210de3..5b1a9eb59ab63 100644 --- a/daemon/execdriver/windows/getpids.go +++ b/daemon/execdriver/windows/getpids.go @@ -4,7 +4,8 @@ package windows import "fmt" -func (d *driver) GetPidsForContainer(id string) ([]int, error) { +// GetPidsForContainer implements the exec driver Driver interface. +func (d *Driver) GetPidsForContainer(id string) ([]int, error) { // TODO Windows: Implementation required. return nil, fmt.Errorf("GetPidsForContainer: GetPidsForContainer() not implemented") } diff --git a/daemon/execdriver/windows/info.go b/daemon/execdriver/windows/info.go index 097f41e23a71f..072bfae5fe327 100644 --- a/daemon/execdriver/windows/info.go +++ b/daemon/execdriver/windows/info.go @@ -9,7 +9,8 @@ type info struct { driver *driver } -func (d *driver) Info(id string) execdriver.Info { +// Info implements the exec driver Driver interface. +func (d *Driver) Info(id string) execdriver.Info { return &info{ ID: id, driver: d, diff --git a/daemon/execdriver/windows/pauseunpause.go b/daemon/execdriver/windows/pauseunpause.go index 35f12528e77fd..c408669c3c623 100644 --- a/daemon/execdriver/windows/pauseunpause.go +++ b/daemon/execdriver/windows/pauseunpause.go @@ -8,10 +8,12 @@ import ( "github.com/docker/docker/daemon/execdriver" ) -func (d *driver) Pause(c *execdriver.Command) error { +// Pause implements the exec driver Driver interface. +func (d *Driver) Pause(c *execdriver.Command) error { return fmt.Errorf("Windows: Containers cannot be paused") } -func (d *driver) Unpause(c *execdriver.Command) error { +// Unpause implements the exec driver Driver interface. +func (d *Driver) Unpause(c *execdriver.Command) error { return fmt.Errorf("Windows: Containers cannot be paused") } diff --git a/daemon/execdriver/windows/run.go b/daemon/execdriver/windows/run.go index 88eaa7f696f1d..8e90821ca220c 100644 --- a/daemon/execdriver/windows/run.go +++ b/daemon/execdriver/windows/run.go @@ -17,7 +17,7 @@ import ( ) type layer struct { - Id string + ID string Path string } @@ -50,7 +50,8 @@ type containerInit struct { Layers []layer } -func (d *driver) Run(c *execdriver.Command, pipes *execdriver.Pipes, startCallback execdriver.StartCallback) (execdriver.ExitStatus, error) { +// Run implements the exec driver Driver interface +func (d *Driver) Run(c *execdriver.Command, pipes *execdriver.Pipes, startCallback execdriver.StartCallback) (execdriver.ExitStatus, error) { var ( term execdriver.Terminal @@ -75,7 +76,7 @@ func (d *driver) Run(c *execdriver.Command, pipes *execdriver.Pipes, startCallba for i := 0; i < len(c.LayerPaths); i++ { cu.Layers = append(cu.Layers, layer{ - Id: hcsshim.NewGUID(c.LayerPaths[i]).ToString(), + ID: hcsshim.NewGUID(c.LayerPaths[i]).ToString(), Path: c.LayerPaths[i], }) } diff --git a/daemon/execdriver/windows/stats.go b/daemon/execdriver/windows/stats.go index b73cdc8f96523..25bd49eaed71e 100644 --- a/daemon/execdriver/windows/stats.go +++ b/daemon/execdriver/windows/stats.go @@ -8,6 +8,7 @@ import ( "github.com/docker/docker/daemon/execdriver" ) -func (d *driver) Stats(id string) (*execdriver.ResourceStats, error) { +// Stats implements the exec driver Driver interface. +func (d *Driver) Stats(id string) (*execdriver.ResourceStats, error) { return nil, fmt.Errorf("Windows: Stats not implemented") } diff --git a/daemon/execdriver/windows/stdconsole.go b/daemon/execdriver/windows/stdconsole.go index abe9e9447abe0..fb1eda2a20441 100644 --- a/daemon/execdriver/windows/stdconsole.go +++ b/daemon/execdriver/windows/stdconsole.go @@ -6,15 +6,18 @@ package windows type StdConsole struct { } +// NewStdConsole returns a new StdConsole struct. func NewStdConsole() *StdConsole { return &StdConsole{} } +// Resize implements Resize method of Terminal interface. func (s *StdConsole) Resize(h, w int) error { // we do not need to resize a non tty return nil } +// Close implements Close method of Terminal interface. func (s *StdConsole) Close() error { // nothing to close here return nil diff --git a/daemon/execdriver/windows/terminatekill.go b/daemon/execdriver/windows/terminatekill.go index f19f16fda385b..f5e14dd06b46e 100644 --- a/daemon/execdriver/windows/terminatekill.go +++ b/daemon/execdriver/windows/terminatekill.go @@ -8,12 +8,14 @@ import ( "github.com/microsoft/hcsshim" ) -func (d *driver) Terminate(p *execdriver.Command) error { +// Terminate implements the exec driver Driver interface. +func (d *Driver) Terminate(p *execdriver.Command) error { logrus.Debugf("WindowsExec: Terminate() id=%s", p.ID) return kill(p.ID, p.ContainerPid) } -func (d *driver) Kill(p *execdriver.Command, sig int) error { +// Kill implements the exec driver Driver interface. +func (d *Driver) Kill(p *execdriver.Command, sig int) error { logrus.Debugf("WindowsExec: Kill() id=%s sig=%d", p.ID, sig) return kill(p.ID, p.ContainerPid) } diff --git a/daemon/execdriver/windows/ttyconsole.go b/daemon/execdriver/windows/ttyconsole.go index 558352d21189e..ca6b1ca27358f 100644 --- a/daemon/execdriver/windows/ttyconsole.go +++ b/daemon/execdriver/windows/ttyconsole.go @@ -6,12 +6,13 @@ import ( "github.com/microsoft/hcsshim" ) -// TtyConsole is for when using a container interactively +// TtyConsole implements the exec driver Terminal interface. type TtyConsole struct { id string processid uint32 } +// NewTtyConsole returns a new TtyConsole struct. func NewTtyConsole(id string, processid uint32) *TtyConsole { tty := &TtyConsole{ id: id, @@ -20,10 +21,12 @@ func NewTtyConsole(id string, processid uint32) *TtyConsole { return tty } +// Resize implements Resize method of Terminal interface. func (t *TtyConsole) Resize(h, w int) error { return hcsshim.ResizeConsoleInComputeSystem(t.id, t.processid, h, w) } +// Close implements Close method of Terminal interface. func (t *TtyConsole) Close() error { return nil } diff --git a/daemon/execdriver/windows/windows.go b/daemon/execdriver/windows/windows.go index 5e0e304fc10c8..198ddc8dd7184 100644 --- a/daemon/execdriver/windows/windows.go +++ b/daemon/execdriver/windows/windows.go @@ -20,6 +20,7 @@ var dummyMode bool // This allows the daemon to terminate containers rather than shutdown var terminateMode bool +// Define name and version for windows var ( DriverName = "Windows 1854" Version = dockerversion.VERSION + " " + dockerversion.GITCOMMIT @@ -29,18 +30,22 @@ type activeContainer struct { command *execdriver.Command } -type driver struct { +// Driver contains all information for windows driver, +// it implements execdriver.Driver +type Driver struct { root string initPath string activeContainers map[string]*activeContainer sync.Mutex } -func (d *driver) Name() string { +// Name implements the exec driver Driver interface. +func (d *Driver) Name() string { return fmt.Sprintf("%s %s", DriverName, Version) } -func NewDriver(root, initPath string, options []string) (*driver, error) { +// NewDriver returns a new windows driver, called from NewDriver of execdriver. +func NewDriver(root, initPath string, options []string) (*Driver, error) { for _, option := range options { key, val, err := parsers.ParseKeyValueOpt(option) @@ -69,7 +74,7 @@ func NewDriver(root, initPath string, options []string) (*driver, error) { } } - return &driver{ + return &Driver{ root: root, initPath: initPath, activeContainers: make(map[string]*activeContainer), diff --git a/hack/make/validate-lint b/hack/make/validate-lint index 8fc6a331e1a08..266e41290f0a2 100644 --- a/hack/make/validate-lint +++ b/hack/make/validate-lint @@ -23,6 +23,7 @@ packages=( daemon/execdriver/lxc daemon/execdriver/native daemon/execdriver/native/template + daemon/execdriver/windows daemon/graphdriver/aufs daemon/graphdriver/devmapper daemon/logger