-
Notifications
You must be signed in to change notification settings - Fork 224
/
volumes.go
57 lines (42 loc) · 1.18 KB
/
volumes.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
53
54
55
56
57
package volumes
import (
"bytes"
"fmt"
"io"
"time"
"github.com/spf13/cobra"
"github.com/superfly/flyctl/api"
"github.com/superfly/flyctl/internal/command"
"github.com/superfly/flyctl/internal/command/volumes/snapshots"
)
func New() *cobra.Command {
const (
long = "Commands for managing Fly Volumes associated with an application"
short = "Volume management commands"
usage = "volumes <command>"
)
cmd := command.New(usage, short, long, nil)
cmd.Aliases = []string{"vol"}
cmd.AddCommand(
newCreate(),
newList(),
newDelete(),
newExtend(),
newShow(),
snapshots.New(),
)
return cmd
}
func printVolume(w io.Writer, vol *api.Volume) error {
var buf bytes.Buffer
fmt.Fprintf(&buf, "%10s: %s\n", "ID", vol.ID)
fmt.Fprintf(&buf, "%10s: %s\n", "Name", vol.Name)
fmt.Fprintf(&buf, "%10s: %s\n", "App", vol.App.Name)
fmt.Fprintf(&buf, "%10s: %s\n", "Region", vol.Region)
fmt.Fprintf(&buf, "%10s: %s\n", "Zone", vol.Host.ID)
fmt.Fprintf(&buf, "%10s: %d\n", "Size GB", vol.SizeGb)
fmt.Fprintf(&buf, "%10s: %t\n", "Encrypted", vol.Encrypted)
fmt.Fprintf(&buf, "%10s: %s\n", "Created at", vol.CreatedAt.Format(time.RFC822))
_, err := buf.WriteTo(w)
return err
}