Enable golint linter

Use the golint linter and fix the reported problems.

[NO TESTS NEEDED]

Signed-off-by: Paul Holzinger <paul.holzinger@web.de>
This commit is contained in:
Paul Holzinger
2021-02-11 22:28:35 +01:00
parent ef2fc90f2d
commit 69ab67bf90
18 changed files with 34 additions and 42 deletions

View File

@ -78,11 +78,11 @@ type ExecConfig struct {
type ExecSession struct {
// Id is the ID of the exec session.
// Named somewhat strangely to not conflict with ID().
// nolint:stylecheck
// nolint:stylecheck,golint
Id string `json:"id"`
// ContainerId is the ID of the container this exec session belongs to.
// Named somewhat strangely to not conflict with ContainerID().
// nolint:stylecheck
// nolint:stylecheck,golint
ContainerId string `json:"containerId"`
// State is the state of the exec session.

View File

@ -266,7 +266,7 @@ func (c *Container) handleRestartPolicy(ctx context.Context) (_ bool, retErr err
c.newContainerEvent(events.Restart)
// Increment restart count
c.state.RestartCount += 1
c.state.RestartCount++
logrus.Debugf("Container %s now on retry %d", c.ID(), c.state.RestartCount)
if err := c.save(); err != nil {
return false, err

View File

@ -190,7 +190,7 @@ func (c *Container) updateHealthCheckLog(hcl define.HealthCheckLog, inStartPerio
}
if !inStartPeriod {
// increment failing streak
healthCheck.FailingStreak += 1
healthCheck.FailingStreak++
// if failing streak > retries, then status to unhealthy
if healthCheck.FailingStreak >= c.HealthCheckConfig().Retries {
healthCheck.Status = define.HealthCheckUnhealthy

View File

@ -75,9 +75,8 @@ func findImageInRepotags(search imageParts, images []*Image) (*storage.Image, er
}
if rwImageCnt > 1 {
return nil, errors.Wrapf(define.ErrMultipleImages, "found multiple read/write images %s", strings.Join(keys, ","))
} else {
return nil, errors.Wrapf(define.ErrMultipleImages, "found multiple read/only images %s", strings.Join(keys, ","))
}
return nil, errors.Wrapf(define.ErrMultipleImages, "found multiple read/only images %s", strings.Join(keys, ","))
}
return candidates[0].image.image, nil
}

View File

@ -222,11 +222,11 @@ func (r *Runtime) getContainerStoreInfo() (define.ContainerStore, error) {
}
switch state {
case define.ContainerStateRunning:
running += 1
running++
case define.ContainerStatePaused:
paused += 1
paused++
default:
stopped += 1
stopped++
}
}
cs.Paused = paused

View File

@ -480,9 +480,8 @@ func (r *Runtime) setupSlirp4netns(ctr *Container) error {
if havePortMapping {
if isSlirpHostForward {
return r.setupRootlessPortMappingViaSlirp(ctr, cmd, apiSocket)
} else {
return r.setupRootlessPortMappingViaRLK(ctr, netnsPath)
}
return r.setupRootlessPortMappingViaRLK(ctr, netnsPath)
}
return nil
}

View File

@ -241,9 +241,8 @@ func (p *VolumePlugin) makeErrorResponse(err, endpoint, volName string) error {
}
if volName != "" {
return errors.Wrapf(errors.New(err), "error on %s on volume %s in volume plugin %s", endpoint, volName, p.Name)
} else {
return errors.Wrapf(errors.New(err), "error on %s in volume plugin %s", endpoint, p.Name)
}
return errors.Wrapf(errors.New(err), "error on %s in volume plugin %s", endpoint, p.Name)
}
// Handle error responses from plugin

View File

@ -313,9 +313,8 @@ func (r *Runtime) LoadImageFromSingleImageArchive(ctx context.Context, writer io
if err == nil && src != nil {
if newImages, err := r.ImageRuntime().LoadFromArchiveReference(ctx, src, signaturePolicy, writer); err == nil {
return getImageNames(newImages), nil
} else {
saveErr = err
}
saveErr = err
}
}
return "", errors.Wrapf(saveErr, "error pulling image")

View File

@ -45,7 +45,7 @@ func (v *Volume) mount() error {
// If the count is non-zero, the volume is already mounted.
// Nothing to do.
if v.state.MountCount > 0 {
v.state.MountCount += 1
v.state.MountCount++
logrus.Debugf("Volume %s mount count now at %d", v.Name(), v.state.MountCount)
return v.save()
}
@ -67,7 +67,7 @@ func (v *Volume) mount() error {
return err
}
v.state.MountCount += 1
v.state.MountCount++
v.state.MountPoint = mountPoint
return v.save()
}
@ -109,7 +109,7 @@ func (v *Volume) mount() error {
logrus.Debugf("Mounted volume %s", v.Name())
// Increment the mount counter
v.state.MountCount += 1
v.state.MountCount++
logrus.Debugf("Volume %s mount count now at %d", v.Name(), v.state.MountCount)
return v.save()
}
@ -152,7 +152,7 @@ func (v *Volume) unmount(force bool) error {
}
if !force {
v.state.MountCount -= 1
v.state.MountCount--
} else {
v.state.MountCount = 0
}