Skip to content

Commit

Permalink
Merge pull request #5813 from baude/v2edtests2
Browse files Browse the repository at this point in the history
More system test fixes on regressions
  • Loading branch information
openshift-merge-robot authored Apr 15, 2020
2 parents ffcb99d + 60dde45 commit a756161
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 16 deletions.
9 changes: 6 additions & 3 deletions cmd/podmanV2/images/history.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func init() {

flags := historyCmd.Flags()
flags.StringVar(&opts.format, "format", "", "Change the output to JSON or a Go template")
flags.BoolVarP(&opts.human, "human", "H", false, "Display sizes and dates in human readable format")
flags.BoolVarP(&opts.human, "human", "H", true, "Display sizes and dates in human readable format")
flags.BoolVar(&opts.noTrunc, "no-trunc", false, "Do not truncate the output")
flags.BoolVar(&opts.noTrunc, "notruncate", false, "Do not truncate the output")
flags.BoolVarP(&opts.quiet, "quiet", "q", false, "Display the numeric IDs only")
Expand All @@ -79,7 +79,7 @@ func history(cmd *cobra.Command, args []string) error {
layers := make([]layer, len(results.Layers))
for i, l := range results.Layers {
layers[i].ImageHistoryLayer = l
layers[i].Created = time.Unix(l.Created, 0).Format(time.RFC3339)
layers[i].Created = l.Created.Format(time.RFC3339)
}
json := jsoniter.ConfigCompatibleWithStandardLibrary
enc := json.NewEncoder(os.Stdout)
Expand Down Expand Up @@ -129,7 +129,10 @@ type historyreporter struct {
}

func (h historyreporter) Created() string {
return units.HumanDuration(time.Since(time.Unix(h.ImageHistoryLayer.Created, 0))) + " ago"
if opts.human {
return units.HumanDuration(time.Since(h.ImageHistoryLayer.Created)) + " ago"
}
return h.ImageHistoryLayer.Created.Format(time.RFC3339)
}

func (h historyreporter) Size() string {
Expand Down
3 changes: 1 addition & 2 deletions cmd/podmanV2/images/inspect.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ func inspect(cmd *cobra.Command, args []string) error {
}
return nil
}

row := inspectFormat(inspectOpts.Format)
format := "{{range . }}" + row + "{{end}}"
tmpl, err := template.New("inspect").Parse(format)
Expand All @@ -77,7 +76,7 @@ func inspect(cmd *cobra.Command, args []string) error {

w := tabwriter.NewWriter(os.Stdout, 8, 2, 2, ' ', 0)
defer func() { _ = w.Flush() }()
err = tmpl.Execute(w, results)
err = tmpl.Execute(w, results.Images)
if err != nil {
return err
}
Expand Down
8 changes: 5 additions & 3 deletions cmd/podmanV2/images/rm.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/containers/libpod/pkg/domain/entities"
"github.com/pkg/errors"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
)

var (
Expand All @@ -33,11 +34,13 @@ func init() {
Parent: imageCmd,
})

flags := rmCmd.Flags()
imageRemoveFlagSet(rmCmd.Flags())
}

func imageRemoveFlagSet(flags *pflag.FlagSet) {
flags.BoolVarP(&imageOpts.All, "all", "a", false, "Remove all images")
flags.BoolVarP(&imageOpts.Force, "force", "f", false, "Force Removal of the image")
}

func rm(cmd *cobra.Command, args []string) error {

if len(args) < 1 && !imageOpts.All {
Expand All @@ -46,7 +49,6 @@ func rm(cmd *cobra.Command, args []string) error {
if len(args) > 0 && imageOpts.All {
return errors.Errorf("when using the --all switch, you may not pass any images names or IDs")
}

report, err := registry.ImageEngine().Delete(registry.GetContext(), args, imageOpts)
if err != nil {
switch {
Expand Down
1 change: 1 addition & 0 deletions cmd/podmanV2/images/rmi.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,5 @@ func init() {
})
rmiCmd.SetHelpTemplate(registry.HelpTemplate())
rmiCmd.SetUsageTemplate(registry.UsageTemplate())
imageRemoveFlagSet(rmiCmd.Flags())
}
13 changes: 7 additions & 6 deletions pkg/domain/entities/images.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package entities

import (
"net/url"
"time"

"github.com/containers/image/v5/manifest"
"github.com/containers/image/v5/types"
Expand Down Expand Up @@ -99,12 +100,12 @@ type ImageDeleteReport struct {
type ImageHistoryOptions struct{}

type ImageHistoryLayer struct {
ID string `json:"Id"`
Created int64 `json:",omitempty"`
CreatedBy string `json:",omitempty"`
Tags []string `json:",omitempty"`
Size int64 `json:",omitempty"`
Comment string `json:",omitempty"`
ID string `json:"id"`
Created time.Time `json:"created,omitempty"`
CreatedBy string `json:",omitempty"`
Tags []string `json:"tags,omitempty"`
Size int64 `json:"size"`
Comment string `json:"comment,omitempty"`
}

type ImageHistoryReport struct {
Expand Down
6 changes: 4 additions & 2 deletions pkg/domain/infra/abi/images.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ func (ir *ImageEngine) Delete(ctx context.Context, nameOrId []string, opts entit
if err != nil {
return &report, errors.Wrapf(err, "unable to query local images")
}

if len(targets) == 0 {
return &report, nil
}
if len(targets) > 0 && len(targets) == len(previousTargets) {
return &report, errors.New("unable to delete all images; re-run the rmi command again.")
}
Expand Down Expand Up @@ -143,7 +145,7 @@ func (ir *ImageEngine) History(ctx context.Context, nameOrId string, opts entiti
func ToDomainHistoryLayer(layer *libpodImage.History) entities.ImageHistoryLayer {
l := entities.ImageHistoryLayer{}
l.ID = layer.ID
l.Created = layer.Created.Unix()
l.Created = *layer.Created
l.CreatedBy = layer.CreatedBy
copy(l.Tags, layer.Tags)
l.Size = layer.Size
Expand Down

0 comments on commit a756161

Please sign in to comment.