// ParseAnyReference parses a reference string as a possible identifier,
// full digest, or familiar name.
500282
func ParseAnyReference(ref string) (Reference, error) {
	if ok := anchoredIdentifierRegexp.MatchString(ref); ok {
		return digestReference("sha256:" + ref), nil
	}
	if dgst, err := digest.Parse(ref); err == nil {
		return digestReference(dgst), nil
	}

	return ParseNormalizedNamed(ref)
}
1146013
func (lock *UserPostUserLock) Reference() Reference {
	post, _ := NewUserPost(lock.Hpid)
	return post
}
1313215
func (m ImageReferenceMappings) MapReference(in string) string {
	ref, err := imageapi.ParseDockerImageReference(in)
	if err != nil {
		return in
	}
	registry := ref.DockerClientDefaults().Registry
	name := ref.RepositoryName()
	for _, mapping := range m {
		if len(mapping.FromRegistry) > 0 && mapping.FromRegistry != registry {
			continue
		}
		if len(mapping.FromName) > 0 && mapping.FromName != name {
			continue
		}
		if len(mapping.ToRegistry) > 0 {
			ref.Registry = mapping.ToRegistry
		}
		if len(mapping.ToName) > 0 {
			ref.Namespace = ""
			ref.Name = mapping.ToName
		}
		return ref.Exact()
	}
	return in
}
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)
		}
	})
}
1126341
func (bookmark *UserPostBookmark) Reference() Reference {
	post, _ := NewUserPost(bookmark.Hpid)
	return post
}
597853
func ParseDockerImageReference(spec string) (reference.DockerImageReference, error) {
	ref, err := reference.Parse(spec)
	if err != nil {
		return ref, err
	}
	return ref, nil
}
398262
func isURIReference(v interface{}) bool {
	s, ok := v.(string)
	if !ok {
		return false
	}
	_, err := url.Parse(s)
	return err == nil
}
1282027
func Parse(remote string) (*Reference, error) {

	n, err := docker.ParseNamed(clean(remote))

	if err != nil {
		return nil, err
	}

	n = docker.WithDefaultTag(n)

	var t string
	switch x := n.(type) {
	case docker.Canonical:
		t = "@" + x.Digest().String()
	case docker.NamedTagged:
		t = ":" + x.Tag()
	}

	return &Reference{named: n, tag: t}, nil
}
759429
func (lurk *UserPostLurk) Reference() Reference {
	post, _ := NewUserPost(lurk.Hpid)
	return post
}
285497
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
}
49064
func (pm *Pm) Reference() Reference {
	user, _ := NewUser(pm.NumericReference())
	return user
}
477418
func (v *baseSchemaVisitor) VisitReference(reference proto.Reference) {
	v.Kind = "reference"
	v.Err = fmt.Errorf("Reference type not expected")
}
749940
func (domain *Domain) propertyNameForReference(reference string) *string {
	parts := strings.Split(reference, "/")
	first := parts[0]
	last := parts[len(parts)-1]
	if first == "#" {
		return &last
	}
	return nil
}
1032794
func (c *Client) ResolveReferenceString(rawurl string) (string, error) {
	u, err := url.Parse(rawurl)
	if err != nil {
		return "", err
	}
	return c.ResolveReference(u).String(), nil
}
609612
func (m *Discriminator) ResolveReferences(root string) (interface{}, error) {
	errors := make([]error, 0)
	if m.Mapping != nil {
		_, err := m.Mapping.ResolveReferences(root)
		if err != nil {
			errors = append(errors, err)
		}
	}
	return nil, compiler.NewErrorGroupOrNil(errors)
}
781034
func typeReference(g Generator, spec compile.TypeSpec) (string, error) {
	name, err := typeName(g, spec)
	if err != nil {
		return "", err
	}
	if isStructType(spec) {
		// Prepend "*" to the result if the field is not required and the type
		// isn't a reference type.
		name = "*" + name
	}
	return name, nil
}
518607
func containerReference(reference string) (name string) {
	if parts := strings.Split(reference, ":"); len(parts) == 2 && (parts[0] == "container" || parts[0] == "service") {
		// We'll just assume here that the reference is a name, and not an id, even
		// though docker supports it, since we have no bullet-proof way to tell:
		// heuristics to detect whether it's an id could bring false positives, and
		// a lookup in the list of container names could bring false negatives
		name = parts[1]
	}
	return
}