Skip to content

Commit

Permalink
Public IP: ensuring the casing matches
Browse files Browse the repository at this point in the history
  • Loading branch information
tombuildsstuff committed Nov 12, 2018
1 parent ffae417 commit b56ded8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 24 deletions.
6 changes: 2 additions & 4 deletions azurerm/resource_arm_public_ip.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,15 +230,13 @@ func resourceArmPublicIpRead(d *schema.ResourceData, meta interface{}) error {
d.Set("location", azureRMNormalizeLocation(*location))
}

d.Set("public_ip_address_allocation", strings.ToLower(string(resp.PublicIPAddressPropertiesFormat.PublicIPAllocationMethod)))

if sku := resp.Sku; sku != nil {
d.Set("sku", string(sku.Name))
}

if props := resp.PublicIPAddressPropertiesFormat; props != nil {
d.Set("public_ip_address_allocation", strings.ToLower(string(props.PublicIPAllocationMethod)))
d.Set("ip_version", strings.ToLower(string(props.PublicIPAddressVersion)))
d.Set("public_ip_address_allocation", string(props.PublicIPAllocationMethod))
d.Set("ip_version", string(props.PublicIPAddressVersion))

if settings := props.DNSSettings; settings != nil {
d.Set("fqdn", settings.Fqdn)
Expand Down
37 changes: 17 additions & 20 deletions azurerm/resource_arm_public_ip_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ func TestAccAzureRMPublicIpStatic_basic(t *testing.T) {
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMPublicIpExists(resourceName),
resource.TestCheckResourceAttrSet(resourceName, "ip_address"),
resource.TestCheckResourceAttr(resourceName, "public_ip_address_allocation", "static"),
resource.TestCheckResourceAttr(resourceName, "public_ip_address_allocation", "Static"),
resource.TestCheckResourceAttr(resourceName, "ip_version", "IPv4"),
),
},
{
Expand All @@ -53,7 +54,7 @@ func TestAccAzureRMPublicIpStatic_zones(t *testing.T) {
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMPublicIpExists(resourceName),
resource.TestCheckResourceAttrSet(resourceName, "ip_address"),
resource.TestCheckResourceAttr(resourceName, "public_ip_address_allocation", "static"),
resource.TestCheckResourceAttr(resourceName, "public_ip_address_allocation", "Static"),
resource.TestCheckResourceAttr(resourceName, "zones.#", "1"),
resource.TestCheckResourceAttr(resourceName, "zones.0", "1"),
),
Expand Down Expand Up @@ -83,7 +84,7 @@ func TestAccAzureRMPublicIpStatic_basic_withDNSLabel(t *testing.T) {
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMPublicIpExists(resourceName),
resource.TestCheckResourceAttrSet(resourceName, "ip_address"),
resource.TestCheckResourceAttr(resourceName, "public_ip_address_allocation", "static"),
resource.TestCheckResourceAttr(resourceName, "public_ip_address_allocation", "Static"),
resource.TestCheckResourceAttr(resourceName, "domain_name_label", dnl),
),
},
Expand Down Expand Up @@ -128,7 +129,7 @@ func TestAccAzureRMPublicIpDynamic_basic_withIPv6(t *testing.T) {
Config: config,
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMPublicIpExists(resourceName),
resource.TestCheckResourceAttr(resourceName, "ip_version", "ipv6"), //api returns all lowercase
resource.TestCheckResourceAttr(resourceName, "ip_version", "IPv6"),
),
},
{
Expand All @@ -155,7 +156,7 @@ func TestAccAzureRMPublicIpStatic_basic_defaultsToIPv4(t *testing.T) {
Config: config,
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMPublicIpExists(resourceName),
resource.TestCheckResourceAttr(resourceName, "ip_version", "ipv4"),
resource.TestCheckResourceAttr(resourceName, "ip_version", "IPv4"),
),
},
{
Expand All @@ -181,7 +182,7 @@ func TestAccAzureRMPublicIpStatic_basic_withIPv4(t *testing.T) {
Config: config,
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMPublicIpExists(resourceName),
resource.TestCheckResourceAttr(resourceName, "ip_version", "ipv4"),
resource.TestCheckResourceAttr(resourceName, "ip_version", "IPv4"),
),
},
{
Expand Down Expand Up @@ -502,11 +503,10 @@ resource "azurerm_resource_group" "test" {
}
resource "azurerm_public_ip" "test" {
name = "acctestpublicip-%d"
location = "${azurerm_resource_group.test.location}"
resource_group_name = "${azurerm_resource_group.test.name}"
public_ip_address_allocation = "static"
name = "acctestpublicip-%d"
location = "${azurerm_resource_group.test.location}"
resource_group_name = "${azurerm_resource_group.test.name}"
public_ip_address_allocation = "Static"
}
`, rInt, location, rInt)
}
Expand All @@ -522,9 +522,8 @@ resource "azurerm_public_ip" "test" {
name = "acctestpublicip-%d"
location = "${azurerm_resource_group.test.location}"
resource_group_name = "${azurerm_resource_group.test.name}"
public_ip_address_allocation = "static"
zones = ["1"]
public_ip_address_allocation = "Static"
zones = ["1"]
}
`, rInt, location, rInt)
}
Expand All @@ -540,9 +539,8 @@ resource "azurerm_public_ip" "test" {
name = "acctestpublicip-%d"
location = "${azurerm_resource_group.test.location}"
resource_group_name = "${azurerm_resource_group.test.name}"
public_ip_address_allocation = "static"
domain_name_label = "%s"
public_ip_address_allocation = "Static"
domain_name_label = "%s"
}
`, rInt, location, rInt, dnsNameLabel)
}
Expand All @@ -558,9 +556,8 @@ resource "azurerm_public_ip" "test" {
name = "acctestpublicip-%d"
location = "${azurerm_resource_group.test.location}"
resource_group_name = "${azurerm_resource_group.test.name}"
public_ip_address_allocation = "static"
ip_version = "%s"
public_ip_address_allocation = "Static"
ip_version = "%s"
}
`, rInt, location, rInt, ipVersion)
}
Expand Down

0 comments on commit b56ded8

Please sign in to comment.