Skip to content

Commit

Permalink
vlanid 0 is supported (#562)
Browse files Browse the repository at this point in the history
  • Loading branch information
Abhishekism9450 authored Apr 27, 2023
1 parent 758987e commit 658129e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
6 changes: 2 additions & 4 deletions nutanix/resource_nutanix_subnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -717,10 +717,8 @@ func getSubnetResources(d *schema.ResourceData, subnet *v3.SubnetResources) {
dhcpo.DomainSearchList = expandStringList(v.([]interface{}))
}

if v, ok := d.GetOk("vlan_id"); ok {
if v.(int) == 0 || ok {
subnet.VlanID = utils.Int64Ptr(int64(v.(int)))
}
if v, ok := d.GetOkExists("vlan_id"); ok {
subnet.VlanID = utils.Int64Ptr(int64(v.(int)))
}

if v, ok := d.GetOk("network_function_chain_reference"); ok {
Expand Down
18 changes: 18 additions & 0 deletions nutanix/resource_nutanix_subnet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,24 @@ func TestAccNutanixSubnet_nameDuplicated(t *testing.T) {
})
}

func TestAccNutanixSubnet_WithVlan0(t *testing.T) {
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckNutanixSubnetDestroy,
Steps: []resource.TestStep{
{
Config: testAccNutanixSubnetConfig(0),
Check: resource.ComposeTestCheckFunc(
testAccCheckNutanixSubnetExists(resourceNameSubnet),
resource.TestCheckResourceAttr(resourceNameSubnet, "name", "acctest-managed-0"),
resource.TestCheckResourceAttr(resourceNameSubnet, "description", "Description of my unit test VLAN"),
),
},
},
})
}

func testAccCheckNutanixSubnetExists(n string) resource.TestCheckFunc {
return func(s *terraform.State) error {
rs, ok := s.RootModule().Resources[n]
Expand Down

0 comments on commit 658129e

Please sign in to comment.