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

Fix go vet warnings

Signed-off-by: Alexander Morozov <lk4d4@docker.com>
This commit is contained in:
Alexander Morozov 2015-11-02 08:28:34 -08:00
parent 270e8cf64d
commit 7aa28b6bdd
7 changed files with 65 additions and 41 deletions

View file

@ -386,9 +386,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

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

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