Adding more validation when creating volumes
diff --git a/rackspace/blockstorage/v1/volumes/delegate.go b/rackspace/blockstorage/v1/volumes/delegate.go
index a0b2380..4f14454 100644
--- a/rackspace/blockstorage/v1/volumes/delegate.go
+++ b/rackspace/blockstorage/v1/volumes/delegate.go
@@ -1,11 +1,25 @@
package volumes
import (
+ "fmt"
+
"github.com/rackspace/gophercloud"
os "github.com/rackspace/gophercloud/openstack/blockstorage/v1/volumes"
"github.com/rackspace/gophercloud/pagination"
)
+type CreateOpts struct {
+ os.CreateOpts
+}
+
+func (opts CreateOpts) ToVolumeCreateMap() (map[string]interface{}, error) {
+ if opts.Size < 75 || opts.Size > 1024 {
+ return nil, fmt.Errorf("Size field must be between 75 and 1024")
+ }
+
+ return opts.CreateOpts.ToVolumeCreateMap()
+}
+
// Create will create a new Volume based on the values in CreateOpts. To extract
// the Volume object from the response, call the Extract method on the
// CreateResult.