mirror of
https://github.com/containers/podman.git
synced 2025-10-18 03:33:32 +08:00
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:
@ -51,7 +51,6 @@ linters:
|
|||||||
- gochecknoinits
|
- gochecknoinits
|
||||||
- goconst
|
- goconst
|
||||||
- gocyclo
|
- gocyclo
|
||||||
- golint
|
|
||||||
- lll
|
- lll
|
||||||
- structcheck
|
- structcheck
|
||||||
- typecheck
|
- typecheck
|
||||||
|
@ -243,12 +243,12 @@ func ps(cmd *cobra.Command, _ []string) error {
|
|||||||
// responses will grow to the largest number of processes reported on, but will not thrash the gc
|
// responses will grow to the largest number of processes reported on, but will not thrash the gc
|
||||||
var responses []psReporter
|
var responses []psReporter
|
||||||
for ; ; responses = responses[:0] {
|
for ; ; responses = responses[:0] {
|
||||||
if ctnrs, err := getResponses(); err != nil {
|
ctnrs, err := getResponses()
|
||||||
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
} else {
|
}
|
||||||
for _, r := range ctnrs {
|
for _, r := range ctnrs {
|
||||||
responses = append(responses, psReporter{r})
|
responses = append(responses, psReporter{r})
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tm.Clear()
|
tm.Clear()
|
||||||
|
@ -78,11 +78,11 @@ type ExecConfig struct {
|
|||||||
type ExecSession struct {
|
type ExecSession struct {
|
||||||
// Id is the ID of the exec session.
|
// Id is the ID of the exec session.
|
||||||
// Named somewhat strangely to not conflict with ID().
|
// Named somewhat strangely to not conflict with ID().
|
||||||
// nolint:stylecheck
|
// nolint:stylecheck,golint
|
||||||
Id string `json:"id"`
|
Id string `json:"id"`
|
||||||
// ContainerId is the ID of the container this exec session belongs to.
|
// ContainerId is the ID of the container this exec session belongs to.
|
||||||
// Named somewhat strangely to not conflict with ContainerID().
|
// Named somewhat strangely to not conflict with ContainerID().
|
||||||
// nolint:stylecheck
|
// nolint:stylecheck,golint
|
||||||
ContainerId string `json:"containerId"`
|
ContainerId string `json:"containerId"`
|
||||||
|
|
||||||
// State is the state of the exec session.
|
// State is the state of the exec session.
|
||||||
|
@ -266,7 +266,7 @@ func (c *Container) handleRestartPolicy(ctx context.Context) (_ bool, retErr err
|
|||||||
c.newContainerEvent(events.Restart)
|
c.newContainerEvent(events.Restart)
|
||||||
|
|
||||||
// Increment restart count
|
// Increment restart count
|
||||||
c.state.RestartCount += 1
|
c.state.RestartCount++
|
||||||
logrus.Debugf("Container %s now on retry %d", c.ID(), c.state.RestartCount)
|
logrus.Debugf("Container %s now on retry %d", c.ID(), c.state.RestartCount)
|
||||||
if err := c.save(); err != nil {
|
if err := c.save(); err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
|
@ -190,7 +190,7 @@ func (c *Container) updateHealthCheckLog(hcl define.HealthCheckLog, inStartPerio
|
|||||||
}
|
}
|
||||||
if !inStartPeriod {
|
if !inStartPeriod {
|
||||||
// increment failing streak
|
// increment failing streak
|
||||||
healthCheck.FailingStreak += 1
|
healthCheck.FailingStreak++
|
||||||
// if failing streak > retries, then status to unhealthy
|
// if failing streak > retries, then status to unhealthy
|
||||||
if healthCheck.FailingStreak >= c.HealthCheckConfig().Retries {
|
if healthCheck.FailingStreak >= c.HealthCheckConfig().Retries {
|
||||||
healthCheck.Status = define.HealthCheckUnhealthy
|
healthCheck.Status = define.HealthCheckUnhealthy
|
||||||
|
@ -75,9 +75,8 @@ func findImageInRepotags(search imageParts, images []*Image) (*storage.Image, er
|
|||||||
}
|
}
|
||||||
if rwImageCnt > 1 {
|
if rwImageCnt > 1 {
|
||||||
return nil, errors.Wrapf(define.ErrMultipleImages, "found multiple read/write images %s", strings.Join(keys, ","))
|
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
|
return candidates[0].image.image, nil
|
||||||
}
|
}
|
||||||
|
@ -222,11 +222,11 @@ func (r *Runtime) getContainerStoreInfo() (define.ContainerStore, error) {
|
|||||||
}
|
}
|
||||||
switch state {
|
switch state {
|
||||||
case define.ContainerStateRunning:
|
case define.ContainerStateRunning:
|
||||||
running += 1
|
running++
|
||||||
case define.ContainerStatePaused:
|
case define.ContainerStatePaused:
|
||||||
paused += 1
|
paused++
|
||||||
default:
|
default:
|
||||||
stopped += 1
|
stopped++
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cs.Paused = paused
|
cs.Paused = paused
|
||||||
|
@ -480,9 +480,8 @@ func (r *Runtime) setupSlirp4netns(ctr *Container) error {
|
|||||||
if havePortMapping {
|
if havePortMapping {
|
||||||
if isSlirpHostForward {
|
if isSlirpHostForward {
|
||||||
return r.setupRootlessPortMappingViaSlirp(ctr, cmd, apiSocket)
|
return r.setupRootlessPortMappingViaSlirp(ctr, cmd, apiSocket)
|
||||||
} else {
|
|
||||||
return r.setupRootlessPortMappingViaRLK(ctr, netnsPath)
|
|
||||||
}
|
}
|
||||||
|
return r.setupRootlessPortMappingViaRLK(ctr, netnsPath)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -241,9 +241,8 @@ func (p *VolumePlugin) makeErrorResponse(err, endpoint, volName string) error {
|
|||||||
}
|
}
|
||||||
if volName != "" {
|
if volName != "" {
|
||||||
return errors.Wrapf(errors.New(err), "error on %s on volume %s in volume plugin %s", endpoint, volName, p.Name)
|
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
|
// Handle error responses from plugin
|
||||||
|
@ -313,9 +313,8 @@ func (r *Runtime) LoadImageFromSingleImageArchive(ctx context.Context, writer io
|
|||||||
if err == nil && src != nil {
|
if err == nil && src != nil {
|
||||||
if newImages, err := r.ImageRuntime().LoadFromArchiveReference(ctx, src, signaturePolicy, writer); err == nil {
|
if newImages, err := r.ImageRuntime().LoadFromArchiveReference(ctx, src, signaturePolicy, writer); err == nil {
|
||||||
return getImageNames(newImages), nil
|
return getImageNames(newImages), nil
|
||||||
} else {
|
|
||||||
saveErr = err
|
|
||||||
}
|
}
|
||||||
|
saveErr = err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return "", errors.Wrapf(saveErr, "error pulling image")
|
return "", errors.Wrapf(saveErr, "error pulling image")
|
||||||
|
@ -45,7 +45,7 @@ func (v *Volume) mount() error {
|
|||||||
// If the count is non-zero, the volume is already mounted.
|
// If the count is non-zero, the volume is already mounted.
|
||||||
// Nothing to do.
|
// Nothing to do.
|
||||||
if v.state.MountCount > 0 {
|
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)
|
logrus.Debugf("Volume %s mount count now at %d", v.Name(), v.state.MountCount)
|
||||||
return v.save()
|
return v.save()
|
||||||
}
|
}
|
||||||
@ -67,7 +67,7 @@ func (v *Volume) mount() error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
v.state.MountCount += 1
|
v.state.MountCount++
|
||||||
v.state.MountPoint = mountPoint
|
v.state.MountPoint = mountPoint
|
||||||
return v.save()
|
return v.save()
|
||||||
}
|
}
|
||||||
@ -109,7 +109,7 @@ func (v *Volume) mount() error {
|
|||||||
logrus.Debugf("Mounted volume %s", v.Name())
|
logrus.Debugf("Mounted volume %s", v.Name())
|
||||||
|
|
||||||
// Increment the mount counter
|
// 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)
|
logrus.Debugf("Volume %s mount count now at %d", v.Name(), v.state.MountCount)
|
||||||
return v.save()
|
return v.save()
|
||||||
}
|
}
|
||||||
@ -152,7 +152,7 @@ func (v *Volume) unmount(force bool) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if !force {
|
if !force {
|
||||||
v.state.MountCount -= 1
|
v.state.MountCount--
|
||||||
} else {
|
} else {
|
||||||
v.state.MountCount = 0
|
v.state.MountCount = 0
|
||||||
}
|
}
|
||||||
|
@ -62,7 +62,7 @@ func handleHeadAndGet(w http.ResponseWriter, r *http.Request, decoder *schema.De
|
|||||||
w.Header().Add(copy.XDockerContainerPathStatHeader, statHeader)
|
w.Header().Add(copy.XDockerContainerPathStatHeader, statHeader)
|
||||||
}
|
}
|
||||||
|
|
||||||
if errors.Cause(err) == define.ErrNoSuchCtr || errors.Cause(err) == copy.ENOENT {
|
if errors.Cause(err) == define.ErrNoSuchCtr || errors.Cause(err) == copy.ErrENOENT {
|
||||||
// 404 is returned for an absent container and path. The
|
// 404 is returned for an absent container and path. The
|
||||||
// clients must deal with it accordingly.
|
// clients must deal with it accordingly.
|
||||||
utils.Error(w, "Not found.", http.StatusNotFound, err)
|
utils.Error(w, "Not found.", http.StatusNotFound, err)
|
||||||
|
@ -130,10 +130,9 @@ func WaitContainerLibpod(w http.ResponseWriter, r *http.Request) {
|
|||||||
if errors.Cause(err) == define.ErrNoSuchCtr {
|
if errors.Cause(err) == define.ErrNoSuchCtr {
|
||||||
ContainerNotFound(w, name, err)
|
ContainerNotFound(w, name, err)
|
||||||
return
|
return
|
||||||
} else {
|
|
||||||
InternalServerError(w, err)
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
InternalServerError(w, err)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
WriteResponse(w, http.StatusOK, strconv.Itoa(int(exitCode)))
|
WriteResponse(w, http.StatusOK, strconv.Itoa(int(exitCode)))
|
||||||
}
|
}
|
||||||
@ -200,9 +199,8 @@ func waitRemoved(ctrWait containerWaitFn) (int32, error) {
|
|||||||
code, err := ctrWait(define.ContainerStateUnknown)
|
code, err := ctrWait(define.ContainerStateUnknown)
|
||||||
if err != nil && errors.Cause(err) == define.ErrNoSuchCtr {
|
if err != nil && errors.Cause(err) == define.ErrNoSuchCtr {
|
||||||
return code, nil
|
return code, nil
|
||||||
} else {
|
|
||||||
return code, err
|
|
||||||
}
|
}
|
||||||
|
return code, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func waitNextExit(ctrWait containerWaitFn) (int32, error) {
|
func waitNextExit(ctrWait containerWaitFn) (int32, error) {
|
||||||
|
@ -30,7 +30,7 @@ func Stat(ctx context.Context, nameOrID string, path string) (*entities.Containe
|
|||||||
|
|
||||||
var finalErr error
|
var finalErr error
|
||||||
if response.StatusCode == http.StatusNotFound {
|
if response.StatusCode == http.StatusNotFound {
|
||||||
finalErr = copy.ENOENT
|
finalErr = copy.ErrENOENT
|
||||||
} else if response.StatusCode != http.StatusOK {
|
} else if response.StatusCode != http.StatusOK {
|
||||||
finalErr = errors.New(response.Status)
|
finalErr = errors.New(response.Status)
|
||||||
}
|
}
|
||||||
|
@ -16,9 +16,9 @@ import (
|
|||||||
// base64 encoded JSON payload of stating a path in a container.
|
// base64 encoded JSON payload of stating a path in a container.
|
||||||
const XDockerContainerPathStatHeader = "X-Docker-Container-Path-Stat"
|
const XDockerContainerPathStatHeader = "X-Docker-Container-Path-Stat"
|
||||||
|
|
||||||
// ENOENT mimics the stdlib's ENOENT and can be used to implement custom logic
|
// ErrENOENT mimics the stdlib's ErrENOENT and can be used to implement custom logic
|
||||||
// while preserving the user-visible error message.
|
// while preserving the user-visible error message.
|
||||||
var ENOENT = errors.New("No such file or directory")
|
var ErrENOENT = errors.New("No such file or directory")
|
||||||
|
|
||||||
// FileInfo describes a file or directory and is returned by
|
// FileInfo describes a file or directory and is returned by
|
||||||
// (*CopyItem).Stat().
|
// (*CopyItem).Stat().
|
||||||
@ -70,7 +70,7 @@ func ResolveHostPath(path string) (*FileInfo, error) {
|
|||||||
statInfo, err := os.Stat(resolvedHostPath)
|
statInfo, err := os.Stat(resolvedHostPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if os.IsNotExist(err) {
|
if os.IsNotExist(err) {
|
||||||
return nil, ENOENT
|
return nil, ErrENOENT
|
||||||
}
|
}
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ type NetworkReloadOptions struct {
|
|||||||
|
|
||||||
// NetworkReloadReport describes the results of reloading a container network.
|
// NetworkReloadReport describes the results of reloading a container network.
|
||||||
type NetworkReloadReport struct {
|
type NetworkReloadReport struct {
|
||||||
// nolint:stylecheck
|
// nolint:stylecheck,golint
|
||||||
Id string
|
Id string
|
||||||
Err error
|
Err error
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,7 @@ func (ic *ContainerEngine) containerStat(container *libpod.Container, containerM
|
|||||||
// ENOENT let's the API handlers return the correct status code
|
// ENOENT let's the API handlers return the correct status code
|
||||||
// which is crucial for the remote client.
|
// which is crucial for the remote client.
|
||||||
if os.IsNotExist(err) || strings.Contains(statInfoErr.Error(), "o such file or directory") {
|
if os.IsNotExist(err) || strings.Contains(statInfoErr.Error(), "o such file or directory") {
|
||||||
statInfoErr = copy.ENOENT
|
statInfoErr = copy.ErrENOENT
|
||||||
}
|
}
|
||||||
// If statInfo is nil, there's nothing we can do anymore. A
|
// If statInfo is nil, there's nothing we can do anymore. A
|
||||||
// non-nil statInfo may indicate a symlink where we must have
|
// non-nil statInfo may indicate a symlink where we must have
|
||||||
@ -129,7 +129,7 @@ func secureStat(root string, path string) (*buildahCopiah.StatForItem, error) {
|
|||||||
|
|
||||||
stat, exists := globStats[0].Results[glob] // only one glob passed, so that's okay
|
stat, exists := globStats[0].Results[glob] // only one glob passed, so that's okay
|
||||||
if !exists {
|
if !exists {
|
||||||
return nil, copy.ENOENT
|
return nil, copy.ErrENOENT
|
||||||
}
|
}
|
||||||
|
|
||||||
var statErr error
|
var statErr error
|
||||||
|
@ -40,10 +40,9 @@ func (ir *ImageEngine) Exists(_ context.Context, nameOrID string) (*entities.Boo
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
if errors.Cause(err) == define.ErrMultipleImages {
|
if errors.Cause(err) == define.ErrMultipleImages {
|
||||||
return &entities.BoolReport{Value: true}, nil
|
return &entities.BoolReport{Value: true}, nil
|
||||||
} else {
|
}
|
||||||
if errors.Cause(err) != define.ErrNoSuchImage {
|
if errors.Cause(err) != define.ErrNoSuchImage {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return &entities.BoolReport{Value: err == nil}, nil
|
return &entities.BoolReport{Value: err == nil}, nil
|
||||||
|
Reference in New Issue
Block a user