Skip to content

[improvement] readvalue is restricted to only primitive or a list of primitive types #134

@piggybankwang

Description

@piggybankwang

Hi
we realize this function https://github.com/mercari/hcledit/blob/main/internal/converter/converter.go can only return primitive and list of primitive types
we'd like to help contribute to read values like map of map, list of map
so we can handle READ more complex field

i.e.

if ctyVal.IsNull() {
		return nil, nil
	} else if ctyVal.IsMapType() || ctyVal.IsObjectType() {
		return GetAttributeMapValues(ctyVal)
	} else if ctyVal.IsListType() || ctyVal.IsTupleType() {
		return GetAttributeSliceValues(ctyVal.AsValueSlice())
	} else if ctyVal.IsSetType() {
		return GetAttributeSliceValues(ctyVal.AsValueSet().Values())
	} else if ctyVal.IsPrimitiveType() {
		switch ctyVal {
		case cty.Bool:
			return ctyVal.True() == true, nil
		case cty.String:
			return ctyVal.AsString(), nil
		case cty.Number:
			return GetAttributeNumValue(ctyVal), nil
		}
	}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions