adds quiet option for ref
Signed-off-by: Mike Brown <brownwm@us.ibm.com>
This commit is contained in:
parent
00f8d32ef5
commit
391b123a5e
@ -202,10 +202,16 @@ var checkCommand = cli.Command{
|
|||||||
Usage: "check existing images to ensure all content is available locally",
|
Usage: "check existing images to ensure all content is available locally",
|
||||||
ArgsUsage: "[flags] [<filter>, ...]",
|
ArgsUsage: "[flags] [<filter>, ...]",
|
||||||
Description: "check existing images to ensure all content is available locally",
|
Description: "check existing images to ensure all content is available locally",
|
||||||
Flags: commands.SnapshotterFlags,
|
Flags: append([]cli.Flag{
|
||||||
|
cli.BoolFlag{
|
||||||
|
Name: "quiet, q",
|
||||||
|
Usage: "print only the ready image refs (fully downloaded and unpacked)",
|
||||||
|
},
|
||||||
|
}, commands.SnapshotterFlags...),
|
||||||
Action: func(context *cli.Context) error {
|
Action: func(context *cli.Context) error {
|
||||||
var (
|
var (
|
||||||
exitErr error
|
exitErr error
|
||||||
|
quiet = context.Bool("quiet")
|
||||||
)
|
)
|
||||||
client, ctx, cancel, err := commands.NewClient(context)
|
client, ctx, cancel, err := commands.NewClient(context)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -226,7 +232,9 @@ var checkCommand = cli.Command{
|
|||||||
}
|
}
|
||||||
|
|
||||||
var tw = tabwriter.NewWriter(os.Stdout, 1, 8, 1, ' ', 0)
|
var tw = tabwriter.NewWriter(os.Stdout, 1, 8, 1, ' ', 0)
|
||||||
fmt.Fprintln(tw, "REF\tTYPE\tDIGEST\tSTATUS\tSIZE\tUNPACKED\t")
|
if !quiet {
|
||||||
|
fmt.Fprintln(tw, "REF\tTYPE\tDIGEST\tSTATUS\tSIZE\tUNPACKED\t")
|
||||||
|
}
|
||||||
|
|
||||||
for _, image := range imageList {
|
for _, image := range imageList {
|
||||||
var (
|
var (
|
||||||
@ -234,6 +242,7 @@ var checkCommand = cli.Command{
|
|||||||
size string
|
size string
|
||||||
requiredSize int64
|
requiredSize int64
|
||||||
presentSize int64
|
presentSize int64
|
||||||
|
complete bool = true
|
||||||
)
|
)
|
||||||
|
|
||||||
available, required, present, missing, err := images.Check(ctx, contentStore, image.Target(), platforms.Default())
|
available, required, present, missing, err := images.Check(ctx, contentStore, image.Target(), platforms.Default())
|
||||||
@ -243,6 +252,7 @@ var checkCommand = cli.Command{
|
|||||||
}
|
}
|
||||||
log.G(ctx).WithError(err).Errorf("unable to check %v", image.Name())
|
log.G(ctx).WithError(err).Errorf("unable to check %v", image.Name())
|
||||||
status = "error"
|
status = "error"
|
||||||
|
complete = false
|
||||||
}
|
}
|
||||||
|
|
||||||
if status != "error" {
|
if status != "error" {
|
||||||
@ -256,6 +266,7 @@ var checkCommand = cli.Command{
|
|||||||
|
|
||||||
if len(missing) > 0 {
|
if len(missing) > 0 {
|
||||||
status = "incomplete"
|
status = "incomplete"
|
||||||
|
complete = false
|
||||||
}
|
}
|
||||||
|
|
||||||
if available {
|
if available {
|
||||||
@ -264,6 +275,7 @@ var checkCommand = cli.Command{
|
|||||||
} else {
|
} else {
|
||||||
status = fmt.Sprintf("unavailable (%v/?)", len(present))
|
status = fmt.Sprintf("unavailable (%v/?)", len(present))
|
||||||
size = fmt.Sprintf("%v/?", progress.Bytes(presentSize))
|
size = fmt.Sprintf("%v/?", progress.Bytes(presentSize))
|
||||||
|
complete = false
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
size = "-"
|
size = "-"
|
||||||
@ -277,16 +289,23 @@ var checkCommand = cli.Command{
|
|||||||
log.G(ctx).WithError(err).Errorf("unable to check unpack for %v", image.Name())
|
log.G(ctx).WithError(err).Errorf("unable to check unpack for %v", image.Name())
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Fprintf(tw, "%v\t%v\t%v\t%v\t%v\t%t\n",
|
if !quiet {
|
||||||
image.Name(),
|
fmt.Fprintf(tw, "%v\t%v\t%v\t%v\t%v\t%t\n",
|
||||||
image.Target().MediaType,
|
image.Name(),
|
||||||
image.Target().Digest,
|
image.Target().MediaType,
|
||||||
status,
|
image.Target().Digest,
|
||||||
size,
|
status,
|
||||||
unpacked)
|
size,
|
||||||
|
unpacked)
|
||||||
|
} else {
|
||||||
|
if complete {
|
||||||
|
fmt.Println(image.Name())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if !quiet {
|
||||||
|
tw.Flush()
|
||||||
}
|
}
|
||||||
tw.Flush()
|
|
||||||
|
|
||||||
return exitErr
|
return exitErr
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user