// ObjectReference returns an object reference to this ref (as it would exist during generation)
425622
func (r *ImageRef) ObjectReference() corev1.ObjectReference {
	switch {
	case r.Stream != nil:
		return corev1.ObjectReference{
			Kind:      "ImageStreamTag",
			Name:      imageapi.JoinImageStreamTag(r.Stream.Name, r.Reference.Tag),
			Namespace: r.Stream.Namespace,
		}
	case r.AsImageStream:
		name, _ := r.SuggestName()
		return corev1.ObjectReference{
			Kind: "ImageStreamTag",
			Name: imageapi.JoinImageStreamTag(name, r.InternalTag()),
		}
	default:
		return corev1.ObjectReference{
			Kind: "DockerImage",
			Name: r.PullSpec(),
		}
	}
}
522423
func (s *BatchRemoveFacetFromObject) SetObjectReference(v *ObjectReference) *BatchRemoveFacetFromObject {
	s.ObjectReference = v
	return s
}
1361978
func (s *ListObjectParentPathsInput) SetObjectReference(v *ObjectReference) *ListObjectParentPathsInput {
	s.ObjectReference = v
	return s
}
824412
func FindReference(refs []types.ManagedObjectReference, match ...types.ManagedObjectReference) *types.ManagedObjectReference {
	for _, ref := range refs {
		for _, m := range match {
			if ref == m {
				return &ref
			}
		}
	}

	return nil
}
25238
func (db *Database) Reference(child common.Hash, parent common.Hash) {
	db.lock.Lock()
	defer db.lock.Unlock()

	db.reference(child, parent)
}
1208701
func (h *Host) ObjectFromRef(permanodeRef blob.Ref) (*Object, error) {
	ctx := context.TODO()
	res, err := h.search.Describe(ctx, &search.DescribeRequest{
		BlobRef: permanodeRef,
		Depth:   1,
	})
	if err != nil {
		return nil, err
	}
	db, ok := res.Meta[permanodeRef.String()]
	if !ok {
		return nil, fmt.Errorf("permanode %v wasn't in Describe response", permanodeRef)
	}
	if db.Permanode == nil {
		return nil, fmt.Errorf("permanode %v had no DescribedPermanode in Describe response", permanodeRef)
	}
	return &Object{
		h:       h,
		pn:      permanodeRef,
		attr:    map[string][]string(db.Permanode.Attr),
		modtime: db.Permanode.ModTime,
	}, nil
}
1366144
func (lock *ProjectPostUserLock) Reference() Reference {
	post, _ := NewProjectPost(lock.Hpid)
	return post
}
268427
func RemoveReference(field *[]types.ManagedObjectReference, ref types.ManagedObjectReference) {
	for i, r := range *field {
		if r == ref {
			*field = append((*field)[:i], (*field)[i+1:]...)
			break
		}
	}
}
190145
func (c *imageResolutionCache) ResolveObjectReference(ref *kapi.ObjectReference, defaultNamespace string, forceResolveLocalNames bool) (*rules.ImagePolicyAttributes, error) {
	switch ref.Kind {
	case "ImageStreamTag":
		ns := ref.Namespace
		if len(ns) == 0 {
			ns = defaultNamespace
		}
		name, tag, ok := imageapi.SplitImageStreamTag(ref.Name)
		if !ok {
			return &rules.ImagePolicyAttributes{IntegratedRegistry: true}, fmt.Errorf("references of kind ImageStreamTag must be of the form NAME:TAG")
		}
		return c.resolveImageStreamTag(ns, name, tag, false, false)

	case "ImageStreamImage":
		ns := ref.Namespace
		if len(ns) == 0 {
			ns = defaultNamespace
		}
		name, id, ok := imageapi.SplitImageStreamImage(ref.Name)
		if !ok {
			return &rules.ImagePolicyAttributes{IntegratedRegistry: true}, fmt.Errorf("references of kind ImageStreamImage must be of the form NAME@DIGEST")
		}
		return c.resolveImageStreamImage(ns, name, id)

	case "DockerImage":
		ref, err := imageapi.ParseDockerImageReference(ref.Name)
		if err != nil {
			return nil, err
		}
		return c.resolveImageReference(ref, defaultNamespace, forceResolveLocalNames)

	default:
		return nil, fmt.Errorf("image policy does not allow image references of kind %q", ref.Kind)
	}
}
1162743
func (s *BatchListIncomingTypedLinks) SetObjectReference(v *ObjectReference) *BatchListIncomingTypedLinks {
	s.ObjectReference = v
	return s
}
301333
func GetReference(obj runtime.Object) (*ObjectReference, error) {
	if obj == nil {
		return nil, ErrNilObject
	}
	if ref, ok := obj.(*ObjectReference); ok {
		// Don't make a reference to a reference.
		return ref, nil
	}
	meta, err := meta.Accessor(obj)
	if err != nil {
		return nil, err
	}

	gvk := obj.GetObjectKind().GroupVersionKind()

	// if the object referenced is actually persisted, we can just get kind from meta
	// if we are building an object reference to something not yet persisted, we should fallback to scheme
	var kind string
	if gvk != nil {
		kind = gvk.Kind
	}
	if len(kind) == 0 {
		// TODO: this is wrong
		gvk, err := Scheme.ObjectKind(obj)
		if err != nil {
			return nil, err
		}
		kind = gvk.Kind
	}

	// if the object referenced is actually persisted, we can also get version from meta
	var version string
	if gvk != nil {
		version = gvk.GroupVersion().String()
	}
	if len(version) == 0 {
		selfLink := meta.GetSelfLink()
		if len(selfLink) == 0 {
			return nil, ErrNoSelfLink
		}
		selfLinkUrl, err := url.Parse(selfLink)
		if err != nil {
			return nil, err
		}
		// example paths: /<prefix>/<version>/*
		parts := strings.Split(selfLinkUrl.Path, "/")
		if len(parts) < 3 {
			return nil, fmt.Errorf("unexpected self link format: '%v'; got version '%v'", selfLink, version)
		}
		version = parts[2]
	}

	return &ObjectReference{
		Kind:            kind,
		APIVersion:      version,
		Name:            meta.GetName(),
		Namespace:       meta.GetNamespace(),
		UID:             meta.GetUID(),
		ResourceVersion: meta.GetResourceVersion(),
	}, nil
}
641926
func Convert_audit_ObjectReference_To_v1_ObjectReference(in *audit.ObjectReference, out *ObjectReference, s conversion.Scope) error {
	return autoConvert_audit_ObjectReference_To_v1_ObjectReference(in, out, s)
}
957240
func (r *Registry) AddReference(obj mo.Reference, field *[]types.ManagedObjectReference, ref types.ManagedObjectReference) {
	r.WithLock(obj, func() {
		if FindReference(*field, ref) == nil {
			*field = append(*field, ref)
		}
	})
}
334872
func (s *BatchDetachFromIndex) SetIndexReference(v *ObjectReference) *BatchDetachFromIndex {
	s.IndexReference = v
	return s
}
191428
func (s *AttachToIndexInput) SetIndexReference(v *ObjectReference) *AttachToIndexInput {
	s.IndexReference = v
	return s
}
1223567
func Convert_v1_ObjectReference_To_audit_ObjectReference(in *ObjectReference, out *audit.ObjectReference, s conversion.Scope) error {
	return autoConvert_v1_ObjectReference_To_audit_ObjectReference(in, out, s)
}
1131175
func (vote *ProjectPostVote) Reference() Reference {
	post, _ := NewProjectPost(vote.Hpid)
	return post
}