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

azurerm_lb - allow private_ip_address to be set to an empty value #1481

Merged
merged 3 commits into from
Jul 3, 2018

Conversation

tombuildsstuff
Copy link
Contributor

Issue #1470 raises a regression in v1.8 of the Provider where it's no longer possible to set the private_ip_address field on azurerm_lb to a blank string. This PR extends the validate.IP4Address method to add an overload which allows for blank spaces.

On master the new test currently fails as an empty string isn't a valid IPv4 address:

$ acctests azurerm TestAccAzureRMLoadBalancer_emptyPrivateIP
=== RUN   TestAccAzureRMLoadBalancer_emptyPrivateIP
--- FAIL: TestAccAzureRMLoadBalancer_emptyPrivateIP (0.03s)
	testing.go:513: Step 0 error: config is invalid: azurerm_lb.test: "frontend_ip_configuration.0.private_ip_address" is not a valid IP4 address: ""
FAIL
FAIL	github.com/terraform-providers/terraform-provider-azurerm/azurerm	0.094s

On this branch - the tests pass as expected.

Fixes #1470

Tests pass:

```
$ go test ./azurerm/helpers/validate/ -v
=== RUN   TestIP4Address
=== RUN   TestIP4Address/#00
=== RUN   TestIP4Address/0.0.0.0
=== RUN   TestIP4Address/1.2.3.no
=== RUN   TestIP4Address/text
=== RUN   TestIP4Address/1.2.3.4
=== RUN   TestIP4Address/12.34.43.21
=== RUN   TestIP4Address/100.123.199.0
=== RUN   TestIP4Address/255.255.255.255
--- PASS: TestIP4Address (0.00s)
    --- PASS: TestIP4Address/#00 (0.00s)
    --- PASS: TestIP4Address/0.0.0.0 (0.00s)
    --- PASS: TestIP4Address/1.2.3.no (0.00s)
    --- PASS: TestIP4Address/text (0.00s)
    --- PASS: TestIP4Address/1.2.3.4 (0.00s)
    --- PASS: TestIP4Address/12.34.43.21 (0.00s)
    --- PASS: TestIP4Address/100.123.199.0 (0.00s)
    --- PASS: TestIP4Address/255.255.255.255 (0.00s)
=== RUN   TestIPv4AddressOrEmpty
=== RUN   TestIPv4AddressOrEmpty/#00
=== RUN   TestIPv4AddressOrEmpty/0.0.0.0
=== RUN   TestIPv4AddressOrEmpty/1.2.3.no
=== RUN   TestIPv4AddressOrEmpty/text
=== RUN   TestIPv4AddressOrEmpty/1.2.3.4
=== RUN   TestIPv4AddressOrEmpty/12.34.43.21
=== RUN   TestIPv4AddressOrEmpty/100.123.199.0
=== RUN   TestIPv4AddressOrEmpty/255.255.255.255
--- PASS: TestIPv4AddressOrEmpty (0.00s)
    --- PASS: TestIPv4AddressOrEmpty/#00 (0.00s)
    --- PASS: TestIPv4AddressOrEmpty/0.0.0.0 (0.00s)
    --- PASS: TestIPv4AddressOrEmpty/1.2.3.no (0.00s)
    --- PASS: TestIPv4AddressOrEmpty/text (0.00s)
    --- PASS: TestIPv4AddressOrEmpty/1.2.3.4 (0.00s)
    --- PASS: TestIPv4AddressOrEmpty/12.34.43.21 (0.00s)
    --- PASS: TestIPv4AddressOrEmpty/100.123.199.0 (0.00s)
    --- PASS: TestIPv4AddressOrEmpty/255.255.255.255 (0.00s)
=== RUN   TestMACAddress
=== RUN   TestMACAddress/#00
=== RUN   TestMACAddress/text_d
=== RUN   TestMACAddress/12:34:no
=== RUN   TestMACAddress/123:34:56:78:90:ab
=== RUN   TestMACAddress/12:34:56:78:90:NO
=== RUN   TestMACAddress/12:34:56:78:90:ab
=== RUN   TestMACAddress/ab:cd:ef:AB:CD:EF
--- PASS: TestMACAddress (0.00s)
    --- PASS: TestMACAddress/#00 (0.00s)
    --- PASS: TestMACAddress/text_d (0.00s)
    --- PASS: TestMACAddress/12:34:no (0.00s)
    --- PASS: TestMACAddress/123:34:56:78:90:ab (0.00s)
    --- PASS: TestMACAddress/12:34:56:78:90:NO (0.00s)
    --- PASS: TestMACAddress/12:34:56:78:90:ab (0.00s)
    --- PASS: TestMACAddress/ab:cd:ef:AB:CD:EF (0.00s)
=== RUN   TestRFC3339Time
=== RUN   TestRFC3339Time/#00
=== RUN   TestRFC3339Time/this_is_not_a_date
=== RUN   TestRFC3339Time/2000-01-01
=== RUN   TestRFC3339Time/2000-01-01T01:23:45
=== RUN   TestRFC3339Time/2000-01-01T01:23:45Z
=== RUN   TestRFC3339Time/2000-01-01T01:23:45+00:00
--- PASS: TestRFC3339Time (0.00s)
    --- PASS: TestRFC3339Time/#00 (0.00s)
    --- PASS: TestRFC3339Time/this_is_not_a_date (0.00s)
    --- PASS: TestRFC3339Time/2000-01-01 (0.00s)
    --- PASS: TestRFC3339Time/2000-01-01T01:23:45 (0.00s)
    --- PASS: TestRFC3339Time/2000-01-01T01:23:45Z (0.00s)
    --- PASS: TestRFC3339Time/2000-01-01T01:23:45+00:00 (0.00s)
=== RUN   TestRfc3339DateInFutureBy
=== RUN   TestRfc3339DateInFutureBy/empty
=== RUN   TestRfc3339DateInFutureBy/not_a_time
=== RUN   TestRfc3339DateInFutureBy/now_is_not_1_hour_ahead
=== RUN   TestRfc3339DateInFutureBy/now_+_7_hours_is_not_1_hour_ahead
=== RUN   TestRfc3339DateInFutureBy/now_+_7_min_is_7_min_ahead
=== RUN   TestRfc3339DateInFutureBy/now_+_8_min_is_at_least_7_min_ahead
--- PASS: TestRfc3339DateInFutureBy (0.00s)
    --- PASS: TestRfc3339DateInFutureBy/empty (0.00s)
    --- PASS: TestRfc3339DateInFutureBy/not_a_time (0.00s)
    --- PASS: TestRfc3339DateInFutureBy/now_is_not_1_hour_ahead (0.00s)
    --- PASS: TestRfc3339DateInFutureBy/now_+_7_hours_is_not_1_hour_ahead (0.00s)
    --- PASS: TestRfc3339DateInFutureBy/now_+_7_min_is_7_min_ahead (0.00s)
    --- PASS: TestRfc3339DateInFutureBy/now_+_8_min_is_at_least_7_min_ahead (0.00s)
=== RUN   TestURLIsHTTPOrHTTPS
=== RUN   TestURLIsHTTPOrHTTPS/#00
=== RUN   TestURLIsHTTPOrHTTPS/this_is_not_a_url
=== RUN   TestURLIsHTTPOrHTTPS/www.example.com
=== RUN   TestURLIsHTTPOrHTTPS/ftp://www.example.com
=== RUN   TestURLIsHTTPOrHTTPS/http://www.example.com
=== RUN   TestURLIsHTTPOrHTTPS/https://www.example.com
--- PASS: TestURLIsHTTPOrHTTPS (0.00s)
    --- PASS: TestURLIsHTTPOrHTTPS/#00 (0.00s)
    --- PASS: TestURLIsHTTPOrHTTPS/this_is_not_a_url (0.00s)
    --- PASS: TestURLIsHTTPOrHTTPS/www.example.com (0.00s)
    --- PASS: TestURLIsHTTPOrHTTPS/ftp://www.example.com (0.00s)
    --- PASS: TestURLIsHTTPOrHTTPS/http://www.example.com (0.00s)
    --- PASS: TestURLIsHTTPOrHTTPS/https://www.example.com (0.00s)
=== RUN   TestUrlWithScheme
=== RUN   TestUrlWithScheme/TestUrlWithScheme
--- PASS: TestUrlWithScheme (0.00s)
    --- PASS: TestUrlWithScheme/TestUrlWithScheme (0.00s)
PASS
ok  	github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/validate	0.027s

```
Tests pass:

```
$ go test ./azurerm/helpers/validate/ -v
=== RUN   TestIPv4Address
=== RUN   TestIPv4Address/#00
=== RUN   TestIPv4Address/0.0.0.0
=== RUN   TestIPv4Address/1.2.3.no
=== RUN   TestIPv4Address/text
=== RUN   TestIPv4Address/1.2.3.4
=== RUN   TestIPv4Address/12.34.43.21
=== RUN   TestIPv4Address/100.123.199.0
=== RUN   TestIPv4Address/255.255.255.255
--- PASS: TestIPv4Address (0.00s)
    --- PASS: TestIPv4Address/#00 (0.00s)
    --- PASS: TestIPv4Address/0.0.0.0 (0.00s)
    --- PASS: TestIPv4Address/1.2.3.no (0.00s)
    --- PASS: TestIPv4Address/text (0.00s)
    --- PASS: TestIPv4Address/1.2.3.4 (0.00s)
    --- PASS: TestIPv4Address/12.34.43.21 (0.00s)
    --- PASS: TestIPv4Address/100.123.199.0 (0.00s)
    --- PASS: TestIPv4Address/255.255.255.255 (0.00s)
=== RUN   TestIPv4AddressOrEmpty
=== RUN   TestIPv4AddressOrEmpty/#00
=== RUN   TestIPv4AddressOrEmpty/0.0.0.0
=== RUN   TestIPv4AddressOrEmpty/1.2.3.no
=== RUN   TestIPv4AddressOrEmpty/text
=== RUN   TestIPv4AddressOrEmpty/1.2.3.4
=== RUN   TestIPv4AddressOrEmpty/12.34.43.21
=== RUN   TestIPv4AddressOrEmpty/100.123.199.0
=== RUN   TestIPv4AddressOrEmpty/255.255.255.255
--- PASS: TestIPv4AddressOrEmpty (0.00s)
    --- PASS: TestIPv4AddressOrEmpty/#00 (0.00s)
    --- PASS: TestIPv4AddressOrEmpty/0.0.0.0 (0.00s)
    --- PASS: TestIPv4AddressOrEmpty/1.2.3.no (0.00s)
    --- PASS: TestIPv4AddressOrEmpty/text (0.00s)
    --- PASS: TestIPv4AddressOrEmpty/1.2.3.4 (0.00s)
    --- PASS: TestIPv4AddressOrEmpty/12.34.43.21 (0.00s)
    --- PASS: TestIPv4AddressOrEmpty/100.123.199.0 (0.00s)
    --- PASS: TestIPv4AddressOrEmpty/255.255.255.255 (0.00s)
=== RUN   TestMACAddress
=== RUN   TestMACAddress/#00
=== RUN   TestMACAddress/text_d
=== RUN   TestMACAddress/12:34:no
=== RUN   TestMACAddress/123:34:56:78:90:ab
=== RUN   TestMACAddress/12:34:56:78:90:NO
=== RUN   TestMACAddress/12:34:56:78:90:ab
=== RUN   TestMACAddress/ab:cd:ef:AB:CD:EF
--- PASS: TestMACAddress (0.00s)
    --- PASS: TestMACAddress/#00 (0.00s)
    --- PASS: TestMACAddress/text_d (0.00s)
    --- PASS: TestMACAddress/12:34:no (0.00s)
    --- PASS: TestMACAddress/123:34:56:78:90:ab (0.00s)
    --- PASS: TestMACAddress/12:34:56:78:90:NO (0.00s)
    --- PASS: TestMACAddress/12:34:56:78:90:ab (0.00s)
    --- PASS: TestMACAddress/ab:cd:ef:AB:CD:EF (0.00s)
=== RUN   TestRFC3339Time
=== RUN   TestRFC3339Time/#00
=== RUN   TestRFC3339Time/this_is_not_a_date
=== RUN   TestRFC3339Time/2000-01-01
=== RUN   TestRFC3339Time/2000-01-01T01:23:45
=== RUN   TestRFC3339Time/2000-01-01T01:23:45Z
=== RUN   TestRFC3339Time/2000-01-01T01:23:45+00:00
--- PASS: TestRFC3339Time (0.00s)
    --- PASS: TestRFC3339Time/#00 (0.00s)
    --- PASS: TestRFC3339Time/this_is_not_a_date (0.00s)
    --- PASS: TestRFC3339Time/2000-01-01 (0.00s)
    --- PASS: TestRFC3339Time/2000-01-01T01:23:45 (0.00s)
    --- PASS: TestRFC3339Time/2000-01-01T01:23:45Z (0.00s)
    --- PASS: TestRFC3339Time/2000-01-01T01:23:45+00:00 (0.00s)
=== RUN   TestRfc3339DateInFutureBy
=== RUN   TestRfc3339DateInFutureBy/empty
=== RUN   TestRfc3339DateInFutureBy/not_a_time
=== RUN   TestRfc3339DateInFutureBy/now_is_not_1_hour_ahead
=== RUN   TestRfc3339DateInFutureBy/now_+_7_hours_is_not_1_hour_ahead
=== RUN   TestRfc3339DateInFutureBy/now_+_7_min_is_7_min_ahead
=== RUN   TestRfc3339DateInFutureBy/now_+_8_min_is_at_least_7_min_ahead
--- PASS: TestRfc3339DateInFutureBy (0.00s)
    --- PASS: TestRfc3339DateInFutureBy/empty (0.00s)
    --- PASS: TestRfc3339DateInFutureBy/not_a_time (0.00s)
    --- PASS: TestRfc3339DateInFutureBy/now_is_not_1_hour_ahead (0.00s)
    --- PASS: TestRfc3339DateInFutureBy/now_+_7_hours_is_not_1_hour_ahead (0.00s)
    --- PASS: TestRfc3339DateInFutureBy/now_+_7_min_is_7_min_ahead (0.00s)
    --- PASS: TestRfc3339DateInFutureBy/now_+_8_min_is_at_least_7_min_ahead (0.00s)
=== RUN   TestURLIsHTTPOrHTTPS
=== RUN   TestURLIsHTTPOrHTTPS/#00
=== RUN   TestURLIsHTTPOrHTTPS/this_is_not_a_url
=== RUN   TestURLIsHTTPOrHTTPS/www.example.com
=== RUN   TestURLIsHTTPOrHTTPS/ftp://www.example.com
=== RUN   TestURLIsHTTPOrHTTPS/http://www.example.com
=== RUN   TestURLIsHTTPOrHTTPS/https://www.example.com
--- PASS: TestURLIsHTTPOrHTTPS (0.00s)
    --- PASS: TestURLIsHTTPOrHTTPS/#00 (0.00s)
    --- PASS: TestURLIsHTTPOrHTTPS/this_is_not_a_url (0.00s)
    --- PASS: TestURLIsHTTPOrHTTPS/www.example.com (0.00s)
    --- PASS: TestURLIsHTTPOrHTTPS/ftp://www.example.com (0.00s)
    --- PASS: TestURLIsHTTPOrHTTPS/http://www.example.com (0.00s)
    --- PASS: TestURLIsHTTPOrHTTPS/https://www.example.com (0.00s)
=== RUN   TestUrlWithScheme
=== RUN   TestUrlWithScheme/TestUrlWithScheme
--- PASS: TestUrlWithScheme (0.00s)
    --- PASS: TestUrlWithScheme/TestUrlWithScheme (0.00s)
PASS
ok  	github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/validate	0.028s
```
Copy link
Collaborator

@katbyte katbyte left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@tombuildsstuff tombuildsstuff merged commit 3facf9a into master Jul 3, 2018
@tombuildsstuff tombuildsstuff deleted the fix-lb-regression-1470 branch July 3, 2018 17:06
tombuildsstuff added a commit that referenced this pull request Jul 3, 2018
@ghost
Copy link

ghost commented Mar 30, 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 30, 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.

Possible regression on resource azurerm_lb with plugin 1.8
2 participants