Signed-off-by: Daehyeok Mun <daehyeok@gmail.com>
| ... | ... |
@@ -79,8 +79,8 @@ func ToParamWithVersion(version string, a Args) (string, error) {
|
| 79 | 79 |
} |
| 80 | 80 |
|
| 81 | 81 |
// for daemons older than v1.10, filter must be of the form map[string][]string |
| 82 |
- buf := []byte{}
|
|
| 83 |
- err := errors.New("")
|
|
| 82 |
+ var buf []byte |
|
| 83 |
+ var err error |
|
| 84 | 84 |
if version != "" && versions.LessThan(version, "1.22") {
|
| 85 | 85 |
buf, err = json.Marshal(convertArgsToSlice(a.fields)) |
| 86 | 86 |
} else {
|
| ... | ... |
@@ -204,10 +204,7 @@ func from(b *Builder, args []string, attributes map[string]bool, original string |
| 204 | 204 |
|
| 205 | 205 |
name := args[0] |
| 206 | 206 |
|
| 207 |
- var ( |
|
| 208 |
- image builder.Image |
|
| 209 |
- err error |
|
| 210 |
- ) |
|
| 207 |
+ var image builder.Image |
|
| 211 | 208 |
|
| 212 | 209 |
// Windows cannot support a container with no base image. |
| 213 | 210 |
if name == api.NoBaseImageSpecifier {
|
| ... | ... |
@@ -219,10 +216,11 @@ func from(b *Builder, args []string, attributes map[string]bool, original string |
| 219 | 219 |
} else {
|
| 220 | 220 |
// TODO: don't use `name`, instead resolve it to a digest |
| 221 | 221 |
if !b.options.PullParent {
|
| 222 |
- image, err = b.docker.GetImageOnBuild(name) |
|
| 222 |
+ image, _ = b.docker.GetImageOnBuild(name) |
|
| 223 | 223 |
// TODO: shouldn't we error out if error is different from "not found" ? |
| 224 | 224 |
} |
| 225 | 225 |
if image == nil {
|
| 226 |
+ var err error |
|
| 226 | 227 |
image, err = b.docker.PullOnBuild(b.clientCtx, name, b.options.AuthConfigs, b.Output) |
| 227 | 228 |
if err != nil {
|
| 228 | 229 |
return err |
| ... | ... |
@@ -113,7 +113,6 @@ func (b *Builder) runContextCommand(args []string, allowRemote bool, allowLocalD |
| 113 | 113 |
var err error |
| 114 | 114 |
for _, orig := range args[0 : len(args)-1] {
|
| 115 | 115 |
var fi builder.FileInfo |
| 116 |
- decompress := allowLocalDecompression |
|
| 117 | 116 |
if urlutil.IsURL(orig) {
|
| 118 | 117 |
if !allowRemote {
|
| 119 | 118 |
return fmt.Errorf("Source can't be a URL for %s", cmdName)
|
| ... | ... |
@@ -123,8 +122,10 @@ func (b *Builder) runContextCommand(args []string, allowRemote bool, allowLocalD |
| 123 | 123 |
return err |
| 124 | 124 |
} |
| 125 | 125 |
defer os.RemoveAll(filepath.Dir(fi.Path())) |
| 126 |
- decompress = false |
|
| 127 |
- infos = append(infos, copyInfo{fi, decompress})
|
|
| 126 |
+ infos = append(infos, copyInfo{
|
|
| 127 |
+ FileInfo: fi, |
|
| 128 |
+ decompress: false, |
|
| 129 |
+ }) |
|
| 128 | 130 |
continue |
| 129 | 131 |
} |
| 130 | 132 |
// not a URL |
| ... | ... |
@@ -81,14 +81,11 @@ func collect(ctx context.Context, s *formatter.ContainerStats, cli client.APICli |
| 81 | 81 |
go func() {
|
| 82 | 82 |
for {
|
| 83 | 83 |
var ( |
| 84 |
- v *types.StatsJSON |
|
| 85 |
- memPercent = 0.0 |
|
| 86 |
- cpuPercent = 0.0 |
|
| 87 |
- blkRead, blkWrite uint64 // Only used on Linux |
|
| 88 |
- mem = 0.0 |
|
| 89 |
- memLimit = 0.0 |
|
| 90 |
- memPerc = 0.0 |
|
| 91 |
- pidsStatsCurrent uint64 |
|
| 84 |
+ v *types.StatsJSON |
|
| 85 |
+ memPercent, cpuPercent float64 |
|
| 86 |
+ blkRead, blkWrite uint64 // Only used on Linux |
|
| 87 |
+ mem, memLimit, memPerc float64 |
|
| 88 |
+ pidsStatsCurrent uint64 |
|
| 92 | 89 |
) |
| 93 | 90 |
|
| 94 | 91 |
if err := dec.Decode(&v); err != nil {
|
| ... | ... |
@@ -41,7 +41,9 @@ func validateConfig(path string) error {
|
| 41 | 41 |
// validateContextDir validates the given dir and returns abs path on success. |
| 42 | 42 |
func validateContextDir(contextDir string) (string, error) {
|
| 43 | 43 |
absContextDir, err := filepath.Abs(contextDir) |
| 44 |
- |
|
| 44 |
+ if err != nil {
|
|
| 45 |
+ return "", err |
|
| 46 |
+ } |
|
| 45 | 47 |
stat, err := os.Lstat(absContextDir) |
| 46 | 48 |
if err != nil {
|
| 47 | 49 |
return "", err |
| ... | ... |
@@ -497,7 +497,7 @@ func UsingSystemd(config *Config) bool {
|
| 497 | 497 |
// verifyPlatformContainerSettings performs platform-specific validation of the |
| 498 | 498 |
// hostconfig and config structures. |
| 499 | 499 |
func verifyPlatformContainerSettings(daemon *Daemon, hostConfig *containertypes.HostConfig, config *containertypes.Config, update bool) ([]string, error) {
|
| 500 |
- warnings := []string{}
|
|
| 500 |
+ var warnings []string |
|
| 501 | 501 |
sysInfo := sysinfo.New(true) |
| 502 | 502 |
|
| 503 | 503 |
warnings, err := daemon.verifyExperimentalContainerSettings(hostConfig, config) |
| ... | ... |
@@ -925,7 +925,6 @@ func parseRemappedRoot(usergrp string) (string, string, error) {
|
| 925 | 925 |
if err != nil {
|
| 926 | 926 |
return "", "", fmt.Errorf("Error during gid lookup for %q: %v", lookupName, err)
|
| 927 | 927 |
} |
| 928 |
- groupID = group.Gid |
|
| 929 | 928 |
groupname = group.Name |
| 930 | 929 |
} |
| 931 | 930 |
} |
| ... | ... |
@@ -64,7 +64,7 @@ func (daemon *Daemon) createSpec(c *container.Container) (*specs.Spec, error) {
|
| 64 | 64 |
s.Process.User.Username = c.Config.User |
| 65 | 65 |
|
| 66 | 66 |
// In spec.Root. This is not set for Hyper-V containers |
| 67 |
- isHyperV := false |
|
| 67 |
+ var isHyperV bool |
|
| 68 | 68 |
if c.HostConfig.Isolation.IsDefault() {
|
| 69 | 69 |
// Container using default isolation, so take the default from the daemon configuration |
| 70 | 70 |
isHyperV = daemon.defaultIsolation.IsHyperV() |
| ... | ... |
@@ -121,7 +121,7 @@ type v1DependencyImage struct {
|
| 121 | 121 |
func newV1DependencyImage(l layer.Layer, parent *v1DependencyImage) *v1DependencyImage {
|
| 122 | 122 |
v1ID := digest.Digest(l.ChainID()).Hex() |
| 123 | 123 |
|
| 124 |
- config := "" |
|
| 124 |
+ var config string |
|
| 125 | 125 |
if parent != nil {
|
| 126 | 126 |
config = fmt.Sprintf(`{"id":"%s","parent":"%s"}`, v1ID, parent.V1ID())
|
| 127 | 127 |
} else {
|
| ... | ... |
@@ -290,7 +290,7 @@ func (r *Session) GetRemoteImageLayer(imgID, registry string, imgSize int64) (io |
| 290 | 290 |
if err != nil {
|
| 291 | 291 |
return nil, fmt.Errorf("Error while getting from the server: %v", err)
|
| 292 | 292 |
} |
| 293 |
- statusCode = 0 |
|
| 293 |
+ |
|
| 294 | 294 |
res, err = r.client.Do(req) |
| 295 | 295 |
if err != nil {
|
| 296 | 296 |
logrus.Debugf("Error contacting registry %s: %v", registry, err)
|
| ... | ... |
@@ -200,12 +200,12 @@ func GetAllDrivers() ([]volume.Driver, error) {
|
| 200 | 200 |
|
| 201 | 201 |
for _, p := range plugins {
|
| 202 | 202 |
name := p.Name() |
| 203 |
- ext, ok := drivers.extensions[name] |
|
| 204 |
- if ok {
|
|
| 203 |
+ |
|
| 204 |
+ if _, ok := drivers.extensions[name]; ok {
|
|
| 205 | 205 |
continue |
| 206 | 206 |
} |
| 207 | 207 |
|
| 208 |
- ext = NewVolumeDriver(name, p.BasePath(), p.Client()) |
|
| 208 |
+ ext := NewVolumeDriver(name, p.BasePath(), p.Client()) |
|
| 209 | 209 |
if p.IsV1() {
|
| 210 | 210 |
drivers.extensions[name] = ext |
| 211 | 211 |
} |