summaryrefslogtreecommitdiff
path: root/pkg/adapter
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2020-01-13 21:03:21 +0100
committerGitHub <noreply@github.com>2020-01-13 21:03:21 +0100
commit796ae87b1a3444557644944ddeb7cb37e303ef83 (patch)
tree192bd260c0b35519fe45ecbc91d7212251d82495 /pkg/adapter
parentc1d93666d4b175be29a0ba229ee0b94d50765888 (diff)
parent768c476ae3c1dbf37204f5769b43746358af899d (diff)
downloadpodman-796ae87b1a3444557644944ddeb7cb37e303ef83.tar.gz
podman-796ae87b1a3444557644944ddeb7cb37e303ef83.tar.bz2
podman-796ae87b1a3444557644944ddeb7cb37e303ef83.zip
Merge pull request #4850 from vrothberg/fix-linting
Fix linting
Diffstat (limited to 'pkg/adapter')
-rw-r--r--pkg/adapter/containers.go16
-rw-r--r--pkg/adapter/runtime.go7
-rw-r--r--pkg/adapter/shortcuts/shortcuts.go7
3 files changed, 17 insertions, 13 deletions
diff --git a/pkg/adapter/containers.go b/pkg/adapter/containers.go
index 4228c3dca..c348d2130 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 {
diff --git a/pkg/adapter/runtime.go b/pkg/adapter/runtime.go
index 121f85755..40089797d 100644
--- a/pkg/adapter/runtime.go
+++ b/pkg/adapter/runtime.go
@@ -407,7 +407,8 @@ func (r *LocalRuntime) Events(c *cliconfig.EventValues) error {
}
w := bufio.NewWriter(os.Stdout)
for event := range eventChannel {
- if c.Format == formats.JSONString {
+ switch {
+ case c.Format == formats.JSONString:
jsonStr, err := event.ToJSONString()
if err != nil {
return errors.Wrapf(err, "unable to format json")
@@ -415,11 +416,11 @@ func (r *LocalRuntime) Events(c *cliconfig.EventValues) error {
if _, err := w.Write([]byte(jsonStr)); err != nil {
return err
}
- } else if len(c.Format) > 0 {
+ case len(c.Format) > 0:
if err := tmpl.Execute(w, event); err != nil {
return err
}
- } else {
+ default:
if _, err := w.Write([]byte(event.ToHumanReadable())); err != nil {
return err
}
diff --git a/pkg/adapter/shortcuts/shortcuts.go b/pkg/adapter/shortcuts/shortcuts.go
index 4f6cfd6a3..8a8459c6c 100644
--- a/pkg/adapter/shortcuts/shortcuts.go
+++ b/pkg/adapter/shortcuts/shortcuts.go
@@ -42,12 +42,13 @@ func GetContainersByContext(all, latest bool, names []string, runtime *libpod.Ru
var ctr *libpod.Container
ctrs = []*libpod.Container{}
- if all {
+ switch {
+ case all:
ctrs, err = runtime.GetAllContainers()
- } else if latest {
+ case latest:
ctr, err = runtime.GetLatestContainer()
ctrs = append(ctrs, ctr)
- } else {
+ default:
for _, n := range names {
ctr, e := runtime.LookupContainer(n)
if e != nil {