Skip to content

Commit c25adef

Browse files
authored
Merge pull request #554 from civo/support-volume-type
support specifying volume-type when creating volumes
2 parents fc13db9 + 7f6263b commit c25adef

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

cmd/volume/volume.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ func init() {
3232

3333
volumeCreateCmd.Flags().IntVarP(&createSizeGB, "size-gb", "s", 0, "The new size in GB (required)")
3434
volumeCreateCmd.Flags().StringVarP(&networkVolumeID, "network", "t", "default", "The network name/ID where the volume will be created")
35+
volumeCreateCmd.Flags().StringVarP(&volumeType, "volume-type", "v", "", "The type of the volume that will be created (as provided by 'civo volumetypes ls')")
3536
volumeCreateCmd.MarkFlagRequired("size-gb")
3637

3738
volumeResizeCmd.Flags().IntVarP(&newSizeGB, "size-gb", "s", 0, "The new size in GB (required)")

cmd/volume/volume_create.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,11 @@ import (
1111
"github.com/spf13/cobra"
1212
)
1313

14-
var createSizeGB int
15-
var networkVolumeID string
14+
var (
15+
createSizeGB int
16+
networkVolumeID string
17+
volumeType string
18+
)
1619

1720
var volumeCreateCmd = &cobra.Command{
1821
Use: "create",
@@ -68,6 +71,10 @@ var volumeCreateCmd = &cobra.Command{
6871
volumeConfig.NetworkID = network.ID
6972
}
7073

74+
if volumeType != "" {
75+
volumeConfig.VolumeType = volumeType
76+
}
77+
7178
volume, err := client.NewVolume(volumeConfig)
7279
if err != nil {
7380
if err == civogo.QuotaLimitReachedError {

0 commit comments

Comments
 (0)