summaryrefslogtreecommitdiff
path: root/libpod/in_memory_state.go
diff options
context:
space:
mode:
authorMatthew Heon <matthew.heon@gmail.com>2018-07-19 17:21:27 -0400
committerMatthew Heon <matthew.heon@gmail.com>2018-07-24 16:12:31 -0400
commit7a358e427738294180a14b1298dfc3a569f0e0fc (patch)
tree933e665feb6090c679e4cbb37ccf1ada398f8da4 /libpod/in_memory_state.go
parentfc95f68247248e4cb029440e2fe4ba0b0df8049c (diff)
downloadpodman-7a358e427738294180a14b1298dfc3a569f0e0fc.tar.gz
podman-7a358e427738294180a14b1298dfc3a569f0e0fc.tar.bz2
podman-7a358e427738294180a14b1298dfc3a569f0e0fc.zip
Address first round of review comments
Signed-off-by: Matthew Heon <matthew.heon@gmail.com>
Diffstat (limited to 'libpod/in_memory_state.go')
-rw-r--r--libpod/in_memory_state.go36
1 files changed, 8 insertions, 28 deletions
diff --git a/libpod/in_memory_state.go b/libpod/in_memory_state.go
index e323b069c..d421a5e8b 100644
--- a/libpod/in_memory_state.go
+++ b/libpod/in_memory_state.go
@@ -144,17 +144,11 @@ func (s *InMemoryState) HasContainer(id string) (bool, error) {
}
ctr, ok := s.containers[id]
- if ok {
- if s.namespace != "" {
- if s.namespace != ctr.config.Namespace {
- return false, nil
- }
- return true, nil
- }
- return true, nil
+ if !ok || (s.namespace != "" && s.namespace != ctr.config.Namespace) {
+ return false, nil
}
- return false, nil
+ return true, nil
}
// AddContainer adds a container to the state
@@ -295,11 +289,7 @@ func (s *InMemoryState) UpdateContainer(ctr *Container) error {
return errors.Wrapf(ErrNoSuchCtr, "container with ID %s not found in state", ctr.ID())
}
- if err := s.checkNSMatch(ctr.ID(), ctr.Namespace()); err != nil {
- return err
- }
-
- return nil
+ return s.checkNSMatch(ctr.ID(), ctr.Namespace())
}
// SaveContainer saves a container's state
@@ -318,11 +308,7 @@ func (s *InMemoryState) SaveContainer(ctr *Container) error {
return errors.Wrapf(ErrNoSuchCtr, "container with ID %s not found in state", ctr.ID())
}
- if err := s.checkNSMatch(ctr.ID(), ctr.Namespace()); err != nil {
- return err
- }
-
- return nil
+ return s.checkNSMatch(ctr.ID(), ctr.Namespace())
}
// ContainerInUse checks if the given container is being used by other containers
@@ -441,17 +427,11 @@ func (s *InMemoryState) HasPod(id string) (bool, error) {
}
pod, ok := s.pods[id]
- if ok {
- if s.namespace != "" {
- if s.namespace != pod.config.Namespace {
- return false, nil
- }
- return true, nil
- }
- return true, nil
+ if !ok || (s.namespace != "" && s.namespace != pod.config.Namespace) {
+ return false, nil
}
- return false, nil
+ return true, nil
}
// PodHasContainer checks if the given pod has a container with the given ID