Fix go vet warnings
Signed-off-by: Alexander Morozov <lk4d4@docker.com>
This commit is contained in:
parent
270e8cf64d
commit
7aa28b6bdd
7 changed files with 65 additions and 41 deletions
|
@ -386,9 +386,14 @@ func (s *router) postBuild(ctx context.Context, w http.ResponseWriter, r *http.R
|
||||||
UIDMaps: uidMaps,
|
UIDMaps: uidMaps,
|
||||||
GIDMaps: gidMaps,
|
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 {
|
if err != nil {
|
||||||
return errf(err)
|
return errf(err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@ func (daemon *Daemon) ContainerCreate(params *ContainerCreateConfig) (types.Cont
|
||||||
|
|
||||||
warnings, err := daemon.verifyContainerSettings(params.HostConfig, params.Config)
|
warnings, err := daemon.verifyContainerSettings(params.HostConfig, params.Config)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return types.ContainerCreateResponse{"", warnings}, err
|
return types.ContainerCreateResponse{ID: "", Warnings: warnings}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
daemon.adaptContainerSettings(params.HostConfig, params.AdjustCPUShares)
|
daemon.adaptContainerSettings(params.HostConfig, params.AdjustCPUShares)
|
||||||
|
@ -40,18 +40,18 @@ func (daemon *Daemon) ContainerCreate(params *ContainerCreateConfig) (types.Cont
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if daemon.Graph().IsNotExist(err, params.Config.Image) {
|
if daemon.Graph().IsNotExist(err, params.Config.Image) {
|
||||||
if strings.Contains(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)
|
img, tag := parsers.ParseRepositoryTag(params.Config.Image)
|
||||||
if tag == "" {
|
if tag == "" {
|
||||||
tag = tags.DefaultTag
|
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.
|
// Create creates a new container from the given configuration with a given name.
|
||||||
|
|
|
@ -43,7 +43,12 @@ func (daemon *Daemon) ContainerInspect(name string, size bool) (*types.Container
|
||||||
Networks: container.NetworkSettings.Networks,
|
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.
|
// 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)
|
mountPoints := addMountPoints(container)
|
||||||
config := &v1p20.ContainerConfig{
|
config := &v1p20.ContainerConfig{
|
||||||
container.Config,
|
Config: container.Config,
|
||||||
container.Config.MacAddress,
|
MacAddress: container.Config.MacAddress,
|
||||||
container.Config.NetworkDisabled,
|
NetworkDisabled: container.Config.NetworkDisabled,
|
||||||
container.Config.ExposedPorts,
|
ExposedPorts: container.Config.ExposedPorts,
|
||||||
container.hostConfig.VolumeDriver,
|
VolumeDriver: container.hostConfig.VolumeDriver,
|
||||||
}
|
}
|
||||||
networkSettings := daemon.getBackwardsCompatibleNetworkSettings(container.NetworkSettings)
|
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) {
|
func (daemon *Daemon) getInspectData(container *Container, size bool) (*types.ContainerJSONBase, error) {
|
||||||
|
|
|
@ -40,19 +40,25 @@ func (daemon *Daemon) ContainerInspectPre120(name string) (*v1p19.ContainerJSON,
|
||||||
}
|
}
|
||||||
|
|
||||||
config := &v1p19.ContainerConfig{
|
config := &v1p19.ContainerConfig{
|
||||||
container.Config,
|
Config: container.Config,
|
||||||
container.Config.MacAddress,
|
MacAddress: container.Config.MacAddress,
|
||||||
container.Config.NetworkDisabled,
|
NetworkDisabled: container.Config.NetworkDisabled,
|
||||||
container.Config.ExposedPorts,
|
ExposedPorts: container.Config.ExposedPorts,
|
||||||
container.hostConfig.VolumeDriver,
|
VolumeDriver: container.hostConfig.VolumeDriver,
|
||||||
container.hostConfig.Memory,
|
Memory: container.hostConfig.Memory,
|
||||||
container.hostConfig.MemorySwap,
|
MemorySwap: container.hostConfig.MemorySwap,
|
||||||
container.hostConfig.CPUShares,
|
CPUShares: container.hostConfig.CPUShares,
|
||||||
container.hostConfig.CpusetCpus,
|
CPUSet: container.hostConfig.CpusetCpus,
|
||||||
}
|
}
|
||||||
networkSettings := daemon.getBackwardsCompatibleNetworkSettings(container.NetworkSettings)
|
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 {
|
func addMountPoints(container *Container) []types.MountPoint {
|
||||||
|
|
|
@ -31,7 +31,7 @@ type v1Puller struct {
|
||||||
func (p *v1Puller) Pull(tag string) (fallback bool, err error) {
|
func (p *v1Puller) Pull(tag string) (fallback bool, err error) {
|
||||||
if utils.DigestReference(tag) {
|
if utils.DigestReference(tag) {
|
||||||
// Allowing fallback, because HTTPS v1 is before HTTP v2
|
// 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)
|
tlsConfig, err := p.registryService.TLSConfig(p.repoInfo.Index.Name)
|
||||||
|
|
|
@ -31,6 +31,18 @@ const (
|
||||||
ChangeDelete
|
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.
|
// Change represents a change, it wraps the change type and path.
|
||||||
// It describes changes of the files in the path respect to the
|
// It describes changes of the files in the path respect to the
|
||||||
// parent layers. The change could be modify, add, delete.
|
// parent layers. The change could be modify, add, delete.
|
||||||
|
@ -41,16 +53,7 @@ type Change struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (change *Change) String() string {
|
func (change *Change) String() string {
|
||||||
var kind string
|
return fmt.Sprintf("%s %s", change.Kind, change.Path)
|
||||||
switch change.Kind {
|
|
||||||
case ChangeModify:
|
|
||||||
kind = "C"
|
|
||||||
case ChangeAdd:
|
|
||||||
kind = "A"
|
|
||||||
case ChangeDelete:
|
|
||||||
kind = "D"
|
|
||||||
}
|
|
||||||
return fmt.Sprintf("%s %s", kind, change.Path)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// for sort.Sort
|
// for sort.Sort
|
||||||
|
|
|
@ -39,14 +39,14 @@ var dockerUserAgent string
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
httpVersion := make([]useragent.VersionInfo, 0, 6)
|
httpVersion := make([]useragent.VersionInfo, 0, 6)
|
||||||
httpVersion = append(httpVersion, useragent.VersionInfo{"docker", dockerversion.VERSION})
|
httpVersion = append(httpVersion, useragent.VersionInfo{Name: "docker", Version: dockerversion.VERSION})
|
||||||
httpVersion = append(httpVersion, useragent.VersionInfo{"go", runtime.Version()})
|
httpVersion = append(httpVersion, useragent.VersionInfo{Name: "go", Version: runtime.Version()})
|
||||||
httpVersion = append(httpVersion, useragent.VersionInfo{"git-commit", dockerversion.GITCOMMIT})
|
httpVersion = append(httpVersion, useragent.VersionInfo{Name: "git-commit", Version: dockerversion.GITCOMMIT})
|
||||||
if kernelVersion, err := kernel.GetKernelVersion(); err == nil {
|
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{Name: "os", Version: runtime.GOOS})
|
||||||
httpVersion = append(httpVersion, useragent.VersionInfo{"arch", runtime.GOARCH})
|
httpVersion = append(httpVersion, useragent.VersionInfo{Name: "arch", Version: runtime.GOARCH})
|
||||||
|
|
||||||
dockerUserAgent = useragent.AppendVersions("", httpVersion...)
|
dockerUserAgent = useragent.AppendVersions("", httpVersion...)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue