From 3e33368a2b02b465dcae16a1e11a686857a3fe2a Mon Sep 17 00:00:00 2001 From: Michael Dokolin Date: Wed, 1 Nov 2023 22:13:14 +0100 Subject: [PATCH] fix: Fix empty value check to handle default numeric values correctly --- docs/resources/interface_eoip.md | 2 +- routeros/mikrotik_serialize.go | 2 +- routeros/resource_interface_eoip.go | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/resources/interface_eoip.md b/docs/resources/interface_eoip.md index 7cfea4e9..11ade8c2 100644 --- a/docs/resources/interface_eoip.md +++ b/docs/resources/interface_eoip.md @@ -43,7 +43,7 @@ resource "routeros_interface_eoip" "eoip_tunnel1" { - `loop_protect_send_interval` (String) - `mtu` (String) Layer3 Maximum transmission unit ('auto', 0 .. 65535) - `remote_address` (String) IP address of the remote end of the tunnel. -- `tunnel_id` (String) Unique tunnel identifier, which must match the other side of the tunnel. +- `tunnel_id` (Number) Unique tunnel identifier, which must match the other side of the tunnel. ### Read-Only diff --git a/routeros/mikrotik_serialize.go b/routeros/mikrotik_serialize.go index a16ca62c..5b6faf25 100644 --- a/routeros/mikrotik_serialize.go +++ b/routeros/mikrotik_serialize.go @@ -48,7 +48,7 @@ func isEmpty(propName string, schemaProp *schema.Schema, d *schema.ResourceData, } return v.(string) == "" && confValue.IsNull() case schema.TypeInt: - return !d.HasChange(propName) + return confValue.IsNull() && schemaProp.Default == nil case schema.TypeBool: // If true, it is always not empty: if v.(bool) { diff --git a/routeros/resource_interface_eoip.go b/routeros/resource_interface_eoip.go index 81a6ccb6..b480fbfb 100644 --- a/routeros/resource_interface_eoip.go +++ b/routeros/resource_interface_eoip.go @@ -34,9 +34,9 @@ func ResourceInterfaceEoip() *schema.Resource { KeyRemoteAddress: PropRemoteAddressRw, KeyRunning: PropRunningRo, "tunnel_id": { - Type: schema.TypeString, + Type: schema.TypeInt, Optional: true, - Default: "0", + Default: 0, Description: "Unique tunnel identifier, which must match the other side of the tunnel.", }, }