()
| 157 | } |
| 158 | |
| 159 | func (ctx *DiskUsageContext) verboseWrite() error { |
| 160 | duc := &diskUsageContext{ |
| 161 | Images: make([]*imageContext, 0, len(ctx.ImageDiskUsage.Items)), |
| 162 | Containers: make([]*ContainerContext, 0, len(ctx.ContainerDiskUsage.Items)), |
| 163 | Volumes: make([]*volumeContext, 0, len(ctx.VolumeDiskUsage.Items)), |
| 164 | BuildCache: make([]*buildCacheContext, 0, len(ctx.BuildCacheDiskUsage.Items)), |
| 165 | } |
| 166 | trunc := ctx.Format.IsTable() |
| 167 | |
| 168 | // First images |
| 169 | for _, i := range ctx.ImageDiskUsage.Items { |
| 170 | repo := "<none>" |
| 171 | tag := "<none>" |
| 172 | if len(i.RepoTags) > 0 && !isDangling(i) { |
| 173 | // Only show the first tag |
| 174 | ref, err := reference.ParseNormalizedNamed(i.RepoTags[0]) |
| 175 | if err != nil { |
| 176 | continue |
| 177 | } |
| 178 | if nt, ok := ref.(reference.NamedTagged); ok { |
| 179 | repo = reference.FamiliarName(ref) |
| 180 | tag = nt.Tag() |
| 181 | } |
| 182 | } |
| 183 | |
| 184 | duc.Images = append(duc.Images, &imageContext{ |
| 185 | repo: repo, |
| 186 | tag: tag, |
| 187 | trunc: trunc, |
| 188 | i: i, |
| 189 | }) |
| 190 | } |
| 191 | |
| 192 | // Now containers |
| 193 | for _, c := range ctx.ContainerDiskUsage.Items { |
| 194 | // Don't display the virtual size |
| 195 | c.SizeRootFs = 0 |
| 196 | duc.Containers = append(duc.Containers, &ContainerContext{trunc: trunc, c: c}) |
| 197 | } |
| 198 | |
| 199 | // And volumes |
| 200 | for _, v := range ctx.VolumeDiskUsage.Items { |
| 201 | duc.Volumes = append(duc.Volumes, &volumeContext{v: v}) |
| 202 | } |
| 203 | |
| 204 | // And build cache |
| 205 | buildCacheSort(ctx.BuildCacheDiskUsage.Items) |
| 206 | for _, v := range ctx.BuildCacheDiskUsage.Items { |
| 207 | duc.BuildCache = append(duc.BuildCache, &buildCacheContext{v: v, trunc: trunc}) |
| 208 | } |
| 209 | |
| 210 | if ctx.Format == TableFormatKey { |
| 211 | return ctx.verboseWriteTable(duc) |
| 212 | } |
| 213 | |
| 214 | tmpl, err := ctx.parseFormat() |
| 215 | if err != nil { |
| 216 | return err |
no test coverage detected