(args []string)
| 48 | } |
| 49 | |
| 50 | func (cmd *listCommand) Run(args []string) (err error) { |
| 51 | reexec() |
| 52 | |
| 53 | // Create the context. |
| 54 | id := identity.NewID() |
| 55 | ctx := session.NewContext(context.Background(), id) |
| 56 | ctx = namespaces.WithNamespace(ctx, "buildkit") |
| 57 | |
| 58 | // Create the client. |
| 59 | c, err := client.New(stateDir, backend, nil) |
| 60 | if err != nil { |
| 61 | return err |
| 62 | } |
| 63 | defer c.Close() |
| 64 | |
| 65 | images, err := c.ListImages(ctx, cmd.filters.GetAll()...) |
| 66 | if err != nil { |
| 67 | return err |
| 68 | } |
| 69 | |
| 70 | tw := tabwriter.NewWriter(os.Stdout, 1, 8, 1, '\t', 0) |
| 71 | |
| 72 | fmt.Fprintln(tw, "NAME\tSIZE\tCREATED AT\tUPDATED AT\tDIGEST") |
| 73 | |
| 74 | for _, image := range images { |
| 75 | fmt.Fprintf(tw, "%s\t%s\t%s\t%s\t%s\n", |
| 76 | image.Name, |
| 77 | units.BytesSize(float64(image.ContentSize)), |
| 78 | units.HumanDuration(time.Now().UTC().Sub(image.CreatedAt))+" ago", |
| 79 | units.HumanDuration(time.Now().UTC().Sub(image.UpdatedAt))+" ago", |
| 80 | image.Target.Digest, |
| 81 | ) |
| 82 | } |
| 83 | |
| 84 | tw.Flush() |
| 85 | |
| 86 | return nil |
| 87 | } |
no test coverage detected