Add validation function for pool argument of disk resource
This commit is contained in:
@@ -214,6 +214,7 @@ func resourceDiskSchemaMake() map[string]*schema.Schema {
|
|||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Required: true,
|
Required: true,
|
||||||
ForceNew: true,
|
ForceNew: true,
|
||||||
|
ValidateFunc: validation.IntAtLeast(1),
|
||||||
Description: "Storage end-point provider serving this disk. Cannot be changed for existing disk.",
|
Description: "Storage end-point provider serving this disk. Cannot be changed for existing disk.",
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -221,12 +222,14 @@ func resourceDiskSchemaMake() map[string]*schema.Schema {
|
|||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Required: true,
|
Required: true,
|
||||||
ForceNew: true,
|
ForceNew: true,
|
||||||
|
ValidateFunc: validation.StringIsNotEmpty,
|
||||||
Description: "Pool where this disk is located. Cannot be changed for existing disk.",
|
Description: "Pool where this disk is located. Cannot be changed for existing disk.",
|
||||||
},
|
},
|
||||||
|
|
||||||
"size": {
|
"size": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Required: true,
|
Required: true,
|
||||||
|
ValidateFunc: validation.IntAtLeast(1),
|
||||||
Description: "Size of the disk in GB. Note, that existing disks can only be grown in size.",
|
Description: "Size of the disk in GB. Note, that existing disks can only be grown in size.",
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ import (
|
|||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
|
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
|
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
|
||||||
|
"github.com/hashicorp/terraform-plugin-sdk/helper/validation"
|
||||||
)
|
)
|
||||||
|
|
||||||
func resourceResgroupCreate(d *schema.ResourceData, m interface{}) error {
|
func resourceResgroupCreate(d *schema.ResourceData, m interface{}) error {
|
||||||
@@ -294,6 +295,7 @@ func resourceResgroup() *schema.Resource {
|
|||||||
"account_id": {
|
"account_id": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Required: true,
|
Required: true,
|
||||||
|
ValidateFunc: validation.IntAtLeast(1),
|
||||||
Description: "Unique ID of the account, which this resource group belongs to.",
|
Description: "Unique ID of the account, which this resource group belongs to.",
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -301,6 +303,7 @@ func resourceResgroup() *schema.Resource {
|
|||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
Default: "PRIVATE",
|
Default: "PRIVATE",
|
||||||
|
// ValidateFunc: validation.StringInSlice([]string{"PRIVATE", "PUBLIC", "NONE"}, false),
|
||||||
Description: "Type of the network, which this resource group will use as default for its computes - PRIVATE or PUBLIC or NONE.",
|
Description: "Type of the network, which this resource group will use as default for its computes - PRIVATE or PUBLIC or NONE.",
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user