// ObjectReference converts the given ManagedObjectReference to a type from the object package via object.NewReference // with the object.Common.InventoryPath field set. func (f *Finder) ObjectReference(ctx context.Context, ref types.ManagedObjectReference) (object.Reference, error) { e, err := f.Element(ctx, ref) if err != nil { return nil, err } r := object.NewReference(f.client, ref) type common interface { SetInventoryPath(string) } r.(common).SetInventoryPath(e.Path) return r, nil }
// ObjectReference converts the given ManagedObjectReference to a type from the object package via object.NewReference // with the object.Common.InventoryPath field set. func (f *Finder) ObjectReference(ctx context.Context, ref types.ManagedObjectReference) (object.Reference, error) { e, err := f.Element(ctx, ref) if err != nil { return nil, err } r := object.NewReference(f.client, ref) type common interface { SetInventoryPath(string) } r.(common).SetInventoryPath(e.Path) if f.dc != nil { if ds, ok := r.(*object.Datastore); ok { ds.DatacenterPath = f.dc.InventoryPath } } return r, nil }