Adding the option to specify the address_type for vSphere provider #242
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.
According to the documentation at https://developer.hashicorp.com/consul/docs/install/cloud-auto-join the vsphere provider should return the first Private IP address of the hosts matching the category and tag. This does not work. The vSphere provider returns all IP addresses of a host. (
net.ip.IsPrivate()
is never used in the vsphere code)This PR adds the option for users to provide an "address_type" option that defaults to "private" so it actually returns RFC1918 addresses (as described by the documentation). Specifying "public" will return the public IP addresses.
Full Disclosure: This is my first time actually touching go-lang code. I know globals should be avoided, hence I've forwarded "addressType" to all functions to finally end up being used in the skipIPAddr function, feels nasty. No idea if there's a better solution, but it works! Feel free to implement a better method.