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

Add unconvert linter

Signed-off-by: Daniel Nephin <dnephin@docker.com>
This commit is contained in:
Daniel Nephin 2017-08-24 13:11:44 -04:00
parent 709bf8b7bc
commit 2f5f0af3fd
23 changed files with 31 additions and 34 deletions

View file

@ -70,7 +70,7 @@ func (s *containerRouter) getContainersStats(ctx context.Context, w http.Respons
config := &backend.ContainerStatsConfig{ config := &backend.ContainerStatsConfig{
Stream: stream, Stream: stream,
OutStream: w, OutStream: w,
Version: string(httputils.VersionFromContext(ctx)), Version: httputils.VersionFromContext(ctx),
} }
return s.backend.ContainerStats(ctx, vars["name"], config) return s.backend.ContainerStats(ctx, vars["name"], config)

View file

@ -66,9 +66,7 @@ func (s *imageRouter) postCommit(ctx context.Context, w http.ResponseWriter, r *
return err return err
} }
return httputils.WriteJSON(w, http.StatusCreated, &types.IDResponse{ return httputils.WriteJSON(w, http.StatusCreated, &types.IDResponse{ID: imgID})
ID: string(imgID),
})
} }
// Creates an image from Pull or from Import // Creates an image from Pull or from Import

View file

@ -551,7 +551,7 @@ func parseOptInterval(f *Flag) (time.Duration, error) {
if err != nil { if err != nil {
return 0, err return 0, err
} }
if d < time.Duration(container.MinimumDuration) { if d < container.MinimumDuration {
return 0, fmt.Errorf("Interval %#v cannot be less than %s", f.name, container.MinimumDuration) return 0, fmt.Errorf("Interval %#v cannot be less than %s", f.name, container.MinimumDuration)
} }
return d, nil return d, nil

View file

@ -243,7 +243,7 @@ func (b *Builder) probeCache(dispatchState *dispatchState, runConfig *container.
} }
fmt.Fprint(b.Stdout, " ---> Using cache\n") fmt.Fprint(b.Stdout, " ---> Using cache\n")
dispatchState.imageID = string(cachedID) dispatchState.imageID = cachedID
b.buildStages.update(dispatchState.imageID) b.buildStages.update(dispatchState.imageID)
return true, nil return true, nil
} }

View file

@ -3,7 +3,6 @@ package convert
import ( import (
"fmt" "fmt"
"strings" "strings"
"time"
types "github.com/docker/docker/api/types/swarm" types "github.com/docker/docker/api/types/swarm"
swarmapi "github.com/docker/swarmkit/api" swarmapi "github.com/docker/swarmkit/api"
@ -115,7 +114,7 @@ func MergeSwarmSpecToGRPC(s types.Spec, spec swarmapi.ClusterSpec) (swarmapi.Clu
spec.Raft.ElectionTick = uint32(s.Raft.ElectionTick) spec.Raft.ElectionTick = uint32(s.Raft.ElectionTick)
} }
if s.Dispatcher.HeartbeatPeriod != 0 { if s.Dispatcher.HeartbeatPeriod != 0 {
spec.Dispatcher.HeartbeatPeriod = gogotypes.DurationProto(time.Duration(s.Dispatcher.HeartbeatPeriod)) spec.Dispatcher.HeartbeatPeriod = gogotypes.DurationProto(s.Dispatcher.HeartbeatPeriod)
} }
if s.CAConfig.NodeCertExpiry != 0 { if s.CAConfig.NodeCertExpiry != 0 {
spec.CAConfig.NodeCertExpiry = gogotypes.DurationProto(s.CAConfig.NodeCertExpiry) spec.CAConfig.NodeCertExpiry = gogotypes.DurationProto(s.CAConfig.NodeCertExpiry)

View file

@ -659,7 +659,7 @@ func (e *exitError) Error() string {
} }
func (e *exitError) ExitCode() int { func (e *exitError) ExitCode() int {
return int(e.code) return e.code
} }
func (e *exitError) Cause() error { func (e *exitError) Cause() error {

View file

@ -158,8 +158,8 @@ func copyDir(srcDir, dstDir string, flags copyFlags) error {
// system.Chtimes doesn't support a NOFOLLOW flag atm // system.Chtimes doesn't support a NOFOLLOW flag atm
if !isSymlink { if !isSymlink {
aTime := time.Unix(int64(stat.Atim.Sec), int64(stat.Atim.Nsec)) aTime := time.Unix(stat.Atim.Sec, stat.Atim.Nsec)
mTime := time.Unix(int64(stat.Mtim.Sec), int64(stat.Mtim.Nsec)) mTime := time.Unix(stat.Mtim.Sec, stat.Mtim.Nsec)
if err := system.Chtimes(dstPath, aTime, mTime); err != nil { if err := system.Chtimes(dstPath, aTime, mTime); err != nil {
return err return err
} }

View file

@ -97,10 +97,10 @@ func (daemon *Daemon) SystemInfo() (*types.Info, error) {
drivers = strings.TrimSpace(drivers) drivers = strings.TrimSpace(drivers)
v := &types.Info{ v := &types.Info{
ID: daemon.ID, ID: daemon.ID,
Containers: int(cRunning + cPaused + cStopped), Containers: cRunning + cPaused + cStopped,
ContainersRunning: int(cRunning), ContainersRunning: cRunning,
ContainersPaused: int(cPaused), ContainersPaused: cPaused,
ContainersStopped: int(cStopped), ContainersStopped: cStopped,
Images: imageCount, Images: imageCount,
Driver: drivers, Driver: drivers,
DriverStatus: daemon.stores[p].layerStore.DriverStatus(), DriverStatus: daemon.stores[p].layerStore.DriverStatus(),

View file

@ -86,7 +86,7 @@ func listenFD(addr string, tlsConfig *tls.Config) ([]net.Listener, error) {
return nil, fmt.Errorf("failed to parse systemd fd address: should be a number: %v", addr) return nil, fmt.Errorf("failed to parse systemd fd address: should be a number: %v", addr)
} }
fdOffset := fdNum - 3 fdOffset := fdNum - 3
if len(listeners) < int(fdOffset)+1 { if len(listeners) < fdOffset+1 {
return nil, fmt.Errorf("too few socket activated files passed in by systemd") return nil, fmt.Errorf("too few socket activated files passed in by systemd")
} }
if listeners[fdOffset] == nil { if listeners[fdOffset] == nil {

View file

@ -834,7 +834,7 @@ func (daemon *Daemon) createSpec(c *container.Container) (*specs.Spec, error) {
s.Process.NoNewPrivileges = c.NoNewPrivileges s.Process.NoNewPrivileges = c.NoNewPrivileges
s.Linux.MountLabel = c.MountLabel s.Linux.MountLabel = c.MountLabel
return (*specs.Spec)(&s), nil return &s, nil
} }
func clearReadOnly(m *specs.Mount) { func clearReadOnly(m *specs.Mount) {

View file

@ -84,7 +84,7 @@ func ComputeV2MetadataHMACKey(authConfig *types.AuthConfig) ([]byte, error) {
if err != nil { if err != nil {
return nil, err return nil, err
} }
return []byte(digest.FromBytes([]byte(buf))), nil return []byte(digest.FromBytes(buf)), nil
} }
// authConfigKeyInput is a reduced AuthConfig structure holding just relevant credential data eligible for // authConfigKeyInput is a reduced AuthConfig structure holding just relevant credential data eligible for

View file

@ -15,6 +15,7 @@
"goimports", "goimports",
"golint", "golint",
"interfacer", "interfacer",
"unconvert",
"vet" "vet"
], ],

View file

@ -50,7 +50,7 @@ func (clnt *client) Create(containerID string, checkpoint string, checkpointDir
return fmt.Errorf("Container %s is already active", containerID) return fmt.Errorf("Container %s is already active", containerID)
} }
uid, gid, err := getRootIDs(specs.Spec(spec)) uid, gid, err := getRootIDs(spec)
if err != nil { if err != nil {
return err return err
} }

View file

@ -180,7 +180,7 @@ func (opts *MapOpts) GetAll() map[string]string {
} }
func (opts *MapOpts) String() string { func (opts *MapOpts) String() string {
return fmt.Sprintf("%v", map[string]string((opts.values))) return fmt.Sprintf("%v", opts.values)
} }
// Type returns a string name for this Option type // Type returns a string name for this Option type

View file

@ -18,7 +18,7 @@ func (s *QuotedString) Type() string {
} }
func (s *QuotedString) String() string { func (s *QuotedString) String() string {
return string(*s.value) return *s.value
} }
func trimQuotes(value string) string { func trimQuotes(value string) string {

View file

@ -50,8 +50,8 @@ func setHeaderForSpecialDevice(hdr *tar.Header, name string, stat interface{}) (
// Currently go does not fill in the major/minors // Currently go does not fill in the major/minors
if s.Mode&unix.S_IFBLK != 0 || if s.Mode&unix.S_IFBLK != 0 ||
s.Mode&unix.S_IFCHR != 0 { s.Mode&unix.S_IFCHR != 0 {
hdr.Devmajor = int64(major(uint64(s.Rdev))) hdr.Devmajor = int64(major(s.Rdev))
hdr.Devminor = int64(minor(uint64(s.Rdev))) hdr.Devminor = int64(minor(s.Rdev))
} }
} }
@ -62,7 +62,7 @@ func getInodeFromStat(stat interface{}) (inode uint64, err error) {
s, ok := stat.(*syscall.Stat_t) s, ok := stat.(*syscall.Stat_t)
if ok { if ok {
inode = uint64(s.Ino) inode = s.Ino
} }
return return

View file

@ -294,7 +294,7 @@ func OverlayChanges(layers []string, rw string) ([]Change, error) {
func overlayDeletedFile(root, path string, fi os.FileInfo) (string, error) { func overlayDeletedFile(root, path string, fi os.FileInfo) (string, error) {
if fi.Mode()&os.ModeCharDevice != 0 { if fi.Mode()&os.ModeCharDevice != 0 {
s := fi.Sys().(*syscall.Stat_t) s := fi.Sys().(*syscall.Stat_t)
if major(uint64(s.Rdev)) == 0 && minor(uint64(s.Rdev)) == 0 { if major(s.Rdev) == 0 && minor(s.Rdev) == 0 {
return path, nil return path, nil
} }
} }

View file

@ -29,7 +29,7 @@ func (info *FileInfo) isDir() bool {
} }
func getIno(fi os.FileInfo) uint64 { func getIno(fi os.FileInfo) uint64 {
return uint64(fi.Sys().(*syscall.Stat_t).Ino) return fi.Sys().(*syscall.Stat_t).Ino
} }
func hasHardlinks(fi os.FileInfo) bool { func hasHardlinks(fi os.FileInfo) bool {

View file

@ -74,7 +74,7 @@ type DefaultLogger struct {
// DMLog is the logging callback containing all of the information from // DMLog is the logging callback containing all of the information from
// devicemapper. The interface is identical to the C libdm counterpart. // devicemapper. The interface is identical to the C libdm counterpart.
func (l DefaultLogger) DMLog(level int, file string, line, dmError int, message string) { func (l DefaultLogger) DMLog(level int, file string, line, dmError int, message string) {
if int(level) <= l.Level { if level <= l.Level {
// Forward the log to the correct logrus level, if allowed by dmLogLevel. // Forward the log to the correct logrus level, if allowed by dmLogLevel.
logMsg := fmt.Sprintf("libdevmapper(%d): %s:%d (%d) %s", level, file, line, dmError, message) logMsg := fmt.Sprintf("libdevmapper(%d): %s:%d (%d) %s", level, file, line, dmError, message)
switch level { switch level {

View file

@ -34,11 +34,11 @@ func Size(dir string) (size int64, err error) {
// Check inode to handle hard links correctly // Check inode to handle hard links correctly
inode := fileInfo.Sys().(*syscall.Stat_t).Ino inode := fileInfo.Sys().(*syscall.Stat_t).Ino
// inode is not a uint64 on all platforms. Cast it to avoid issues. // inode is not a uint64 on all platforms. Cast it to avoid issues.
if _, exists := data[uint64(inode)]; exists { if _, exists := data[inode]; exists {
return nil return nil
} }
// inode is not a uint64 on all platforms. Cast it to avoid issues. // inode is not a uint64 on all platforms. Cast it to avoid issues.
data[uint64(inode)] = struct{}{} data[inode] = struct{}{}
size += s size += s

View file

@ -5,10 +5,10 @@ import "syscall"
// fromStatT converts a syscall.Stat_t type to a system.Stat_t type // fromStatT converts a syscall.Stat_t type to a system.Stat_t type
func fromStatT(s *syscall.Stat_t) (*StatT, error) { func fromStatT(s *syscall.Stat_t) (*StatT, error) {
return &StatT{size: s.Size, return &StatT{size: s.Size,
mode: uint32(s.Mode), mode: s.Mode,
uid: s.Uid, uid: s.Uid,
gid: s.Gid, gid: s.Gid,
rdev: uint64(s.Rdev), rdev: s.Rdev,
mtim: s.Mtim}, nil mtim: s.Mtim}, nil
} }

View file

@ -59,7 +59,7 @@ next:
return nil, fmt.Errorf("Unknown character: '%s'", key) return nil, fmt.Errorf("Unknown character: '%s'", key)
} }
} else { } else {
codes = append(codes, byte(key[0])) codes = append(codes, key[0])
} }
} }
return codes, nil return codes, nil

View file

@ -18,7 +18,6 @@ import (
"github.com/docker/docker/pkg/stringid" "github.com/docker/docker/pkg/stringid"
"github.com/docker/docker/plugin/v2" "github.com/docker/docker/plugin/v2"
"github.com/opencontainers/go-digest" "github.com/opencontainers/go-digest"
specs "github.com/opencontainers/runtime-spec/specs-go"
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
"golang.org/x/sys/unix" "golang.org/x/sys/unix"
@ -62,7 +61,7 @@ func (pm *Manager) enable(p *v2.Plugin, c *controller, force bool) error {
return errors.WithStack(err) return errors.WithStack(err)
} }
if err := pm.containerdClient.Create(p.GetID(), "", "", specs.Spec(*spec), attachToLog(p.GetID())); err != nil { if err := pm.containerdClient.Create(p.GetID(), "", "", *spec, attachToLog(p.GetID())); err != nil {
if p.PropagatedMount != "" { if p.PropagatedMount != "" {
if err := mount.Unmount(p.PropagatedMount); err != nil { if err := mount.Unmount(p.PropagatedMount); err != nil {
logrus.Warnf("Could not unmount %s: %v", p.PropagatedMount, err) logrus.Warnf("Could not unmount %s: %v", p.PropagatedMount, err)