vsphere/datastore_structure.go
func resourceVSphereDatastoreReadFolderOrStorageClusterPath(d *schema.ResourceData, ds *object.Datastore) error {
	props, err := datastore.Properties(ds)
	if err != nil {
		return fmt.Errorf("error fetching datastore properties while parsing path: %s", err)
	}
	switch props.Parent.Type {
	case "Folder":
		return resourceVSphereDatastoreReadFolderOrStorageClusterPathAsFolder(d, ds)
	case "StoragePod":
		return resourceVSphereDatastoreReadFolderOrStorageClusterPathSetAttributes(d, "", props.Parent.Value)
	}
	return fmt.Errorf("unknown datastore parent type %q while parsing inventory path", props.Parent.Type)
}
func resourceVSphereDatastoreReadFolderOrStorageClusterPath(d *schema.ResourceData, ds *object.Datastore) error {
	props, err := datastore.Properties(ds)
	if err != nil {
		return fmt.Errorf("error fetching datastore properties while parsing path: %s", err)
	}
	switch props.Parent.Type {
	case "Folder":
		return resourceVSphereDatastoreReadFolderOrStorageClusterPathAsFolder(d, ds)
	case "StoragePod":
		return resourceVSphereDatastoreReadFolderOrStorageClusterPathSetAttributes(d, "", props.Parent.Value)
	}
	return fmt.Errorf("unknown datastore parent type %q while parsing inventory path", props.Parent.Type)
}
// resourceVSphereDatastoreReadFolderOrStorageClusterPath checks the inventory
// path of the supplied datastore and checks to see if it is a normal folder or
// if it's a datastore cluster, and saves the attributes accordingly.