Skip to content

Commit

Permalink
fix(network): remove computed flag from mtu attribute (#572)
Browse files Browse the repository at this point in the history
* chore(code): refactor & update network tests

* fix(network): remove `computed` flag from `mtu` attribute

* chore: revert accidentally committed files

* chore: update docs
  • Loading branch information
bpg authored Sep 20, 2023
1 parent 7d064a8 commit 5720fe4
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 38 deletions.
2 changes: 1 addition & 1 deletion docs/resources/virtual_environment_network_linux_bridge.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ resource "proxmox_virtual_environment_network_linux_bridge" "vmbr99" {
- `gateway6` (String) Default IPv6 gateway address.
- `mtu` (Number) The interface MTU.
- `ports` (List of String) The interface bridge ports.
- `vlan_aware` (Boolean) Whether the interface bridge is VLAN aware (defaults to `true`).
- `vlan_aware` (Boolean) Whether the interface bridge is VLAN aware (defaults to `false`).

### Read-Only

Expand Down
3 changes: 1 addition & 2 deletions fwprovider/resource_linux_bridge.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,6 @@ func (r *linuxBridgeResource) Schema(
"mtu": schema.Int64Attribute{
Description: "The interface MTU.",
Optional: true,
Computed: true,
},
"comment": schema.StringAttribute{
Description: "Comment for the interface.",
Expand All @@ -233,7 +232,7 @@ func (r *linuxBridgeResource) Schema(
ElementType: types.StringType,
},
"vlan_aware": schema.BoolAttribute{
Description: "Whether the interface bridge is VLAN aware (defaults to `true`).",
Description: "Whether the interface bridge is VLAN aware (defaults to `false`).",
Optional: true,
Computed: true,
},
Expand Down
1 change: 0 additions & 1 deletion fwprovider/resource_linux_vlan.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,6 @@ func (r *linuxVLANResource) Schema(
"mtu": schema.Int64Attribute{
Description: "The interface MTU.",
Optional: true,
Computed: true,
},
"comment": schema.StringAttribute{
Description: "Comment for the interface.",
Expand Down
30 changes: 15 additions & 15 deletions fwprovider/tests/resource_linux_bridge_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,53 +56,53 @@ func TestAccResourceLinuxBridge(t *testing.T) {
func testAccResourceLinuxBridgeCreatedConfig(name string, ipV4cidr string) string {
return fmt.Sprintf(`
resource "proxmox_virtual_environment_network_linux_bridge" "test" {
node_name = "%s"
name = "%s"
address = "%s"
comment = "created by terraform"
vlan_aware = true
autostart = true
comment = "created by terraform"
mtu = 1499
name = "%s"
node_name = "%s"
vlan_aware = true
}
`, accTestNodeName, name, ipV4cidr)
`, ipV4cidr, name, accTestNodeName)
}

func testAccResourceLinuxBridgeCreatedCheck(name string, ipV4cidr string) resource.TestCheckFunc {
return resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(accTestLinuxBridgeName, "name", name),
resource.TestCheckResourceAttr(accTestLinuxBridgeName, "address", ipV4cidr),
resource.TestCheckResourceAttr(accTestLinuxBridgeName, "comment", "created by terraform"),
resource.TestCheckResourceAttr(accTestLinuxBridgeName, "vlan_aware", "true"),
resource.TestCheckResourceAttr(accTestLinuxBridgeName, "autostart", "true"),
resource.TestCheckResourceAttr(accTestLinuxBridgeName, "comment", "created by terraform"),
resource.TestCheckResourceAttr(accTestLinuxBridgeName, "mtu", "1499"),
resource.TestCheckResourceAttr(accTestLinuxBridgeName, "name", name),
resource.TestCheckResourceAttr(accTestLinuxBridgeName, "vlan_aware", "true"),
resource.TestCheckResourceAttrSet(accTestLinuxBridgeName, "id"),
)
}

func testAccResourceLinuxBridgeUpdatedConfig(name string, ipV4cidr string, ipV6cidr string) string {
return fmt.Sprintf(`
resource "proxmox_virtual_environment_network_linux_bridge" "test" {
node_name = "%s"
name = "%s"
address = "%s"
address6 = "%s"
comment = "updated by terraform"
vlan_aware = false
autostart = false
comment = "updated by terraform"
mtu = null
name = "%s"
node_name = "%s"
vlan_aware = false
}
`, accTestNodeName, name, ipV4cidr, ipV6cidr)
`, ipV4cidr, ipV6cidr, name, accTestNodeName)
}

func testAccResourceLinuxBridgeUpdatedCheck(name string, ipV4cidr string, ipV6cidr string) resource.TestCheckFunc {
return resource.ComposeTestCheckFunc(
resource.ComposeAggregateTestCheckFunc(
resource.TestCheckResourceAttr(accTestLinuxBridgeName, "name", name),
resource.TestCheckResourceAttr(accTestLinuxBridgeName, "address", ipV4cidr),
resource.TestCheckResourceAttr(accTestLinuxBridgeName, "address6", ipV6cidr),
resource.TestCheckResourceAttr(accTestLinuxBridgeName, "autostart", "false"),
resource.TestCheckResourceAttr(accTestLinuxBridgeName, "comment", "updated by terraform"),
resource.TestCheckResourceAttr(accTestLinuxBridgeName, "name", name),
resource.TestCheckResourceAttr(accTestLinuxBridgeName, "vlan_aware", "false"),
resource.TestCheckResourceAttr(accTestLinuxBridgeName, "autostart", "false"),
resource.TestCheckNoResourceAttr(accTestLinuxBridgeName, "mtu"),
resource.TestCheckResourceAttrSet(accTestLinuxBridgeName, "id"),
),
Expand Down
37 changes: 18 additions & 19 deletions fwprovider/tests/resource_linux_vlan_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,70 +66,69 @@ func TestAccResourceLinuxVLAN(t *testing.T) {
func testAccResourceLinuxVLANCreatedConfig(iface string, vlan int) string {
return fmt.Sprintf(`
resource "proxmox_virtual_environment_network_linux_vlan" "test" {
node_name = "%s"
name = "%s.%d"
comment = "created by terraform"
mtu = 1499
name = "%s.%d"
node_name = "%s"
}
`, accTestNodeName, iface, vlan)
`, iface, vlan, accTestNodeName)
}

func testAccResourceLinuxVLANCreatedCheck(iface string, vlan int) resource.TestCheckFunc {
return resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(accTestLinuxVLANName, "name", fmt.Sprintf("%s.%d", iface, vlan)),
resource.TestCheckResourceAttr(accTestLinuxVLANName, "comment", "created by terraform"),
resource.TestCheckResourceAttr(accTestLinuxVLANName, "vlan", strconv.Itoa(vlan)),
resource.TestCheckResourceAttr(accTestLinuxVLANName, "interface", iface),
resource.TestCheckResourceAttr(accTestLinuxVLANName, "name", fmt.Sprintf("%s.%d", iface, vlan)),
resource.TestCheckResourceAttr(accTestLinuxVLANName, "vlan", strconv.Itoa(vlan)),
resource.TestCheckResourceAttrSet(accTestLinuxVLANName, "id"),
)
}

func testAccResourceLinuxVLANCustomNameCreatedConfig(name string, iface string, vlan int) string {
return fmt.Sprintf(`
resource "proxmox_virtual_environment_network_linux_vlan" "%s" {
node_name = "%s"
name = "%s"
interface = "%s"
vlan = %d
comment = "created by terraform"
interface = "%s"
mtu = 1499
name = "%s"
node_name = "%s"
vlan = %d
}
`, name, accTestNodeName, name, iface, vlan)
`, name, iface, name, accTestNodeName, vlan)
}

func testAccResourceLinuxVLANCustomNameCreatedCheck(name string, iface string, vlan int) resource.TestCheckFunc {
resourceName := fmt.Sprintf("proxmox_virtual_environment_network_linux_vlan.%s", name)

return resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(resourceName, "name", name),
resource.TestCheckResourceAttr(resourceName, "comment", "created by terraform"),
resource.TestCheckResourceAttr(resourceName, "vlan", strconv.Itoa(vlan)),
resource.TestCheckResourceAttr(resourceName, "interface", iface),
resource.TestCheckResourceAttr(resourceName, "name", name),
resource.TestCheckResourceAttr(resourceName, "vlan", strconv.Itoa(vlan)),
resource.TestCheckResourceAttrSet(resourceName, "id"),
)
}

func testAccResourceLinuxVLANUpdatedConfig(iface string, vlan int, ipV4cidr string) string {
return fmt.Sprintf(`
resource "proxmox_virtual_environment_network_linux_vlan" "test" {
node_name = "%s"
name = "%s.%d"
address = "%s"
address6 = "FE80:0000:0000:0000:0202:B3FF:FE1E:8329/64"
comment = "updated by terraform"
mtu = null
name = "%s.%d"
node_name = "%s"
}
`, accTestNodeName, iface, vlan, ipV4cidr)
`, ipV4cidr, iface, vlan, accTestNodeName)
}

func testAccResourceLinuxVLANUpdatedCheck(iface string, vlan int, ipV4cidr string) resource.TestCheckFunc {
return resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(accTestLinuxVLANName, "name", fmt.Sprintf("%s.%d", iface, vlan)),
resource.TestCheckResourceAttr(accTestLinuxVLANName, "vlan", strconv.Itoa(vlan)),
resource.TestCheckResourceAttr(accTestLinuxVLANName, "interface", iface),
resource.TestCheckResourceAttr(accTestLinuxVLANName, "address", ipV4cidr),
resource.TestCheckResourceAttr(accTestLinuxVLANName, "address6", "FE80:0000:0000:0000:0202:B3FF:FE1E:8329/64"),
resource.TestCheckResourceAttr(accTestLinuxVLANName, "comment", "updated by terraform"),
resource.TestCheckResourceAttr(accTestLinuxVLANName, "interface", iface),
resource.TestCheckResourceAttr(accTestLinuxVLANName, "name", fmt.Sprintf("%s.%d", iface, vlan)),
resource.TestCheckResourceAttr(accTestLinuxVLANName, "vlan", strconv.Itoa(vlan)),
resource.TestCheckNoResourceAttr(accTestLinuxVLANName, "mtu"),
resource.TestCheckResourceAttrSet(accTestLinuxVLANName, "id"),
)
Expand Down

0 comments on commit 5720fe4

Please sign in to comment.