NewDiskUsageFormat returns a format for rendering an DiskUsageContext
(source string, verbose bool)
| 52 | |
| 53 | // NewDiskUsageFormat returns a format for rendering an DiskUsageContext |
| 54 | func NewDiskUsageFormat(source string, verbose bool) Format { |
| 55 | switch { |
| 56 | case verbose && source == RawFormatKey: |
| 57 | format := `{{range .Images}}type: Image |
| 58 | ` + NewImageFormat(source, false, true) + ` |
| 59 | {{end -}} |
| 60 | {{range .Containers}}type: Container |
| 61 | ` + NewContainerFormat(source, false, true) + ` |
| 62 | {{end -}} |
| 63 | {{range .Volumes}}type: Volume |
| 64 | ` + NewVolumeFormat(source, false) + ` |
| 65 | {{end -}} |
| 66 | {{range .BuildCache}}type: Build Cache |
| 67 | ` + NewBuildCacheFormat(source, false) + ` |
| 68 | {{end -}}` |
| 69 | return format |
| 70 | case !verbose && source == TableFormatKey: |
| 71 | return defaultDiskUsageTableFormat |
| 72 | case !verbose && source == RawFormatKey: |
| 73 | format := `type: {{.Type}} |
| 74 | total: {{.TotalCount}} |
| 75 | active: {{.Active}} |
| 76 | size: {{.Size}} |
| 77 | reclaimable: {{.Reclaimable}} |
| 78 | ` |
| 79 | return Format(format) |
| 80 | default: |
| 81 | return Format(source) |
| 82 | } |
| 83 | } |
| 84 | |
| 85 | func (ctx *DiskUsageContext) Write() (err error) { |
| 86 | if ctx.Verbose { |
searching dependent graphs…