func folderFromObject(client *govmomi.Client, obj interface{}, folderType RootPathParticle, relative string) (*object.Folder, error) {
	// If we are using this for anything else other than the root folder on ESXi,
	// return an error.
	if err := viapi.ValidateVirtualCenter(client); err != nil && relative != "" {
		return nil, errors.New("folders are only supported vCenter only")
	}
	var p string
	var err error
	switch o := obj.(type) {
	case *object.VmwareDistributedVirtualSwitch:
		p, err = RootPathParticleNetwork.PathFromNewRoot(o.InventoryPath, folderType, relative)
	case *object.Datastore:
		p, err = RootPathParticleDatastore.PathFromNewRoot(o.InventoryPath, folderType, relative)
	case *object.StoragePod:
		p, err = RootPathParticleDatastore.PathFromNewRoot(o.InventoryPath, folderType, relative)
	case *object.HostSystem:
		p, err = RootPathParticleHost.PathFromNewRoot(o.InventoryPath, folderType, relative)
	case *object.ResourcePool:
		p, err = RootPathParticleHost.PathFromNewRoot(o.InventoryPath, folderType, relative)
	case *object.ComputeResource:
		p, err = RootPathParticleHost.PathFromNewRoot(o.InventoryPath, folderType, relative)
	case *object.ClusterComputeResource:
		p, err = RootPathParticleHost.PathFromNewRoot(o.InventoryPath, folderType, relative)
	case *object.VirtualMachine:
		p, err = RootPathParticleVM.PathFromNewRoot(o.InventoryPath, folderType, relative)
	default:
		return nil, fmt.Errorf("unsupported object type %T", o)
	}
	if err != nil {
		return nil, err
	}
	return FromAbsolutePath(client, p)
}
func folderFromObject(client *govmomi.Client, obj interface{}, folderType RootPathParticle, relative string) (*object.Folder, error) {
	
	
	if err := viapi.ValidateVirtualCenter(client); err != nil && relative != "" {
		return nil, errors.New("folders are only supported vCenter only")
	}
	var p string
	var err error
	switch o := obj.(type) {
	case *object.VmwareDistributedVirtualSwitch:
		p, err = RootPathParticleNetwork.PathFromNewRoot(o.InventoryPath, folderType, relative)
	case *object.Datastore:
		p, err = RootPathParticleDatastore.PathFromNewRoot(o.InventoryPath, folderType, relative)
	case *object.StoragePod:
		p, err = RootPathParticleDatastore.PathFromNewRoot(o.InventoryPath, folderType, relative)
	case *object.HostSystem:
		p, err = RootPathParticleHost.PathFromNewRoot(o.InventoryPath, folderType, relative)
	case *object.ResourcePool:
		p, err = RootPathParticleHost.PathFromNewRoot(o.InventoryPath, folderType, relative)
	case *object.ComputeResource:
		p, err = RootPathParticleHost.PathFromNewRoot(o.InventoryPath, folderType, relative)
	case *object.ClusterComputeResource:
		p, err = RootPathParticleHost.PathFromNewRoot(o.InventoryPath, folderType, relative)
	case *object.VirtualMachine:
		p, err = RootPathParticleVM.PathFromNewRoot(o.InventoryPath, folderType, relative)
	default:
		return nil, fmt.Errorf("unsupported object type %T", o)
	}
	if err != nil {
		return nil, err
	}
	return FromAbsolutePath(client, p)
}
func folderFromObject ( client * govmomi . Client , obj interface { } , folderType RootPathParticle , relative string ) ( * object . Folder , error ) { // If we are using this for anything else other than the root folder on ESXi, // return an error. if err := viapi . ValidateVirtualCenter ( client ) ; err != nil && relative != " " { return nil , errors . New ( " " ) } var p string var err error switch o := obj . ( type ) { case * object . VmwareDistributedVirtualSwitch : p , err = RootPathParticleNetwork . PathFromNewRoot ( o . InventoryPath , folderType , relative ) case * object . Datastore : p , err = RootPathParticleDatastore . PathFromNewRoot ( o . InventoryPath , folderType , relative ) case * object . StoragePod : p , err = RootPathParticleDatastore . PathFromNewRoot ( o . InventoryPath , folderType , relative ) case * object . HostSystem : p , err = RootPathParticleHost . PathFromNewRoot ( o . InventoryPath , folderType , relative ) case * object . ResourcePool : p , err = RootPathParticleHost . PathFromNewRoot ( o . InventoryPath , folderType , relative ) case * object . ComputeResource : p , err = RootPathParticleHost . PathFromNewRoot ( o . InventoryPath , folderType , relative ) case * object . ClusterComputeResource : p , err = RootPathParticleHost . PathFromNewRoot ( o . InventoryPath , folderType , relative ) case * object . VirtualMachine : p , err = RootPathParticleVM . PathFromNewRoot ( o . InventoryPath , folderType , relative ) default : return nil , fmt . Errorf ( " " , o ) } if err != nil { return nil , err } return FromAbsolutePath ( client , p ) }
// folderFromObject returns an *object.Folder from a given object of specific
// types, and relative path of a type defined in folderType. If no such folder
// is found, an appropriate error will be returned.
//
// The list of supported object types will grow as the provider supports more
// resources.
folderFromObject returns an * object . Folder from a given object of specific types and relative path of a type defined in folderType . If no such folder is found an appropriate error will be returned . The list of supported object types will grow as the provider supports more resources .