From d0fdf38473991eb7bab9b075bf5784fabe334802 Mon Sep 17 00:00:00 2001 From: Sergey Shubin svs1370 Date: Sat, 2 Oct 2021 10:15:32 +0300 Subject: [PATCH] Add validation function for pool argument of disk resource --- decort/resource_disk.go | 3 +++ decort/resource_rg.go | 3 +++ 2 files changed, 6 insertions(+) diff --git a/decort/resource_disk.go b/decort/resource_disk.go index cac103e..d0225cc 100644 --- a/decort/resource_disk.go +++ b/decort/resource_disk.go @@ -214,6 +214,7 @@ func resourceDiskSchemaMake() map[string]*schema.Schema { Type: schema.TypeInt, Required: true, ForceNew: true, + ValidateFunc: validation.IntAtLeast(1), 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, Required: true, ForceNew: true, + ValidateFunc: validation.StringIsNotEmpty, Description: "Pool where this disk is located. Cannot be changed for existing disk.", }, "size": { Type: schema.TypeInt, Required: true, + ValidateFunc: validation.IntAtLeast(1), Description: "Size of the disk in GB. Note, that existing disks can only be grown in size.", }, diff --git a/decort/resource_rg.go b/decort/resource_rg.go index 8daceaf..c59730d 100644 --- a/decort/resource_rg.go +++ b/decort/resource_rg.go @@ -30,6 +30,7 @@ import ( log "github.com/sirupsen/logrus" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/helper/validation" ) func resourceResgroupCreate(d *schema.ResourceData, m interface{}) error { @@ -294,6 +295,7 @@ func resourceResgroup() *schema.Resource { "account_id": { Type: schema.TypeInt, Required: true, + ValidateFunc: validation.IntAtLeast(1), Description: "Unique ID of the account, which this resource group belongs to.", }, @@ -301,6 +303,7 @@ func resourceResgroup() *schema.Resource { Type: schema.TypeString, Optional: true, 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.", },