Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions cmd/objectstorage/objectstorage.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,15 @@ func NewCmdObjectStorage(base *cli.Base) *cobra.Command { //nolint:gocyclo
return fmt.Errorf("error parsing flag 'label' for object storage create : %v", errLa)
}

tierID, errTi := cmd.Flags().GetInt("tier-id")
if errTi != nil {
return fmt.Errorf("error parsing flag 'tier-id' for object storage create : %v", errTi)
}

o.ObjectStorageReq = &govultr.ObjectStorageReq{
ClusterID: clusterID,
Label: label,
TierID: tierID,
}

os, err := o.create()
Expand All @@ -120,10 +126,21 @@ func NewCmdObjectStorage(base *cli.Base) *cobra.Command { //nolint:gocyclo

create.Flags().StringP("label", "l", "", "label you want your object storage to have")
create.Flags().IntP("cluster-id", "i", 0, "ID of the cluster in which to create the object storage")
create.Flags().IntP(
"tier-id",
"t",
0,
"ID of the tier to create the object storage in. Must be one of the available tiers for the cluster",
)

if err := create.MarkFlagRequired("cluster-id"); err != nil {
printer.Error(fmt.Errorf("error marking object storage create 'cluster-id' flag required : %v", err))
os.Exit(1)
}
if err := create.MarkFlagRequired("tier-id"); err != nil {
printer.Error(fmt.Errorf("error marking object storage create 'tier-id' flag required : %v", err))
os.Exit(1)
}

// Label
label := &cobra.Command{
Expand Down
9 changes: 8 additions & 1 deletion cmd/objectstorage/printer.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package objectstorage

import (
"strconv"
"strings"

"github.com/vultr/govultr/v3"
"github.com/vultr/vultr-cli/v3/cmd/printer"
Expand Down Expand Up @@ -239,17 +240,22 @@ func (o *ObjectStorageTiersPrinter) Columns() [][]string {
"PRICE DISK",
"RATELIMIT OPS",
"RATELIMIT BYTES",
"AVAILABLE REGIONS",
}}
}

// Data ...
func (o *ObjectStorageTiersPrinter) Data() [][]string {
if len(o.Tiers) == 0 {
return [][]string{0: {"---", "---", "---", "---", "---", "---", "---"}}
return [][]string{0: {"---", "---", "---", "---", "---", "---", "---", "---"}}
}

var data [][]string
for i := range o.Tiers {
var regions []string
for _, id := range o.Tiers[i].Locations {
regions = append(regions, id.Region)
}
data = append(data, []string{
strconv.Itoa(o.Tiers[i].ID),
o.Tiers[i].Slug,
Expand All @@ -273,6 +279,7 @@ func (o *ObjectStorageTiersPrinter) Data() [][]string {
),
strconv.Itoa(o.Tiers[i].RateLimitOpsSec),
strconv.Itoa(o.Tiers[i].RateLimitBytesSec),
strings.Join(regions, ", "),
})
}

Expand Down