From 13a006d9736fc73c3d00580c11cbe7a483996925 Mon Sep 17 00:00:00 2001 From: Vaerh Date: Sun, 14 May 2023 22:30:16 +0300 Subject: [PATCH] chore: Add a helper for the MAC address property --- routeros/provider_schema_helpers.go | 6 ++++++ routeros/resource_interface_bridge.go | 5 +---- routeros/resource_interface_vlan.go | 11 ++++------- routeros/resource_interface_vrrp.go | 9 +++------ routeros/resource_ovpn_server.go | 1 + 5 files changed, 15 insertions(+), 17 deletions(-) diff --git a/routeros/provider_schema_helpers.go b/routeros/provider_schema_helpers.go index c71464b7..620fabd2 100644 --- a/routeros/provider_schema_helpers.go +++ b/routeros/provider_schema_helpers.go @@ -31,6 +31,7 @@ const ( KeyInterface = "interface" KeyInvalid = "invalid" KeyL2Mtu = "l2mtu" + KeyMacAddress = "mac_address" KeyMtu = "mtu" KeyName = "name" KeyPlaceBefore = "place_before" @@ -157,6 +158,11 @@ var ( Computed: true, Description: "Layer2 Maximum transmission unit.", } + PropMacAddressRo = &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "Current mac address.", + } PropNameForceNewRw = &schema.Schema{ Type: schema.TypeString, Required: true, diff --git a/routeros/resource_interface_bridge.go b/routeros/resource_interface_bridge.go index ae93a0d2..49b15832 100644 --- a/routeros/resource_interface_bridge.go +++ b/routeros/resource_interface_bridge.go @@ -124,10 +124,7 @@ func ResourceInterfaceBridge() *schema.Resource { "forwarding a certain multicast stream. This property only has effect when igmp-snooping is set to yes.", RequiredWith: []string{"igmp_snooping"}, }, - "mac_address": { - Type: schema.TypeString, - Computed: true, - }, + KeyMacAddress: PropMacAddressRo, "max_hops": { Type: schema.TypeInt, Optional: true, diff --git a/routeros/resource_interface_vlan.go b/routeros/resource_interface_vlan.go index 85c06f96..4d9641f5 100644 --- a/routeros/resource_interface_vlan.go +++ b/routeros/resource_interface_vlan.go @@ -41,13 +41,10 @@ func ResourceInterfaceVlan() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "mac_address": { - Type: schema.TypeString, - Computed: true, - }, - KeyMtu: PropMtuRw(), - KeyName: PropNameForceNewRw, - KeyRunning: PropRunningRo, + KeyMacAddress: PropMacAddressRo, + KeyMtu: PropMtuRw(), + KeyName: PropNameForceNewRw, + KeyRunning: PropRunningRo, "use_service_tag": { Type: schema.TypeBool, Optional: true, diff --git a/routeros/resource_interface_vrrp.go b/routeros/resource_interface_vrrp.go index f200e7dd..043f6941 100644 --- a/routeros/resource_interface_vrrp.go +++ b/routeros/resource_interface_vrrp.go @@ -84,12 +84,9 @@ func ResourceInterfaceVrrp() *schema.Resource { Type: schema.TypeBool, Computed: true, }, - "mac_address": { - Type: schema.TypeString, - Computed: true, - }, - KeyMtu: PropMtuRw(), - KeyName: PropNameForceNewRw, + KeyMacAddress: PropMacAddressRo, + KeyMtu: PropMtuRw(), + KeyName: PropNameForceNewRw, "on_fail": { Type: schema.TypeString, Optional: true, diff --git a/routeros/resource_ovpn_server.go b/routeros/resource_ovpn_server.go index a77b5913..99cf1f8b 100644 --- a/routeros/resource_ovpn_server.go +++ b/routeros/resource_ovpn_server.go @@ -90,6 +90,7 @@ func ResourceOpenVPNServer() *schema.Resource { "disconnected", DiffSuppressFunc: TimeEquall, }, + // Computed only??? "mac_address": { Type: schema.TypeString, Optional: true,