mirror of
https://github.com/containers/podman.git
synced 2025-05-21 17:16:22 +08:00
Merge pull request #2161 from baude/remotehistory
add support for podman-remote history
This commit is contained in:
@ -1,15 +1,15 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"github.com/containers/libpod/libpod/adapter"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/containers/libpod/cmd/podman/formats"
|
"github.com/containers/libpod/cmd/podman/formats"
|
||||||
"github.com/containers/libpod/cmd/podman/libpodruntime"
|
|
||||||
"github.com/containers/libpod/libpod/image"
|
"github.com/containers/libpod/libpod/image"
|
||||||
units "github.com/docker/go-units"
|
"github.com/docker/go-units"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/urfave/cli"
|
"github.com/urfave/cli"
|
||||||
)
|
)
|
||||||
@ -72,11 +72,11 @@ func historyCmd(c *cli.Context) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
runtime, err := libpodruntime.GetRuntime(c)
|
runtime, err := adapter.GetRuntime(c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrapf(err, "could not get runtime")
|
return errors.Wrapf(err, "could not get runtime")
|
||||||
}
|
}
|
||||||
defer runtime.Shutdown(false)
|
defer runtime.Runtime.Shutdown(false)
|
||||||
|
|
||||||
format := genHistoryFormat(c.String("format"), c.Bool("quiet"))
|
format := genHistoryFormat(c.String("format"), c.Bool("quiet"))
|
||||||
|
|
||||||
@ -88,7 +88,7 @@ func historyCmd(c *cli.Context) error {
|
|||||||
return errors.Errorf("podman history takes at most 1 argument")
|
return errors.Errorf("podman history takes at most 1 argument")
|
||||||
}
|
}
|
||||||
|
|
||||||
image, err := runtime.ImageRuntime().NewFromLocal(args[0])
|
image, err := runtime.NewImageFromLocal(args[0])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -221,3 +221,28 @@ func (r RemoteRuntime) RemoveImage(force bool) error {
|
|||||||
func (r *LocalRuntime) RemoveImage(ctx context.Context, img *ContainerImage, force bool) (string, error) {
|
func (r *LocalRuntime) RemoveImage(ctx context.Context, img *ContainerImage, force bool) (string, error) {
|
||||||
return iopodman.RemoveImage().Call(r.Conn, img.InputName, force)
|
return iopodman.RemoveImage().Call(r.Conn, img.InputName, force)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// History returns the history of an image and its layers
|
||||||
|
func (ci *ContainerImage) History(ctx context.Context) ([]*image.History, error) {
|
||||||
|
var imageHistories []*image.History
|
||||||
|
|
||||||
|
reply, err := iopodman.HistoryImage().Call(ci.Runtime.Conn, ci.InputName)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
for _, h := range reply {
|
||||||
|
created, err := splitStringDate(h.Created)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
ih := image.History{
|
||||||
|
ID: h.Id,
|
||||||
|
Created: &created,
|
||||||
|
CreatedBy: h.CreatedBy,
|
||||||
|
Size: h.Size,
|
||||||
|
Comment: h.Comment,
|
||||||
|
}
|
||||||
|
imageHistories = append(imageHistories, &ih)
|
||||||
|
}
|
||||||
|
return imageHistories, nil
|
||||||
|
}
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
// +build !remoteclient
|
|
||||||
|
|
||||||
package integration
|
package integration
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
Reference in New Issue
Block a user