mirror of https://github.com/containers/podman.git
Address first round of review comments
Signed-off-by: Matthew Heon <matthew.heon@gmail.com>
This commit is contained in:
parent
fc95f68247
commit
7a358e4277
|
@ -174,7 +174,7 @@ func main() {
|
|||
},
|
||||
cli.StringFlag{
|
||||
Name: "namespace",
|
||||
Usage: "set the libpod namespace, used create separate views of the containers and pods on the system",
|
||||
Usage: "set the libpod namespace, used to create separate views of the containers and pods on the system",
|
||||
Value: "",
|
||||
},
|
||||
cli.StringFlag{
|
||||
|
|
|
@ -41,7 +41,7 @@ log messages above specified level: debug, info, warn, error (default), fatal or
|
|||
|
||||
**--namespace**
|
||||
|
||||
set namespace libpod namespace. Namespaces are used to separate groups of containers and pods in libpod's state.
|
||||
set libpod namespace. Namespaces are used to separate groups of containers and pods in libpod's state.
|
||||
When namespace is set, created containers and pods will join the given namespace, and only containers and pods in the given namespace will be visible to Podman.
|
||||
|
||||
**--root**=**value**
|
||||
|
|
|
@ -443,10 +443,8 @@ func (s *BoltState) UpdateContainer(ctr *Container) error {
|
|||
return ErrCtrRemoved
|
||||
}
|
||||
|
||||
if s.namespace != "" {
|
||||
if s.namespace != ctr.config.Namespace {
|
||||
return errors.Wrapf(ErrNSMismatch, "container %s is in namespace %q, does not match our namespace %q", ctr.ID(), ctr.config.Namespace, s.namespace)
|
||||
}
|
||||
if s.namespace != "" && s.namespace != ctr.config.Namespace {
|
||||
return errors.Wrapf(ErrNSMismatch, "container %s is in namespace %q, does not match our namespace %q", ctr.ID(), ctr.config.Namespace, s.namespace)
|
||||
}
|
||||
|
||||
newState := new(containerState)
|
||||
|
@ -511,10 +509,8 @@ func (s *BoltState) SaveContainer(ctr *Container) error {
|
|||
return ErrCtrRemoved
|
||||
}
|
||||
|
||||
if s.namespace != "" {
|
||||
if s.namespace != ctr.config.Namespace {
|
||||
return errors.Wrapf(ErrNSMismatch, "container %s is in namespace %q, does not match our namespace %q", ctr.ID(), ctr.config.Namespace, s.namespace)
|
||||
}
|
||||
if s.namespace != "" && s.namespace != ctr.config.Namespace {
|
||||
return errors.Wrapf(ErrNSMismatch, "container %s is in namespace %q, does not match our namespace %q", ctr.ID(), ctr.config.Namespace, s.namespace)
|
||||
}
|
||||
|
||||
stateJSON, err := json.Marshal(ctr.state)
|
||||
|
@ -576,10 +572,8 @@ func (s *BoltState) ContainerInUse(ctr *Container) ([]string, error) {
|
|||
return nil, ErrCtrRemoved
|
||||
}
|
||||
|
||||
if s.namespace != "" {
|
||||
if s.namespace != ctr.config.Namespace {
|
||||
return nil, errors.Wrapf(ErrNSMismatch, "container %s is in namespace %q, does not match our namespace %q", ctr.ID(), ctr.config.Namespace, s.namespace)
|
||||
}
|
||||
if s.namespace != "" && s.namespace != ctr.config.Namespace {
|
||||
return nil, errors.Wrapf(ErrNSMismatch, "container %s is in namespace %q, does not match our namespace %q", ctr.ID(), ctr.config.Namespace, s.namespace)
|
||||
}
|
||||
|
||||
depCtrs := []string{}
|
||||
|
@ -876,10 +870,8 @@ func (s *BoltState) PodHasContainer(pod *Pod, id string) (bool, error) {
|
|||
return false, ErrPodRemoved
|
||||
}
|
||||
|
||||
if s.namespace != "" {
|
||||
if s.namespace != pod.config.Namespace {
|
||||
return false, errors.Wrapf(ErrNSMismatch, "pod %s is in namespace %q but we are in namespace %q", pod.ID(), pod.config.Namespace, s.namespace)
|
||||
}
|
||||
if s.namespace != "" && s.namespace != pod.config.Namespace {
|
||||
return false, errors.Wrapf(ErrNSMismatch, "pod %s is in namespace %q but we are in namespace %q", pod.ID(), pod.config.Namespace, s.namespace)
|
||||
}
|
||||
|
||||
ctrID := []byte(id)
|
||||
|
@ -941,10 +933,8 @@ func (s *BoltState) PodContainersByID(pod *Pod) ([]string, error) {
|
|||
return nil, ErrPodRemoved
|
||||
}
|
||||
|
||||
if s.namespace != "" {
|
||||
if s.namespace != pod.config.Namespace {
|
||||
return nil, errors.Wrapf(ErrNSMismatch, "pod %s is in namespace %q but we are in namespace %q", pod.ID(), pod.config.Namespace, s.namespace)
|
||||
}
|
||||
if s.namespace != "" && s.namespace != pod.config.Namespace {
|
||||
return nil, errors.Wrapf(ErrNSMismatch, "pod %s is in namespace %q but we are in namespace %q", pod.ID(), pod.config.Namespace, s.namespace)
|
||||
}
|
||||
|
||||
podID := []byte(pod.ID())
|
||||
|
@ -1005,10 +995,8 @@ func (s *BoltState) PodContainers(pod *Pod) ([]*Container, error) {
|
|||
return nil, ErrPodRemoved
|
||||
}
|
||||
|
||||
if s.namespace != "" {
|
||||
if s.namespace != pod.config.Namespace {
|
||||
return nil, errors.Wrapf(ErrNSMismatch, "pod %s is in namespace %q but we are in namespace %q", pod.ID(), pod.config.Namespace, s.namespace)
|
||||
}
|
||||
if s.namespace != "" && s.namespace != pod.config.Namespace {
|
||||
return nil, errors.Wrapf(ErrNSMismatch, "pod %s is in namespace %q but we are in namespace %q", pod.ID(), pod.config.Namespace, s.namespace)
|
||||
}
|
||||
|
||||
podID := []byte(pod.ID())
|
||||
|
@ -1077,10 +1065,8 @@ func (s *BoltState) AddPod(pod *Pod) error {
|
|||
return ErrPodRemoved
|
||||
}
|
||||
|
||||
if s.namespace != "" {
|
||||
if s.namespace != pod.config.Namespace {
|
||||
return errors.Wrapf(ErrNSMismatch, "pod %s is in namespace %q but we are in namespace %q", pod.ID(), pod.config.Namespace, s.namespace)
|
||||
}
|
||||
if s.namespace != "" && s.namespace != pod.config.Namespace {
|
||||
return errors.Wrapf(ErrNSMismatch, "pod %s is in namespace %q but we are in namespace %q", pod.ID(), pod.config.Namespace, s.namespace)
|
||||
}
|
||||
|
||||
podID := []byte(pod.ID())
|
||||
|
@ -1203,10 +1189,8 @@ func (s *BoltState) RemovePod(pod *Pod) error {
|
|||
return ErrPodRemoved
|
||||
}
|
||||
|
||||
if s.namespace != "" {
|
||||
if s.namespace != pod.config.Namespace {
|
||||
return errors.Wrapf(ErrNSMismatch, "pod %s is in namespace %q but we are in namespace %q", pod.ID(), pod.config.Namespace, s.namespace)
|
||||
}
|
||||
if s.namespace != "" && s.namespace != pod.config.Namespace {
|
||||
return errors.Wrapf(ErrNSMismatch, "pod %s is in namespace %q but we are in namespace %q", pod.ID(), pod.config.Namespace, s.namespace)
|
||||
}
|
||||
|
||||
podID := []byte(pod.ID())
|
||||
|
@ -1301,10 +1285,8 @@ func (s *BoltState) RemovePodContainers(pod *Pod) error {
|
|||
return ErrPodRemoved
|
||||
}
|
||||
|
||||
if s.namespace != "" {
|
||||
if s.namespace != pod.config.Namespace {
|
||||
return errors.Wrapf(ErrNSMismatch, "pod %s is in namespace %q but we are in namespace %q", pod.ID(), pod.config.Namespace, s.namespace)
|
||||
}
|
||||
if s.namespace != "" && s.namespace != pod.config.Namespace {
|
||||
return errors.Wrapf(ErrNSMismatch, "pod %s is in namespace %q but we are in namespace %q", pod.ID(), pod.config.Namespace, s.namespace)
|
||||
}
|
||||
|
||||
podID := []byte(pod.ID())
|
||||
|
@ -1492,10 +1474,8 @@ func (s *BoltState) UpdatePod(pod *Pod) error {
|
|||
return ErrPodRemoved
|
||||
}
|
||||
|
||||
if s.namespace != "" {
|
||||
if s.namespace != pod.config.Namespace {
|
||||
return errors.Wrapf(ErrNSMismatch, "pod %s is in namespace %q but we are in namespace %q", pod.ID(), pod.config.Namespace, s.namespace)
|
||||
}
|
||||
if s.namespace != "" && s.namespace != pod.config.Namespace {
|
||||
return errors.Wrapf(ErrNSMismatch, "pod %s is in namespace %q but we are in namespace %q", pod.ID(), pod.config.Namespace, s.namespace)
|
||||
}
|
||||
|
||||
newState := new(podState)
|
||||
|
@ -1551,10 +1531,8 @@ func (s *BoltState) SavePod(pod *Pod) error {
|
|||
return ErrPodRemoved
|
||||
}
|
||||
|
||||
if s.namespace != "" {
|
||||
if s.namespace != pod.config.Namespace {
|
||||
return errors.Wrapf(ErrNSMismatch, "pod %s is in namespace %q but we are in namespace %q", pod.ID(), pod.config.Namespace, s.namespace)
|
||||
}
|
||||
if s.namespace != "" && s.namespace != pod.config.Namespace {
|
||||
return errors.Wrapf(ErrNSMismatch, "pod %s is in namespace %q but we are in namespace %q", pod.ID(), pod.config.Namespace, s.namespace)
|
||||
}
|
||||
|
||||
stateJSON, err := json.Marshal(pod.state)
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue