Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
piggybankwang opened this issue Aug 23, 2024 · 0 comments

Comments

@piggybankwang
Copy link
Contributor

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
		}
	}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant