-
Notifications
You must be signed in to change notification settings - Fork 162
/
blobs.go
52 lines (40 loc) · 1019 Bytes
/
blobs.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package cmd
import (
boshreldir "github.com/cloudfoundry/bosh-cli/releasedir"
boshui "github.com/cloudfoundry/bosh-cli/ui"
boshtbl "github.com/cloudfoundry/bosh-cli/ui/table"
)
type BlobsCmd struct {
blobsDir boshreldir.BlobsDir
ui boshui.UI
}
func NewBlobsCmd(blobsDir boshreldir.BlobsDir, ui boshui.UI) BlobsCmd {
return BlobsCmd{blobsDir: blobsDir, ui: ui}
}
func (c BlobsCmd) Run() error {
blobs, err := c.blobsDir.Blobs()
if err != nil {
return err
}
table := boshtbl.Table{
Content: "blobs",
Header: []string{"Path", "Size", "Blobstore ID", "SHA1"},
SortBy: []boshtbl.ColumnSort{
{Column: 0, Asc: true},
},
}
for _, blob := range blobs {
blobID := blob.BlobstoreID
if len(blobID) == 0 {
blobID = "(local)"
}
table.Rows = append(table.Rows, []boshtbl.Value{
boshtbl.NewValueString(blob.Path),
boshtbl.NewValueBytes(uint64(blob.Size)),
boshtbl.NewValueString(blobID),
boshtbl.NewValueString(blob.SHA1),
})
}
c.ui.PrintTable(table)
return nil
}