From e6f7549ac69533d2e1edd62b2e1fcb6bcb0c58b0 Mon Sep 17 00:00:00 2001 From: Bill Rich Date: Tue, 14 Jan 2020 19:49:18 -0800 Subject: [PATCH] b/virtual_disk: enforce vmdk suffix vmdk_path must end with a '.vmdk' suffix or the created disks will not work properly or be able to be found with the Read function. Adding a validate function to provide a better user experience when the suffix is left off. --- vsphere/resource_vsphere_virtual_disk.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/vsphere/resource_vsphere_virtual_disk.go b/vsphere/resource_vsphere_virtual_disk.go index 7463b3c8e..a6fd4c5d3 100644 --- a/vsphere/resource_vsphere_virtual_disk.go +++ b/vsphere/resource_vsphere_virtual_disk.go @@ -51,6 +51,12 @@ func resourceVSphereVirtualDisk() *schema.Resource { Type: schema.TypeString, Required: true, ForceNew: true, + ValidateFunc: func(v interface{}, k string) (warns []string, errors []error) { + if !strings.HasSuffix(v.(string), ".vmdk") { + errors = append(errors, fmt.Errorf("vmdk_path must end with '.vmdk'")) + } + return + }, }, "datastore": {