Fix windows lint issues and enable ci

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
This commit is contained in:
Michael Crosby 2017-10-25 15:37:29 -04:00
parent 1c533a2725
commit 1d298c89a4
9 changed files with 29 additions and 13 deletions

View File

@ -26,6 +26,7 @@ before_build:
build_script: build_script:
- bash.exe -elc "export PATH=/c/tools/mingw64/bin:$PATH ; mingw32-make.exe setup" - bash.exe -elc "export PATH=/c/tools/mingw64/bin:$PATH ; mingw32-make.exe setup"
- bash.exe -elc "export PATH=/c/tools/mingw64/bin:$PATH ; mingw32-make.exe fmt" - bash.exe -elc "export PATH=/c/tools/mingw64/bin:$PATH ; mingw32-make.exe fmt"
- bash.exe -elc "export PATH=/c/tools/mingw64/bin:/c/gopath/bin:$PATH ; mingw32-make.exe lint"
- bash.exe -elc "export PATH=/c/tools/mingw64/bin:$PATH ; mingw32-make.exe vet" - bash.exe -elc "export PATH=/c/tools/mingw64/bin:$PATH ; mingw32-make.exe vet"
- bash.exe -elc "export PATH=/c/tools/mingw64/bin:/c/gopath/bin:$PATH ; mingw32-make.exe ineffassign" - bash.exe -elc "export PATH=/c/tools/mingw64/bin:/c/gopath/bin:$PATH ; mingw32-make.exe ineffassign"
- bash.exe -elc "export PATH=/c/tools/mingw64/bin:$PATH ; mingw32-make.exe build" - bash.exe -elc "export PATH=/c/tools/mingw64/bin:$PATH ; mingw32-make.exe build"

View File

@ -53,8 +53,8 @@ script:
# Note that `go build -i` requires write permission to GOROOT. (So it is not called in Makefile) # Note that `go build -i` requires write permission to GOROOT. (So it is not called in Makefile)
- go build -i . - go build -i .
- make setup - make setup
- make lint
- make vet - make vet
- if [ "$GOOS" = "linux" ]; then make lint ; fi
- make ineffassign - make ineffassign
- if [ "$GOOS" = "linux" ]; then make check-protos check-api-descriptors; fi - if [ "$GOOS" = "linux" ]; then make check-protos check-api-descriptors; fi
- make build - make build

View File

@ -24,6 +24,7 @@ func dialer(address string, timeout time.Duration) (net.Conn, error) {
return winio.DialPipe(address, &timeout) return winio.DialPipe(address, &timeout)
} }
// DialAddress returns the dial address
func DialAddress(address string) string { func DialAddress(address string) string {
return address return address
} }

View File

@ -3,17 +3,21 @@ package mount
import "github.com/pkg/errors" import "github.com/pkg/errors"
var ( var (
// ErrNotImplementOnWindows is returned when an action is not implemented for windows
ErrNotImplementOnWindows = errors.New("not implemented under windows") ErrNotImplementOnWindows = errors.New("not implemented under windows")
) )
// Mount to the provided target
func (m *Mount) Mount(target string) error { func (m *Mount) Mount(target string) error {
return ErrNotImplementOnWindows return ErrNotImplementOnWindows
} }
// Unmount the mount at the provided path
func Unmount(mount string, flags int) error { func Unmount(mount string, flags int) error {
return ErrNotImplementOnWindows return ErrNotImplementOnWindows
} }
// UnmountAll mounts at the provided path
func UnmountAll(mount string, flags int) error { func UnmountAll(mount string, flags int) error {
return ErrNotImplementOnWindows return ErrNotImplementOnWindows
} }

View File

@ -64,7 +64,7 @@ type Registration struct {
ID string ID string
// Config specific to the plugin // Config specific to the plugin
Config interface{} Config interface{}
// Requires is a list of plugins that the registered plugin requires to be avaliable // Requires is a list of plugins that the registered plugin requires to be available
Requires []Type Requires []Type
// InitFn is called when initializing a plugin. The registration and // InitFn is called when initializing a plugin. The registration and

View File

@ -12,6 +12,7 @@ import (
) )
var ( var (
// ErrNotImplemented is returned when an action is not implemented
ErrNotImplemented = errors.New("not implemented") ErrNotImplemented = errors.New("not implemented")
) )
@ -25,12 +26,13 @@ func init() {
}) })
} }
type Snapshotter struct { type snapshotter struct {
root string root string
} }
// NewSnapshotter returns a new windows snapshotter
func NewSnapshotter(root string) (snapshot.Snapshotter, error) { func NewSnapshotter(root string) (snapshot.Snapshotter, error) {
return &Snapshotter{ return &snapshotter{
root: root, root: root,
}, nil }, nil
} }
@ -40,23 +42,23 @@ func NewSnapshotter(root string) (snapshot.Snapshotter, error) {
// //
// Should be used for parent resolution, existence checks and to discern // Should be used for parent resolution, existence checks and to discern
// the kind of snapshot. // the kind of snapshot.
func (o *Snapshotter) Stat(ctx context.Context, key string) (snapshot.Info, error) { func (o *snapshotter) Stat(ctx context.Context, key string) (snapshot.Info, error) {
panic("not implemented") panic("not implemented")
} }
func (o *Snapshotter) Update(ctx context.Context, info snapshot.Info, fieldpaths ...string) (snapshot.Info, error) { func (o *snapshotter) Update(ctx context.Context, info snapshot.Info, fieldpaths ...string) (snapshot.Info, error) {
panic("not implemented") panic("not implemented")
} }
func (o *Snapshotter) Usage(ctx context.Context, key string) (snapshot.Usage, error) { func (o *snapshotter) Usage(ctx context.Context, key string) (snapshot.Usage, error) {
panic("not implemented") panic("not implemented")
} }
func (o *Snapshotter) Prepare(ctx context.Context, key, parent string, opts ...snapshot.Opt) ([]mount.Mount, error) { func (o *snapshotter) Prepare(ctx context.Context, key, parent string, opts ...snapshot.Opt) ([]mount.Mount, error) {
panic("not implemented") panic("not implemented")
} }
func (o *Snapshotter) View(ctx context.Context, key, parent string, opts ...snapshot.Opt) ([]mount.Mount, error) { func (o *snapshotter) View(ctx context.Context, key, parent string, opts ...snapshot.Opt) ([]mount.Mount, error) {
panic("not implemented") panic("not implemented")
} }
@ -64,21 +66,21 @@ func (o *Snapshotter) View(ctx context.Context, key, parent string, opts ...snap
// called on an read-write or readonly transaction. // called on an read-write or readonly transaction.
// //
// This can be used to recover mounts after calling View or Prepare. // This can be used to recover mounts after calling View or Prepare.
func (o *Snapshotter) Mounts(ctx context.Context, key string) ([]mount.Mount, error) { func (o *snapshotter) Mounts(ctx context.Context, key string) ([]mount.Mount, error) {
panic("not implemented") panic("not implemented")
} }
func (o *Snapshotter) Commit(ctx context.Context, name, key string, opts ...snapshot.Opt) error { func (o *snapshotter) Commit(ctx context.Context, name, key string, opts ...snapshot.Opt) error {
panic("not implemented") panic("not implemented")
} }
// Remove abandons the transaction identified by key. All resources // Remove abandons the transaction identified by key. All resources
// associated with the key will be removed. // associated with the key will be removed.
func (o *Snapshotter) Remove(ctx context.Context, key string) error { func (o *snapshotter) Remove(ctx context.Context, key string) error {
panic("not implemented") panic("not implemented")
} }
// Walk the committed snapshots. // Walk the committed snapshots.
func (o *Snapshotter) Walk(ctx context.Context, fn func(context.Context, snapshot.Info) error) error { func (o *snapshotter) Walk(ctx context.Context, fn func(context.Context, snapshot.Info) error) error {
panic("not implemented") panic("not implemented")
} }

View File

@ -15,6 +15,7 @@ import (
specs "github.com/opencontainers/runtime-spec/specs-go" specs "github.com/opencontainers/runtime-spec/specs-go"
) )
// WithImageConfig configures the spec to from the configuration of an Image
func WithImageConfig(i Image) SpecOpts { func WithImageConfig(i Image) SpecOpts {
return func(ctx context.Context, client *Client, _ *containers.Container, s *specs.Spec) error { return func(ctx context.Context, client *Client, _ *containers.Container, s *specs.Spec) error {
var ( var (
@ -51,6 +52,8 @@ func WithImageConfig(i Image) SpecOpts {
} }
} }
// WithTTY sets the information on the spec as well as the environment variables for
// using a TTY
func WithTTY(width, height int) SpecOpts { func WithTTY(width, height int) SpecOpts {
return func(_ context.Context, _ *Client, _ *containers.Container, s *specs.Spec) error { return func(_ context.Context, _ *Client, _ *containers.Container, s *specs.Spec) error {
s.Process.Terminal = true s.Process.Terminal = true
@ -63,6 +66,7 @@ func WithTTY(width, height int) SpecOpts {
} }
} }
// WithResources sets the provided resources on the spec for task updates
func WithResources(resources *specs.WindowsResources) UpdateTaskOpts { func WithResources(resources *specs.WindowsResources) UpdateTaskOpts {
return func(ctx context.Context, client *Client, r *UpdateTaskInfo) error { return func(ctx context.Context, client *Client, r *UpdateTaskInfo) error {
r.Resources = resources r.Resources = resources

View File

@ -1,5 +1,8 @@
package sys package sys
// SetOOMScore sets the oom score for the process
//
// Not implemented on Windows
func SetOOMScore(pid, score int) error { func SetOOMScore(pid, score int) error {
return nil return nil
} }

View File

@ -50,6 +50,7 @@ func init() {
}) })
} }
// New returns a new Windows runtime
func New(ic *plugin.InitContext) (interface{}, error) { func New(ic *plugin.InitContext) (interface{}, error) {
if err := os.MkdirAll(ic.Root, 0700); err != nil { if err := os.MkdirAll(ic.Root, 0700); err != nil {
return nil, errors.Wrapf(err, "could not create state directory at %s", ic.Root) return nil, errors.Wrapf(err, "could not create state directory at %s", ic.Root)