// attributeFromRef returns a base attribute given a reference data type.
// It takes care of running the DSL on the reference type if it hasn't run yet.
427776
func attributeFromRef(name string, ref design.DataType) *design.AttributeDefinition {
	if ref == nil {
		return nil
	}
	switch t := ref.(type) {
	case *design.UserTypeDefinition:
		if t.DSLFunc != nil {
			dsl := t.DSLFunc
			t.DSLFunc = nil
			dslengine.Execute(dsl, t.AttributeDefinition)
		}
		if att, ok := t.ToObject()[name]; ok {
			return design.DupAtt(att)
		}
	case *design.MediaTypeDefinition:
		if t.DSLFunc != nil {
			dsl := t.DSLFunc
			t.DSLFunc = nil
			dslengine.Execute(dsl, t)
		}
		if att, ok := t.ToObject()[name]; ok {
			return design.DupAtt(att)
		}
	case design.Object:
		if att, ok := t[name]; ok {
			return design.DupAtt(att)
		}
	}
	return nil
}
790877
func (d *DeploymentRequest) GetRef() string {
	if d == nil || d.Ref == nil {
		return ""
	}
	return *d.Ref
}
927853
func (a *AddRequest) Attribute(attrType string, attrVals []string) {
	a.Attributes = append(a.Attributes, Attribute{Type: attrType, Vals: attrVals})
}
688630
func NewPathForRef(ref ast.Ref) (path Path, err error) {

	if len(ref) == 0 {
		return nil, fmt.Errorf("empty reference (indicates error in caller)")
	}

	if len(ref) == 1 {
		return Path{}, nil
	}

	for _, term := range ref[1:] {
		switch v := term.Value.(type) {
		case ast.String:
			path = append(path, string(v))
		case ast.Number:
			path = append(path, v.String())
		case ast.Boolean, ast.Null:
			return nil, &Error{
				Code:    NotFoundErr,
				Message: fmt.Sprintf("%v: does not exist", ref),
			}
		case ast.Array, ast.Object, ast.Set:
			return nil, fmt.Errorf("composites cannot be base document keys: %v", ref)
		default:
			return nil, fmt.Errorf("unresolved reference (indicates error in caller): %v", ref)
		}
	}

	return path, nil
}
846964
func (d *Domain) resolveReference(prop PropSetter) bool {

	if prop.GetRef() == "" {
		fmt.Printf("ref was empty: %s\n", prop.GetGoType())
		return false
	}
	refName := ""
	// Local reference, add . between domain/ref type so we can look it up in our globalRefs
	if !strings.Contains(prop.GetRef(), ".") {
		refName = d.Domain + "." + prop.GetRef()
	} else {
		refName = prop.GetRef()
	}

	ref := globalRefs[refName]
	fmt.Printf("REF (%s): %#v\n", refName, ref)
	// base type
	if ref.IsBaseType {
		prop.SetGoType(ref.BaseType)
	} else {
		// we can have this type, reference another type, which is just a base type
		// so just set that here.
		if ref2ref, ok := globalRefs[ref.RefToRefName]; ok {
			if ref2ref.IsBaseType {
				prop.SetGoType(ref2ref.BaseType)
			}
		} else {
			prop.SetGoType(ref.ExternalGoName)
		}
		prop.SetIsRef(true)
	}
	// set the type as being an array of whatever type it references
	if ref.IsArrayRef {
		prop.SetIsTypeArray(true)
	}
	// add enum possible values to description
	if ref.EnumDescription != "" {
		prop.SetDescription(prop.GetDescription() + ref.EnumDescription)
	}

	if isPointerType(prop) {
		prop.SetPointerType(true)
	}
	return true
}
115329
func getFieldRef(obj runtime.Object, from *corev1.EnvVarSource) (string, error) {
	return fieldpath.ExtractFieldPathAsString(obj, from.FieldRef.FieldPath)
}
977178
func (c *ClassifierSerializer) WriteAttributeForKey(key string, a Attribute) error {
	b, err := SerializeAttribute(a)
	if err != nil {
		return WrapError(err)
	}
	return c.WriteBytesForKey(key, b)
}
170047
func RefType(s *spec.Schema) string {
	return strings.TrimPrefix(s.Ref.String(), "#/definitions/")
}
443168
func (d *Deployment) GetRef() string {
	if d == nil || d.Ref == nil {
		return ""
	}
	return *d.Ref
}
47493
func (l *LazilyFilteredInstances) GetAttribute(target Attribute) (AttributeSpec, error) {
	if l.unfilteredMap[target] {
		return l.src.GetAttribute(target)
	}
	var ret AttributeSpec
	ret.pond = -1
	for i, a := range l.attrs {
		if a.New.Equals(target) {
			ret.position = i
			ret.attr = target
			return ret, nil
		}
	}
	return ret, fmt.Errorf("Couldn't resolve %s", target)
}
1328236
func getVolumeFromRef(ref string) (volNamespace string, volName string, err error) {
	refParts := strings.Split(ref, ".")
	switch len(refParts) {
	case 2:
		return refParts[0], refParts[1], nil
	case 3:
		return refParts[1], refParts[2], nil
	}
	return "", "", fmt.Errorf("ref not in format volNamespace.volName or pvName.volNamespace.volName")
}
1341098
func (c *RefManager) GetRef(id ContainerID) (ref *v1.ObjectReference, ok bool) {
	c.RLock()
	defer c.RUnlock()
	ref, ok = c.containerIDToRef[id]
	return ref, ok
}
582538
func UpdateRef(ref *Ref, to []byte, reason string) error {
	return UpdateRefIn("", ref, to, reason)
}
83720
func (f *Footer) AddRef() {
	f.m.Lock()
	f.refs++
	f.m.Unlock()
}
400102
func (s *FacetAttribute) SetAttributeReference(v *FacetAttributeReference) *FacetAttribute {
	s.AttributeReference = v
	return s
}
1117917
func (d *DeleteEvent) GetRef() string {
	if d == nil || d.Ref == nil {
		return ""
	}
	return *d.Ref
}
568241
func (c *ClassifierDeserializer) GetAttributesForKey(key string) ([]Attribute, error) {

	attrCountKey := c.Prefix(key, "ATTR_COUNT")
	attrCount, err := c.GetU64ForKey(attrCountKey)
	if err != nil {
		return nil, DescribeError("Unable to read ATTR_COUNT", err)
	}

	ret := make([]Attribute, attrCount)

	for i := range ret {
		attrKey := c.Prefix(key, fmt.Sprintf("%d", i))
		ret[i], err = c.GetAttributeForKey(attrKey)
		if err != nil {
			return nil, DescribeError("Unable to read Attribute", err)
		}
	}
	return ret, nil
}