mirror of
https://github.com/containers/podman
synced 2024-10-21 01:34:37 +00:00
Make one runtime for the varlink service
Rather than making a runtime each time a client hits a varlink endpoint, we now make a single runtime when the varlink service starts up. This fixes a problem where we hit a max inotify limit from CNI. Resolves: #1211 Signed-off-by: baude <bbaude@redhat.com> Closes: #1215 Approved by: rhatdan
This commit is contained in:
parent
debf23c72a
commit
a1e3e542ff
|
@ -6,6 +6,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/projectatomic/libpod/cmd/podman/libpodruntime"
|
||||
ioprojectatomicpodman "github.com/projectatomic/libpod/cmd/podman/varlink"
|
||||
"github.com/projectatomic/libpod/pkg/varlinkapi"
|
||||
"github.com/projectatomic/libpod/version"
|
||||
|
@ -44,7 +45,14 @@ func varlinkCmd(c *cli.Context) error {
|
|||
}
|
||||
timeout := time.Duration(c.Int64("timeout")) * time.Millisecond
|
||||
|
||||
var varlinkInterfaces = []*ioprojectatomicpodman.VarlinkInterface{varlinkapi.New(c)}
|
||||
// Create a single runtime for varlink
|
||||
runtime, err := libpodruntime.GetRuntime(c)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "error creating libpod runtime")
|
||||
}
|
||||
defer runtime.Shutdown(false)
|
||||
|
||||
var varlinkInterfaces = []*ioprojectatomicpodman.VarlinkInterface{varlinkapi.New(c, runtime)}
|
||||
// Register varlink service. The metadata can be retrieved with:
|
||||
// $ varlink info [varlink address URI]
|
||||
service, err := varlink.NewService(
|
||||
|
|
|
@ -2,6 +2,7 @@ package varlinkapi
|
|||
|
||||
import (
|
||||
ioprojectatomicpodman "github.com/projectatomic/libpod/cmd/podman/varlink"
|
||||
"github.com/projectatomic/libpod/libpod"
|
||||
"github.com/urfave/cli"
|
||||
)
|
||||
|
||||
|
@ -9,10 +10,11 @@ import (
|
|||
type LibpodAPI struct {
|
||||
Cli *cli.Context
|
||||
ioprojectatomicpodman.VarlinkInterface
|
||||
Runtime *libpod.Runtime
|
||||
}
|
||||
|
||||
// New creates a new varlink client
|
||||
func New(cli *cli.Context) *ioprojectatomicpodman.VarlinkInterface {
|
||||
lp := LibpodAPI{Cli: cli}
|
||||
func New(cli *cli.Context, runtime *libpod.Runtime) *ioprojectatomicpodman.VarlinkInterface {
|
||||
lp := LibpodAPI{Cli: cli, Runtime: runtime}
|
||||
return ioprojectatomicpodman.VarlinkNew(&lp)
|
||||
}
|
||||
|
|
|
@ -12,7 +12,6 @@ import (
|
|||
"github.com/containers/storage/pkg/archive"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/projectatomic/libpod/cmd/podman/batchcontainer"
|
||||
"github.com/projectatomic/libpod/cmd/podman/libpodruntime"
|
||||
"github.com/projectatomic/libpod/cmd/podman/varlink"
|
||||
"github.com/projectatomic/libpod/libpod"
|
||||
)
|
||||
|
@ -23,11 +22,7 @@ func (i *LibpodAPI) ListContainers(call ioprojectatomicpodman.VarlinkCall) error
|
|||
listContainers []ioprojectatomicpodman.ListContainerData
|
||||
)
|
||||
|
||||
runtime, err := libpodruntime.GetRuntime(i.Cli)
|
||||
if err != nil {
|
||||
return call.ReplyRuntimeError(err.Error())
|
||||
}
|
||||
containers, err := runtime.GetAllContainers()
|
||||
containers, err := i.Runtime.GetAllContainers()
|
||||
if err != nil {
|
||||
return call.ReplyErrorOccurred(err.Error())
|
||||
}
|
||||
|
@ -48,11 +43,7 @@ func (i *LibpodAPI) ListContainers(call ioprojectatomicpodman.VarlinkCall) error
|
|||
|
||||
// GetContainer ...
|
||||
func (i *LibpodAPI) GetContainer(call ioprojectatomicpodman.VarlinkCall, name string) error {
|
||||
runtime, err := libpodruntime.GetRuntime(i.Cli)
|
||||
if err != nil {
|
||||
return call.ReplyRuntimeError(err.Error())
|
||||
}
|
||||
ctr, err := runtime.LookupContainer(name)
|
||||
ctr, err := i.Runtime.LookupContainer(name)
|
||||
if err != nil {
|
||||
return call.ReplyContainerNotFound(name)
|
||||
}
|
||||
|
@ -69,11 +60,7 @@ func (i *LibpodAPI) GetContainer(call ioprojectatomicpodman.VarlinkCall, name st
|
|||
|
||||
// InspectContainer ...
|
||||
func (i *LibpodAPI) InspectContainer(call ioprojectatomicpodman.VarlinkCall, name string) error {
|
||||
runtime, err := libpodruntime.GetRuntime(i.Cli)
|
||||
if err != nil {
|
||||
return call.ReplyRuntimeError(err.Error())
|
||||
}
|
||||
ctr, err := runtime.LookupContainer(name)
|
||||
ctr, err := i.Runtime.LookupContainer(name)
|
||||
if err != nil {
|
||||
return call.ReplyContainerNotFound(name)
|
||||
}
|
||||
|
@ -94,11 +81,7 @@ func (i *LibpodAPI) InspectContainer(call ioprojectatomicpodman.VarlinkCall, nam
|
|||
|
||||
// ListContainerProcesses ...
|
||||
func (i *LibpodAPI) ListContainerProcesses(call ioprojectatomicpodman.VarlinkCall, name string, opts []string) error {
|
||||
runtime, err := libpodruntime.GetRuntime(i.Cli)
|
||||
if err != nil {
|
||||
return call.ReplyRuntimeError(err.Error())
|
||||
}
|
||||
ctr, err := runtime.LookupContainer(name)
|
||||
ctr, err := i.Runtime.LookupContainer(name)
|
||||
if err != nil {
|
||||
return call.ReplyContainerNotFound(name)
|
||||
}
|
||||
|
@ -126,11 +109,7 @@ func (i *LibpodAPI) ListContainerProcesses(call ioprojectatomicpodman.VarlinkCal
|
|||
// GetContainerLogs ...
|
||||
func (i *LibpodAPI) GetContainerLogs(call ioprojectatomicpodman.VarlinkCall, name string) error {
|
||||
var logs []string
|
||||
runtime, err := libpodruntime.GetRuntime(i.Cli)
|
||||
if err != nil {
|
||||
return call.ReplyRuntimeError(err.Error())
|
||||
}
|
||||
ctr, err := runtime.LookupContainer(name)
|
||||
ctr, err := i.Runtime.LookupContainer(name)
|
||||
if err != nil {
|
||||
return call.ReplyContainerNotFound(name)
|
||||
}
|
||||
|
@ -190,11 +169,7 @@ func (i *LibpodAPI) GetContainerLogs(call ioprojectatomicpodman.VarlinkCall, nam
|
|||
|
||||
// ListContainerChanges ...
|
||||
func (i *LibpodAPI) ListContainerChanges(call ioprojectatomicpodman.VarlinkCall, name string) error {
|
||||
runtime, err := libpodruntime.GetRuntime(i.Cli)
|
||||
if err != nil {
|
||||
return call.ReplyRuntimeError(err.Error())
|
||||
}
|
||||
changes, err := runtime.GetDiff("", name)
|
||||
changes, err := i.Runtime.GetDiff("", name)
|
||||
if err != nil {
|
||||
return call.ReplyErrorOccurred(err.Error())
|
||||
}
|
||||
|
@ -214,11 +189,7 @@ func (i *LibpodAPI) ListContainerChanges(call ioprojectatomicpodman.VarlinkCall,
|
|||
|
||||
// ExportContainer ...
|
||||
func (i *LibpodAPI) ExportContainer(call ioprojectatomicpodman.VarlinkCall, name, path string) error {
|
||||
runtime, err := libpodruntime.GetRuntime(i.Cli)
|
||||
if err != nil {
|
||||
return call.ReplyRuntimeError(err.Error())
|
||||
}
|
||||
ctr, err := runtime.LookupContainer(name)
|
||||
ctr, err := i.Runtime.LookupContainer(name)
|
||||
if err != nil {
|
||||
return call.ReplyContainerNotFound(name)
|
||||
}
|
||||
|
@ -230,11 +201,7 @@ func (i *LibpodAPI) ExportContainer(call ioprojectatomicpodman.VarlinkCall, name
|
|||
|
||||
// GetContainerStats ...
|
||||
func (i *LibpodAPI) GetContainerStats(call ioprojectatomicpodman.VarlinkCall, name string) error {
|
||||
runtime, err := libpodruntime.GetRuntime(i.Cli)
|
||||
if err != nil {
|
||||
return call.ReplyRuntimeError(err.Error())
|
||||
}
|
||||
ctr, err := runtime.LookupContainer(name)
|
||||
ctr, err := i.Runtime.LookupContainer(name)
|
||||
if err != nil {
|
||||
return call.ReplyContainerNotFound(name)
|
||||
}
|
||||
|
@ -267,11 +234,7 @@ func (i *LibpodAPI) ResizeContainerTty(call ioprojectatomicpodman.VarlinkCall) e
|
|||
|
||||
// StartContainer ...
|
||||
func (i *LibpodAPI) StartContainer(call ioprojectatomicpodman.VarlinkCall, name string) error {
|
||||
runtime, err := libpodruntime.GetRuntime(i.Cli)
|
||||
if err != nil {
|
||||
return call.ReplyRuntimeError(err.Error())
|
||||
}
|
||||
ctr, err := runtime.LookupContainer(name)
|
||||
ctr, err := i.Runtime.LookupContainer(name)
|
||||
if err != nil {
|
||||
return call.ReplyContainerNotFound(name)
|
||||
}
|
||||
|
@ -290,11 +253,7 @@ func (i *LibpodAPI) StartContainer(call ioprojectatomicpodman.VarlinkCall, name
|
|||
|
||||
// StopContainer ...
|
||||
func (i *LibpodAPI) StopContainer(call ioprojectatomicpodman.VarlinkCall, name string, timeout int64) error {
|
||||
runtime, err := libpodruntime.GetRuntime(i.Cli)
|
||||
if err != nil {
|
||||
return call.ReplyRuntimeError(err.Error())
|
||||
}
|
||||
ctr, err := runtime.LookupContainer(name)
|
||||
ctr, err := i.Runtime.LookupContainer(name)
|
||||
if err != nil {
|
||||
return call.ReplyContainerNotFound(name)
|
||||
}
|
||||
|
@ -306,11 +265,7 @@ func (i *LibpodAPI) StopContainer(call ioprojectatomicpodman.VarlinkCall, name s
|
|||
|
||||
// RestartContainer ...
|
||||
func (i *LibpodAPI) RestartContainer(call ioprojectatomicpodman.VarlinkCall, name string, timeout int64) error {
|
||||
runtime, err := libpodruntime.GetRuntime(i.Cli)
|
||||
if err != nil {
|
||||
return call.ReplyRuntimeError(err.Error())
|
||||
}
|
||||
ctr, err := runtime.LookupContainer(name)
|
||||
ctr, err := i.Runtime.LookupContainer(name)
|
||||
if err != nil {
|
||||
return call.ReplyContainerNotFound(name)
|
||||
}
|
||||
|
@ -327,11 +282,7 @@ func (i *LibpodAPI) KillContainer(call ioprojectatomicpodman.VarlinkCall, name s
|
|||
if signal != -1 {
|
||||
killSignal = uint(signal)
|
||||
}
|
||||
runtime, err := libpodruntime.GetRuntime(i.Cli)
|
||||
if err != nil {
|
||||
return call.ReplyRuntimeError(err.Error())
|
||||
}
|
||||
ctr, err := runtime.LookupContainer(name)
|
||||
ctr, err := i.Runtime.LookupContainer(name)
|
||||
if err != nil {
|
||||
return call.ReplyContainerNotFound(name)
|
||||
}
|
||||
|
@ -353,11 +304,7 @@ func (i *LibpodAPI) RenameContainer(call ioprojectatomicpodman.VarlinkCall) erro
|
|||
|
||||
// PauseContainer ...
|
||||
func (i *LibpodAPI) PauseContainer(call ioprojectatomicpodman.VarlinkCall, name string) error {
|
||||
runtime, err := libpodruntime.GetRuntime(i.Cli)
|
||||
if err != nil {
|
||||
return call.ReplyRuntimeError(err.Error())
|
||||
}
|
||||
ctr, err := runtime.LookupContainer(name)
|
||||
ctr, err := i.Runtime.LookupContainer(name)
|
||||
if err != nil {
|
||||
return call.ReplyContainerNotFound(name)
|
||||
}
|
||||
|
@ -369,11 +316,7 @@ func (i *LibpodAPI) PauseContainer(call ioprojectatomicpodman.VarlinkCall, name
|
|||
|
||||
// UnpauseContainer ...
|
||||
func (i *LibpodAPI) UnpauseContainer(call ioprojectatomicpodman.VarlinkCall, name string) error {
|
||||
runtime, err := libpodruntime.GetRuntime(i.Cli)
|
||||
if err != nil {
|
||||
return call.ReplyRuntimeError(err.Error())
|
||||
}
|
||||
ctr, err := runtime.LookupContainer(name)
|
||||
ctr, err := i.Runtime.LookupContainer(name)
|
||||
if err != nil {
|
||||
return call.ReplyContainerNotFound(name)
|
||||
}
|
||||
|
@ -391,11 +334,7 @@ func (i *LibpodAPI) AttachToContainer(call ioprojectatomicpodman.VarlinkCall) er
|
|||
|
||||
// WaitContainer ...
|
||||
func (i *LibpodAPI) WaitContainer(call ioprojectatomicpodman.VarlinkCall, name string) error {
|
||||
runtime, err := libpodruntime.GetRuntime(i.Cli)
|
||||
if err != nil {
|
||||
return call.ReplyRuntimeError(err.Error())
|
||||
}
|
||||
ctr, err := runtime.LookupContainer(name)
|
||||
ctr, err := i.Runtime.LookupContainer(name)
|
||||
if err != nil {
|
||||
return call.ReplyContainerNotFound(name)
|
||||
}
|
||||
|
@ -410,15 +349,11 @@ func (i *LibpodAPI) WaitContainer(call ioprojectatomicpodman.VarlinkCall, name s
|
|||
// RemoveContainer ...
|
||||
func (i *LibpodAPI) RemoveContainer(call ioprojectatomicpodman.VarlinkCall, name string, force bool) error {
|
||||
ctx := getContext()
|
||||
runtime, err := libpodruntime.GetRuntime(i.Cli)
|
||||
if err != nil {
|
||||
return call.ReplyRuntimeError(err.Error())
|
||||
}
|
||||
ctr, err := runtime.LookupContainer(name)
|
||||
ctr, err := i.Runtime.LookupContainer(name)
|
||||
if err != nil {
|
||||
return call.ReplyContainerNotFound(name)
|
||||
}
|
||||
if err := runtime.RemoveContainer(ctx, ctr, force); err != nil {
|
||||
if err := i.Runtime.RemoveContainer(ctx, ctr, force); err != nil {
|
||||
return call.ReplyErrorOccurred(err.Error())
|
||||
}
|
||||
return call.ReplyRemoveContainer(ctr.ID())
|
||||
|
@ -429,11 +364,7 @@ func (i *LibpodAPI) RemoveContainer(call ioprojectatomicpodman.VarlinkCall, name
|
|||
func (i *LibpodAPI) DeleteStoppedContainers(call ioprojectatomicpodman.VarlinkCall) error {
|
||||
ctx := getContext()
|
||||
var deletedContainers []string
|
||||
runtime, err := libpodruntime.GetRuntime(i.Cli)
|
||||
if err != nil {
|
||||
return call.ReplyRuntimeError(err.Error())
|
||||
}
|
||||
containers, err := runtime.GetAllContainers()
|
||||
containers, err := i.Runtime.GetAllContainers()
|
||||
if err != nil {
|
||||
return call.ReplyErrorOccurred(err.Error())
|
||||
}
|
||||
|
@ -443,7 +374,7 @@ func (i *LibpodAPI) DeleteStoppedContainers(call ioprojectatomicpodman.VarlinkCa
|
|||
return call.ReplyErrorOccurred(err.Error())
|
||||
}
|
||||
if state != libpod.ContainerStateRunning {
|
||||
if err := runtime.RemoveContainer(ctx, ctr, false); err != nil {
|
||||
if err := i.Runtime.RemoveContainer(ctx, ctr, false); err != nil {
|
||||
return call.ReplyErrorOccurred(err.Error())
|
||||
}
|
||||
deletedContainers = append(deletedContainers, ctr.ID())
|
||||
|
@ -454,11 +385,7 @@ func (i *LibpodAPI) DeleteStoppedContainers(call ioprojectatomicpodman.VarlinkCa
|
|||
|
||||
// GetAttachSockets ...
|
||||
func (i *LibpodAPI) GetAttachSockets(call ioprojectatomicpodman.VarlinkCall, name string) error {
|
||||
runtime, err := libpodruntime.GetRuntime(i.Cli)
|
||||
if err != nil {
|
||||
return call.ReplyRuntimeError(err.Error())
|
||||
}
|
||||
ctr, err := runtime.LookupContainer(name)
|
||||
ctr, err := i.Runtime.LookupContainer(name)
|
||||
if err != nil {
|
||||
return call.ReplyContainerNotFound(name)
|
||||
}
|
||||
|
|
|
@ -10,7 +10,6 @@ import (
|
|||
|
||||
"github.com/docker/docker/api/types/container"
|
||||
"github.com/docker/docker/pkg/signal"
|
||||
"github.com/projectatomic/libpod/cmd/podman/libpodruntime"
|
||||
"github.com/projectatomic/libpod/cmd/podman/varlink"
|
||||
"github.com/projectatomic/libpod/libpod"
|
||||
"github.com/projectatomic/libpod/libpod/image"
|
||||
|
@ -22,22 +21,16 @@ import (
|
|||
|
||||
// CreateContainer ...
|
||||
func (i *LibpodAPI) CreateContainer(call ioprojectatomicpodman.VarlinkCall, config ioprojectatomicpodman.Create) error {
|
||||
runtime, err := libpodruntime.GetRuntime(i.Cli)
|
||||
if err != nil {
|
||||
return call.ReplyRuntimeError(err.Error())
|
||||
}
|
||||
defer runtime.Shutdown(false)
|
||||
|
||||
rtc := runtime.GetConfig()
|
||||
rtc := i.Runtime.GetConfig()
|
||||
ctx := getContext()
|
||||
|
||||
newImage, err := runtime.ImageRuntime().New(ctx, config.Image, rtc.SignaturePolicyPath, "", os.Stderr, nil, image.SigningOptions{}, false, false)
|
||||
newImage, err := i.Runtime.ImageRuntime().New(ctx, config.Image, rtc.SignaturePolicyPath, "", os.Stderr, nil, image.SigningOptions{}, false, false)
|
||||
if err != nil {
|
||||
return call.ReplyErrorOccurred(err.Error())
|
||||
}
|
||||
data, err := newImage.Inspect(ctx)
|
||||
|
||||
createConfig, err := varlinkCreateToCreateConfig(ctx, config, runtime, config.Image, data)
|
||||
createConfig, err := varlinkCreateToCreateConfig(ctx, config, i.Runtime, config.Image, data)
|
||||
if err != nil {
|
||||
return call.ReplyErrorOccurred(err.Error())
|
||||
}
|
||||
|
@ -47,12 +40,12 @@ func (i *LibpodAPI) CreateContainer(call ioprojectatomicpodman.VarlinkCall, conf
|
|||
return call.ReplyErrorOccurred(err.Error())
|
||||
}
|
||||
|
||||
options, err := createConfig.GetContainerCreateOptions(runtime)
|
||||
options, err := createConfig.GetContainerCreateOptions(i.Runtime)
|
||||
if err != nil {
|
||||
return call.ReplyErrorOccurred(err.Error())
|
||||
}
|
||||
|
||||
ctr, err := runtime.NewContainer(ctx, runtimeSpec, options...)
|
||||
ctr, err := i.Runtime.NewContainer(ctx, runtimeSpec, options...)
|
||||
if err != nil {
|
||||
return call.ReplyErrorOccurred(err.Error())
|
||||
}
|
||||
|
|
|
@ -17,7 +17,6 @@ import (
|
|||
"github.com/pkg/errors"
|
||||
"github.com/projectatomic/buildah"
|
||||
"github.com/projectatomic/buildah/imagebuildah"
|
||||
"github.com/projectatomic/libpod/cmd/podman/libpodruntime"
|
||||
"github.com/projectatomic/libpod/cmd/podman/varlink"
|
||||
"github.com/projectatomic/libpod/libpod"
|
||||
"github.com/projectatomic/libpod/libpod/image"
|
||||
|
@ -28,11 +27,7 @@ import (
|
|||
// ListImages lists all the images in the store
|
||||
// It requires no inputs.
|
||||
func (i *LibpodAPI) ListImages(call ioprojectatomicpodman.VarlinkCall) error {
|
||||
runtime, err := libpodruntime.GetRuntime(i.Cli)
|
||||
if err != nil {
|
||||
return call.ReplyRuntimeError(err.Error())
|
||||
}
|
||||
images, err := runtime.ImageRuntime().GetImages()
|
||||
images, err := i.Runtime.ImageRuntime().GetImages()
|
||||
if err != nil {
|
||||
return call.ReplyErrorOccurred(fmt.Sprintf("unable to get list of images %q", err))
|
||||
}
|
||||
|
@ -60,11 +55,7 @@ func (i *LibpodAPI) ListImages(call ioprojectatomicpodman.VarlinkCall) error {
|
|||
|
||||
// GetImage returns a single image in the form of a ImageInList
|
||||
func (i *LibpodAPI) GetImage(call ioprojectatomicpodman.VarlinkCall, name string) error {
|
||||
runtime, err := libpodruntime.GetRuntime(i.Cli)
|
||||
if err != nil {
|
||||
return call.ReplyRuntimeError(err.Error())
|
||||
}
|
||||
newImage, err := runtime.ImageRuntime().NewFromLocal(name)
|
||||
newImage, err := i.Runtime.ImageRuntime().NewFromLocal(name)
|
||||
if err != nil {
|
||||
return call.ReplyErrorOccurred(err.Error())
|
||||
}
|
||||
|
@ -101,14 +92,9 @@ func (i *LibpodAPI) BuildImage(call ioprojectatomicpodman.VarlinkCall, config io
|
|||
memoryLimit int64
|
||||
memorySwap int64
|
||||
namespace []buildah.NamespaceOption
|
||||
err error
|
||||
)
|
||||
|
||||
runtime, err := libpodruntime.GetRuntime(i.Cli)
|
||||
if err != nil {
|
||||
return call.ReplyRuntimeError(err.Error())
|
||||
}
|
||||
defer runtime.Shutdown(false)
|
||||
|
||||
systemContext := types.SystemContext{}
|
||||
dockerfiles := config.Dockerfile
|
||||
contextDir := ""
|
||||
|
@ -215,7 +201,7 @@ func (i *LibpodAPI) BuildImage(call ioprojectatomicpodman.VarlinkCall, config io
|
|||
call.Continues = true
|
||||
}
|
||||
|
||||
c := build(runtime, options, config.Dockerfile)
|
||||
c := build(i.Runtime, options, config.Dockerfile)
|
||||
var log []string
|
||||
done := false
|
||||
for {
|
||||
|
@ -249,7 +235,7 @@ func (i *LibpodAPI) BuildImage(call ioprojectatomicpodman.VarlinkCall, config io
|
|||
}
|
||||
}
|
||||
call.Continues = false
|
||||
newImage, err := runtime.ImageRuntime().NewFromLocal(config.Tags[0])
|
||||
newImage, err := i.Runtime.ImageRuntime().NewFromLocal(config.Tags[0])
|
||||
if err != nil {
|
||||
return call.ReplyErrorOccurred(err.Error())
|
||||
}
|
||||
|
@ -280,11 +266,7 @@ func (i *LibpodAPI) CreateImage(call ioprojectatomicpodman.VarlinkCall) error {
|
|||
// InspectImage returns an image's inspect information as a string that can be serialized.
|
||||
// Requires an image ID or name
|
||||
func (i *LibpodAPI) InspectImage(call ioprojectatomicpodman.VarlinkCall, name string) error {
|
||||
runtime, err := libpodruntime.GetRuntime(i.Cli)
|
||||
if err != nil {
|
||||
return call.ReplyRuntimeError(err.Error())
|
||||
}
|
||||
newImage, err := runtime.ImageRuntime().NewFromLocal(name)
|
||||
newImage, err := i.Runtime.ImageRuntime().NewFromLocal(name)
|
||||
if err != nil {
|
||||
return call.ReplyImageNotFound(name)
|
||||
}
|
||||
|
@ -299,11 +281,7 @@ func (i *LibpodAPI) InspectImage(call ioprojectatomicpodman.VarlinkCall, name st
|
|||
// HistoryImage returns the history of the image's layers
|
||||
// Requires an image or name
|
||||
func (i *LibpodAPI) HistoryImage(call ioprojectatomicpodman.VarlinkCall, name string) error {
|
||||
runtime, err := libpodruntime.GetRuntime(i.Cli)
|
||||
if err != nil {
|
||||
return call.ReplyRuntimeError(err.Error())
|
||||
}
|
||||
newImage, err := runtime.ImageRuntime().NewFromLocal(name)
|
||||
newImage, err := i.Runtime.ImageRuntime().NewFromLocal(name)
|
||||
if err != nil {
|
||||
return call.ReplyImageNotFound(name)
|
||||
}
|
||||
|
@ -329,11 +307,7 @@ func (i *LibpodAPI) HistoryImage(call ioprojectatomicpodman.VarlinkCall, name st
|
|||
// PushImage pushes an local image to registry
|
||||
// TODO We need to add options for signing, credentials, tls, and multi-tag
|
||||
func (i *LibpodAPI) PushImage(call ioprojectatomicpodman.VarlinkCall, name, tag string, tlsVerify bool) error {
|
||||
runtime, err := libpodruntime.GetRuntime(i.Cli)
|
||||
if err != nil {
|
||||
return call.ReplyRuntimeError(err.Error())
|
||||
}
|
||||
newImage, err := runtime.ImageRuntime().NewFromLocal(name)
|
||||
newImage, err := i.Runtime.ImageRuntime().NewFromLocal(name)
|
||||
if err != nil {
|
||||
return call.ReplyImageNotFound(err.Error())
|
||||
}
|
||||
|
@ -356,11 +330,7 @@ func (i *LibpodAPI) PushImage(call ioprojectatomicpodman.VarlinkCall, name, tag
|
|||
|
||||
// TagImage accepts an image name and tag as strings and tags an image in the local store.
|
||||
func (i *LibpodAPI) TagImage(call ioprojectatomicpodman.VarlinkCall, name, tag string) error {
|
||||
runtime, err := libpodruntime.GetRuntime(i.Cli)
|
||||
if err != nil {
|
||||
return call.ReplyRuntimeError(err.Error())
|
||||
}
|
||||
newImage, err := runtime.ImageRuntime().NewFromLocal(name)
|
||||
newImage, err := i.Runtime.ImageRuntime().NewFromLocal(name)
|
||||
if err != nil {
|
||||
return call.ReplyImageNotFound(name)
|
||||
}
|
||||
|
@ -374,15 +344,11 @@ func (i *LibpodAPI) TagImage(call ioprojectatomicpodman.VarlinkCall, name, tag s
|
|||
// remove the image even if being used by stopped containers
|
||||
func (i *LibpodAPI) RemoveImage(call ioprojectatomicpodman.VarlinkCall, name string, force bool) error {
|
||||
ctx := getContext()
|
||||
runtime, err := libpodruntime.GetRuntime(i.Cli)
|
||||
if err != nil {
|
||||
return call.ReplyRuntimeError(err.Error())
|
||||
}
|
||||
newImage, err := runtime.ImageRuntime().NewFromLocal(name)
|
||||
newImage, err := i.Runtime.ImageRuntime().NewFromLocal(name)
|
||||
if err != nil {
|
||||
return call.ReplyImageNotFound(name)
|
||||
}
|
||||
_, err = runtime.RemoveImage(ctx, newImage, force)
|
||||
_, err = i.Runtime.RemoveImage(ctx, newImage, force)
|
||||
if err != nil {
|
||||
return call.ReplyErrorOccurred(err.Error())
|
||||
}
|
||||
|
@ -420,11 +386,7 @@ func (i *LibpodAPI) SearchImage(call ioprojectatomicpodman.VarlinkCall, name str
|
|||
// DeleteUnusedImages deletes any images that do not have containers associated with it.
|
||||
// TODO Filters are not implemented
|
||||
func (i *LibpodAPI) DeleteUnusedImages(call ioprojectatomicpodman.VarlinkCall) error {
|
||||
runtime, err := libpodruntime.GetRuntime(i.Cli)
|
||||
if err != nil {
|
||||
return call.ReplyRuntimeError(err.Error())
|
||||
}
|
||||
images, err := runtime.ImageRuntime().GetImages()
|
||||
images, err := i.Runtime.ImageRuntime().GetImages()
|
||||
if err != nil {
|
||||
return call.ReplyErrorOccurred(err.Error())
|
||||
}
|
||||
|
@ -446,17 +408,13 @@ func (i *LibpodAPI) DeleteUnusedImages(call ioprojectatomicpodman.VarlinkCall) e
|
|||
|
||||
// Commit ...
|
||||
func (i *LibpodAPI) Commit(call ioprojectatomicpodman.VarlinkCall, name, imageName string, changes []string, author, message string, pause bool) error {
|
||||
runtime, err := libpodruntime.GetRuntime(i.Cli)
|
||||
if err != nil {
|
||||
return call.ReplyRuntimeError(err.Error())
|
||||
}
|
||||
ctr, err := runtime.LookupContainer(name)
|
||||
ctr, err := i.Runtime.LookupContainer(name)
|
||||
if err != nil {
|
||||
return call.ReplyContainerNotFound(name)
|
||||
}
|
||||
sc := image.GetSystemContext(runtime.GetConfig().SignaturePolicyPath, "", false)
|
||||
sc := image.GetSystemContext(i.Runtime.GetConfig().SignaturePolicyPath, "", false)
|
||||
coptions := buildah.CommitOptions{
|
||||
SignaturePolicyPath: runtime.GetConfig().SignaturePolicyPath,
|
||||
SignaturePolicyPath: i.Runtime.GetConfig().SignaturePolicyPath,
|
||||
ReportWriter: nil,
|
||||
SystemContext: sc,
|
||||
PreferredManifestType: buildah.OCIv1ImageManifest,
|
||||
|
@ -478,10 +436,6 @@ func (i *LibpodAPI) Commit(call ioprojectatomicpodman.VarlinkCall, name, imageNa
|
|||
|
||||
// ImportImage imports an image from a tarball to the image store
|
||||
func (i *LibpodAPI) ImportImage(call ioprojectatomicpodman.VarlinkCall, source, reference, message string, changes []string) error {
|
||||
runtime, err := libpodruntime.GetRuntime(i.Cli)
|
||||
if err != nil {
|
||||
return call.ReplyRuntimeError(err.Error())
|
||||
}
|
||||
configChanges, err := util.GetImageConfig(changes)
|
||||
if err != nil {
|
||||
return call.ReplyErrorOccurred(err.Error())
|
||||
|
@ -493,7 +447,7 @@ func (i *LibpodAPI) ImportImage(call ioprojectatomicpodman.VarlinkCall, source,
|
|||
Config: configChanges,
|
||||
History: history,
|
||||
}
|
||||
newImage, err := runtime.ImageRuntime().Import(getContext(), source, reference, nil, image.SigningOptions{}, config)
|
||||
newImage, err := i.Runtime.ImageRuntime().Import(getContext(), source, reference, nil, image.SigningOptions{}, config)
|
||||
if err != nil {
|
||||
return call.ReplyErrorOccurred(err.Error())
|
||||
}
|
||||
|
@ -503,11 +457,7 @@ func (i *LibpodAPI) ImportImage(call ioprojectatomicpodman.VarlinkCall, source,
|
|||
// ExportImage exports an image to the provided destination
|
||||
// destination must have the transport type!!
|
||||
func (i *LibpodAPI) ExportImage(call ioprojectatomicpodman.VarlinkCall, name, destination string, compress bool, tags []string) error {
|
||||
runtime, err := libpodruntime.GetRuntime(i.Cli)
|
||||
if err != nil {
|
||||
return call.ReplyRuntimeError(err.Error())
|
||||
}
|
||||
newImage, err := runtime.ImageRuntime().NewFromLocal(name)
|
||||
newImage, err := i.Runtime.ImageRuntime().NewFromLocal(name)
|
||||
if err != nil {
|
||||
return call.ReplyImageNotFound(name)
|
||||
}
|
||||
|
@ -526,11 +476,7 @@ func (i *LibpodAPI) ExportImage(call ioprojectatomicpodman.VarlinkCall, name, de
|
|||
// PullImage pulls an image from a registry to the image store.
|
||||
// TODO This implementation is incomplete
|
||||
func (i *LibpodAPI) PullImage(call ioprojectatomicpodman.VarlinkCall, name string) error {
|
||||
runtime, err := libpodruntime.GetRuntime(i.Cli)
|
||||
if err != nil {
|
||||
return call.ReplyRuntimeError(err.Error())
|
||||
}
|
||||
newImage, err := runtime.ImageRuntime().New(getContext(), name, "", "", nil, &image.DockerRegistryOptions{}, image.SigningOptions{}, true, false)
|
||||
newImage, err := i.Runtime.ImageRuntime().New(getContext(), name, "", "", nil, &image.DockerRegistryOptions{}, image.SigningOptions{}, true, false)
|
||||
if err != nil {
|
||||
return call.ReplyErrorOccurred(fmt.Sprintf("unable to pull %s: %s", name, err.Error()))
|
||||
}
|
||||
|
|
|
@ -4,7 +4,6 @@ import (
|
|||
goruntime "runtime"
|
||||
"strings"
|
||||
|
||||
"github.com/projectatomic/libpod/cmd/podman/libpodruntime"
|
||||
"github.com/projectatomic/libpod/cmd/podman/varlink"
|
||||
"github.com/projectatomic/libpod/libpod"
|
||||
)
|
||||
|
@ -36,11 +35,7 @@ func (i *LibpodAPI) Ping(call ioprojectatomicpodman.VarlinkCall) error {
|
|||
// GetInfo returns details about the podman host and its stores
|
||||
func (i *LibpodAPI) GetInfo(call ioprojectatomicpodman.VarlinkCall) error {
|
||||
podmanInfo := ioprojectatomicpodman.PodmanInfo{}
|
||||
runtime, err := libpodruntime.GetRuntime(i.Cli)
|
||||
if err != nil {
|
||||
return call.ReplyRuntimeError(err.Error())
|
||||
}
|
||||
info, err := runtime.Info()
|
||||
info, err := i.Runtime.Info()
|
||||
if err != nil {
|
||||
return call.ReplyErrorOccurred(err.Error())
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue