@@ -202,10 +202,16 @@ var checkCommand = cli.Command{
202202 Usage : "check existing images to ensure all content is available locally" ,
203203 ArgsUsage : "[flags] [<filter>, ...]" ,
204204 Description : "check existing images to ensure all content is available locally" ,
205- Flags : commands .SnapshotterFlags ,
205+ Flags : append ([]cli.Flag {
206+ cli.BoolFlag {
207+ Name : "quiet, q" ,
208+ Usage : "print only the ready image refs (fully downloaded and unpacked)" ,
209+ },
210+ }, commands .SnapshotterFlags ... ),
206211 Action : func (context * cli.Context ) error {
207212 var (
208213 exitErr error
214+ quiet = context .Bool ("quiet" )
209215 )
210216 client , ctx , cancel , err := commands .NewClient (context )
211217 if err != nil {
@@ -226,14 +232,17 @@ var checkCommand = cli.Command{
226232 }
227233
228234 var tw = tabwriter .NewWriter (os .Stdout , 1 , 8 , 1 , ' ' , 0 )
229- fmt .Fprintln (tw , "REF\t TYPE\t DIGEST\t STATUS\t SIZE\t UNPACKED\t " )
235+ if ! quiet {
236+ fmt .Fprintln (tw , "REF\t TYPE\t DIGEST\t STATUS\t SIZE\t UNPACKED\t " )
237+ }
230238
231239 for _ , image := range imageList {
232240 var (
233241 status string = "complete"
234242 size string
235243 requiredSize int64
236244 presentSize int64
245+ complete bool = true
237246 )
238247
239248 available , required , present , missing , err := images .Check (ctx , contentStore , image .Target (), platforms .Default ())
@@ -243,6 +252,7 @@ var checkCommand = cli.Command{
243252 }
244253 log .G (ctx ).WithError (err ).Errorf ("unable to check %v" , image .Name ())
245254 status = "error"
255+ complete = false
246256 }
247257
248258 if status != "error" {
@@ -256,6 +266,7 @@ var checkCommand = cli.Command{
256266
257267 if len (missing ) > 0 {
258268 status = "incomplete"
269+ complete = false
259270 }
260271
261272 if available {
@@ -264,6 +275,7 @@ var checkCommand = cli.Command{
264275 } else {
265276 status = fmt .Sprintf ("unavailable (%v/?)" , len (present ))
266277 size = fmt .Sprintf ("%v/?" , progress .Bytes (presentSize ))
278+ complete = false
267279 }
268280 } else {
269281 size = "-"
@@ -277,16 +289,23 @@ var checkCommand = cli.Command{
277289 log .G (ctx ).WithError (err ).Errorf ("unable to check unpack for %v" , image .Name ())
278290 }
279291
280- fmt .Fprintf (tw , "%v\t %v\t %v\t %v\t %v\t %t\n " ,
281- image .Name (),
282- image .Target ().MediaType ,
283- image .Target ().Digest ,
284- status ,
285- size ,
286- unpacked )
292+ if ! quiet {
293+ fmt .Fprintf (tw , "%v\t %v\t %v\t %v\t %v\t %t\n " ,
294+ image .Name (),
295+ image .Target ().MediaType ,
296+ image .Target ().Digest ,
297+ status ,
298+ size ,
299+ unpacked )
300+ } else {
301+ if complete {
302+ fmt .Println (image .Name ())
303+ }
304+ }
305+ }
306+ if ! quiet {
307+ tw .Flush ()
287308 }
288- tw .Flush ()
289-
290309 return exitErr
291310 },
292311}
0 commit comments