summaryrefslogtreecommitdiff
path: root/pkg
diff options
context:
space:
mode:
Diffstat (limited to 'pkg')
-rw-r--r--pkg/hooks/0.1.0/hook.go4
-rw-r--r--pkg/hooks/0.1.0/hook_test.go2
-rw-r--r--pkg/hooks/hooks.go2
-rw-r--r--pkg/hooks/hooks_test.go2
-rw-r--r--pkg/hooks/read.go2
-rw-r--r--pkg/hooks/read_test.go2
-rw-r--r--pkg/registries/registries.go2
-rw-r--r--pkg/secrets/secrets.go2
-rw-r--r--pkg/spec/createconfig.go4
-rw-r--r--pkg/spec/spec.go11
-rw-r--r--pkg/varlinkapi/config.go4
-rw-r--r--pkg/varlinkapi/containers.go16
-rw-r--r--pkg/varlinkapi/containers_create.go12
-rw-r--r--pkg/varlinkapi/images.go41
-rw-r--r--pkg/varlinkapi/pods.go189
-rw-r--r--pkg/varlinkapi/system.go4
-rw-r--r--pkg/varlinkapi/util.go66
17 files changed, 314 insertions, 51 deletions
diff --git a/pkg/hooks/0.1.0/hook.go b/pkg/hooks/0.1.0/hook.go
index e10c3d254..4ebc5ff9d 100644
--- a/pkg/hooks/0.1.0/hook.go
+++ b/pkg/hooks/0.1.0/hook.go
@@ -6,9 +6,9 @@ import (
"errors"
"strings"
+ hooks "github.com/containers/libpod/pkg/hooks"
+ current "github.com/containers/libpod/pkg/hooks/1.0.0"
rspec "github.com/opencontainers/runtime-spec/specs-go"
- hooks "github.com/projectatomic/libpod/pkg/hooks"
- current "github.com/projectatomic/libpod/pkg/hooks/1.0.0"
)
// Version is the hook configuration version defined in this package.
diff --git a/pkg/hooks/0.1.0/hook_test.go b/pkg/hooks/0.1.0/hook_test.go
index 44cb21e3a..66774075e 100644
--- a/pkg/hooks/0.1.0/hook_test.go
+++ b/pkg/hooks/0.1.0/hook_test.go
@@ -3,8 +3,8 @@ package hook
import (
"testing"
+ current "github.com/containers/libpod/pkg/hooks/1.0.0"
rspec "github.com/opencontainers/runtime-spec/specs-go"
- current "github.com/projectatomic/libpod/pkg/hooks/1.0.0"
"github.com/stretchr/testify/assert"
)
diff --git a/pkg/hooks/hooks.go b/pkg/hooks/hooks.go
index fdc8a6c46..8a44a4982 100644
--- a/pkg/hooks/hooks.go
+++ b/pkg/hooks/hooks.go
@@ -7,9 +7,9 @@ import (
"path/filepath"
"sync"
+ current "github.com/containers/libpod/pkg/hooks/1.0.0"
rspec "github.com/opencontainers/runtime-spec/specs-go"
"github.com/pkg/errors"
- current "github.com/projectatomic/libpod/pkg/hooks/1.0.0"
"github.com/sirupsen/logrus"
"golang.org/x/text/collate"
"golang.org/x/text/language"
diff --git a/pkg/hooks/hooks_test.go b/pkg/hooks/hooks_test.go
index b93a1d54d..2925a99e4 100644
--- a/pkg/hooks/hooks_test.go
+++ b/pkg/hooks/hooks_test.go
@@ -9,8 +9,8 @@ import (
"runtime"
"testing"
+ current "github.com/containers/libpod/pkg/hooks/1.0.0"
rspec "github.com/opencontainers/runtime-spec/specs-go"
- current "github.com/projectatomic/libpod/pkg/hooks/1.0.0"
"github.com/stretchr/testify/assert"
"golang.org/x/text/language"
)
diff --git a/pkg/hooks/read.go b/pkg/hooks/read.go
index 20431bdf1..d3995a0be 100644
--- a/pkg/hooks/read.go
+++ b/pkg/hooks/read.go
@@ -9,8 +9,8 @@ import (
"path/filepath"
"strings"
+ current "github.com/containers/libpod/pkg/hooks/1.0.0"
"github.com/pkg/errors"
- current "github.com/projectatomic/libpod/pkg/hooks/1.0.0"
"github.com/sirupsen/logrus"
)
diff --git a/pkg/hooks/read_test.go b/pkg/hooks/read_test.go
index 811cace23..606c25df4 100644
--- a/pkg/hooks/read_test.go
+++ b/pkg/hooks/read_test.go
@@ -7,8 +7,8 @@ import (
"path/filepath"
"testing"
+ current "github.com/containers/libpod/pkg/hooks/1.0.0"
rspec "github.com/opencontainers/runtime-spec/specs-go"
- current "github.com/projectatomic/libpod/pkg/hooks/1.0.0"
"github.com/stretchr/testify/assert"
)
diff --git a/pkg/registries/registries.go b/pkg/registries/registries.go
index c84bb21f6..73aa93d68 100644
--- a/pkg/registries/registries.go
+++ b/pkg/registries/registries.go
@@ -6,8 +6,8 @@ import (
"github.com/containers/image/pkg/sysregistries"
"github.com/containers/image/types"
+ "github.com/containers/libpod/pkg/rootless"
"github.com/pkg/errors"
- "github.com/projectatomic/libpod/pkg/rootless"
)
// userRegistriesFile is the path to the per user registry configuration file.
diff --git a/pkg/secrets/secrets.go b/pkg/secrets/secrets.go
index bc63ece00..6f38f1fd5 100644
--- a/pkg/secrets/secrets.go
+++ b/pkg/secrets/secrets.go
@@ -7,10 +7,10 @@ import (
"path/filepath"
"strings"
+ "github.com/containers/libpod/pkg/rootless"
rspec "github.com/opencontainers/runtime-spec/specs-go"
"github.com/opencontainers/selinux/go-selinux/label"
"github.com/pkg/errors"
- "github.com/projectatomic/libpod/pkg/rootless"
"github.com/sirupsen/logrus"
)
diff --git a/pkg/spec/createconfig.go b/pkg/spec/createconfig.go
index fb45f042b..6df6fb480 100644
--- a/pkg/spec/createconfig.go
+++ b/pkg/spec/createconfig.go
@@ -7,6 +7,8 @@ import (
"strings"
"syscall"
+ "github.com/containers/libpod/libpod"
+ "github.com/containers/libpod/pkg/rootless"
"github.com/containers/storage"
"github.com/cri-o/ocicni/pkg/ocicni"
"github.com/docker/docker/api/types/container"
@@ -15,8 +17,6 @@ import (
"github.com/opencontainers/runtime-tools/generate"
"github.com/opencontainers/selinux/go-selinux/label"
"github.com/pkg/errors"
- "github.com/projectatomic/libpod/libpod"
- "github.com/projectatomic/libpod/pkg/rootless"
"github.com/sirupsen/logrus"
"golang.org/x/sys/unix"
)
diff --git a/pkg/spec/spec.go b/pkg/spec/spec.go
index d9888e999..97305610a 100644
--- a/pkg/spec/spec.go
+++ b/pkg/spec/spec.go
@@ -1,15 +1,16 @@
package createconfig
import (
+ "os"
"strings"
+ "github.com/containers/libpod/pkg/rootless"
"github.com/docker/docker/daemon/caps"
"github.com/docker/docker/pkg/mount"
"github.com/docker/go-units"
spec "github.com/opencontainers/runtime-spec/specs-go"
"github.com/opencontainers/runtime-tools/generate"
"github.com/pkg/errors"
- "github.com/projectatomic/libpod/pkg/rootless"
"github.com/sirupsen/logrus"
)
@@ -73,6 +74,14 @@ func CreateConfigToOCISpec(config *CreateConfig) (*spec.Spec, error) { //nolint
g.AddAnnotation(key, val)
}
g.SetRootReadonly(config.ReadOnlyRootfs)
+ if config.Hostname == "" {
+ if config.NetMode.IsHost() {
+ config.Hostname, err = os.Hostname()
+ if err != nil {
+ return nil, errors.Wrap(err, "unable to retrieve hostname")
+ }
+ }
+ }
g.SetHostname(config.Hostname)
if config.Hostname != "" {
g.AddProcessEnv("HOSTNAME", config.Hostname)
diff --git a/pkg/varlinkapi/config.go b/pkg/varlinkapi/config.go
index fa1983463..8dd217b77 100644
--- a/pkg/varlinkapi/config.go
+++ b/pkg/varlinkapi/config.go
@@ -1,8 +1,8 @@
package varlinkapi
import (
- iopodman "github.com/projectatomic/libpod/cmd/podman/varlink"
- "github.com/projectatomic/libpod/libpod"
+ iopodman "github.com/containers/libpod/cmd/podman/varlink"
+ "github.com/containers/libpod/libpod"
"github.com/urfave/cli"
)
diff --git a/pkg/varlinkapi/containers.go b/pkg/varlinkapi/containers.go
index f42386194..58452716a 100644
--- a/pkg/varlinkapi/containers.go
+++ b/pkg/varlinkapi/containers.go
@@ -9,11 +9,11 @@ import (
"syscall"
"time"
+ "github.com/containers/libpod/cmd/podman/shared"
+ "github.com/containers/libpod/cmd/podman/varlink"
+ "github.com/containers/libpod/libpod"
"github.com/containers/storage/pkg/archive"
"github.com/pkg/errors"
- "github.com/projectatomic/libpod/cmd/podman/batchcontainer"
- "github.com/projectatomic/libpod/cmd/podman/varlink"
- "github.com/projectatomic/libpod/libpod"
)
// ListContainers ...
@@ -26,12 +26,12 @@ func (i *LibpodAPI) ListContainers(call iopodman.VarlinkCall) error {
if err != nil {
return call.ReplyErrorOccurred(err.Error())
}
- opts := batchcontainer.PsOptions{
+ opts := shared.PsOptions{
Namespace: true,
Size: true,
}
for _, ctr := range containers {
- batchInfo, err := batchcontainer.BatchContainerOp(ctr, opts)
+ batchInfo, err := shared.BatchContainerOp(ctr, opts)
if err != nil {
return call.ReplyErrorOccurred(err.Error())
}
@@ -47,11 +47,11 @@ func (i *LibpodAPI) GetContainer(call iopodman.VarlinkCall, name string) error {
if err != nil {
return call.ReplyContainerNotFound(name)
}
- opts := batchcontainer.PsOptions{
+ opts := shared.PsOptions{
Namespace: true,
Size: true,
}
- batchInfo, err := batchcontainer.BatchContainerOp(ctr, opts)
+ batchInfo, err := shared.BatchContainerOp(ctr, opts)
if err != nil {
return call.ReplyErrorOccurred(err.Error())
}
@@ -68,7 +68,7 @@ func (i *LibpodAPI) InspectContainer(call iopodman.VarlinkCall, name string) err
if err != nil {
return call.ReplyErrorOccurred(err.Error())
}
- data, err := batchcontainer.GetCtrInspectInfo(ctr, inspectInfo)
+ data, err := shared.GetCtrInspectInfo(ctr, inspectInfo)
if err != nil {
return call.ReplyErrorOccurred(err.Error())
}
diff --git a/pkg/varlinkapi/containers_create.go b/pkg/varlinkapi/containers_create.go
index 5f69a8205..e57f51cc1 100644
--- a/pkg/varlinkapi/containers_create.go
+++ b/pkg/varlinkapi/containers_create.go
@@ -8,14 +8,14 @@ import (
"strings"
"syscall"
+ "github.com/containers/libpod/cmd/podman/varlink"
+ "github.com/containers/libpod/libpod"
+ "github.com/containers/libpod/libpod/image"
+ "github.com/containers/libpod/pkg/inspect"
+ cc "github.com/containers/libpod/pkg/spec"
+ "github.com/containers/libpod/pkg/util"
"github.com/docker/docker/api/types/container"
"github.com/docker/docker/pkg/signal"
- "github.com/projectatomic/libpod/cmd/podman/varlink"
- "github.com/projectatomic/libpod/libpod"
- "github.com/projectatomic/libpod/libpod/image"
- "github.com/projectatomic/libpod/pkg/inspect"
- cc "github.com/projectatomic/libpod/pkg/spec"
- "github.com/projectatomic/libpod/pkg/util"
"github.com/sirupsen/logrus"
)
diff --git a/pkg/varlinkapi/images.go b/pkg/varlinkapi/images.go
index da19483b3..7953c1fc6 100644
--- a/pkg/varlinkapi/images.go
+++ b/pkg/varlinkapi/images.go
@@ -10,18 +10,19 @@ import (
"time"
"github.com/containers/image/docker"
+ "github.com/containers/image/manifest"
"github.com/containers/image/types"
+ "github.com/containers/libpod/cmd/podman/varlink"
+ "github.com/containers/libpod/libpod"
+ "github.com/containers/libpod/libpod/image"
+ sysreg "github.com/containers/libpod/pkg/registries"
+ "github.com/containers/libpod/pkg/util"
"github.com/docker/go-units"
"github.com/opencontainers/image-spec/specs-go/v1"
"github.com/opencontainers/runtime-spec/specs-go"
"github.com/pkg/errors"
"github.com/projectatomic/buildah"
"github.com/projectatomic/buildah/imagebuildah"
- "github.com/projectatomic/libpod/cmd/podman/varlink"
- "github.com/projectatomic/libpod/libpod"
- "github.com/projectatomic/libpod/libpod/image"
- sysreg "github.com/projectatomic/libpod/pkg/registries"
- "github.com/projectatomic/libpod/pkg/util"
)
// ListImages lists all the images in the store
@@ -126,18 +127,17 @@ func (i *LibpodAPI) BuildImage(call iopodman.VarlinkCall, config iopodman.BuildI
if config.Pull_always {
pullPolicy = imagebuildah.PullAlways
}
-
- format := "oci"
+ manifestType := "oci"
if config.Image_format != "" {
- format = config.Image_format
+ manifestType = config.Image_format
}
- if strings.HasPrefix(format, "oci") {
- format = imagebuildah.OCIv1ImageFormat
- } else if strings.HasPrefix(format, "docker") {
- format = imagebuildah.Dockerv2ImageFormat
+ if strings.HasPrefix(manifestType, "oci") {
+ manifestType = imagebuildah.OCIv1ImageFormat
+ } else if strings.HasPrefix(manifestType, "docker") {
+ manifestType = imagebuildah.Dockerv2ImageFormat
} else {
- return call.ReplyErrorOccurred(fmt.Sprintf("unrecognized image type %q", format))
+ return call.ReplyErrorOccurred(fmt.Sprintf("unrecognized image type %q", manifestType))
}
if config.Memory != "" {
@@ -187,7 +187,7 @@ func (i *LibpodAPI) BuildImage(call iopodman.VarlinkCall, config iopodman.BuildI
AdditionalTags: config.Tags,
//Runtime: runtime.
//RuntimeArgs: ,
- OutputFormat: format,
+ OutputFormat: manifestType,
SystemContext: &systemContext,
CommonBuildOpts: commonOpts,
Squash: config.Squash,
@@ -413,17 +413,26 @@ func (i *LibpodAPI) DeleteUnusedImages(call iopodman.VarlinkCall) error {
}
// Commit ...
-func (i *LibpodAPI) Commit(call iopodman.VarlinkCall, name, imageName string, changes []string, author, message string, pause bool) error {
+func (i *LibpodAPI) Commit(call iopodman.VarlinkCall, name, imageName string, changes []string, author, message string, pause bool, manifestType string) error {
ctr, err := i.Runtime.LookupContainer(name)
if err != nil {
return call.ReplyContainerNotFound(name)
}
sc := image.GetSystemContext(i.Runtime.GetConfig().SignaturePolicyPath, "", false)
+ var mimeType string
+ switch manifestType {
+ case "oci", "":
+ mimeType = buildah.OCIv1ImageManifest
+ case "docker":
+ mimeType = manifest.DockerV2Schema2MediaType
+ default:
+ return call.ReplyErrorOccurred(fmt.Sprintf("unrecognized image format %q", manifestType))
+ }
coptions := buildah.CommitOptions{
SignaturePolicyPath: i.Runtime.GetConfig().SignaturePolicyPath,
ReportWriter: nil,
SystemContext: sc,
- PreferredManifestType: buildah.OCIv1ImageManifest,
+ PreferredManifestType: mimeType,
}
options := libpod.ContainerCommitOptions{
CommitOptions: coptions,
diff --git a/pkg/varlinkapi/pods.go b/pkg/varlinkapi/pods.go
new file mode 100644
index 000000000..640dd665e
--- /dev/null
+++ b/pkg/varlinkapi/pods.go
@@ -0,0 +1,189 @@
+package varlinkapi
+
+import (
+ "encoding/json"
+ "syscall"
+
+ "github.com/containers/libpod/cmd/podman/shared"
+ "github.com/containers/libpod/cmd/podman/varlink"
+ "github.com/containers/libpod/libpod"
+)
+
+// CreatePod ...
+func (i *LibpodAPI) CreatePod(call iopodman.VarlinkCall, create iopodman.PodCreate) error {
+ var options []libpod.PodCreateOption
+ if create.CgroupParent != "" {
+ options = append(options, libpod.WithPodCgroupParent(create.CgroupParent))
+ }
+ if len(create.Labels) > 0 {
+ options = append(options, libpod.WithPodLabels(create.Labels))
+ }
+ if create.Name != "" {
+ options = append(options, libpod.WithPodName(create.Name))
+ }
+ options = append(options, libpod.WithPodCgroups())
+
+ pod, err := i.Runtime.NewPod(options...)
+ if err != nil {
+ return call.ReplyErrorOccurred(err.Error())
+ }
+ return call.ReplyCreatePod(pod.ID())
+}
+
+// ListPods ...
+func (i *LibpodAPI) ListPods(call iopodman.VarlinkCall) error {
+ var (
+ listPods []iopodman.ListPodData
+ )
+
+ pods, err := i.Runtime.GetAllPods()
+ if err != nil {
+ return call.ReplyErrorOccurred(err.Error())
+ }
+ opts := shared.PsOptions{}
+ for _, pod := range pods {
+ listPod, err := makeListPod(pod, opts)
+ if err != nil {
+ return call.ReplyErrorOccurred(err.Error())
+ }
+ listPods = append(listPods, listPod)
+ }
+ return call.ReplyListPods(listPods)
+}
+
+// GetPod ...
+func (i *LibpodAPI) GetPod(call iopodman.VarlinkCall, name string) error {
+ pod, err := i.Runtime.LookupPod(name)
+ if err != nil {
+ return call.ReplyPodNotFound(name)
+ }
+ opts := shared.PsOptions{}
+
+ listPod, err := makeListPod(pod, opts)
+ if err != nil {
+ return call.ReplyErrorOccurred(err.Error())
+ }
+
+ return call.ReplyGetPod(listPod)
+}
+
+// InspectPod ...
+func (i *LibpodAPI) InspectPod(call iopodman.VarlinkCall, name string) error {
+ pod, err := i.Runtime.LookupPod(name)
+ if err != nil {
+ return call.ReplyPodNotFound(name)
+ }
+ inspectData, err := pod.Inspect()
+ if err != nil {
+ return call.ReplyErrorOccurred(err.Error())
+ }
+ b, err := json.Marshal(&inspectData)
+ if err != nil {
+ return call.ReplyErrorOccurred("unable to serialize")
+ }
+ return call.ReplyInspectPod(string(b))
+}
+
+// StartPod ...
+func (i *LibpodAPI) StartPod(call iopodman.VarlinkCall, name string) error {
+ pod, err := i.Runtime.LookupPod(name)
+ if err != nil {
+ return call.ReplyPodNotFound(name)
+ }
+ ctrErrs, err := pod.Start(getContext())
+ callErr := handlePodCall(call, pod, ctrErrs, err)
+ if callErr != nil {
+ return err
+ }
+ return call.ReplyStartPod(pod.ID())
+}
+
+// StopPod ...
+func (i *LibpodAPI) StopPod(call iopodman.VarlinkCall, name string) error {
+ pod, err := i.Runtime.LookupPod(name)
+ if err != nil {
+ return call.ReplyPodNotFound(name)
+ }
+ ctrErrs, err := pod.Stop(true)
+ callErr := handlePodCall(call, pod, ctrErrs, err)
+ if callErr != nil {
+ return err
+ }
+ return call.ReplyStopPod(pod.ID())
+}
+
+// RestartPod ...
+func (i *LibpodAPI) RestartPod(call iopodman.VarlinkCall, name string) error {
+ pod, err := i.Runtime.LookupPod(name)
+ if err != nil {
+ return call.ReplyPodNotFound(name)
+ }
+ ctrErrs, err := pod.Restart(getContext())
+ callErr := handlePodCall(call, pod, ctrErrs, err)
+ if callErr != nil {
+ return err
+ }
+ return call.ReplyRestartPod(pod.ID())
+}
+
+// KillPod kills the running containers in a pod. If you want to use the default SIGTERM signal,
+// just send a -1 for the signal arg.
+func (i *LibpodAPI) KillPod(call iopodman.VarlinkCall, name string, signal int64) error {
+ killSignal := uint(syscall.SIGTERM)
+ if signal != -1 {
+ killSignal = uint(signal)
+ }
+
+ pod, err := i.Runtime.LookupPod(name)
+ if err != nil {
+ return call.ReplyPodNotFound(name)
+ }
+ ctrErrs, err := pod.Kill(killSignal)
+ callErr := handlePodCall(call, pod, ctrErrs, err)
+ if callErr != nil {
+ return err
+ }
+ return call.ReplyKillPod(pod.ID())
+}
+
+// PausePod ...
+func (i *LibpodAPI) PausePod(call iopodman.VarlinkCall, name string) error {
+ pod, err := i.Runtime.LookupPod(name)
+ if err != nil {
+ return call.ReplyPodNotFound(name)
+ }
+ ctrErrs, err := pod.Pause()
+ callErr := handlePodCall(call, pod, ctrErrs, err)
+ if callErr != nil {
+ return err
+ }
+ return call.ReplyPausePod(pod.ID())
+}
+
+// UnpausePod ...
+func (i *LibpodAPI) UnpausePod(call iopodman.VarlinkCall, name string) error {
+ pod, err := i.Runtime.LookupPod(name)
+ if err != nil {
+ return call.ReplyPodNotFound(name)
+ }
+ ctrErrs, err := pod.Unpause()
+ callErr := handlePodCall(call, pod, ctrErrs, err)
+ if callErr != nil {
+ return err
+ }
+ return call.ReplyUnpausePod(pod.ID())
+}
+
+// RemovePod ...
+func (i *LibpodAPI) RemovePod(call iopodman.VarlinkCall, name string, force bool) error {
+ ctx := getContext()
+ pod, err := i.Runtime.LookupPod(name)
+ if err != nil {
+ return call.ReplyPodNotFound(name)
+ }
+ if err = i.Runtime.RemovePod(ctx, pod, force, force); err != nil {
+ return call.ReplyErrorOccurred(err.Error())
+ }
+
+ return call.ReplyRemovePod(pod.ID())
+}
diff --git a/pkg/varlinkapi/system.go b/pkg/varlinkapi/system.go
index 042aef942..a90b72a6d 100644
--- a/pkg/varlinkapi/system.go
+++ b/pkg/varlinkapi/system.go
@@ -4,8 +4,8 @@ import (
goruntime "runtime"
"strings"
- "github.com/projectatomic/libpod/cmd/podman/varlink"
- "github.com/projectatomic/libpod/libpod"
+ "github.com/containers/libpod/cmd/podman/varlink"
+ "github.com/containers/libpod/libpod"
)
// GetVersion ...
diff --git a/pkg/varlinkapi/util.go b/pkg/varlinkapi/util.go
index 667c09562..a80c8db41 100644
--- a/pkg/varlinkapi/util.go
+++ b/pkg/varlinkapi/util.go
@@ -5,9 +5,9 @@ import (
"strconv"
"time"
- "github.com/projectatomic/libpod/cmd/podman/batchcontainer"
- "github.com/projectatomic/libpod/cmd/podman/varlink"
- "github.com/projectatomic/libpod/libpod"
+ "github.com/containers/libpod/cmd/podman/shared"
+ "github.com/containers/libpod/cmd/podman/varlink"
+ "github.com/containers/libpod/libpod"
)
// getContext returns a non-nil, empty context
@@ -15,12 +15,12 @@ func getContext() context.Context {
return context.TODO()
}
-func makeListContainer(containerID string, batchInfo batchcontainer.BatchContainerStruct) iopodman.ListContainerData {
+func makeListContainer(containerID string, batchInfo shared.BatchContainerStruct) iopodman.ListContainerData {
var (
mounts []iopodman.ContainerMount
ports []iopodman.ContainerPortMappings
)
- ns := batchcontainer.GetNamespaces(batchInfo.Pid)
+ ns := shared.GetNamespaces(batchInfo.Pid)
for _, mount := range batchInfo.ConConfig.Spec.Mounts {
m := iopodman.ContainerMount{
@@ -77,3 +77,59 @@ func makeListContainer(containerID string, batchInfo batchcontainer.BatchContain
}
return lc
}
+
+func makeListPodContainers(containerID string, batchInfo shared.BatchContainerStruct) iopodman.ListPodContainerInfo {
+ lc := iopodman.ListPodContainerInfo{
+ Id: containerID,
+ Status: batchInfo.ConState.String(),
+ Name: batchInfo.ConConfig.Name,
+ }
+ return lc
+}
+
+func makeListPod(pod *libpod.Pod, batchInfo shared.PsOptions) (iopodman.ListPodData, error) {
+ var listPodsContainers []iopodman.ListPodContainerInfo
+ var errPodData = iopodman.ListPodData{}
+ status, err := shared.GetPodStatus(pod)
+ if err != nil {
+ return errPodData, err
+ }
+ containers, err := pod.AllContainers()
+ if err != nil {
+ return errPodData, err
+ }
+ for _, ctr := range containers {
+ batchInfo, err := shared.BatchContainerOp(ctr, batchInfo)
+ if err != nil {
+ return errPodData, err
+ }
+
+ listPodsContainers = append(listPodsContainers, makeListPodContainers(ctr.ID(), batchInfo))
+ }
+ listPod := iopodman.ListPodData{
+ Createdat: pod.CreatedTime().String(),
+ Id: pod.ID(),
+ Name: pod.Name(),
+ Status: status,
+ Cgroup: pod.CgroupParent(),
+ Numberofcontainers: strconv.Itoa(len(listPodsContainers)),
+ Containersinfo: listPodsContainers,
+ }
+ return listPod, nil
+}
+
+func handlePodCall(call iopodman.VarlinkCall, pod *libpod.Pod, ctrErrs map[string]error, err error) error {
+ if err != nil && ctrErrs == nil {
+ return call.ReplyErrorOccurred(err.Error())
+ }
+ if ctrErrs != nil {
+ containerErrs := make([]iopodman.PodContainerErrorData, len(ctrErrs))
+ for ctr, reason := range ctrErrs {
+ ctrErr := iopodman.PodContainerErrorData{Containerid: ctr, Reason: reason.Error()}
+ containerErrs = append(containerErrs, ctrErr)
+ }
+ return call.ReplyPodContainerError(pod.ID(), containerErrs)
+ }
+
+ return nil
+}