summaryrefslogtreecommitdiff
path: root/libpod
diff options
context:
space:
mode:
authorMatthew Heon <matthew.heon@gmail.com>2018-02-07 16:23:18 -0500
committerAtomic Bot <atomic-devel@projectatomic.io>2018-02-09 15:01:34 +0000
commit9e6855f3480f3710ac0e039754890c5d980a817d (patch)
tree9fd3542b3aa37847baddb84cea171037086483d4 /libpod
parent86d549f2cdaf22e07017d04c9eb0afbbf4475934 (diff)
downloadpodman-9e6855f3480f3710ac0e039754890c5d980a817d.tar.gz
podman-9e6855f3480f3710ac0e039754890c5d980a817d.tar.bz2
podman-9e6855f3480f3710ac0e039754890c5d980a817d.zip
Address style issues in in_memory_state
Signed-off-by: Matthew Heon <matthew.heon@gmail.com> Closes: #268 Approved by: rhatdan
Diffstat (limited to 'libpod')
-rw-r--r--libpod/in_memory_state.go21
1 files changed, 8 insertions, 13 deletions
diff --git a/libpod/in_memory_state.go b/libpod/in_memory_state.go
index 4a2d5a311..8aa2360ba 100644
--- a/libpod/in_memory_state.go
+++ b/libpod/in_memory_state.go
@@ -114,8 +114,7 @@ func (s *InMemoryState) AddContainer(ctr *Container) error {
return errors.Wrapf(ErrCtrRemoved, "container with ID %s is not valid", ctr.ID())
}
- _, ok := s.containers[ctr.ID()]
- if ok {
+ if _, ok := s.containers[ctr.ID()]; ok {
return errors.Wrapf(ErrCtrExists, "container with ID %s already exists in state", ctr.ID())
}
@@ -128,8 +127,7 @@ func (s *InMemoryState) AddContainer(ctr *Container) error {
// use, so this should be fine.
depCtrs := ctr.Dependencies()
for _, depCtr := range depCtrs {
- _, ok = s.containers[depCtr]
- if !ok {
+ if _, ok := s.containers[depCtr]; !ok {
return errors.Wrapf(ErrNoSuchCtr, "cannot depend on nonexistent container %s", depCtr)
}
}
@@ -309,7 +307,7 @@ func (s *InMemoryState) HasPod(id string) (bool, error) {
// PodHasContainer checks if the given pod has a container with the given ID
func (s *InMemoryState) PodHasContainer(pod *Pod, ctrID string) (bool, error) {
if !pod.valid {
- return false, errors.Wrapf(ErrPodRemoved, "pod %s is not valid")
+ return false, errors.Wrapf(ErrPodRemoved, "pod %s is not valid", pod.ID())
}
if ctrID == "" {
@@ -329,7 +327,7 @@ func (s *InMemoryState) PodHasContainer(pod *Pod, ctrID string) (bool, error) {
// PodContainersByID returns the IDs of all containers in the given pod
func (s *InMemoryState) PodContainersByID(pod *Pod) ([]string, error) {
if !pod.valid {
- return nil, errors.Wrapf(ErrPodRemoved, "pod %s is not valid")
+ return nil, errors.Wrapf(ErrPodRemoved, "pod %s is not valid", pod.ID())
}
podCtrs, ok := s.podContainers[pod.ID()]
@@ -354,7 +352,7 @@ func (s *InMemoryState) PodContainersByID(pod *Pod) ([]string, error) {
// PodContainers retrieves the containers from a pod
func (s *InMemoryState) PodContainers(pod *Pod) ([]*Container, error) {
if !pod.valid {
- return nil, errors.Wrapf(ErrPodRemoved, "pod %s is not valid")
+ return nil, errors.Wrapf(ErrPodRemoved, "pod %s is not valid", pod.ID())
}
podCtrs, ok := s.podContainers[pod.ID()]
@@ -456,8 +454,7 @@ func (s *InMemoryState) RemovePodContainers(pod *Pod) error {
ctrDeps, ok := s.ctrDepends[ctr]
if ok {
for _, dep := range ctrDeps {
- _, ok := podCtrs[dep]
- if !ok {
+ if _, ok := podCtrs[dep]; !ok {
return errors.Wrapf(ErrCtrExists, "container %s has dependency %s outside of pod %s", ctr, dep, pod.ID())
}
}
@@ -511,15 +508,13 @@ func (s *InMemoryState) AddContainerToPod(pod *Pod, ctr *Container) error {
// use, so this should be fine.
depCtrs := ctr.Dependencies()
for _, depCtr := range depCtrs {
- _, ok = s.containers[depCtr]
- if !ok {
+ if _, ok = s.containers[depCtr]; !ok {
return errors.Wrapf(ErrNoSuchCtr, "cannot depend on nonexistent container %s", depCtr)
}
}
// Add container to state
- _, ok = s.containers[ctr.ID()]
- if ok {
+ if _, ok = s.containers[ctr.ID()]; ok {
return errors.Wrapf(ErrCtrExists, "container with ID %s already exists in state", ctr.ID())
}