summaryrefslogtreecommitdiff
path: root/libpod
diff options
context:
space:
mode:
authorhaircommander <pehunt@redhat.com>2018-07-09 13:04:29 -0400
committerhaircommander <pehunt@redhat.com>2018-07-13 09:05:03 -0400
commit1aad3fd96b61705243e8f6ae35f65946916aa8a5 (patch)
treef4dfc5822357e04f556fd64ab8128a36619f1f17 /libpod
parenta2dde5a50d21f8857a57d412a8a1c4c8f731a8d1 (diff)
downloadpodman-1aad3fd96b61705243e8f6ae35f65946916aa8a5.tar.gz
podman-1aad3fd96b61705243e8f6ae35f65946916aa8a5.tar.bz2
podman-1aad3fd96b61705243e8f6ae35f65946916aa8a5.zip
Podman pod create/rm commands with man page and tests.
Includes a very stripped down version of podman pod ps, just for testing Signed-off-by: haircommander <pehunt@redhat.com>
Diffstat (limited to 'libpod')
-rw-r--r--libpod/runtime_pod.go45
-rw-r--r--libpod/runtime_pod_linux.go2
2 files changed, 46 insertions, 1 deletions
diff --git a/libpod/runtime_pod.go b/libpod/runtime_pod.go
index f5a2b017b..3ad8454b4 100644
--- a/libpod/runtime_pod.go
+++ b/libpod/runtime_pod.go
@@ -52,6 +52,51 @@ func (r *Runtime) HasPod(id string) (bool, error) {
return r.state.HasPod(id)
}
+// ContainerIDsInPod returns the IDs of containers in the pod
+func (r *Runtime) ContainerIDsInPod(pod *Pod) ([]string, error) {
+ r.lock.RLock()
+ defer r.lock.RUnlock()
+
+ if !r.valid {
+ return nil, ErrRuntimeStopped
+ }
+
+ return r.state.PodContainersByID(pod)
+}
+
+// ContainersInPod returns the containers in the pod
+func (r *Runtime) ContainersInPod(pod *Pod) ([]*Container, error) {
+ r.lock.RLock()
+ defer r.lock.RUnlock()
+
+ if !r.valid {
+ return nil, ErrRuntimeStopped
+ }
+
+ return r.state.PodContainers(pod)
+}
+
+// ContainerNamesInPod returns the names of containers in the pod
+func (r *Runtime) ContainerNamesInPod(pod *Pod) ([]string, error) {
+ r.lock.RLock()
+ defer r.lock.RUnlock()
+
+ if !r.valid {
+ return nil, ErrRuntimeStopped
+ }
+
+ var ctrNames []string
+ ctrs, err := r.ContainersInPod(pod)
+ if err != nil {
+ return nil, err
+ }
+ for _, ctr := range ctrs {
+ ctrNames = append(ctrNames, ctr.Name())
+ }
+
+ return ctrNames, nil
+}
+
// LookupPod retrieves a pod by its name or a partial ID
// If a partial ID is not unique, an error will be returned
func (r *Runtime) LookupPod(idOrName string) (*Pod, error) {
diff --git a/libpod/runtime_pod_linux.go b/libpod/runtime_pod_linux.go
index 35d095ba3..25340abdb 100644
--- a/libpod/runtime_pod_linux.go
+++ b/libpod/runtime_pod_linux.go
@@ -74,7 +74,7 @@ func (r *Runtime) NewPod(options ...PodCreateOption) (*Pod, error) {
return nil, errors.Wrapf(err, "error adding pod to state")
}
- return nil, ErrNotImplemented
+ return pod, nil
}
func (r *Runtime) removePod(ctx context.Context, p *Pod, removeCtrs, force bool) error {