summaryrefslogtreecommitdiff
path: root/pkg/adapter/containers.go
diff options
context:
space:
mode:
authorValentin Rothberg <rothberg@redhat.com>2020-01-13 13:01:45 +0100
committerValentin Rothberg <rothberg@redhat.com>2020-01-13 14:27:02 +0100
commit67165b76753f65b6f58d471f314678ae12a4c722 (patch)
tree72580ee08e5d9d2e57b97a7293deaf8a2a0f2e67 /pkg/adapter/containers.go
parent270d892c3d77de4fd8e6341193175c0572fb5f99 (diff)
downloadpodman-67165b76753f65b6f58d471f314678ae12a4c722.tar.gz
podman-67165b76753f65b6f58d471f314678ae12a4c722.tar.bz2
podman-67165b76753f65b6f58d471f314678ae12a4c722.zip
make lint: enable gocritic
`gocritic` is a powerful linter that helps in preventing certain kinds of errors as well as enforcing a coding style. Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
Diffstat (limited to 'pkg/adapter/containers.go')
-rw-r--r--pkg/adapter/containers.go16
1 files changed, 9 insertions, 7 deletions
diff --git a/pkg/adapter/containers.go b/pkg/adapter/containers.go
index fdd9f6ab3..4e6bcfaa7 100644
--- a/pkg/adapter/containers.go
+++ b/pkg/adapter/containers.go
@@ -609,11 +609,12 @@ func (r *LocalRuntime) Restore(ctx context.Context, c *cliconfig.RestoreValues)
return state == define.ContainerStateExited
})
- if c.Import != "" {
+ switch {
+ case c.Import != "":
containers, err = crImportCheckpoint(ctx, r.Runtime, c.Import, c.Name)
- } else if c.All {
+ case c.All:
containers, err = r.GetContainers(filterFuncs...)
- } else {
+ default:
containers, err = shortcuts.GetContainersByContext(false, c.Latest, c.InputArgs, r.Runtime)
}
if err != nil {
@@ -835,25 +836,26 @@ func (r *LocalRuntime) Restart(ctx context.Context, c *cliconfig.RestartValues)
inputTimeout := c.Timeout
// Handle --latest
- if c.Latest {
+ switch {
+ case c.Latest:
lastCtr, err := r.Runtime.GetLatestContainer()
if err != nil {
return nil, nil, errors.Wrapf(err, "unable to get latest container")
}
restartContainers = append(restartContainers, lastCtr)
- } else if c.Running {
+ case c.Running:
containers, err = r.GetRunningContainers()
if err != nil {
return nil, nil, err
}
restartContainers = append(restartContainers, containers...)
- } else if c.All {
+ case c.All:
containers, err = r.Runtime.GetAllContainers()
if err != nil {
return nil, nil, err
}
restartContainers = append(restartContainers, containers...)
- } else {
+ default:
for _, id := range c.InputArgs {
ctr, err := r.Runtime.LookupContainer(id)
if err != nil {