From 0eed9e556c42d9892303db4711fd967d7079557a Mon Sep 17 00:00:00 2001 From: danischm Date: Wed, 18 Oct 2023 21:00:57 +0200 Subject: [PATCH] Fix ospf feature template idempotency issue --- CHANGELOG.md | 1 + docs/guides/changelog.md | 1 + gen/templates/feature_templates/model.go | 15 ++++++++++++ .../model_sdwan_cisco_bgp_feature_template.go | 18 ++++++++++++++ ...model_sdwan_cisco_ospf_feature_template.go | 18 ++++++++++++++ ...ecure_internet_gateway_feature_template.go | 6 +++++ ...l_sdwan_cisco_security_feature_template.go | 12 ++++++++++ ...model_sdwan_cisco_snmp_feature_template.go | 3 +++ ...del_sdwan_cisco_system_feature_template.go | 3 +++ .../model_sdwan_cisco_vpn_feature_template.go | 12 ++++++++++ ...an_cisco_vpn_interface_feature_template.go | 24 +++++++++++++++++++ templates/guides/changelog.md.tmpl | 1 + 12 files changed, 114 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ccd9db6f..00eead7d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ - Fix issue with `sdwan_cisco_snmp_feature_template` resource when configuring SNMPv2 - Add `sdwan_device` data source - Add `sdwan_vedge_inventory` data source +- Fix idempotency issue with `sdwan_cisco_ospf_feature_template` resource when enabling `default_information_originate` ## 0.2.9 diff --git a/docs/guides/changelog.md b/docs/guides/changelog.md index 568ab5b0..3efb6193 100644 --- a/docs/guides/changelog.md +++ b/docs/guides/changelog.md @@ -13,6 +13,7 @@ description: |- - Fix issue with `sdwan_cisco_snmp_feature_template` resource when configuring SNMPv2 - Add `sdwan_device` data source - Add `sdwan_vedge_inventory` data source +- Fix idempotency issue with `sdwan_cisco_ospf_feature_template` resource when enabling `default_information_originate` ## 0.2.9 diff --git a/gen/templates/feature_templates/model.go b/gen/templates/feature_templates/model.go index b4e4883b..ad432e64 100644 --- a/gen/templates/feature_templates/model.go +++ b/gen/templates/feature_templates/model.go @@ -583,6 +583,11 @@ func (data *{{camelCase .Name}}) fromBody(ctx context.Context, res gjson.Result) data.{{toGoName .TfName}} = types.BoolValue(v.Bool()) {{if .Variable}}data.{{toGoName .TfName}}Variable = types.StringNull(){{end}} } + {{- if eq .ObjectType "node-only"}} + } else if value := res.Get(path + "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}"); value.Exists() { + data.{{toGoName .TfName}} = types.BoolValue(true) + {{if .Variable}}data.{{toGoName .TfName}}Variable = types.StringNull(){{end}} + {{- end}} } else { data.{{toGoName .TfName}} = types.BoolNull() {{if .Variable}}data.{{toGoName .TfName}}Variable = types.StringNull(){{end}} @@ -695,6 +700,11 @@ func (data *{{camelCase .Name}}) fromBody(ctx context.Context, res gjson.Result) item.{{toGoName .TfName}} = types.BoolValue(cv.Bool()) {{if .Variable}}item.{{toGoName .TfName}}Variable = types.StringNull(){{end}} } + {{- if eq .ObjectType "node-only"}} + } else if cValue := v.Get("{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}"); cValue.Exists() { + item.{{toGoName .TfName}} = types.BoolValue(true) + {{if .Variable}}item.{{toGoName .TfName}}Variable = types.StringNull(){{end}} + {{- end}} } else { item.{{toGoName .TfName}} = types.BoolNull() {{if .Variable}}item.{{toGoName .TfName}}Variable = types.StringNull(){{end}} @@ -806,6 +816,11 @@ func (data *{{camelCase .Name}}) fromBody(ctx context.Context, res gjson.Result) cItem.{{toGoName .TfName}} = types.BoolValue(ccv.Bool()) {{if .Variable}}cItem.{{toGoName .TfName}}Variable = types.StringNull(){{end}} } + {{- if eq .ObjectType "node-only"}} + } else if ccValue := cv.Get("{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}"); ccValue.Exists() { + cItem.{{toGoName .TfName}} = types.BoolValue(true) + {{if .Variable}}cItem.{{toGoName .TfName}}Variable = types.StringNull(){{end}} + {{- end}} } else { cItem.{{toGoName .TfName}} = types.BoolNull() {{if .Variable}}cItem.{{toGoName .TfName}}Variable = types.StringNull(){{end}} diff --git a/internal/provider/model_sdwan_cisco_bgp_feature_template.go b/internal/provider/model_sdwan_cisco_bgp_feature_template.go index ae2124e2..675b1fcb 100644 --- a/internal/provider/model_sdwan_cisco_bgp_feature_template.go +++ b/internal/provider/model_sdwan_cisco_bgp_feature_template.go @@ -2379,6 +2379,9 @@ func (data *CiscoBGP) fromBody(ctx context.Context, res gjson.Result) { cItem.AsSetPath = types.BoolValue(ccv.Bool()) cItem.AsSetPathVariable = types.StringNull() } + } else if ccValue := cv.Get("as-set"); ccValue.Exists() { + cItem.AsSetPath = types.BoolValue(true) + cItem.AsSetPathVariable = types.StringNull() } else { cItem.AsSetPath = types.BoolNull() cItem.AsSetPathVariable = types.StringNull() @@ -2398,6 +2401,9 @@ func (data *CiscoBGP) fromBody(ctx context.Context, res gjson.Result) { cItem.SummaryOnly = types.BoolValue(ccv.Bool()) cItem.SummaryOnlyVariable = types.StringNull() } + } else if ccValue := cv.Get("summary-only"); ccValue.Exists() { + cItem.SummaryOnly = types.BoolValue(true) + cItem.SummaryOnlyVariable = types.StringNull() } else { cItem.SummaryOnly = types.BoolNull() cItem.SummaryOnlyVariable = types.StringNull() @@ -2449,6 +2455,9 @@ func (data *CiscoBGP) fromBody(ctx context.Context, res gjson.Result) { cItem.AsSetPath = types.BoolValue(ccv.Bool()) cItem.AsSetPathVariable = types.StringNull() } + } else if ccValue := cv.Get("as-set"); ccValue.Exists() { + cItem.AsSetPath = types.BoolValue(true) + cItem.AsSetPathVariable = types.StringNull() } else { cItem.AsSetPath = types.BoolNull() cItem.AsSetPathVariable = types.StringNull() @@ -2468,6 +2477,9 @@ func (data *CiscoBGP) fromBody(ctx context.Context, res gjson.Result) { cItem.SummaryOnly = types.BoolValue(ccv.Bool()) cItem.SummaryOnlyVariable = types.StringNull() } + } else if ccValue := cv.Get("summary-only"); ccValue.Exists() { + cItem.SummaryOnly = types.BoolValue(true) + cItem.SummaryOnlyVariable = types.StringNull() } else { cItem.SummaryOnly = types.BoolNull() cItem.SummaryOnlyVariable = types.StringNull() @@ -2574,6 +2586,9 @@ func (data *CiscoBGP) fromBody(ctx context.Context, res gjson.Result) { item.DefaultInformationOriginate = types.BoolValue(cv.Bool()) item.DefaultInformationOriginateVariable = types.StringNull() } + } else if cValue := v.Get("default-information.originate"); cValue.Exists() { + item.DefaultInformationOriginate = types.BoolValue(true) + item.DefaultInformationOriginateVariable = types.StringNull() } else { item.DefaultInformationOriginate = types.BoolNull() item.DefaultInformationOriginateVariable = types.StringNull() @@ -2612,6 +2627,9 @@ func (data *CiscoBGP) fromBody(ctx context.Context, res gjson.Result) { item.TableMapFilter = types.BoolValue(cv.Bool()) item.TableMapFilterVariable = types.StringNull() } + } else if cValue := v.Get("table-map.filter"); cValue.Exists() { + item.TableMapFilter = types.BoolValue(true) + item.TableMapFilterVariable = types.StringNull() } else { item.TableMapFilter = types.BoolNull() item.TableMapFilterVariable = types.StringNull() diff --git a/internal/provider/model_sdwan_cisco_ospf_feature_template.go b/internal/provider/model_sdwan_cisco_ospf_feature_template.go index 2b9e839c..3557657a 100644 --- a/internal/provider/model_sdwan_cisco_ospf_feature_template.go +++ b/internal/provider/model_sdwan_cisco_ospf_feature_template.go @@ -849,6 +849,9 @@ func (data *CiscoOSPF) fromBody(ctx context.Context, res gjson.Result) { data.DefaultInformationOriginate = types.BoolValue(v.Bool()) } + } else if value := res.Get(path + "ospf.default-information.originate"); value.Exists() { + data.DefaultInformationOriginate = types.BoolValue(true) + } else { data.DefaultInformationOriginate = types.BoolNull() @@ -868,6 +871,9 @@ func (data *CiscoOSPF) fromBody(ctx context.Context, res gjson.Result) { data.DefaultInformationOriginateAlways = types.BoolValue(v.Bool()) data.DefaultInformationOriginateAlwaysVariable = types.StringNull() } + } else if value := res.Get(path + "ospf.default-information.originate.always"); value.Exists() { + data.DefaultInformationOriginateAlways = types.BoolValue(true) + data.DefaultInformationOriginateAlwaysVariable = types.StringNull() } else { data.DefaultInformationOriginateAlways = types.BoolNull() data.DefaultInformationOriginateAlwaysVariable = types.StringNull() @@ -1236,6 +1242,9 @@ func (data *CiscoOSPF) fromBody(ctx context.Context, res gjson.Result) { item.StubNoSummary = types.BoolValue(cv.Bool()) item.StubNoSummaryVariable = types.StringNull() } + } else if cValue := v.Get("stub.no-summary"); cValue.Exists() { + item.StubNoSummary = types.BoolValue(true) + item.StubNoSummaryVariable = types.StringNull() } else { item.StubNoSummary = types.BoolNull() item.StubNoSummaryVariable = types.StringNull() @@ -1255,6 +1264,9 @@ func (data *CiscoOSPF) fromBody(ctx context.Context, res gjson.Result) { item.NssaNoSummary = types.BoolValue(cv.Bool()) item.NssaNoSummaryVariable = types.StringNull() } + } else if cValue := v.Get("nssa.no-summary"); cValue.Exists() { + item.NssaNoSummary = types.BoolValue(true) + item.NssaNoSummaryVariable = types.StringNull() } else { item.NssaNoSummary = types.BoolNull() item.NssaNoSummaryVariable = types.StringNull() @@ -1416,6 +1428,9 @@ func (data *CiscoOSPF) fromBody(ctx context.Context, res gjson.Result) { cItem.PassiveInterface = types.BoolValue(ccv.Bool()) cItem.PassiveInterfaceVariable = types.StringNull() } + } else if ccValue := cv.Get("passive-interface"); ccValue.Exists() { + cItem.PassiveInterface = types.BoolValue(true) + cItem.PassiveInterfaceVariable = types.StringNull() } else { cItem.PassiveInterface = types.BoolNull() cItem.PassiveInterfaceVariable = types.StringNull() @@ -1543,6 +1558,9 @@ func (data *CiscoOSPF) fromBody(ctx context.Context, res gjson.Result) { cItem.NoAdvertise = types.BoolValue(ccv.Bool()) cItem.NoAdvertiseVariable = types.StringNull() } + } else if ccValue := cv.Get("no-advertise"); ccValue.Exists() { + cItem.NoAdvertise = types.BoolValue(true) + cItem.NoAdvertiseVariable = types.StringNull() } else { cItem.NoAdvertise = types.BoolNull() cItem.NoAdvertiseVariable = types.StringNull() diff --git a/internal/provider/model_sdwan_cisco_secure_internet_gateway_feature_template.go b/internal/provider/model_sdwan_cisco_secure_internet_gateway_feature_template.go index fb69d22a..e7b1ed0c 100644 --- a/internal/provider/model_sdwan_cisco_secure_internet_gateway_feature_template.go +++ b/internal/provider/model_sdwan_cisco_secure_internet_gateway_feature_template.go @@ -1059,6 +1059,9 @@ func (data *CiscoSecureInternetGateway) fromBody(ctx context.Context, res gjson. item.IpUnnumbered = types.BoolValue(cv.Bool()) } + } else if cValue := v.Get("ip.unnumbered"); cValue.Exists() { + item.IpUnnumbered = types.BoolValue(true) + } else { item.IpUnnumbered = types.BoolNull() @@ -1389,6 +1392,9 @@ func (data *CiscoSecureInternetGateway) fromBody(ctx context.Context, res gjson. item.IkePreSharedKeyDynamic = types.BoolValue(cv.Bool()) } + } else if cValue := v.Get("ike.authentication-type.pre-shared-key-dynamic"); cValue.Exists() { + item.IkePreSharedKeyDynamic = types.BoolValue(true) + } else { item.IkePreSharedKeyDynamic = types.BoolNull() diff --git a/internal/provider/model_sdwan_cisco_security_feature_template.go b/internal/provider/model_sdwan_cisco_security_feature_template.go index 54979259..92b20d73 100644 --- a/internal/provider/model_sdwan_cisco_security_feature_template.go +++ b/internal/provider/model_sdwan_cisco_security_feature_template.go @@ -779,6 +779,9 @@ func (data *CiscoSecurity) fromBody(ctx context.Context, res gjson.Result) { item.SendLifetime = types.BoolValue(cv.Bool()) item.SendLifetimeVariable = types.StringNull() } + } else if cValue := v.Get("send-lifetime.lifetime-group-v1.local"); cValue.Exists() { + item.SendLifetime = types.BoolValue(true) + item.SendLifetimeVariable = types.StringNull() } else { item.SendLifetime = types.BoolNull() item.SendLifetimeVariable = types.StringNull() @@ -865,6 +868,9 @@ func (data *CiscoSecurity) fromBody(ctx context.Context, res gjson.Result) { item.SendLifetimeInfinite = types.BoolValue(cv.Bool()) item.SendLifetimeInfiniteVariable = types.StringNull() } + } else if cValue := v.Get("send-lifetime.lifetime-group-v1.infinite"); cValue.Exists() { + item.SendLifetimeInfinite = types.BoolValue(true) + item.SendLifetimeInfiniteVariable = types.StringNull() } else { item.SendLifetimeInfinite = types.BoolNull() item.SendLifetimeInfiniteVariable = types.StringNull() @@ -884,6 +890,9 @@ func (data *CiscoSecurity) fromBody(ctx context.Context, res gjson.Result) { item.AcceptLifetime = types.BoolValue(cv.Bool()) item.AcceptLifetimeVariable = types.StringNull() } + } else if cValue := v.Get("accept-lifetime.lifetime-group-v1.local"); cValue.Exists() { + item.AcceptLifetime = types.BoolValue(true) + item.AcceptLifetimeVariable = types.StringNull() } else { item.AcceptLifetime = types.BoolNull() item.AcceptLifetimeVariable = types.StringNull() @@ -970,6 +979,9 @@ func (data *CiscoSecurity) fromBody(ctx context.Context, res gjson.Result) { item.AcceptLifetimeInfinite = types.BoolValue(cv.Bool()) item.AcceptLifetimeInfiniteVariable = types.StringNull() } + } else if cValue := v.Get("accept-lifetime.lifetime-group-v1.infinite"); cValue.Exists() { + item.AcceptLifetimeInfinite = types.BoolValue(true) + item.AcceptLifetimeInfiniteVariable = types.StringNull() } else { item.AcceptLifetimeInfinite = types.BoolNull() item.AcceptLifetimeInfiniteVariable = types.StringNull() diff --git a/internal/provider/model_sdwan_cisco_snmp_feature_template.go b/internal/provider/model_sdwan_cisco_snmp_feature_template.go index 9c60e390..6690ac11 100644 --- a/internal/provider/model_sdwan_cisco_snmp_feature_template.go +++ b/internal/provider/model_sdwan_cisco_snmp_feature_template.go @@ -669,6 +669,9 @@ func (data *CiscoSNMP) fromBody(ctx context.Context, res gjson.Result) { cItem.Exclude = types.BoolValue(ccv.Bool()) cItem.ExcludeVariable = types.StringNull() } + } else if ccValue := cv.Get("exclude"); ccValue.Exists() { + cItem.Exclude = types.BoolValue(true) + cItem.ExcludeVariable = types.StringNull() } else { cItem.Exclude = types.BoolNull() cItem.ExcludeVariable = types.StringNull() diff --git a/internal/provider/model_sdwan_cisco_system_feature_template.go b/internal/provider/model_sdwan_cisco_system_feature_template.go index 6c2ccaf9..d366a1af 100644 --- a/internal/provider/model_sdwan_cisco_system_feature_template.go +++ b/internal/provider/model_sdwan_cisco_system_feature_template.go @@ -1439,6 +1439,9 @@ func (data *CiscoSystem) fromBody(ctx context.Context, res gjson.Result) { data.MultiTenant = types.BoolValue(v.Bool()) data.MultiTenantVariable = types.StringNull() } + } else if value := res.Get(path + "multi-tenant"); value.Exists() { + data.MultiTenant = types.BoolValue(true) + data.MultiTenantVariable = types.StringNull() } else { data.MultiTenant = types.BoolNull() data.MultiTenantVariable = types.StringNull() diff --git a/internal/provider/model_sdwan_cisco_vpn_feature_template.go b/internal/provider/model_sdwan_cisco_vpn_feature_template.go index df751e2a..35dce680 100644 --- a/internal/provider/model_sdwan_cisco_vpn_feature_template.go +++ b/internal/provider/model_sdwan_cisco_vpn_feature_template.go @@ -2592,6 +2592,9 @@ func (data *CiscoVPN) fromBody(ctx context.Context, res gjson.Result) { item.Null0 = types.BoolValue(cv.Bool()) item.Null0Variable = types.StringNull() } + } else if cValue := v.Get("null0"); cValue.Exists() { + item.Null0 = types.BoolValue(true) + item.Null0Variable = types.StringNull() } else { item.Null0 = types.BoolNull() item.Null0Variable = types.StringNull() @@ -2649,6 +2652,9 @@ func (data *CiscoVPN) fromBody(ctx context.Context, res gjson.Result) { item.Dhcp = types.BoolValue(cv.Bool()) item.DhcpVariable = types.StringNull() } + } else if cValue := v.Get("dhcp"); cValue.Exists() { + item.Dhcp = types.BoolValue(true) + item.DhcpVariable = types.StringNull() } else { item.Dhcp = types.BoolNull() item.DhcpVariable = types.StringNull() @@ -2821,6 +2827,9 @@ func (data *CiscoVPN) fromBody(ctx context.Context, res gjson.Result) { item.Null0 = types.BoolValue(cv.Bool()) item.Null0Variable = types.StringNull() } + } else if cValue := v.Get("null0"); cValue.Exists() { + item.Null0 = types.BoolValue(true) + item.Null0Variable = types.StringNull() } else { item.Null0 = types.BoolNull() item.Null0Variable = types.StringNull() @@ -3372,6 +3381,9 @@ func (data *CiscoVPN) fromBody(ctx context.Context, res gjson.Result) { item.Overload = types.BoolValue(cv.Bool()) item.OverloadVariable = types.StringNull() } + } else if cValue := v.Get("overload"); cValue.Exists() { + item.Overload = types.BoolValue(true) + item.OverloadVariable = types.StringNull() } else { item.Overload = types.BoolNull() item.OverloadVariable = types.StringNull() diff --git a/internal/provider/model_sdwan_cisco_vpn_interface_feature_template.go b/internal/provider/model_sdwan_cisco_vpn_interface_feature_template.go index ef1ec479..612fa54a 100644 --- a/internal/provider/model_sdwan_cisco_vpn_interface_feature_template.go +++ b/internal/provider/model_sdwan_cisco_vpn_interface_feature_template.go @@ -2918,6 +2918,9 @@ func (data *CiscoVPNInterface) fromBody(ctx context.Context, res gjson.Result) { data.Nat = types.BoolValue(v.Bool()) data.NatVariable = types.StringNull() } + } else if value := res.Get(path + "nat"); value.Exists() { + data.Nat = types.BoolValue(true) + data.NatVariable = types.StringNull() } else { data.Nat = types.BoolNull() data.NatVariable = types.StringNull() @@ -3089,6 +3092,9 @@ func (data *CiscoVPNInterface) fromBody(ctx context.Context, res gjson.Result) { data.Ipv6Nat = types.BoolValue(v.Bool()) data.Ipv6NatVariable = types.StringNull() } + } else if value := res.Get(path + "nat64.enable"); value.Exists() { + data.Ipv6Nat = types.BoolValue(true) + data.Ipv6NatVariable = types.StringNull() } else { data.Ipv6Nat = types.BoolNull() data.Ipv6NatVariable = types.StringNull() @@ -3108,6 +3114,9 @@ func (data *CiscoVPNInterface) fromBody(ctx context.Context, res gjson.Result) { data.Nat64Interface = types.BoolValue(v.Bool()) data.Nat64InterfaceVariable = types.StringNull() } + } else if value := res.Get(path + "nat64"); value.Exists() { + data.Nat64Interface = types.BoolValue(true) + data.Nat64InterfaceVariable = types.StringNull() } else { data.Nat64Interface = types.BoolNull() data.Nat64InterfaceVariable = types.StringNull() @@ -3124,6 +3133,9 @@ func (data *CiscoVPNInterface) fromBody(ctx context.Context, res gjson.Result) { data.Nat66Interface = types.BoolValue(v.Bool()) } + } else if value := res.Get(path + "nat66"); value.Exists() { + data.Nat66Interface = types.BoolValue(true) + } else { data.Nat66Interface = types.BoolNull() @@ -3816,6 +3828,9 @@ func (data *CiscoVPNInterface) fromBody(ctx context.Context, res gjson.Result) { data.TunnelInterfaceColorRestrict = types.BoolValue(v.Bool()) data.TunnelInterfaceColorRestrictVariable = types.StringNull() } + } else if value := res.Get(path + "tunnel-interface.color.restrict"); value.Exists() { + data.TunnelInterfaceColorRestrict = types.BoolValue(true) + data.TunnelInterfaceColorRestrictVariable = types.StringNull() } else { data.TunnelInterfaceColorRestrict = types.BoolNull() data.TunnelInterfaceColorRestrictVariable = types.StringNull() @@ -5039,6 +5054,9 @@ func (data *CiscoVPNInterface) fromBody(ctx context.Context, res gjson.Result) { item.TrackOmp = types.BoolValue(cv.Bool()) } + } else if cValue := v.Get("track-omp"); cValue.Exists() { + item.TrackOmp = types.BoolValue(true) + } else { item.TrackOmp = types.BoolNull() @@ -5303,6 +5321,9 @@ func (data *CiscoVPNInterface) fromBody(ctx context.Context, res gjson.Result) { item.TrackOmp = types.BoolValue(cv.Bool()) item.TrackOmpVariable = types.StringNull() } + } else if cValue := v.Get("track-omp"); cValue.Exists() { + item.TrackOmp = types.BoolValue(true) + item.TrackOmpVariable = types.StringNull() } else { item.TrackOmp = types.BoolNull() item.TrackOmpVariable = types.StringNull() @@ -5428,6 +5449,9 @@ func (data *CiscoVPNInterface) fromBody(ctx context.Context, res gjson.Result) { data.StaticSgtTrusted = types.BoolValue(v.Bool()) } + } else if value := res.Get(path + "trustsec.static.trusted"); value.Exists() { + data.StaticSgtTrusted = types.BoolValue(true) + } else { data.StaticSgtTrusted = types.BoolNull() diff --git a/templates/guides/changelog.md.tmpl b/templates/guides/changelog.md.tmpl index 568ab5b0..3efb6193 100644 --- a/templates/guides/changelog.md.tmpl +++ b/templates/guides/changelog.md.tmpl @@ -13,6 +13,7 @@ description: |- - Fix issue with `sdwan_cisco_snmp_feature_template` resource when configuring SNMPv2 - Add `sdwan_device` data source - Add `sdwan_vedge_inventory` data source +- Fix idempotency issue with `sdwan_cisco_ospf_feature_template` resource when enabling `default_information_originate` ## 0.2.9