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

Merge pull request #17614 from LK4D4/fix_golint

Update linting tools to latest versions
This commit is contained in:
Jess Frazelle 2015-11-03 15:32:12 -08:00
commit e704182c9c
14 changed files with 78 additions and 55 deletions

View file

@ -102,8 +102,7 @@ ENV GOARM 5
# ENV GOFMT_VERSION 1.3.3
# RUN curl -sSL https://storage.googleapis.com/golang/go${GOFMT_VERSION}.$(go env GOOS)-$(go env GOARCH).tar.gz | tar -C /go/bin -xz --strip-components=2 go/bin/gofmt
# Update this sha when we upgrade to go 1.5.0
ENV GO_TOOLS_COMMIT 069d2f3bcb68257b627205f0486d6cc69a231ff9
ENV GO_TOOLS_COMMIT 823804e1ae08dbb14eb807afc7db9993bc9e3cc3
# Grab Go's cover tool for dead-simple code coverage testing
# Grab Go's vet tool for examining go code to find suspicious constructs
# and help prevent errors that the compiler might not catch
@ -112,7 +111,7 @@ RUN git clone https://github.com/golang/tools.git /go/src/golang.org/x/tools \
&& go install -v golang.org/x/tools/cmd/cover \
&& go install -v golang.org/x/tools/cmd/vet
# Grab Go's lint tool
ENV GO_LINT_COMMIT f42f5c1c440621302702cb0741e9d2ca547ae80f
ENV GO_LINT_COMMIT 32a87160691b3c96046c0c678fe57c5bef761456
RUN git clone https://github.com/golang/lint.git /go/src/github.com/golang/lint \
&& (cd /go/src/github.com/golang/lint && git checkout -q $GO_LINT_COMMIT) \
&& go install -v github.com/golang/lint/golint

View file

@ -390,9 +390,14 @@ func (s *router) postBuild(ctx context.Context, w http.ResponseWriter, r *http.R
UIDMaps: uidMaps,
GIDMaps: gidMaps,
}
docker := daemonbuilder.Docker{s.daemon, output, authConfigs, defaultArchiver}
docker := &daemonbuilder.Docker{
Daemon: s.daemon,
OutOld: output,
AuthConfigs: authConfigs,
Archiver: defaultArchiver,
}
b, err := dockerfile.NewBuilder(buildConfig, docker, builder.DockerIgnoreContext{context}, nil)
b, err := dockerfile.NewBuilder(buildConfig, docker, builder.DockerIgnoreContext{ModifiableContext: context}, nil)
if err != nil {
return errf(err)
}

View file

@ -31,7 +31,7 @@ func (daemon *Daemon) ContainerCreate(params *ContainerCreateConfig) (types.Cont
warnings, err := daemon.verifyContainerSettings(params.HostConfig, params.Config)
if err != nil {
return types.ContainerCreateResponse{"", warnings}, err
return types.ContainerCreateResponse{ID: "", Warnings: warnings}, err
}
daemon.adaptContainerSettings(params.HostConfig, params.AdjustCPUShares)
@ -40,18 +40,18 @@ func (daemon *Daemon) ContainerCreate(params *ContainerCreateConfig) (types.Cont
if err != nil {
if daemon.Graph().IsNotExist(err, params.Config.Image) {
if strings.Contains(params.Config.Image, "@") {
return types.ContainerCreateResponse{"", warnings}, derr.ErrorCodeNoSuchImageHash.WithArgs(params.Config.Image)
return types.ContainerCreateResponse{ID: "", Warnings: warnings}, derr.ErrorCodeNoSuchImageHash.WithArgs(params.Config.Image)
}
img, tag := parsers.ParseRepositoryTag(params.Config.Image)
if tag == "" {
tag = tags.DefaultTag
}
return types.ContainerCreateResponse{"", warnings}, derr.ErrorCodeNoSuchImageTag.WithArgs(img, tag)
return types.ContainerCreateResponse{ID: "", Warnings: warnings}, derr.ErrorCodeNoSuchImageTag.WithArgs(img, tag)
}
return types.ContainerCreateResponse{"", warnings}, err
return types.ContainerCreateResponse{ID: "", Warnings: warnings}, err
}
return types.ContainerCreateResponse{container.ID, warnings}, nil
return types.ContainerCreateResponse{ID: container.ID, Warnings: warnings}, nil
}
// Create creates a new container from the given configuration with a given name.

View file

@ -43,7 +43,12 @@ func (daemon *Daemon) ContainerInspect(name string, size bool) (*types.Container
Networks: container.NetworkSettings.Networks,
}
return &types.ContainerJSON{base, mountPoints, container.Config, networkSettings}, nil
return &types.ContainerJSON{
ContainerJSONBase: base,
Mounts: mountPoints,
Config: container.Config,
NetworkSettings: networkSettings,
}, nil
}
// ContainerInspect120 serializes the master version of a container into a json type.
@ -63,15 +68,20 @@ func (daemon *Daemon) ContainerInspect120(name string) (*v1p20.ContainerJSON, er
mountPoints := addMountPoints(container)
config := &v1p20.ContainerConfig{
container.Config,
container.Config.MacAddress,
container.Config.NetworkDisabled,
container.Config.ExposedPorts,
container.hostConfig.VolumeDriver,
Config: container.Config,
MacAddress: container.Config.MacAddress,
NetworkDisabled: container.Config.NetworkDisabled,
ExposedPorts: container.Config.ExposedPorts,
VolumeDriver: container.hostConfig.VolumeDriver,
}
networkSettings := daemon.getBackwardsCompatibleNetworkSettings(container.NetworkSettings)
return &v1p20.ContainerJSON{base, mountPoints, config, networkSettings}, nil
return &v1p20.ContainerJSON{
ContainerJSONBase: base,
Mounts: mountPoints,
Config: config,
NetworkSettings: networkSettings,
}, nil
}
func (daemon *Daemon) getInspectData(container *Container, size bool) (*types.ContainerJSONBase, error) {

View file

@ -40,19 +40,25 @@ func (daemon *Daemon) ContainerInspectPre120(name string) (*v1p19.ContainerJSON,
}
config := &v1p19.ContainerConfig{
container.Config,
container.Config.MacAddress,
container.Config.NetworkDisabled,
container.Config.ExposedPorts,
container.hostConfig.VolumeDriver,
container.hostConfig.Memory,
container.hostConfig.MemorySwap,
container.hostConfig.CPUShares,
container.hostConfig.CpusetCpus,
Config: container.Config,
MacAddress: container.Config.MacAddress,
NetworkDisabled: container.Config.NetworkDisabled,
ExposedPorts: container.Config.ExposedPorts,
VolumeDriver: container.hostConfig.VolumeDriver,
Memory: container.hostConfig.Memory,
MemorySwap: container.hostConfig.MemorySwap,
CPUShares: container.hostConfig.CPUShares,
CPUSet: container.hostConfig.CpusetCpus,
}
networkSettings := daemon.getBackwardsCompatibleNetworkSettings(container.NetworkSettings)
return &v1p19.ContainerJSON{base, volumes, volumesRW, config, networkSettings}, nil
return &v1p19.ContainerJSON{
ContainerJSONBase: base,
Volumes: volumes,
VolumesRW: volumesRW,
Config: config,
NetworkSettings: networkSettings,
}, nil
}
func addMountPoints(container *Container) []types.MountPoint {

View file

@ -44,10 +44,9 @@ func (graph *Graph) depth(img *image.Image) (int, error) {
return count, nil
}
// Set the max depth to the aufs default that most
// kernels are compiled with
// Set the max depth to the aufs default that most kernels are compiled with.
// For more information see: http://sourceforge.net/p/aufs/aufs3-standalone/ci/aufs3.12/tree/config.mk
const MaxImageDepth = 127
const maxImageDepth = 127
// CheckDepth returns an error if the depth of an image, as returned
// by ImageDepth, is too large to support creating a container from it
@ -59,8 +58,8 @@ func (graph *Graph) CheckDepth(img *image.Image) error {
if err != nil {
return err
}
if depth+2 >= MaxImageDepth {
return fmt.Errorf("Cannot create container with more than %d parents", MaxImageDepth)
if depth+2 >= maxImageDepth {
return fmt.Errorf("Cannot create container with more than %d parents", maxImageDepth)
}
return nil
}

View file

@ -31,7 +31,7 @@ type v1Puller struct {
func (p *v1Puller) Pull(tag string) (fallback bool, err error) {
if utils.DigestReference(tag) {
// Allowing fallback, because HTTPS v1 is before HTTP v2
return true, registry.ErrNoSupport{errors.New("Cannot pull by digest with v1 registry")}
return true, registry.ErrNoSupport{Err: errors.New("Cannot pull by digest with v1 registry")}
}
tlsConfig, err := p.registryService.TLSConfig(p.repoInfo.Index.Name)

View file

@ -31,6 +31,18 @@ const (
ChangeDelete
)
func (c ChangeType) String() string {
switch c {
case ChangeModify:
return "C"
case ChangeAdd:
return "A"
case ChangeDelete:
return "D"
}
return ""
}
// Change represents a change, it wraps the change type and path.
// It describes changes of the files in the path respect to the
// parent layers. The change could be modify, add, delete.
@ -41,16 +53,7 @@ type Change struct {
}
func (change *Change) String() string {
var kind string
switch change.Kind {
case ChangeModify:
kind = "C"
case ChangeAdd:
kind = "A"
case ChangeDelete:
kind = "D"
}
return fmt.Sprintf("%s %s", kind, change.Path)
return fmt.Sprintf("%s %s", change.Kind, change.Path)
}
// for sort.Sort

View file

@ -8,7 +8,7 @@ package devicemapper
*/
import "C"
// LibraryDeferredRemovalsupport is supported when statically linked.
// LibraryDeferredRemovalSupport is supported when statically linked.
const LibraryDeferredRemovalSupport = true
func dmTaskDeferredRemoveFct(task *cdmTask) int {

View file

@ -589,7 +589,7 @@ var Usage = func() {
PrintDefaults()
}
// Usage prints to standard error a usage message documenting the standard command layout
// ShortUsage prints to standard error a usage message documenting the standard command layout
// The function is a variable that may be changed to point to a custom function.
var ShortUsage = func() {
fmt.Fprintf(CommandLine.output, "Usage of %s:\n", os.Args[0])

View file

@ -34,7 +34,7 @@ func TruncateID(id string) string {
func generateID(crypto bool) string {
b := make([]byte, 32)
var r io.Reader = random.Reader
r := random.Reader
if crypto {
r = rand.Reader
}

View file

@ -146,7 +146,7 @@ var (
}
)
// TarSum default is "sha256"
// DefaultTHash is default TarSum hashing algoritm - "sha256".
var DefaultTHash = NewTHash("sha256", sha256.New)
type simpleTHash struct {

View file

@ -47,8 +47,9 @@ var clientCipherSuites = []uint16{
tls.TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,
}
// For use by code which already has a crypto/tls options struct but wants to
// use a commonly accepted set of TLS cipher suites, with known weak algorithms removed
// DefaultServerAcceptedCiphers should be uses by code which already has a crypto/tls
// options struct but wants to use a commonly accepted set of TLS cipher suites, with
// known weak algorithms removed.
var DefaultServerAcceptedCiphers = append(clientCipherSuites, acceptedCBCCiphers...)
// ServerDefault is a secure-enough TLS configuration for the server TLS configuration.

View file

@ -39,14 +39,14 @@ var dockerUserAgent string
func init() {
httpVersion := make([]useragent.VersionInfo, 0, 6)
httpVersion = append(httpVersion, useragent.VersionInfo{"docker", dockerversion.VERSION})
httpVersion = append(httpVersion, useragent.VersionInfo{"go", runtime.Version()})
httpVersion = append(httpVersion, useragent.VersionInfo{"git-commit", dockerversion.GITCOMMIT})
httpVersion = append(httpVersion, useragent.VersionInfo{Name: "docker", Version: dockerversion.VERSION})
httpVersion = append(httpVersion, useragent.VersionInfo{Name: "go", Version: runtime.Version()})
httpVersion = append(httpVersion, useragent.VersionInfo{Name: "git-commit", Version: dockerversion.GITCOMMIT})
if kernelVersion, err := kernel.GetKernelVersion(); err == nil {
httpVersion = append(httpVersion, useragent.VersionInfo{"kernel", kernelVersion.String()})
httpVersion = append(httpVersion, useragent.VersionInfo{Name: "kernel", Version: kernelVersion.String()})
}
httpVersion = append(httpVersion, useragent.VersionInfo{"os", runtime.GOOS})
httpVersion = append(httpVersion, useragent.VersionInfo{"arch", runtime.GOARCH})
httpVersion = append(httpVersion, useragent.VersionInfo{Name: "os", Version: runtime.GOOS})
httpVersion = append(httpVersion, useragent.VersionInfo{Name: "arch", Version: runtime.GOARCH})
dockerUserAgent = useragent.AppendVersions("", httpVersion...)