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

adding a * catchall for var interpolation #6284

Closed
wants to merge 2 commits into from

Conversation

mzupan
Copy link
Contributor

@mzupan mzupan commented Apr 21, 2016

This adds the following functionality for #2312

variable "instance_type" {
  default = {
    prod = "m4.xlarge"
    "*" = "m4.large"
  }
}

It allows a catch all. The * needs to be quotes since terraform thinks its an invalid character.

I tried to edit the test but my knowledge of test writing in go is bad at best. This passes all my tests that I tried.

@jen20
Copy link
Contributor

jen20 commented Apr 21, 2016

Hi @mzupan! Thanks for the effort involved in a PR here. I don't personally have an opinion here on whether a catch all lookup is a good idea (perhaps @mitchellh or @phinze do), but the implementation will need some rework because of changes to how maps work on the dev-0.7 branch. If we go ahead with this I'm happy to port your work over to that branch for 0.7. Thanks!

@mitchellh
Copy link
Contributor

mitchellh commented Apr 21, 2016

My initial reaction is: good idea! 😄

I didn't look at the PR (I'll leave that to @jen20 since he is most familiar with these code paths right now), so I'll just talk about high levels, UX, any pitfalls I see, etc. But since I didn't look at the PR, I apologize if your code already addresses this (likely does), I just want to be complete for the text history.

I think the functionality of this from a UX perspective is simple. When looking up "foo" in map "m":

  • If "foo" exists as a key, use the value of "foo"
  • If "" exists as a key, use the value of ""
  • Else, runtime error.

👍

@jen20
Copy link
Contributor

jen20 commented Apr 21, 2016

@mitchellh this needs re-implementing for 0.7 so I am inclined to defer it until then (the implementation for the current tree looks good, however). As part of this, do you think we should modify HCL to allow * as an object key without quotation?

@mitchellh
Copy link
Contributor

@jen20 Agreed, 0.7

@mzupan
Copy link
Contributor Author

mzupan commented Apr 21, 2016

@mitchellh yes correct it will look for a key first and if not found it'll look for the * and if its not there it'll throw the not found error linking the key name used for the lookup

@mzupan
Copy link
Contributor Author

mzupan commented Apr 21, 2016

@jen20 I'm fine trying to get it into 0.7 if someone lets me know how to try to go about doing it if not I can wait and use this patch till it gets released

@manojlds
Copy link
Contributor

Can we get this merged in both 0.6.x and 0.7.x so that we can leverage this quicker? I hope there is 0.6.15 coming up at the least (looking at master's CHANGELOG.md)?

@mitchellh
Copy link
Contributor

0.7 isn't too far away (0.6.15 will come out sooner), and we've done significant changes there. We'll likely just push this into there to avoid any instability in 0.6.x. Trust me that 0.7 is close.

@mzupan
Copy link
Contributor Author

mzupan commented Apr 26, 2016

I created a new PR for 0.7 #6351

so this can be closed since it won't go into 0.6

@mzupan mzupan closed this Apr 26, 2016
@ghost
Copy link

ghost commented Apr 26, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators Apr 26, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants