support TraverseSplat for hclwrite.TokensForTraversal#587
Conversation
|
Hi @jlarfors, Honestly my memory of the details here is spotty but I think we ended up not supporting Honestly I think I just forgot to delete that vestigial type when I removed my attempt to implement splat expressions as just another kind of traversal. As you noticed, nothing is using it. I feel uncomfortable with the assymetry of using this traversal type only for For similar requests so far we've been gradually adding new functions that return values of type I think a function like this for the splat operator would probably have a signature like this: func TokensForSplat(source, perElem Tokens) TokensThe Of course all this function would really do is join two token sequences together with the hard-coded delimiter What do you think? |
|
@apparentlymart thanks for the detailed explanation, and sorry for my delayed response. I understand that In my case, we are building a way for a user to create a reference to an attribute from a Resource or Data Resource, and we added a Right now we have the following type type ReferenceValue struct {
tr hcl.Traversal
}This implements a I'd prefer to use the standard HCL library as much as possible, so do you have a recommendation for how we could store and programmatically build a reference to an attribute (i.e. a traversal), and also provide some special features like One thing I consider was re-implementing the |
I am working on some tooling to generate HCL and found that the
hclwrite.TokensForTraversalmethod does not support thehcl.TraverseSplattraverser.I could also not find any use of
hcl.TraverseSplatin thehclpackage, or in the Terraform code base, so not sure where it is actually used.Any chance this could be added to the core
hclpackage? Right now I am relying on my fork and it works great.