Merge pull request #15114 from hqhq/hq_exedriver_win_lint

Fix golint warnings for daemon/execdriver/windows
This commit is contained in:
Arnaud Porterie 2015-08-03 16:28:47 -07:00
commit ff3adb135d
12 changed files with 40 additions and 18 deletions

View File

@ -2,6 +2,7 @@
package windows 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 return nil
} }

View File

@ -13,13 +13,14 @@ import (
"github.com/natefinch/npipe" "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 ( var (
inListen, outListen, errListen *npipe.PipeListener inListen, outListen, errListen *npipe.PipeListener
term execdriver.Terminal term execdriver.Terminal
err error err error
randomID string = stringid.GenerateNonCryptoID() randomID = stringid.GenerateNonCryptoID()
serverPipeFormat, clientPipeFormat string serverPipeFormat, clientPipeFormat string
pid uint32 pid uint32
exitCode int32 exitCode int32

View File

@ -4,7 +4,8 @@ package windows
import "fmt" 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. // TODO Windows: Implementation required.
return nil, fmt.Errorf("GetPidsForContainer: GetPidsForContainer() not implemented") return nil, fmt.Errorf("GetPidsForContainer: GetPidsForContainer() not implemented")
} }

View File

@ -9,7 +9,8 @@ type info struct {
driver *driver 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{ return &info{
ID: id, ID: id,
driver: d, driver: d,

View File

@ -8,10 +8,12 @@ import (
"github.com/docker/docker/daemon/execdriver" "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") 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") return fmt.Errorf("Windows: Containers cannot be paused")
} }

View File

@ -17,7 +17,7 @@ import (
) )
type layer struct { type layer struct {
Id string ID string
Path string Path string
} }
@ -50,7 +50,8 @@ type containerInit struct {
Layers []layer 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 ( var (
term execdriver.Terminal 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++ { for i := 0; i < len(c.LayerPaths); i++ {
cu.Layers = append(cu.Layers, layer{ cu.Layers = append(cu.Layers, layer{
Id: hcsshim.NewGUID(c.LayerPaths[i]).ToString(), ID: hcsshim.NewGUID(c.LayerPaths[i]).ToString(),
Path: c.LayerPaths[i], Path: c.LayerPaths[i],
}) })
} }

View File

@ -8,6 +8,7 @@ import (
"github.com/docker/docker/daemon/execdriver" "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") return nil, fmt.Errorf("Windows: Stats not implemented")
} }

View File

@ -6,15 +6,18 @@ package windows
type StdConsole struct { type StdConsole struct {
} }
// NewStdConsole returns a new StdConsole struct.
func NewStdConsole() *StdConsole { func NewStdConsole() *StdConsole {
return &StdConsole{} return &StdConsole{}
} }
// Resize implements Resize method of Terminal interface.
func (s *StdConsole) Resize(h, w int) error { func (s *StdConsole) Resize(h, w int) error {
// we do not need to resize a non tty // we do not need to resize a non tty
return nil return nil
} }
// Close implements Close method of Terminal interface.
func (s *StdConsole) Close() error { func (s *StdConsole) Close() error {
// nothing to close here // nothing to close here
return nil return nil

View File

@ -8,12 +8,14 @@ import (
"github.com/microsoft/hcsshim" "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) logrus.Debugf("WindowsExec: Terminate() id=%s", p.ID)
return kill(p.ID, p.ContainerPid) 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) logrus.Debugf("WindowsExec: Kill() id=%s sig=%d", p.ID, sig)
return kill(p.ID, p.ContainerPid) return kill(p.ID, p.ContainerPid)
} }

View File

@ -6,12 +6,13 @@ import (
"github.com/microsoft/hcsshim" "github.com/microsoft/hcsshim"
) )
// TtyConsole is for when using a container interactively // TtyConsole implements the exec driver Terminal interface.
type TtyConsole struct { type TtyConsole struct {
id string id string
processid uint32 processid uint32
} }
// NewTtyConsole returns a new TtyConsole struct.
func NewTtyConsole(id string, processid uint32) *TtyConsole { func NewTtyConsole(id string, processid uint32) *TtyConsole {
tty := &TtyConsole{ tty := &TtyConsole{
id: id, id: id,
@ -20,10 +21,12 @@ func NewTtyConsole(id string, processid uint32) *TtyConsole {
return tty return tty
} }
// Resize implements Resize method of Terminal interface.
func (t *TtyConsole) Resize(h, w int) error { func (t *TtyConsole) Resize(h, w int) error {
return hcsshim.ResizeConsoleInComputeSystem(t.id, t.processid, h, w) return hcsshim.ResizeConsoleInComputeSystem(t.id, t.processid, h, w)
} }
// Close implements Close method of Terminal interface.
func (t *TtyConsole) Close() error { func (t *TtyConsole) Close() error {
return nil return nil
} }

View File

@ -20,6 +20,7 @@ var dummyMode bool
// This allows the daemon to terminate containers rather than shutdown // This allows the daemon to terminate containers rather than shutdown
var terminateMode bool var terminateMode bool
// Define name and version for windows
var ( var (
DriverName = "Windows 1854" DriverName = "Windows 1854"
Version = dockerversion.VERSION + " " + dockerversion.GITCOMMIT Version = dockerversion.VERSION + " " + dockerversion.GITCOMMIT
@ -29,18 +30,22 @@ type activeContainer struct {
command *execdriver.Command command *execdriver.Command
} }
type driver struct { // Driver contains all information for windows driver,
// it implements execdriver.Driver
type Driver struct {
root string root string
initPath string initPath string
activeContainers map[string]*activeContainer activeContainers map[string]*activeContainer
sync.Mutex 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) 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 { for _, option := range options {
key, val, err := parsers.ParseKeyValueOpt(option) 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, root: root,
initPath: initPath, initPath: initPath,
activeContainers: make(map[string]*activeContainer), activeContainers: make(map[string]*activeContainer),

View File

@ -23,6 +23,7 @@ packages=(
daemon/execdriver/lxc daemon/execdriver/lxc
daemon/execdriver/native daemon/execdriver/native
daemon/execdriver/native/template daemon/execdriver/native/template
daemon/execdriver/windows
daemon/graphdriver/aufs daemon/graphdriver/aufs
daemon/graphdriver/devmapper daemon/graphdriver/devmapper
daemon/logger daemon/logger