Move types.Volumes optional fields under a new type

This allows us to hide those fields when they are not filled.

Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
This commit is contained in:
Kenfe-Mickael Laventure 2016-10-11 11:49:26 -07:00
parent 80bc917226
commit 5018781cab
2 changed files with 11 additions and 11 deletions

View File

@ -288,7 +288,7 @@ func (c *diskUsageVolumesContext) Active() string {
used := 0 used := 0
for _, v := range c.volumes { for _, v := range c.volumes {
if v.RefCount > 0 { if v.UsageData.RefCount > 0 {
used++ used++
} }
} }
@ -301,8 +301,8 @@ func (c *diskUsageVolumesContext) Size() string {
c.AddHeader(sizeHeader) c.AddHeader(sizeHeader)
for _, v := range c.volumes { for _, v := range c.volumes {
if v.Size != -1 { if v.UsageData.Size != -1 {
size += v.Size size += v.UsageData.Size
} }
} }
@ -315,11 +315,11 @@ func (c *diskUsageVolumesContext) Reclaimable() string {
c.AddHeader(reclaimableHeader) c.AddHeader(reclaimableHeader)
for _, v := range c.volumes { for _, v := range c.volumes {
if v.Size != -1 { if v.UsageData.Size != -1 {
if v.RefCount == 0 { if v.UsageData.RefCount == 0 {
reclaimable += v.Size reclaimable += v.UsageData.Size
} }
totalSize += v.Size totalSize += v.UsageData.Size
} }
} }

View File

@ -101,16 +101,16 @@ func (c *volumeContext) Label(name string) string {
func (c *volumeContext) Links() string { func (c *volumeContext) Links() string {
c.AddHeader(linksHeader) c.AddHeader(linksHeader)
if c.v.Size == -1 { if c.v.UsageData == nil {
return "N/A" return "N/A"
} }
return fmt.Sprintf("%d", c.v.RefCount) return fmt.Sprintf("%d", c.v.UsageData.RefCount)
} }
func (c *volumeContext) Size() string { func (c *volumeContext) Size() string {
c.AddHeader(sizeHeader) c.AddHeader(sizeHeader)
if c.v.Size == -1 { if c.v.UsageData == nil {
return "N/A" return "N/A"
} }
return units.HumanSize(float64(c.v.Size)) return units.HumanSize(float64(c.v.UsageData.Size))
} }