-
Notifications
You must be signed in to change notification settings - Fork 33
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
Add support for indexing into variables #3
Conversation
cc @phinze, @mitchellh. |
f74742c
to
350ebe6
Compare
} | ||
|
||
func (n *Index) Accept(v Visitor) Node { | ||
//n.Key = n.Key.Accept(v) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Stray line here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch - will fix - that was actually what was causing the panic :-)
350ebe6
to
0d1756f
Compare
true, | ||
nil, | ||
ast.TypeInvalid, | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should add a test here for tests sake that the index can be a reference to another variable ${foo[bar]}
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 and also that it can be the result of a second indexing operation. I'll add these.
0d1756f
to
865db3d
Compare
This adds support for indexing into variables of the new type "List". The syntax is typical C-style array syntax, so for example, the following is valid for interpolating the element of the list in variable foo at position 1: "${foo[1]}" There is a restriction that lists must be homogenous in type. This is to enable the type checker to work without having to actually perform the indexing operation. During discussion there was no compelling use case for lists of heterogenous types - this is open for discussion in future though if one is found.
865db3d
to
730ac9b
Compare
@mitchellh I went with your suggestion of listing the types which are present in the error - which was actually my original implementation hence the stray |
LGTM! Woohoo! |
Add support for indexing into variables
Is this feature would be present in next Terraform release? |
This adds support for indexing into variables of the new type "List". The syntax is typical C-style array syntax, so for example, the following is valid for interpolating the element of the list in variable
foo
at position 1:There is a restriction that lists must be homogenous in type. This is to enable the type checker to work without having to actually perform the indexing operation. During discussion there was no compelling use case for lists of heterogenous types - this is open for discussion in future though if one is found.