vsphere/internal/helper/folder/folder_helper.go
func FindType(folder *object.Folder) (VSphereFolderType, error) {
	var ft VSphereFolderType

	props, err := Properties(folder)
	if err != nil {
		return ft, err
	}

	// Depending on the container type, the actual folder type may be contained
	// in either the first or second element, the former for clusters, datastore
	// clusters, or standalone ESXi for VMs, and the latter in the case of actual
	// folders that can contain subfolders.
	var ct string
	if props.ChildType[0] != "Folder" {
		ct = props.ChildType[0]
	} else {
		ct = props.ChildType[1]
	}

	switch ct {
	case "Datacenter":
		ft = VSphereFolderTypeDatacenter
	case "ComputeResource":
		ft = VSphereFolderTypeHost
	case "VirtualMachine":
		ft = VSphereFolderTypeVM
	case "Datastore":
		ft = VSphereFolderTypeDatastore
	case "Network":
		ft = VSphereFolderTypeNetwork
	default:
		return ft, fmt.Errorf("unknown folder type: %#v", ct)
	}

	return ft, nil
}
func FindType(folder *object.Folder) (VSphereFolderType, error) {
	var ft VSphereFolderType

	props, err := Properties(folder)
	if err != nil {
		return ft, err
	}

	// Depending on the container type, the actual folder type may be contained
	// in either the first or second element, the former for clusters, datastore
	// clusters, or standalone ESXi for VMs, and the latter in the case of actual
	// folders that can contain subfolders.
	var ct string
	if props.ChildType[0] != "Folder" {
		ct = props.ChildType[0]
	} else {
		ct = props.ChildType[1]
	}

	switch ct {
	case "Datacenter":
		ft = VSphereFolderTypeDatacenter
	case "ComputeResource":
		ft = VSphereFolderTypeHost
	case "VirtualMachine":
		ft = VSphereFolderTypeVM
	case "Datastore":
		ft = VSphereFolderTypeDatastore
	case "Network":
		ft = VSphereFolderTypeNetwork
	default:
		return ft, fmt.Errorf("unknown folder type: %#v", ct)
	}

	return ft, nil
}
// FindType returns a proper VSphereFolderType for a folder object by checking its child type.