Merge pull request #5868 from baude/v2t2

Fixes for system tests
This commit is contained in:
OpenShift Merge Robot 2020-04-17 14:43:21 -04:00 committed by GitHub
commit ba289dcd79
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 38 additions and 22 deletions

View File

@ -136,6 +136,7 @@ func run(cmd *cobra.Command, args []string) error {
} }
if cliVals.Detach { if cliVals.Detach {
fmt.Println(report.Id) fmt.Println(report.Id)
return nil
} }
if runRmi { if runRmi {
_, err := registry.ImageEngine().Delete(registry.GetContext(), []string{args[0]}, entities.ImageDeleteOptions{}) _, err := registry.ImageEngine().Delete(registry.GetContext(), []string{args[0]}, entities.ImageDeleteOptions{})

View File

@ -113,13 +113,15 @@ func writeJSON(imageS []*entities.ImageSummary) error {
type image struct { type image struct {
entities.ImageSummary entities.ImageSummary
Created string Created string
CreatedAt string
} }
imgs := make([]image, 0, len(imageS)) imgs := make([]image, 0, len(imageS))
for _, e := range imageS { for _, e := range imageS {
var h image var h image
h.ImageSummary = *e h.ImageSummary = *e
h.Created = time.Unix(e.Created, 0).Format(time.RFC3339) h.Created = units.HumanDuration(time.Since(e.Created)) + " ago"
h.CreatedAt = e.Created.Format(time.RFC3339Nano)
h.RepoTags = nil h.RepoTags = nil
imgs = append(imgs, h) imgs = append(imgs, h)
@ -196,7 +198,7 @@ func sortFunc(key string, data []*entities.ImageSummary) func(i, j int) bool {
default: default:
// case "created": // case "created":
return func(i, j int) bool { return func(i, j int) bool {
return data[i].Created >= data[j].Created return data[i].Created.After(data[j].Created)
} }
} }
} }
@ -255,11 +257,11 @@ func (i imageReporter) ID() string {
if !listFlag.noTrunc && len(i.ImageSummary.ID) >= 12 { if !listFlag.noTrunc && len(i.ImageSummary.ID) >= 12 {
return i.ImageSummary.ID[0:12] return i.ImageSummary.ID[0:12]
} }
return i.ImageSummary.ID return "sha256:" + i.ImageSummary.ID
} }
func (i imageReporter) Created() string { func (i imageReporter) Created() string {
return units.HumanDuration(time.Since(time.Unix(i.ImageSummary.Created, 0))) + " ago" return units.HumanDuration(time.Since(i.ImageSummary.Created)) + " ago"
} }
func (i imageReporter) Size() string { func (i imageReporter) Size() string {

View File

@ -4,6 +4,7 @@ import (
"context" "context"
"fmt" "fmt"
"github.com/containers/image/v5/docker/reference"
"github.com/containers/libpod/cmd/podman/common" "github.com/containers/libpod/cmd/podman/common"
"github.com/containers/libpod/cmd/podman/containers" "github.com/containers/libpod/cmd/podman/containers"
"github.com/containers/libpod/cmd/podman/images" "github.com/containers/libpod/cmd/podman/images"
@ -37,12 +38,14 @@ func init() {
} }
func inspect(cmd *cobra.Command, args []string) error { func inspect(cmd *cobra.Command, args []string) error {
// First check if the input is even valid for an image
if _, err := reference.Parse(args[0]); err == nil {
if found, err := registry.ImageEngine().Exists(context.Background(), args[0]); err != nil { if found, err := registry.ImageEngine().Exists(context.Background(), args[0]); err != nil {
return err return err
} else if found.Value { } else if found.Value {
return images.Inspect(cmd, args, inspectOpts) return images.Inspect(cmd, args, inspectOpts)
} }
}
if found, err := registry.ContainerEngine().ContainerExists(context.Background(), args[0]); err != nil { if found, err := registry.ContainerEngine().ContainerExists(context.Background(), args[0]); err != nil {
return err return err
} else if found.Value { } else if found.Value {

View File

@ -111,7 +111,7 @@ func GetImages(w http.ResponseWriter, r *http.Request) {
return return
} }
// libpod has additional fields that we need to populate. // libpod has additional fields that we need to populate.
is.Created = img.Created().Unix() is.Created = img.Created()
is.ReadOnly = img.IsReadOnly() is.ReadOnly = img.IsReadOnly()
summaries[j] = is summaries[j] = is
} }

View File

@ -262,7 +262,7 @@ func ImageToImageSummary(l *libpodImage.Image) (*entities.ImageSummary, error) {
ID: l.ID(), ID: l.ID(),
ParentId: l.Parent, ParentId: l.Parent,
RepoTags: repoTags, RepoTags: repoTags,
Created: l.Created().Unix(), Created: l.Created(),
Size: int64(*size), Size: int64(*size),
SharedSize: 0, SharedSize: 0,
VirtualSize: l.VirtualSize, VirtualSize: l.VirtualSize,

View File

@ -50,10 +50,10 @@ func (i *Image) Id() string {
} }
type ImageSummary struct { type ImageSummary struct {
ID string `json:"Id"` ID string
ParentId string `json:",omitempty"` ParentId string `json:",omitempty"`
RepoTags []string `json:",omitempty"` RepoTags []string `json:",omitempty"`
Created int64 `json:",omitempty"` Created time.Time `json:",omitempty"`
Size int64 `json:",omitempty"` Size int64 `json:",omitempty"`
SharedSize int `json:",omitempty"` SharedSize int `json:",omitempty"`
VirtualSize int64 `json:",omitempty"` VirtualSize int64 `json:",omitempty"`

View File

@ -736,6 +736,16 @@ func (ic *ContainerEngine) ContainerRun(ctx context.Context, opts entities.Conta
} else { } else {
report.ExitCode = int(ecode) report.ExitCode = int(ecode)
} }
if opts.Rm {
if err := ic.Libpod.RemoveContainer(ctx, ctr, false, true); err != nil {
if errors.Cause(err) == define.ErrNoSuchCtr ||
errors.Cause(err) == define.ErrCtrRemoved {
logrus.Warnf("Container %s does not exist: %v", ctr.ID(), err)
} else {
logrus.Errorf("Error removing container %s: %v", ctr.ID(), err)
}
}
}
return &report, nil return &report, nil
} }

View File

@ -54,7 +54,7 @@ func (ir *ImageEngine) List(ctx context.Context, opts entities.ImageListOptions)
ID: img.ID(), ID: img.ID(),
ConfigDigest: string(img.ConfigDigest), ConfigDigest: string(img.ConfigDigest),
Created: img.Created().Unix(), Created: img.Created(),
Dangling: img.Dangling(), Dangling: img.Dangling(),
Digest: string(img.Digest()), Digest: string(img.Digest()),
Digests: digests, Digests: digests,

View File

@ -8,19 +8,19 @@ load helpers
run_podman info run_podman info
expected_keys=" expected_keys="
buildahVersion: *[0-9.]\\\+ buildahversion: *[0-9.]\\\+
conmon:\\\s\\\+package: conmon:\\\s\\\+package:
distribution: distribution:
ociRuntime:\\\s\\\+name: ociruntime:\\\s\\\+name:
os: os:
rootless: rootless:
registries: registries:
store: store:
graphDriverName: graphdrivername:
graphRoot: graphroot:
graphStatus: graphstatus:
imageStore:\\\s\\\+number: 1 imagestore:\\\s\\\+number: 1
runRoot: runroot:
" "
while read expect; do while read expect; do
is "$output" ".*$expect" "output includes '$expect'" is "$output" ".*$expect" "output includes '$expect'"