(desc ocispec.Descriptor, img images.Image, blobSize int64, size int64, plt platforms.Platform)
| 357 | } |
| 358 | |
| 359 | func (x *imagePrinter) printImageSinglePlatform(desc ocispec.Descriptor, img images.Image, blobSize int64, size int64, plt platforms.Platform) error { |
| 360 | var ( |
| 361 | repository string |
| 362 | tag string |
| 363 | ) |
| 364 | // cri plugin will create an image named digest of image's config, skip parsing. |
| 365 | if x.namesFlag || desc.Digest.String() != img.Name { |
| 366 | repository, tag = imgutil.ParseRepoTag(img.Name) |
| 367 | } |
| 368 | |
| 369 | p := imagePrintable{ |
| 370 | CreatedAt: img.CreatedAt.Round(time.Second).Local().String(), // format like "2021-08-07 02:19:45 +0900 JST" |
| 371 | CreatedSince: formatter.TimeSinceInHuman(img.CreatedAt), |
| 372 | Digest: img.Target.Digest.String(), |
| 373 | ID: img.Target.Digest.String(), |
| 374 | Repository: repository, |
| 375 | Tag: tag, |
| 376 | Name: img.Name, |
| 377 | Size: units.HumanSize(float64(size)), |
| 378 | BlobSize: units.HumanSize(float64(blobSize)), |
| 379 | Platform: platforms.FormatAll(plt), |
| 380 | } |
| 381 | if p.Repository == "" { |
| 382 | p.Repository = "<none>" |
| 383 | } |
| 384 | if p.Tag == "" { |
| 385 | p.Tag = "<none>" // for Docker compatibility |
| 386 | } |
| 387 | if !x.noTrunc { |
| 388 | // p.Digest does not need to be truncated |
| 389 | p.ID = strings.Split(p.ID, ":")[1][:12] |
| 390 | } |
| 391 | if x.tmpl != nil { |
| 392 | var b bytes.Buffer |
| 393 | if err := x.tmpl.Execute(&b, p); err != nil { |
| 394 | return err |
| 395 | } |
| 396 | if _, err := fmt.Fprintln(x.w, b.String()); err != nil { |
| 397 | return err |
| 398 | } |
| 399 | } else if x.quiet { |
| 400 | if _, err := fmt.Fprintln(x.w, p.ID); err != nil { |
| 401 | return err |
| 402 | } |
| 403 | } else { |
| 404 | format := "" |
| 405 | args := []interface{}{} |
| 406 | if x.namesFlag { |
| 407 | format += "%s\t" |
| 408 | args = append(args, p.Name) |
| 409 | } else { |
| 410 | format += "%s\t%s\t" |
| 411 | args = append(args, p.Repository, p.Tag) |
| 412 | } |
| 413 | if x.digestsFlag { |
| 414 | format += "%s\t" |
| 415 | args = append(args, p.Digest) |
| 416 | } |
no test coverage detected