diff options
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/podman/images.go | 2 | ||||
-rw-r--r-- | cmd/podman/images_prune.go | 2 | ||||
-rw-r--r-- | cmd/podman/rmi.go | 2 | ||||
-rw-r--r-- | cmd/podman/shared/events.go | 115 | ||||
-rw-r--r-- | cmd/podman/system_df.go | 10 | ||||
-rw-r--r-- | cmd/podman/system_prune.go | 2 |
6 files changed, 9 insertions, 124 deletions
diff --git a/cmd/podman/images.go b/cmd/podman/images.go index f584c1131..41aa213a8 100644 --- a/cmd/podman/images.go +++ b/cmd/podman/images.go @@ -243,7 +243,7 @@ func getImagesTemplateOutput(ctx context.Context, images []*adapter.ContainerIma // If all is false and the image doesn't have a name, check to see if the top layer of the image is a parent // to another image's top layer. If it is, then it is an intermediate image so don't print out if the --all flag // is not set. - isParent, err := img.IsParent() + isParent, err := img.IsParent(ctx) if err != nil { logrus.Errorf("error checking if image is a parent %q: %v", img.ID(), err) } diff --git a/cmd/podman/images_prune.go b/cmd/podman/images_prune.go index 84181d0a2..c522c8b15 100644 --- a/cmd/podman/images_prune.go +++ b/cmd/podman/images_prune.go @@ -45,7 +45,7 @@ func pruneImagesCmd(c *cliconfig.PruneImagesValues) error { // Call prune; if any cids are returned, print them and then // return err in case an error also came up - pruneCids, err := runtime.PruneImages(c.All) + pruneCids, err := runtime.PruneImages(getContext(), c.All) if len(pruneCids) > 0 { for _, cid := range pruneCids { fmt.Println(cid) diff --git a/cmd/podman/rmi.go b/cmd/podman/rmi.go index 7ec875d5b..be7c81dab 100644 --- a/cmd/podman/rmi.go +++ b/cmd/podman/rmi.go @@ -97,7 +97,7 @@ func rmiCmd(c *cliconfig.RmiValues) error { return errors.New("unable to delete all images; re-run the rmi command again.") } for _, i := range imagesToDelete { - isParent, err := i.IsParent() + isParent, err := i.IsParent(ctx) if err != nil { return err } diff --git a/cmd/podman/shared/events.go b/cmd/podman/shared/events.go deleted file mode 100644 index c62044271..000000000 --- a/cmd/podman/shared/events.go +++ /dev/null @@ -1,115 +0,0 @@ -package shared - -import ( - "fmt" - "strings" - "time" - - "github.com/containers/libpod/libpod/events" - "github.com/containers/libpod/pkg/util" - "github.com/pkg/errors" -) - -func generateEventFilter(filter, filterValue string) (func(e *events.Event) bool, error) { - switch strings.ToUpper(filter) { - case "CONTAINER": - return func(e *events.Event) bool { - if e.Type != events.Container { - return false - } - if e.Name == filterValue { - return true - } - return strings.HasPrefix(e.ID, filterValue) - }, nil - case "EVENT", "STATUS": - return func(e *events.Event) bool { - return fmt.Sprintf("%s", e.Status) == filterValue - }, nil - case "IMAGE": - return func(e *events.Event) bool { - if e.Type != events.Image { - return false - } - if e.Name == filterValue { - return true - } - return strings.HasPrefix(e.ID, filterValue) - }, nil - case "POD": - return func(e *events.Event) bool { - if e.Type != events.Pod { - return false - } - if e.Name == filterValue { - return true - } - return strings.HasPrefix(e.ID, filterValue) - }, nil - case "VOLUME": - return func(e *events.Event) bool { - if e.Type != events.Volume { - return false - } - return strings.HasPrefix(e.ID, filterValue) - }, nil - case "TYPE": - return func(e *events.Event) bool { - return fmt.Sprintf("%s", e.Type) == filterValue - }, nil - } - return nil, errors.Errorf("%s is an invalid filter", filter) -} - -func generateEventSinceOption(timeSince time.Time) func(e *events.Event) bool { - return func(e *events.Event) bool { - return e.Time.After(timeSince) - } -} - -func generateEventUntilOption(timeUntil time.Time) func(e *events.Event) bool { - return func(e *events.Event) bool { - return e.Time.Before(timeUntil) - - } -} - -func parseFilter(filter string) (string, string, error) { - filterSplit := strings.Split(filter, "=") - if len(filterSplit) != 2 { - return "", "", errors.Errorf("%s is an invalid filter", filter) - } - return filterSplit[0], filterSplit[1], nil -} - -func GenerateEventOptions(filters []string, since, until string) ([]events.EventFilter, error) { - var options []events.EventFilter - for _, filter := range filters { - key, val, err := parseFilter(filter) - if err != nil { - return nil, err - } - funcFilter, err := generateEventFilter(key, val) - if err != nil { - return nil, err - } - options = append(options, funcFilter) - } - - if len(since) > 0 { - timeSince, err := util.ParseInputTime(since) - if err != nil { - return nil, errors.Wrapf(err, "unable to convert since time of %s", since) - } - options = append(options, generateEventSinceOption(timeSince)) - } - - if len(until) > 0 { - timeUntil, err := util.ParseInputTime(until) - if err != nil { - return nil, errors.Wrapf(err, "unable to convert until time of %s", until) - } - options = append(options, generateEventUntilOption(timeUntil)) - } - return options, nil -} diff --git a/cmd/podman/system_df.go b/cmd/podman/system_df.go index 16a8ad120..aa0ead022 100644 --- a/cmd/podman/system_df.go +++ b/cmd/podman/system_df.go @@ -201,7 +201,7 @@ func imageUniqueSize(ctx context.Context, images []*image.Image) (map[string]uin for _, img := range images { parentImg := img for { - next, err := parentImg.GetParent() + next, err := parentImg.GetParent(ctx) if err != nil { return nil, errors.Wrapf(err, "error getting parent of image %s", parentImg.ID()) } @@ -246,11 +246,11 @@ func getImageDiskUsage(ctx context.Context, images []*image.Image, imageUsedbyCi unreclaimableSize += imageUsedSize(img, imgUniqueSizeMap, imageUsedbyCintainerMap, imageUsedbyActiveContainerMap) - isParent, err := img.IsParent() + isParent, err := img.IsParent(ctx) if err != nil { return imageDiskUsage, err } - parent, err := img.GetParent() + parent, err := img.GetParent(ctx) if err != nil { return imageDiskUsage, errors.Wrapf(err, "error getting parent of image %s", img.ID()) } @@ -437,11 +437,11 @@ func getImageVerboseDiskUsage(ctx context.Context, images []*image.Image, images return imagesVerboseDiskUsage, errors.Wrapf(err, "error getting unique size of images") } for _, img := range images { - isParent, err := img.IsParent() + isParent, err := img.IsParent(ctx) if err != nil { return imagesVerboseDiskUsage, errors.Wrapf(err, "error checking if %s is a parent images", img.ID()) } - parent, err := img.GetParent() + parent, err := img.GetParent(ctx) if err != nil { return imagesVerboseDiskUsage, errors.Wrapf(err, "error getting parent of image %s", img.ID()) } diff --git a/cmd/podman/system_prune.go b/cmd/podman/system_prune.go index 8900e2644..2c1c5607a 100644 --- a/cmd/podman/system_prune.go +++ b/cmd/podman/system_prune.go @@ -110,7 +110,7 @@ Are you sure you want to continue? [y/N] `, volumeString) // Call prune; if any cids are returned, print them and then // return err in case an error also came up - pruneCids, err := runtime.PruneImages(c.All) + pruneCids, err := runtime.PruneImages(ctx, c.All) if len(pruneCids) > 0 { fmt.Println("Deleted Images") for _, cid := range pruneCids { |