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
for _, v := range c.volumes {
if v.RefCount > 0 {
if v.UsageData.RefCount > 0 {
used++
}
}
@ -301,8 +301,8 @@ func (c *diskUsageVolumesContext) Size() string {
c.AddHeader(sizeHeader)
for _, v := range c.volumes {
if v.Size != -1 {
size += v.Size
if v.UsageData.Size != -1 {
size += v.UsageData.Size
}
}
@ -315,11 +315,11 @@ func (c *diskUsageVolumesContext) Reclaimable() string {
c.AddHeader(reclaimableHeader)
for _, v := range c.volumes {
if v.Size != -1 {
if v.RefCount == 0 {
reclaimable += v.Size
if v.UsageData.Size != -1 {
if v.UsageData.RefCount == 0 {
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 {
c.AddHeader(linksHeader)
if c.v.Size == -1 {
if c.v.UsageData == nil {
return "N/A"
}
return fmt.Sprintf("%d", c.v.RefCount)
return fmt.Sprintf("%d", c.v.UsageData.RefCount)
}
func (c *volumeContext) Size() string {
c.AddHeader(sizeHeader)
if c.v.Size == -1 {
if c.v.UsageData == nil {
return "N/A"
}
return units.HumanSize(float64(c.v.Size))
return units.HumanSize(float64(c.v.UsageData.Size))
}