func()

in terraformutils/flatmap.go [97:155]


func (p *FlatmapParser) fromFlatmapObject(prefix string, tys map[string]cty.Type) (map[string]interface{}, error) {
	values := make(map[string]interface{})
	for name, ty := range tys {
		inAttributes := false
		attributeName := ""
		for k := range p.attributes {
			if k == prefix+name {
				attributeName = k
				inAttributes = true
				break
			}
			if k == name {
				attributeName = k
				inAttributes = true
				break
			}

			if strings.HasPrefix(k, prefix+name+".") {
				attributeName = k
				inAttributes = true
				break
			}
			lastAttribute := (prefix + name)[len(prefix):]
			if lastAttribute == k {
				attributeName = k
				inAttributes = true
				break
			}
		}

		if _, exist := p.attributes[prefix+name+".#"]; exist {
			attributeName = prefix + name + ".#"
			inAttributes = true
		}

		if _, exist := p.attributes[prefix+name+".%"]; exist {
			attributeName = prefix + name + ".%"
			inAttributes = true
		}

		if !inAttributes {
			continue
		}
		if p.isAttributeIgnored(prefix + name) {
			continue
		}
		value, err := p.fromFlatmapValue(prefix+name, ty)
		if err != nil {
			return nil, err
		}
		if p.isValueAllowed(value, attributeName) {
			values[name] = value
		}
	}
	if len(values) == 0 {
		return nil, nil
	}
	return values, nil
}