Skip to content

Commit 3d58631

Browse files
authored
Resolve Issue #426 (#464)
1 parent 207231d commit 3d58631

14 files changed

+194
-204
lines changed

docs/resources/service_lan_vpn_interface_ethernet_feature.md

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -44,20 +44,9 @@ resource "sdwan_service_lan_vpn_interface_ethernet_feature" "example" {
4444
ipv4_nat_range_end = "4.5.6.7"
4545
ipv4_nat_prefix_length = 1
4646
ipv4_nat_overload = true
47-
ipv4_nat_loopback = "123"
48-
ipv4_nat_udp_timeout = 123
49-
ipv4_nat_tcp_timeout = 123
50-
static_nats = [
51-
{
52-
source_ip = "1.2.3.4"
53-
translate_ip = "2.3.4.5"
54-
direction = "inside"
55-
source_vpn = 0
56-
}
57-
]
58-
ipv6_nat = true
59-
nat64 = false
60-
acl_shaping_rate = 12
47+
ipv6_nat = true
48+
nat64 = false
49+
acl_shaping_rate = 12
6150
ipv6_vrrps = [
6251
{
6352
group_id = 1

examples/resources/sdwan_service_lan_vpn_interface_ethernet_feature/resource.tf

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,20 +27,9 @@ resource "sdwan_service_lan_vpn_interface_ethernet_feature" "example" {
2727
ipv4_nat_range_end = "4.5.6.7"
2828
ipv4_nat_prefix_length = 1
2929
ipv4_nat_overload = true
30-
ipv4_nat_loopback = "123"
31-
ipv4_nat_udp_timeout = 123
32-
ipv4_nat_tcp_timeout = 123
33-
static_nats = [
34-
{
35-
source_ip = "1.2.3.4"
36-
translate_ip = "2.3.4.5"
37-
direction = "inside"
38-
source_vpn = 0
39-
}
40-
]
41-
ipv6_nat = true
42-
nat64 = false
43-
acl_shaping_rate = 12
30+
ipv6_nat = true
31+
nat64 = false
32+
acl_shaping_rate = 12
4433
ipv6_vrrps = [
4534
{
4635
group_id = 1

gen/definitions/profile_parcels/service_lan_vpn_interface_ethernet.yaml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,34 +109,58 @@ attributes:
109109
- model_name: rangeStart
110110
tf_name: ipv4_nat_range_start
111111
data_path: [natAttributesIpv4, natPool]
112+
exclude_null: true
113+
# conditional_attribute:
114+
# name: Ipv4NatType
115+
# value: pool
112116
example: 1.2.3.4
113117
- model_name: rangeEnd
114118
tf_name: ipv4_nat_range_end
115119
data_path: [natAttributesIpv4, natPool]
120+
exclude_null: true
121+
# conditional_attribute:
122+
# name: Ipv4NatType
123+
# value: pool
116124
example: 4.5.6.7
117125
- model_name: prefixLength
118126
tf_name: ipv4_nat_prefix_length
119127
data_path: [natAttributesIpv4, natPool]
128+
exclude_null: true
129+
# conditional_attribute:
130+
# name: Ipv4NatType
131+
# value: pool
120132
example: 1
121133
- model_name: overload
122134
tf_name: ipv4_nat_overload
123135
data_path: [natAttributesIpv4, natPool]
136+
exclude_null: true
137+
# conditional_attribute:
138+
# name: Ipv4NatType
139+
# value: pool
124140
example: true
125141
- model_name: natLookback
126142
tf_name: ipv4_nat_loopback
127143
data_path: [natAttributesIpv4]
144+
exclude_test: true
145+
exclude_null: true
146+
# conditional_attribute:
147+
# name: Ipv4NatType
148+
# value: loopback
128149
example: 123
129150
- model_name: udpTimeout
130151
tf_name: ipv4_nat_udp_timeout
131152
data_path: [natAttributesIpv4]
153+
exclude_test: true
132154
example: 123
133155
- model_name: tcpTimeout
134156
tf_name: ipv4_nat_tcp_timeout
135157
data_path: [natAttributesIpv4]
158+
exclude_test: true
136159
example: 123
137160
- model_name: newStaticNat
138161
tf_name: static_nats
139162
data_path: [natAttributesIpv4]
163+
exclude_test: true
140164
attributes:
141165
- model_name: sourceIp
142166
id: true

internal/provider/data_source_sdwan_service_lan_vpn_feature.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424
"net/url"
2525

2626
"github.com/CiscoDevNet/terraform-provider-sdwan/internal/provider/helpers"
27+
"github.com/hashicorp/go-version"
2728
"github.com/hashicorp/terraform-plugin-framework/datasource"
2829
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
2930
"github.com/hashicorp/terraform-plugin-framework/types"
@@ -961,7 +962,6 @@ func (d *ServiceLANVPNProfileParcelDataSource) Configure(_ context.Context, req
961962

962963
// End of section. //template:end model
963964

964-
// Section below is generated&owned by "gen/generator.go". //template:begin read
965965
func (d *ServiceLANVPNProfileParcelDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) {
966966
var config ServiceLANVPN
967967

@@ -974,18 +974,19 @@ func (d *ServiceLANVPNProfileParcelDataSource) Read(ctx context.Context, req dat
974974

975975
tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Read", config.Id.String()))
976976

977+
// Get Manager Version
978+
currentVersion := version.Must(version.NewVersion(d.client.ManagerVersion))
979+
977980
res, err := d.client.Get(config.getPath() + "/" + url.QueryEscape(config.Id.ValueString()))
978981
if err != nil {
979982
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object, got error: %s", err))
980983
return
981984
}
982985

983-
config.fromBody(ctx, res)
986+
config.fromBody(ctx, res, currentVersion)
984987

985988
tflog.Debug(ctx, fmt.Sprintf("%s: Read finished successfully", config.Name.ValueString()))
986989

987990
diags = resp.State.Set(ctx, &config)
988991
resp.Diagnostics.Append(diags...)
989992
}
990-
991-
// End of section. //template:end read

internal/provider/data_source_sdwan_service_lan_vpn_interface_ethernet_feature.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424
"net/url"
2525

2626
"github.com/CiscoDevNet/terraform-provider-sdwan/internal/provider/helpers"
27+
"github.com/hashicorp/go-version"
2728
"github.com/hashicorp/terraform-plugin-framework/datasource"
2829
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
2930
"github.com/hashicorp/terraform-plugin-framework/types"
@@ -710,7 +711,6 @@ func (d *ServiceLANVPNInterfaceEthernetProfileParcelDataSource) Configure(_ cont
710711

711712
// End of section. //template:end model
712713

713-
// Section below is generated&owned by "gen/generator.go". //template:begin read
714714
func (d *ServiceLANVPNInterfaceEthernetProfileParcelDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) {
715715
var config ServiceLANVPNInterfaceEthernet
716716

@@ -723,18 +723,19 @@ func (d *ServiceLANVPNInterfaceEthernetProfileParcelDataSource) Read(ctx context
723723

724724
tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Read", config.Id.String()))
725725

726+
// Get Manager Version
727+
currentVersion := version.Must(version.NewVersion(d.client.ManagerVersion))
728+
726729
res, err := d.client.Get(config.getPath() + "/" + url.QueryEscape(config.Id.ValueString()))
727730
if err != nil {
728731
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object, got error: %s", err))
729732
return
730733
}
731734

732-
config.fromBody(ctx, res)
735+
config.fromBody(ctx, res, currentVersion)
733736

734737
tflog.Debug(ctx, fmt.Sprintf("%s: Read finished successfully", config.Name.ValueString()))
735738

736739
diags = resp.State.Set(ctx, &config)
737740
resp.Diagnostics.Append(diags...)
738741
}
739-
740-
// End of section. //template:end read

internal/provider/data_source_sdwan_service_lan_vpn_interface_ethernet_feature_test.go

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,6 @@ func TestAccDataSourceSdwanServiceLANVPNInterfaceEthernetProfileParcel(t *testin
4848
checks = append(checks, resource.TestCheckResourceAttr("data.sdwan_service_lan_vpn_interface_ethernet_feature.test", "ipv4_nat_range_end", "4.5.6.7"))
4949
checks = append(checks, resource.TestCheckResourceAttr("data.sdwan_service_lan_vpn_interface_ethernet_feature.test", "ipv4_nat_prefix_length", "1"))
5050
checks = append(checks, resource.TestCheckResourceAttr("data.sdwan_service_lan_vpn_interface_ethernet_feature.test", "ipv4_nat_overload", "true"))
51-
checks = append(checks, resource.TestCheckResourceAttr("data.sdwan_service_lan_vpn_interface_ethernet_feature.test", "ipv4_nat_loopback", "123"))
52-
checks = append(checks, resource.TestCheckResourceAttr("data.sdwan_service_lan_vpn_interface_ethernet_feature.test", "ipv4_nat_udp_timeout", "123"))
53-
checks = append(checks, resource.TestCheckResourceAttr("data.sdwan_service_lan_vpn_interface_ethernet_feature.test", "ipv4_nat_tcp_timeout", "123"))
54-
checks = append(checks, resource.TestCheckResourceAttr("data.sdwan_service_lan_vpn_interface_ethernet_feature.test", "static_nats.0.source_ip", "1.2.3.4"))
55-
checks = append(checks, resource.TestCheckResourceAttr("data.sdwan_service_lan_vpn_interface_ethernet_feature.test", "static_nats.0.translate_ip", "2.3.4.5"))
56-
checks = append(checks, resource.TestCheckResourceAttr("data.sdwan_service_lan_vpn_interface_ethernet_feature.test", "static_nats.0.direction", "inside"))
57-
checks = append(checks, resource.TestCheckResourceAttr("data.sdwan_service_lan_vpn_interface_ethernet_feature.test", "static_nats.0.source_vpn", "0"))
5851
checks = append(checks, resource.TestCheckResourceAttr("data.sdwan_service_lan_vpn_interface_ethernet_feature.test", "ipv6_nat", "true"))
5952
checks = append(checks, resource.TestCheckResourceAttr("data.sdwan_service_lan_vpn_interface_ethernet_feature.test", "nat64", "false"))
6053
checks = append(checks, resource.TestCheckResourceAttr("data.sdwan_service_lan_vpn_interface_ethernet_feature.test", "acl_shaping_rate", "12"))
@@ -167,15 +160,6 @@ func testAccDataSourceSdwanServiceLANVPNInterfaceEthernetProfileParcelConfig() s
167160
config += ` ipv4_nat_range_end = "4.5.6.7"` + "\n"
168161
config += ` ipv4_nat_prefix_length = 1` + "\n"
169162
config += ` ipv4_nat_overload = true` + "\n"
170-
config += ` ipv4_nat_loopback = "123"` + "\n"
171-
config += ` ipv4_nat_udp_timeout = 123` + "\n"
172-
config += ` ipv4_nat_tcp_timeout = 123` + "\n"
173-
config += ` static_nats = [{` + "\n"
174-
config += ` source_ip = "1.2.3.4"` + "\n"
175-
config += ` translate_ip = "2.3.4.5"` + "\n"
176-
config += ` direction = "inside"` + "\n"
177-
config += ` source_vpn = 0` + "\n"
178-
config += ` }]` + "\n"
179163
config += ` ipv6_nat = true` + "\n"
180164
config += ` nat64 = false` + "\n"
181165
config += ` acl_shaping_rate = 12` + "\n"

internal/provider/data_source_sdwan_transport_wan_vpn_interface_ethernet_feature.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424
"net/url"
2525

2626
"github.com/CiscoDevNet/terraform-provider-sdwan/internal/provider/helpers"
27+
"github.com/hashicorp/go-version"
2728
"github.com/hashicorp/terraform-plugin-framework/datasource"
2829
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
2930
"github.com/hashicorp/terraform-plugin-framework/types"
@@ -1007,7 +1008,6 @@ func (d *TransportWANVPNInterfaceEthernetProfileParcelDataSource) Configure(_ co
10071008

10081009
// End of section. //template:end model
10091010

1010-
// Section below is generated&owned by "gen/generator.go". //template:begin read
10111011
func (d *TransportWANVPNInterfaceEthernetProfileParcelDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) {
10121012
var config TransportWANVPNInterfaceEthernet
10131013

@@ -1020,18 +1020,19 @@ func (d *TransportWANVPNInterfaceEthernetProfileParcelDataSource) Read(ctx conte
10201020

10211021
tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Read", config.Id.String()))
10221022

1023+
// Get Manager Version
1024+
currentVersion := version.Must(version.NewVersion(d.client.ManagerVersion))
1025+
10231026
res, err := d.client.Get(config.getPath() + "/" + url.QueryEscape(config.Id.ValueString()))
10241027
if err != nil {
10251028
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object, got error: %s", err))
10261029
return
10271030
}
10281031

1029-
config.fromBody(ctx, res)
1032+
config.fromBody(ctx, res, currentVersion)
10301033

10311034
tflog.Debug(ctx, fmt.Sprintf("%s: Read finished successfully", config.Name.ValueString()))
10321035

10331036
diags = resp.State.Set(ctx, &config)
10341037
resp.Diagnostics.Append(diags...)
10351038
}
1036-
1037-
// End of section. //template:end read

0 commit comments

Comments
 (0)