From de9f231ed56a6369815535a984d4b58beaa673eb Mon Sep 17 00:00:00 2001 From: Sean Conroy Date: Tue, 13 Aug 2024 12:30:05 +0100 Subject: [PATCH] Resolve issue #284 --- ...transport_management_vpn_profile_parcel.md | 1 + ...transport_management_vpn_profile_parcel.md | 6 ++++- .../resource.tf | 3 ++- .../transport_management_vpn.yaml | 21 ++++++++++++++++++ gen/templates/profile_parcels/model.go | 22 +++++++++---------- ...transport_management_vpn_profile_parcel.go | 4 ++++ ...port_management_vpn_profile_parcel_test.go | 2 ++ ...transport_management_vpn_profile_parcel.go | 16 +++++++++----- ...transport_management_vpn_profile_parcel.go | 9 +++++++- ...port_management_vpn_profile_parcel_test.go | 2 ++ 10 files changed, 67 insertions(+), 19 deletions(-) diff --git a/docs/data-sources/transport_management_vpn_profile_parcel.md b/docs/data-sources/transport_management_vpn_profile_parcel.md index ad1076c9..c324cc99 100644 --- a/docs/data-sources/transport_management_vpn_profile_parcel.md +++ b/docs/data-sources/transport_management_vpn_profile_parcel.md @@ -83,6 +83,7 @@ Read-Only: - `null0` (Boolean) IPv6 Route Gateway Next Hop - `prefix` (String) Prefix - `prefix_variable` (String) Variable name +- `route_type` (String) Must be set to configure either next_hop, null0 or nat. ### Nested Schema for `ipv6_static_routes.next_hops` diff --git a/docs/resources/transport_management_vpn_profile_parcel.md b/docs/resources/transport_management_vpn_profile_parcel.md index 5fd65793..57b3da2b 100644 --- a/docs/resources/transport_management_vpn_profile_parcel.md +++ b/docs/resources/transport_management_vpn_profile_parcel.md @@ -46,7 +46,8 @@ resource "sdwan_transport_management_vpn_profile_parcel" "example" { ] ipv6_static_routes = [ { - prefix = "2002::/16" + prefix = "2002::/16" + route_type = "next_hop" next_hops = [ { address = "2001:0:0:1::1" @@ -133,6 +134,8 @@ Optional: - `null0` (Boolean) IPv6 Route Gateway Next Hop - `prefix` (String) Prefix - `prefix_variable` (String) Variable name +- `route_type` (String) Must be set to configure either next_hop, null0 or nat. + - Choices: `next_hop`, `null0`, `nat` ### Nested Schema for `ipv6_static_routes.next_hops` @@ -143,6 +146,7 @@ Optional: - `address_variable` (String) Variable name - `administrative_distance` (Number) Administrative distance - Range: `1`-`254` + - Default value: `1` - `administrative_distance_variable` (String) Variable name diff --git a/examples/resources/sdwan_transport_management_vpn_profile_parcel/resource.tf b/examples/resources/sdwan_transport_management_vpn_profile_parcel/resource.tf index 2c8b737a..da342a5d 100644 --- a/examples/resources/sdwan_transport_management_vpn_profile_parcel/resource.tf +++ b/examples/resources/sdwan_transport_management_vpn_profile_parcel/resource.tf @@ -29,7 +29,8 @@ resource "sdwan_transport_management_vpn_profile_parcel" "example" { ] ipv6_static_routes = [ { - prefix = "2002::/16" + prefix = "2002::/16" + route_type = "next_hop" next_hops = [ { address = "2001:0:0:1::1" diff --git a/gen/definitions/profile_parcels/transport_management_vpn.yaml b/gen/definitions/profile_parcels/transport_management_vpn.yaml index 1cc5c0f9..453529c8 100644 --- a/gen/definitions/profile_parcels/transport_management_vpn.yaml +++ b/gen/definitions/profile_parcels/transport_management_vpn.yaml @@ -65,11 +65,15 @@ attributes: - model_name: distance tf_name: administrative_distance example: 1 + default_value: 1 + default_value_present: true - model_name: distance tf_name: administrative_distance conditional_attribute: name: gateway value: null0 + default_value: 1 + default_value_present: true example: 1 - model_name: ipv6Route tf_name: ipv6_static_routes @@ -77,10 +81,19 @@ attributes: - model_name: prefix id: true example: 2002::/16 + - tf_name: route_type + type: String + tf_only: true + description: Must be set to configure either next_hop, null0 or nat. + enum_values: [next_hop, null0, nat] + example: next_hop - model_name: nextHop tf_name: next_hops data_path: [oneOfIpRoute, nextHopContainer] mandatory: true + conditional_attribute: + name: route_type + value: next_hop attributes: - model_name: address id: true @@ -88,13 +101,21 @@ attributes: - model_name: distance tf_name: administrative_distance example: 1 + default_value: 1 + default_value_present: true - model_name: null0 data_path: [oneOfIpRoute] exclude_test: true + conditional_attribute: + name: route_type + value: null0 example: true - model_name: nat data_path: [oneOfIpRoute] exclude_test: true + conditional_attribute: + name: route_type + value: nat example: NAT64 test_prerequisites: | diff --git a/gen/templates/profile_parcels/model.go b/gen/templates/profile_parcels/model.go index e3f7682c..45d41fb3 100644 --- a/gen/templates/profile_parcels/model.go +++ b/gen/templates/profile_parcels/model.go @@ -165,7 +165,7 @@ func (data {{camelCase .Name}}) toBody(ctx context.Context) string { body, _ = sjson.Set(body, path+"{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}.optionType", "default") body, _ = sjson.Set(body, path+"{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}.value", {{if eq .Type "String"}}"{{end}}{{.Value}}{{if eq .Type "String"}}"{{end}}) } - {{- else if and (or (eq .Type "String") (eq .Type "Int64") (eq .Type "Float64") (eq .Type "Bool") (isListSet .)) (not .Reference)}} + {{- else if and (or (eq .Type "String") (eq .Type "Int64") (eq .Type "Float64") (eq .Type "Bool") (isListSet .)) (not .TfOnly) (not .Reference)}} {{if .Variable}} if !data.{{toGoName .TfName}}Variable.IsNull() { if true{{if ne .ConditionalAttribute.Name ""}} {{if eq .ConditionalAttribute.Type "Bool"}} && data.{{toGoName .ConditionalAttribute.Name}}.ValueBool() == {{.ConditionalAttribute.Value}} {{else}} && data.{{toGoName .ConditionalAttribute.Name}}.ValueString() == "{{.ConditionalAttribute.Value}}" {{end}}{{end}} { @@ -200,7 +200,7 @@ func (data {{camelCase .Name}}) toBody(ctx context.Context) string { itemBody, _ = sjson.Set(itemBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}.optionType", "default") itemBody, _ = sjson.Set(itemBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}.value", {{if eq .Type "String"}}"{{end}}{{.Value}}{{if eq .Type "String"}}"{{end}}) } - {{- else if or (eq .Type "String") (eq .Type "Int64") (eq .Type "Float64") (eq .Type "Bool") (isListSet .)}} + {{- else if and (or (eq .Type "String") (eq .Type "Int64") (eq .Type "Float64") (eq .Type "Bool") (isListSet .)) (not .TfOnly)}} {{if .Variable}} if !item.{{toGoName .TfName}}Variable.IsNull() { if true{{if ne .ConditionalAttribute.Name ""}} {{if eq .ConditionalAttribute.Type "Bool"}} && item.{{toGoName .ConditionalAttribute.Name}}.ValueBool() == {{.ConditionalAttribute.Value}} {{else}} && item.{{toGoName .ConditionalAttribute.Name}}.ValueString() == "{{.ConditionalAttribute.Value}}" {{end}}{{end}} { @@ -270,7 +270,7 @@ func (data {{camelCase .Name}}) toBody(ctx context.Context) string { itemChildChildBody, _ = sjson.Set(itemChildChildBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}.optionType", "default") itemChildChildBody, _ = sjson.Set(itemChildChildBody, "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}.value", {{if eq .Type "String"}}"{{end}}{{.Value}}{{if eq .Type "String"}}"{{end}}) } - {{- else if or (eq .Type "String") (eq .Type "Int64") (eq .Type "Float64") (eq .Type "Bool") (isListSet .)}} + {{- else if and (or (eq .Type "String") (eq .Type "Int64") (eq .Type "Float64") (eq .Type "Bool") (isListSet .)) (not .TfOnly)}} {{if .Variable}} if !childChildItem.{{toGoName .TfName}}Variable.IsNull() { if true{{if ne .ConditionalAttribute.Name ""}} {{if eq .ConditionalAttribute.Type "Bool"}} && childChildItem.{{toGoName .ConditionalAttribute.Name}}.ValueBool() == {{.ConditionalAttribute.Value}} {{else}} && childChildItem.{{toGoName .ConditionalAttribute.Name}}.ValueString() == "{{.ConditionalAttribute.Value}}" {{end}}{{end}} { @@ -325,7 +325,7 @@ func (data *{{camelCase .Name}}) fromBody(ctx context.Context, res gjson.Result) path := "payload.data." {{- range .Attributes}} {{- $cname := toGoName .TfName}} - {{- if and (or (eq .Type "String") (eq .Type "Int64") (eq .Type "Float64") (eq .Type "Bool") (isListSet .)) (not .Reference) (not .WriteOnly) (not .Value)}} + {{- if and (or (eq .Type "String") (eq .Type "Int64") (eq .Type "Float64") (eq .Type "Bool") (isListSet .)) (not .Reference) (not .TfOnly) (not .WriteOnly) (not .Value)}} data.{{toGoName .TfName}} = types.{{.Type}}Null({{if isListSet .}}types.{{.ElementType}}Type{{end}}) {{ if .Variable}}data.{{toGoName .TfName}}Variable = types.StringNull(){{end}} if t := res.Get(path + "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}.optionType"); t.Exists() { @@ -343,7 +343,7 @@ func (data *{{camelCase .Name}}) fromBody(ctx context.Context, res gjson.Result) item := {{$name}}{{toGoName .TfName}}{} {{- range .Attributes}} {{- $ccname := toGoName .TfName}} - {{- if and (or (eq .Type "String") (eq .Type "Int64") (eq .Type "Float64") (eq .Type "Bool") (isListSet .)) (not .Reference) (not .WriteOnly) (not .Value)}} + {{- if and (or (eq .Type "String") (eq .Type "Int64") (eq .Type "Float64") (eq .Type "Bool") (isListSet .)) (not .Reference) (not .TfOnly) (not .WriteOnly) (not .Value)}} item.{{toGoName .TfName}} = types.{{.Type}}Null({{if isListSet .}}types.{{.ElementType}}Type{{end}}) {{ if .Variable}}item.{{toGoName .TfName}}Variable = types.StringNull(){{end}} if t := v.Get("{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}.optionType"); t.Exists() { @@ -360,7 +360,7 @@ func (data *{{camelCase .Name}}) fromBody(ctx context.Context, res gjson.Result) cValue.ForEach(func(ck, cv gjson.Result) bool { cItem := {{$name}}{{$cname}}{{toGoName .TfName}}{} {{- range .Attributes}} - {{- if and (or (eq .Type "String") (eq .Type "Int64") (eq .Type "Float64") (eq .Type "Bool") (isListSet .)) (not .Reference) (not .WriteOnly) (not .Value)}} + {{- if and (or (eq .Type "String") (eq .Type "Int64") (eq .Type "Float64") (eq .Type "Bool") (isListSet .)) (not .Reference) (not .TfOnly) (not .WriteOnly) (not .Value)}} cItem.{{toGoName .TfName}} = types.{{.Type}}Null({{if isListSet .}}types.{{.ElementType}}Type{{end}}) {{ if .Variable}}cItem.{{toGoName .TfName}}Variable = types.StringNull(){{end}} if t := cv.Get("{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}.optionType"); t.Exists() { @@ -377,7 +377,7 @@ func (data *{{camelCase .Name}}) fromBody(ctx context.Context, res gjson.Result) ccValue.ForEach(func(cck, ccv gjson.Result) bool { ccItem := {{$name}}{{$cname}}{{$ccname}}{{toGoName .TfName}}{} {{- range .Attributes}} - {{- if and (or (eq .Type "String") (eq .Type "Int64") (eq .Type "Float64") (eq .Type "Bool") (isListSet .)) (not .Reference) (not .WriteOnly) (not .Value)}} + {{- if and (or (eq .Type "String") (eq .Type "Int64") (eq .Type "Float64") (eq .Type "Bool") (isListSet .)) (not .Reference) (not .TfOnly) (not .WriteOnly) (not .Value)}} ccItem.{{toGoName .TfName}} = types.{{.Type}}Null({{if isListSet .}}types.{{.ElementType}}Type{{end}}) {{ if .Variable}}ccItem.{{toGoName .TfName}}Variable = types.StringNull(){{end}} if t := ccv.Get("{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}.optionType"); t.Exists() { @@ -421,7 +421,7 @@ func (data *{{camelCase .Name}}) updateFromBody(ctx context.Context, res gjson.R } path := "payload.data." {{- range .Attributes}} - {{- if and (or (eq .Type "String") (eq .Type "Int64") (eq .Type "Float64") (eq .Type "Bool") (isListSet .)) (not .Reference) (not .WriteOnly) (not .Value)}} + {{- if and (or (eq .Type "String") (eq .Type "Int64") (eq .Type "Float64") (eq .Type "Bool") (isListSet .)) (not .Reference) (not .TfOnly) (not .WriteOnly) (not .Value)}} data.{{toGoName .TfName}} = types.{{.Type}}Null({{if isListSet .}}types.{{.ElementType}}Type{{end}}) {{ if .Variable}}data.{{toGoName .TfName}}Variable = types.StringNull(){{end}} if t := res.Get(path + "{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}.optionType"); t.Exists() { @@ -462,7 +462,7 @@ func (data *{{camelCase .Name}}) updateFromBody(ctx context.Context, res gjson.R ) {{- range .Attributes}} - {{- if and (or (eq .Type "String") (eq .Type "Int64") (eq .Type "Float64") (eq .Type "Bool") (isListSet .)) (not .Reference) (not .WriteOnly) (not .Value)}} + {{- if and (or (eq .Type "String") (eq .Type "Int64") (eq .Type "Float64") (eq .Type "Bool") (isListSet .)) (not .Reference) (not .TfOnly) (not .WriteOnly) (not .Value)}} data.{{$list}}[i].{{toGoName .TfName}} = types.{{.Type}}Null({{if isListSet .}}types.{{.ElementType}}Type{{end}}) {{ if .Variable}}data.{{$list}}[i].{{toGoName .TfName}}Variable = types.StringNull(){{end}} if t := r.Get("{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}.optionType"); t.Exists() { @@ -503,7 +503,7 @@ func (data *{{camelCase .Name}}) updateFromBody(ctx context.Context, res gjson.R ) {{- range .Attributes}} - {{- if and (or (eq .Type "String") (eq .Type "Int64") (eq .Type "Float64") (eq .Type "Bool") (isListSet .)) (not .Reference) (not .WriteOnly) (not .Value)}} + {{- if and (or (eq .Type "String") (eq .Type "Int64") (eq .Type "Float64") (eq .Type "Bool") (isListSet .)) (not .Reference) (not .TfOnly) (not .WriteOnly) (not .Value)}} data.{{$list}}[i].{{$clist}}[ci].{{toGoName .TfName}} = types.{{.Type}}Null({{if isListSet .}}types.{{.ElementType}}Type{{end}}) {{ if .Variable}}data.{{$list}}[i].{{$clist}}[ci].{{toGoName .TfName}}Variable = types.StringNull(){{end}} if t := cr.Get("{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}.optionType"); t.Exists() { @@ -544,7 +544,7 @@ func (data *{{camelCase .Name}}) updateFromBody(ctx context.Context, res gjson.R ) {{- range .Attributes}} - {{- if and (or (eq .Type "String") (eq .Type "Int64") (eq .Type "Float64") (eq .Type "Bool") (isListSet .)) (not .Reference) (not .WriteOnly) (not .Value)}} + {{- if and (or (eq .Type "String") (eq .Type "Int64") (eq .Type "Float64") (eq .Type "Bool") (isListSet .)) (not .Reference) (not .TfOnly) (not .WriteOnly) (not .Value)}} data.{{$list}}[i].{{$clist}}[ci].{{$cclist}}[cci].{{toGoName .TfName}} = types.{{.Type}}Null({{if isListSet .}}types.{{.ElementType}}Type{{end}}) {{ if .Variable}}data.{{$list}}[i].{{$clist}}[ci].{{$cclist}}[cci].{{toGoName .TfName}}Variable = types.StringNull(){{end}} if t := ccr.Get("{{range .DataPath}}{{.}}.{{end}}{{.ModelName}}.optionType"); t.Exists() { diff --git a/internal/provider/data_source_sdwan_transport_management_vpn_profile_parcel.go b/internal/provider/data_source_sdwan_transport_management_vpn_profile_parcel.go index a4b18350..bbb89018 100644 --- a/internal/provider/data_source_sdwan_transport_management_vpn_profile_parcel.go +++ b/internal/provider/data_source_sdwan_transport_management_vpn_profile_parcel.go @@ -217,6 +217,10 @@ func (d *TransportManagementVPNProfileParcelDataSource) Schema(ctx context.Conte MarkdownDescription: helpers.NewAttributeDescription("Variable name").String, Computed: true, }, + "route_type": schema.StringAttribute{ + MarkdownDescription: "Must be set to configure either next_hop, null0 or nat.", + Computed: true, + }, "next_hops": schema.ListNestedAttribute{ MarkdownDescription: "IPv6 Route Gateway Next Hop", Computed: true, diff --git a/internal/provider/data_source_sdwan_transport_management_vpn_profile_parcel_test.go b/internal/provider/data_source_sdwan_transport_management_vpn_profile_parcel_test.go index b1444294..e1111545 100644 --- a/internal/provider/data_source_sdwan_transport_management_vpn_profile_parcel_test.go +++ b/internal/provider/data_source_sdwan_transport_management_vpn_profile_parcel_test.go @@ -46,6 +46,7 @@ func TestAccDataSourceSdwanTransportManagementVPNProfileParcel(t *testing.T) { checks = append(checks, resource.TestCheckResourceAttr("data.sdwan_transport_management_vpn_profile_parcel.test", "ipv4_static_routes.0.next_hops.0.administrative_distance", "1")) checks = append(checks, resource.TestCheckResourceAttr("data.sdwan_transport_management_vpn_profile_parcel.test", "ipv4_static_routes.0.administrative_distance", "1")) checks = append(checks, resource.TestCheckResourceAttr("data.sdwan_transport_management_vpn_profile_parcel.test", "ipv6_static_routes.0.prefix", "2002::/16")) + checks = append(checks, resource.TestCheckResourceAttr("data.sdwan_transport_management_vpn_profile_parcel.test", "ipv6_static_routes.0.route_type", "next_hop")) checks = append(checks, resource.TestCheckResourceAttr("data.sdwan_transport_management_vpn_profile_parcel.test", "ipv6_static_routes.0.next_hops.0.address", "2001:0:0:1::1")) checks = append(checks, resource.TestCheckResourceAttr("data.sdwan_transport_management_vpn_profile_parcel.test", "ipv6_static_routes.0.next_hops.0.administrative_distance", "1")) resource.Test(t, resource.TestCase{ @@ -100,6 +101,7 @@ func testAccDataSourceSdwanTransportManagementVPNProfileParcelConfig() string { config += ` }]` + "\n" config += ` ipv6_static_routes = [{` + "\n" config += ` prefix = "2002::/16"` + "\n" + config += ` route_type = "next_hop"` + "\n" config += ` next_hops = [{` + "\n" config += ` address = "2001:0:0:1::1"` + "\n" config += ` administrative_distance = 1` + "\n" diff --git a/internal/provider/model_sdwan_transport_management_vpn_profile_parcel.go b/internal/provider/model_sdwan_transport_management_vpn_profile_parcel.go index f3716690..0c6df560 100644 --- a/internal/provider/model_sdwan_transport_management_vpn_profile_parcel.go +++ b/internal/provider/model_sdwan_transport_management_vpn_profile_parcel.go @@ -74,6 +74,7 @@ type TransportManagementVPNIpv4StaticRoutes struct { type TransportManagementVPNIpv6StaticRoutes struct { Prefix types.String `tfsdk:"prefix"` PrefixVariable types.String `tfsdk:"prefix_variable"` + RouteType types.String `tfsdk:"route_type"` NextHops []TransportManagementVPNIpv6StaticRoutesNextHops `tfsdk:"next_hops"` Null0 types.Bool `tfsdk:"null0"` Nat types.String `tfsdk:"nat"` @@ -349,7 +350,7 @@ func (data TransportManagementVPN) toBody(ctx context.Context) string { itemBody, _ = sjson.Set(itemBody, "prefix.value", item.Prefix.ValueString()) } } - if true { + if true && item.RouteType.ValueString() == "next_hop" { for _, childItem := range item.NextHops { itemChildBody := "" @@ -371,7 +372,12 @@ func (data TransportManagementVPN) toBody(ctx context.Context) string { itemChildBody, _ = sjson.Set(itemChildBody, "distance.optionType", "variable") itemChildBody, _ = sjson.Set(itemChildBody, "distance.value", childItem.AdministrativeDistanceVariable.ValueString()) } - } else if !childItem.AdministrativeDistance.IsNull() { + } else if childItem.AdministrativeDistance.IsNull() { + if true { + itemChildBody, _ = sjson.Set(itemChildBody, "distance.optionType", "default") + itemChildBody, _ = sjson.Set(itemChildBody, "distance.value", 1) + } + } else { if true { itemChildBody, _ = sjson.Set(itemChildBody, "distance.optionType", "global") itemChildBody, _ = sjson.Set(itemChildBody, "distance.value", childItem.AdministrativeDistance.ValueInt64()) @@ -381,19 +387,19 @@ func (data TransportManagementVPN) toBody(ctx context.Context) string { } } if !item.Null0.IsNull() { - if true { + if true && item.RouteType.ValueString() == "null0" { itemBody, _ = sjson.Set(itemBody, "oneOfIpRoute.null0.optionType", "global") itemBody, _ = sjson.Set(itemBody, "oneOfIpRoute.null0.value", item.Null0.ValueBool()) } } if !item.NatVariable.IsNull() { - if true { + if true && item.RouteType.ValueString() == "nat" { itemBody, _ = sjson.Set(itemBody, "oneOfIpRoute.nat.optionType", "variable") itemBody, _ = sjson.Set(itemBody, "oneOfIpRoute.nat.value", item.NatVariable.ValueString()) } } else if !item.Nat.IsNull() { - if true { + if true && item.RouteType.ValueString() == "nat" { itemBody, _ = sjson.Set(itemBody, "oneOfIpRoute.nat.optionType", "global") itemBody, _ = sjson.Set(itemBody, "oneOfIpRoute.nat.value", item.Nat.ValueString()) } diff --git a/internal/provider/resource_sdwan_transport_management_vpn_profile_parcel.go b/internal/provider/resource_sdwan_transport_management_vpn_profile_parcel.go index a7a84964..9dd4e7d9 100644 --- a/internal/provider/resource_sdwan_transport_management_vpn_profile_parcel.go +++ b/internal/provider/resource_sdwan_transport_management_vpn_profile_parcel.go @@ -248,6 +248,13 @@ func (r *TransportManagementVPNProfileParcelResource) Schema(ctx context.Context MarkdownDescription: helpers.NewAttributeDescription("Variable name").String, Optional: true, }, + "route_type": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("Must be set to configure either next_hop, null0 or nat.").AddStringEnumDescription("next_hop", "null0", "nat").String, + Optional: true, + Validators: []validator.String{ + stringvalidator.OneOf("next_hop", "null0", "nat"), + }, + }, "next_hops": schema.ListNestedAttribute{ MarkdownDescription: helpers.NewAttributeDescription("IPv6 Route Gateway Next Hop").String, Optional: true, @@ -262,7 +269,7 @@ func (r *TransportManagementVPNProfileParcelResource) Schema(ctx context.Context Optional: true, }, "administrative_distance": schema.Int64Attribute{ - MarkdownDescription: helpers.NewAttributeDescription("Administrative distance").AddIntegerRangeDescription(1, 254).String, + MarkdownDescription: helpers.NewAttributeDescription("Administrative distance").AddIntegerRangeDescription(1, 254).AddDefaultValueDescription("1").String, Optional: true, Validators: []validator.Int64{ int64validator.Between(1, 254), diff --git a/internal/provider/resource_sdwan_transport_management_vpn_profile_parcel_test.go b/internal/provider/resource_sdwan_transport_management_vpn_profile_parcel_test.go index 2f784abf..6ae7ef69 100644 --- a/internal/provider/resource_sdwan_transport_management_vpn_profile_parcel_test.go +++ b/internal/provider/resource_sdwan_transport_management_vpn_profile_parcel_test.go @@ -46,6 +46,7 @@ func TestAccSdwanTransportManagementVPNProfileParcel(t *testing.T) { checks = append(checks, resource.TestCheckResourceAttr("sdwan_transport_management_vpn_profile_parcel.test", "ipv4_static_routes.0.next_hops.0.administrative_distance", "1")) checks = append(checks, resource.TestCheckResourceAttr("sdwan_transport_management_vpn_profile_parcel.test", "ipv4_static_routes.0.administrative_distance", "1")) checks = append(checks, resource.TestCheckResourceAttr("sdwan_transport_management_vpn_profile_parcel.test", "ipv6_static_routes.0.prefix", "2002::/16")) + checks = append(checks, resource.TestCheckResourceAttr("sdwan_transport_management_vpn_profile_parcel.test", "ipv6_static_routes.0.route_type", "next_hop")) checks = append(checks, resource.TestCheckResourceAttr("sdwan_transport_management_vpn_profile_parcel.test", "ipv6_static_routes.0.next_hops.0.address", "2001:0:0:1::1")) checks = append(checks, resource.TestCheckResourceAttr("sdwan_transport_management_vpn_profile_parcel.test", "ipv6_static_routes.0.next_hops.0.administrative_distance", "1")) resource.Test(t, resource.TestCase{ @@ -115,6 +116,7 @@ func testAccSdwanTransportManagementVPNProfileParcelConfig_all() string { config += ` }]` + "\n" config += ` ipv6_static_routes = [{` + "\n" config += ` prefix = "2002::/16"` + "\n" + config += ` route_type = "next_hop"` + "\n" config += ` next_hops = [{` + "\n" config += ` address = "2001:0:0:1::1"` + "\n" config += ` administrative_distance = 1` + "\n"