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

Add Beta support & Beta feature ip_version to google_compute_global_address #250

Merged
merged 7 commits into from
Aug 4, 2017

Conversation

rileykarson
Copy link
Collaborator

Waiting on #249 to merge, but otherwise able to be reviewed.

  • Convert google_compute_global_address to a versioned resource with Beta support.
  • Add support for the Beta field ip_version to google_compute_global_address

Explicitly setting IPV4 on a v1 resource forces a recreate as you're going from "" to IPV4 and this resource can't update; this is working as expected based on #185. We don't have enough information at refresh time to perform the read at v0beta.

Part 1/2 of #245.
Related to #93

resource.TestStep{
Config: testAccComputeGlobalAddress_ipv6,
Check: resource.ComposeTestCheckFunc(
testAccCheckComputeBetaGlobalAddressExists(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider asserting on the format of the computed address to make sure an IPv6 is used.
Additionally, to prevent regression, make sure the ipv4 address follows the ipv4 pattern.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I agree that we need to validate that the API isn't lying to us when it says an IP address is at some version; especially when we would need to use a regex or vendor a new package to verify it.

Added a test for IPV4 on _basic, and moved checks to a TestCheckFunc.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could use https://golang.org/pkg/net/#ParseIP

ip := ParseIP(address)
ip.To16 != nil // means it is a IPv6 address.
ip.To4 != nil // means this is a IPv4 address.

Checking if the IpVersion match what we expect is probably fine for the IPv6 case. My main goal was not to test if the API "lies" to us but rather make sure we don't create an ipv6 address when we don't use the beta feature (and since we don't have the ip version field in that case, the only way to check is looking at address itself to validate it is ipv4).

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, ok - we can actually just read the resource using a Beta API in this test and see the IpVersion; that's what the TestCheckFunc does.

@rileykarson
Copy link
Collaborator Author

==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./google -v -run=TestAccComputeGlobalAddress -timeout 120m
=== RUN   TestAccComputeGlobalAddress_importBasic
--- PASS: TestAccComputeGlobalAddress_importBasic (22.65s)
=== RUN   TestAccComputeGlobalAddress_basic
--- PASS: TestAccComputeGlobalAddress_basic (22.71s)
=== RUN   TestAccComputeGlobalAddress_ipv6
--- PASS: TestAccComputeGlobalAddress_ipv6 (22.45s)
PASS
ok  	github.com/terraform-providers/terraform-provider-google/google	67.973s

@rileykarson rileykarson merged commit 68f2e35 into hashicorp:master Aug 4, 2017
z1nkum pushed a commit to z1nkum/terraform-provider-google that referenced this pull request Aug 15, 2017
…ddress (hashicorp#250)

* Make google_compute_global_address a versioned resource with Beta support.

* Added Beta support for ip_version in google_compute_global_address.

* Move checks to TestCheckFuncs, add a regression test for IPV4 on v1 resources.

* Consolidated TestCheckFuncs to a single function.

* Add missing return statement.

* Fix IPV4 test

* Clarified comment.
negz pushed a commit to negz/terraform-provider-google that referenced this pull request Oct 17, 2017
…ddress (hashicorp#250)

* Make google_compute_global_address a versioned resource with Beta support.

* Added Beta support for ip_version in google_compute_global_address.

* Move checks to TestCheckFuncs, add a regression test for IPV4 on v1 resources.

* Consolidated TestCheckFuncs to a single function.

* Add missing return statement.

* Fix IPV4 test

* Clarified comment.
chrisst pushed a commit to chrisst/terraform-provider-google that referenced this pull request Nov 9, 2018
…ddress (hashicorp#250)

* Make google_compute_global_address a versioned resource with Beta support.

* Added Beta support for ip_version in google_compute_global_address.

* Move checks to TestCheckFuncs, add a regression test for IPV4 on v1 resources.

* Consolidated TestCheckFuncs to a single function.

* Add missing return statement.

* Fix IPV4 test

* Clarified comment.
luis-silva pushed a commit to luis-silva/terraform-provider-google that referenced this pull request May 21, 2019
<!-- This change is generated by MagicModules. -->
/cc @danawillow
@ghost
Copy link

ghost commented Mar 31, 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 feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 [email protected]. Thanks!

@ghost ghost locked and limited conversation to collaborators Mar 31, 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.

2 participants