vsphere/tags_helper.go
func tagTypeForObject(obj object.Reference) (string, error) {
	switch obj.(type) {
	case *object.VirtualMachine:
		return vSphereTagTypeVirtualMachine, nil
	case *object.Datastore:
		return vSphereTagTypeDatastore, nil
	case *object.Network:
		return vSphereTagTypeNetwork, nil
	case *object.Folder:
		return vSphereTagTypeFolder, nil
	case *object.VmwareDistributedVirtualSwitch:
		return vSphereTagTypeVmwareDistributedVirtualSwitch, nil
	case *object.DistributedVirtualSwitch:
		return vSphereTagTypeDistributedVirtualSwitch, nil
	case *object.DistributedVirtualPortgroup:
		return vSphereTagTypeDistributedVirtualPortgroup, nil
	case *object.Datacenter:
		return vSphereTagTypeDatacenter, nil
	case *object.ClusterComputeResource:
		return vSphereTagTypeClusterComputeResource, nil
	case *object.HostSystem:
		return vSphereTagTypeHostSystem, nil
	case *object.StoragePod:
		return vSphereTagTypeStoragePod, nil
	case *object.ResourcePool:
		return vSphereTagTypeResourcePool, nil
	case *object.VirtualApp:
		return vSphereTagTypeVirtualApp, nil
	}
	return "", fmt.Errorf("unsupported type for tagging: %T", obj)
}
func tagTypeForObject(obj object.Reference) (string, error) {
	switch obj.(type) {
	case *object.VirtualMachine:
		return vSphereTagTypeVirtualMachine, nil
	case *object.Datastore:
		return vSphereTagTypeDatastore, nil
	case *object.Network:
		return vSphereTagTypeNetwork, nil
	case *object.Folder:
		return vSphereTagTypeFolder, nil
	case *object.VmwareDistributedVirtualSwitch:
		return vSphereTagTypeVmwareDistributedVirtualSwitch, nil
	case *object.DistributedVirtualSwitch:
		return vSphereTagTypeDistributedVirtualSwitch, nil
	case *object.DistributedVirtualPortgroup:
		return vSphereTagTypeDistributedVirtualPortgroup, nil
	case *object.Datacenter:
		return vSphereTagTypeDatacenter, nil
	case *object.ClusterComputeResource:
		return vSphereTagTypeClusterComputeResource, nil
	case *object.HostSystem:
		return vSphereTagTypeHostSystem, nil
	case *object.StoragePod:
		return vSphereTagTypeStoragePod, nil
	case *object.ResourcePool:
		return vSphereTagTypeResourcePool, nil
	case *object.VirtualApp:
		return vSphereTagTypeVirtualApp, nil
	}
	return "", fmt.Errorf("unsupported type for tagging: %T", obj)
}
// tagTypeForObject takes an object.Reference and returns the tag type based on
// its underlying type. If it's not in this list, we don't support it for
// tagging and we return an error.