vsphere/resource_vsphere_datastore_cluster.go
func resourceVSphereDatastoreClusterApplyNameChange(
	d *schema.ResourceData,
	meta interface{},
	pod *object.StoragePod,
) (*object.StoragePod, error) {
	log.Printf(
		"[DEBUG] %s: Applying any name changes (old path = %q)",
		resourceVSphereDatastoreClusterIDString(d),
		pod.InventoryPath,
	)

	var changed bool
	var err error

	if d.HasChange("name") {
		if err = storagepod.Rename(pod, d.Get("name").(string)); err != nil {
			return nil, fmt.Errorf("error renaming datastore cluster: %s", err)
		}
		changed = true
	}

	if changed {
		// Update the pod so that we have the new inventory path for logging and
		// other things
		pod, err = resourceVSphereDatastoreClusterGetPod(d, meta)
		if err != nil {
			return nil, fmt.Errorf("error refreshing datastore cluster after name change: %s", err)
		}
		log.Printf(
			"[DEBUG] %s: Name changed, new path = %q",
			resourceVSphereDatastoreClusterIDString(d),
			pod.InventoryPath,
		)
	}

	return pod, nil
}
func resourceVSphereDatastoreClusterApplyNameChange(
	d *schema.ResourceData,
	meta interface{},
	pod *object.StoragePod,
) (*object.StoragePod, error) {
	log.Printf(
		"[DEBUG] %s: Applying any name changes (old path = %q)",
		resourceVSphereDatastoreClusterIDString(d),
		pod.InventoryPath,
	)

	var changed bool
	var err error

	if d.HasChange("name") {
		if err = storagepod.Rename(pod, d.Get("name").(string)); err != nil {
			return nil, fmt.Errorf("error renaming datastore cluster: %s", err)
		}
		changed = true
	}

	if changed {
		// Update the pod so that we have the new inventory path for logging and
		// other things
		pod, err = resourceVSphereDatastoreClusterGetPod(d, meta)
		if err != nil {
			return nil, fmt.Errorf("error refreshing datastore cluster after name change: %s", err)
		}
		log.Printf(
			"[DEBUG] %s: Name changed, new path = %q",
			resourceVSphereDatastoreClusterIDString(d),
			pod.InventoryPath,
		)
	}

	return pod, nil
}
// resourceVSphereDatastoreClusterApplyNameChange applies any changes to a
// StoragePod's name.