1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Fix golint warnings for daemon/execdriver/windows

Addresses: #14756

Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>
This commit is contained in:
Qiang Huang 2015-08-03 09:54:02 +08:00
parent 05529ab584
commit f9b5eb0cac
12 changed files with 40 additions and 18 deletions

View file

@ -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
}

View file

@ -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

View file

@ -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")
}

View file

@ -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,

View file

@ -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")
}

View file

@ -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],
})
}

View file

@ -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")
}

View file

@ -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

View file

@ -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)
}

View file

@ -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
}

View file

@ -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),

View file

@ -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