-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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 alias_ip_range in google_compute_instance network interface #375
Merged
rosbo
merged 6 commits into
hashicorp:master
from
rosbo:compute-instance-beta-ip-aliasing
Sep 7, 2017
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
2076f16
Add support for alias_ip_range in google_compute_instance network int…
rosbo e1eb2a6
Generic method to diffsuppress self_link or name field.
rosbo bb44d58
Add documentation on field path for api versions
rosbo 0f0f2c6
make fmt
rosbo 4f7ab64
Improve documentation
rosbo 838cfeb
Improve documentation
rosbo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I have to say I'm not a huge fan of this syntax. I appreciate that you do have to make some sort of change however to be able to see if this feature is in use for any of the
network_interface
properties.If I see a '*' I would expect it to be globbing like a regex rather than having it match a sublist. Anyway to make the behavior like that?
(Alternatively, if we could see if a feature is in use by using a more structural syntax I'd totally love that (similar to how we navigate the
schema.ResourceData
struct)Also, can we document this syntax in the
inUseBy
method?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.
There is no use case for globbing on a field. I don't expect why a beta field would be present under two different field.
inUseBy
is only use for api versions.You can see the
*
as globbing on the indices. Usually, you would havefield.5.nested_field
.I am not sure I follow your suggestion about structural syntax...
I will add more documentation once we agree on the syntax.
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.
But you're globbing on a field right now! (or at least, you're globbing on an integer)
I guess I'm saying is that if we introduce syntax like '*' but it is specific to integers, it's asking for a bug in the future when someone uses '*' like globbing. Given that globbing would work here, would it be too hard to add?
For a more structural syntax, I meant being able to receive and parse the actual
schema.ResourceData
struct usingGetOk
and other syntax to see if a given feature is in use, rather than using the serialize string data.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.
Supporting globbing also on field names would definitely add complexity (and potentially bugs) when there is clearly no needs for this. However, I can make sure it fails if with a nice error message if someone uses the
*
on a field name instead of an indice. This way, we prevent somebody from misusing it without knowing they are misusing it.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.
I don't want to block this whole PR on the syntax (especially since what's currently-implemented would work if * was a globbing symbol) but I'm starting to worry that this
inUseBy
method is an anti-pattern. Right now it depends on the serialized state and not the providedschema.ResourceData
which provides a well-defined set of methods for dealing with the schema. My understanding is thatinUseBy
is used because it's convenient, but if we ever depend on values like optionals or validation then we'll regret using it here.That said, we can probably have that discussion outside of this PR. If we document the '*' syntax I'm ok as-is.
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.
I'm a bit confused -
inUseBy
uses the methods fromschema.ResourceData
;TerraformResourceData
is just an interface for the two methodsinUseBy
needs, since we don't need the rest of the behaviour of the class and are able to unit test this code w/ a mock of that interface.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.
OK, after looking at the code, you were right and I was confused; it IS operating on
schema.ResourceData
; I had no idea you could directly access attributes likefoobar.#
to get the size of a list for example using the Get or GetOk method. For some reason I assumed it was using something similar to the the attributes map that we constantly assert on in unit tests.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.
Documentation added.