Skip to content

Commit

Permalink
Fix golint warnings for daemon/execdriver/windows
Browse files Browse the repository at this point in the history
Addresses: moby#14756

Signed-off-by: Qiang Huang <[email protected]>
  • Loading branch information
hqhq committed Aug 3, 2015
1 parent 05529ab commit f9b5eb0
Show file tree
Hide file tree
Showing 12 changed files with 40 additions and 18 deletions.
3 changes: 2 additions & 1 deletion daemon/execdriver/windows/clean.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
5 changes: 3 additions & 2 deletions daemon/execdriver/windows/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion daemon/execdriver/windows/getpids.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
3 changes: 2 additions & 1 deletion daemon/execdriver/windows/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 4 additions & 2 deletions daemon/execdriver/windows/pauseunpause.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
7 changes: 4 additions & 3 deletions daemon/execdriver/windows/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
)

type layer struct {
Id string
ID string
Path string
}

Expand Down Expand Up @@ -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
Expand All @@ -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],
})
}
Expand Down
3 changes: 2 additions & 1 deletion daemon/execdriver/windows/stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
3 changes: 3 additions & 0 deletions daemon/execdriver/windows/stdconsole.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions daemon/execdriver/windows/terminatekill.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
5 changes: 4 additions & 1 deletion daemon/execdriver/windows/ttyconsole.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
}
13 changes: 9 additions & 4 deletions daemon/execdriver/windows/windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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),
Expand Down
1 change: 1 addition & 0 deletions hack/make/validate-lint
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f9b5eb0

Please sign in to comment.