Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions cmd/nerdctl/images.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ Properties:
return imagesCommand
}

func processImagesFlag(cmd *cobra.Command, args []string) (types.ImageListOptions, error) {
func processImageListOptions(cmd *cobra.Command, args []string) (types.ImageListOptions, error) {
globalOptions, err := processRootCmdFlags(cmd)
if err != nil {
return types.ImageListOptions{}, err
Expand Down Expand Up @@ -118,12 +118,13 @@ func processImagesFlag(cmd *cobra.Command, args []string) (types.ImageListOption
Digests: digests,
Names: names,
All: true,
Stdout: cmd.OutOrStdout(),
}, nil

}

func imagesAction(cmd *cobra.Command, args []string) error {
options, err := processImagesFlag(cmd, args)
options, err := processImageListOptions(cmd, args)
if err != nil {
return err
}
Expand Down
3 changes: 2 additions & 1 deletion pkg/api/types/image_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ package types

import "io"

// ImageListOptions specifies options for `nerdctl image ls`.
// ImageListOptions specifies options for `nerdctl image list`.
type ImageListOptions struct {
Stdout io.Writer
// GOptions is the global options
GOptions GlobalCommandOptions
// Quiet only show numeric IDs
Expand Down
8 changes: 3 additions & 5 deletions pkg/cmd/image/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
"errors"
"fmt"
"io"
"os"
"regexp"
"strings"
"text/tabwriter"
Expand Down Expand Up @@ -95,7 +94,7 @@ func List(ctx context.Context, options types.ImageListOptions) error {

imageList = imgutil.FilterImages(imageList, beforeImages, sinceImages)
}
return printImages(ctx, options, client, imageList)
return printImages(ctx, client, imageList, options)
}

func filterByReference(imageList []images.Image, filters []string) ([]images.Image, error) {
Expand Down Expand Up @@ -181,10 +180,9 @@ type imagePrintable struct {
Platform string // nerdctl extension
}

func printImages(ctx context.Context, options types.ImageListOptions, client *containerd.Client, imageList []images.Image) error {
func printImages(ctx context.Context, client *containerd.Client, imageList []images.Image, options types.ImageListOptions) error {
w := options.Stdout
digestsFlag := options.Digests
var w io.Writer
w = os.Stdout
if options.Format == "wide" {
digestsFlag = true
}
Expand Down