Skip to content

Commit

Permalink
Resolve issue #320 and #284 (#370)
Browse files Browse the repository at this point in the history
  • Loading branch information
seconroy authored Nov 21, 2024
1 parent 2e860e6 commit 4390d82
Show file tree
Hide file tree
Showing 29 changed files with 102 additions and 39 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.5.1 (unreleased)

- BREAKING CHANGE: Adds `gateway` attribute to `sdwan_transport_wan_vpn_feature` resource

## 0.5.0

- Add `sdwan_policy_object_application_list` resource and data source
Expand Down
1 change: 1 addition & 0 deletions docs/data-sources/transport_wan_vpn_feature.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ Read-Only:

Read-Only:

- `gateway` (String) Gateway
- `nat` (String) IPv6 Nat
- `nat_variable` (String) Variable name
- `next_hops` (Attributes List) IPv6 Route Gateway Next Hop (see [below for nested schema](#nestedatt--ipv6_static_routes--next_hops))
Expand Down
4 changes: 4 additions & 0 deletions docs/guides/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ description: |-

# Changelog

## 0.5.1 (unreleased)

- BREAKING CHANGE: Adds `gateway` attribute to `sdwan_transport_wan_vpn_feature` resource

## 0.5.0

- Add `sdwan_policy_object_application_list` resource and data source
Expand Down
6 changes: 4 additions & 2 deletions docs/resources/other_ucse_feature.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ resource "sdwan_other_ucse_feature" "example" {

### Required

- `access_port_shared_failover_type` (String) - Choices: `ge2`, `te2`
- `access_port_shared_type` (String) - Choices: `ge1`, `ge2`, `ge3`, `te2`, `te3`, `console`, `failover`
- `bay` (Number) Bay
- Range: `0`-`2`
- `feature_profile_id` (String) Feature Profile ID
Expand All @@ -56,6 +54,10 @@ resource "sdwan_other_ucse_feature" "example" {

- `access_port_dedicated` (Boolean) Dedicated
- Default value: `true`
- `access_port_shared_failover_type` (String) , Attribute conditional on `access_port_dedicated` being equal to `false`
- Choices: `ge2`, `te2`
- `access_port_shared_type` (String) , Attribute conditional on `access_port_dedicated` being equal to `false`
- Choices: `ge1`, `ge2`, `ge3`, `te2`, `te3`, `console`, `failover`
- `assign_priority` (Number) Assign priority
- Range: `0`-`7`
- `assign_priority_variable` (String) Variable name
Expand Down
4 changes: 2 additions & 2 deletions docs/resources/system_remote_access_feature.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ resource "sdwan_system_remote_access_feature" "example" {

### Required

- `any_connect_eap_authentication_type` (String) , Attribute conditional on `connection_type_ssl` being equal to `false`
- Choices: `user`, `device`
- `name` (String) The name of the Feature
- `radius_group_name` (String)

Expand All @@ -61,6 +59,8 @@ resource "sdwan_system_remote_access_feature" "example" {
- `aaa_specify_name_policy_name_variable` (String) Variable name
- `aaa_specify_name_policy_password` (String)
- `aaa_specify_name_policy_password_variable` (String) Variable name
- `any_connect_eap_authentication_type` (String) , Attribute conditional on `connection_type_ssl` being equal to `false`
- Choices: `user`, `device`
- `connection_type_ssl` (Boolean) Enabled SSL VPN
- Default value: `false`
- `description` (String) The description of the Feature
Expand Down
6 changes: 3 additions & 3 deletions docs/resources/transport_management_vpn_feature.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ resource "sdwan_transport_management_vpn_feature" "example" {
ipv6_static_routes = [
{
prefix = "2002::/16"
gateway = "next_hop"
gateway = "nextHop"
next_hops = [
{
address = "2001:0:0:1::1"
Expand Down Expand Up @@ -127,11 +127,11 @@ Optional:
Optional:

- `gateway` (String) Gateway
- Choices: `next_hop`, `null0`, `nat`
- Choices: `nextHop`, `null0`, `nat`
- `nat` (String) IPv6 Nat, Attribute conditional on `gateway` being equal to `nat`
- Choices: `NAT64`, `NAT66`
- `nat_variable` (String) Variable name
- `next_hops` (Attributes List) IPv6 Route Gateway Next Hop, Attribute conditional on `gateway` being equal to `next_hop` (see [below for nested schema](#nestedatt--ipv6_static_routes--next_hops))
- `next_hops` (Attributes List) IPv6 Route Gateway Next Hop, Attribute conditional on `gateway` being equal to `nextHop` (see [below for nested schema](#nestedatt--ipv6_static_routes--next_hops))
- `null0` (Boolean) IPv6 Route Gateway Next Hop, Attribute conditional on `gateway` being equal to `null0`
- `prefix` (String) Prefix
- `prefix_variable` (String) Variable name
Expand Down
11 changes: 7 additions & 4 deletions docs/resources/transport_wan_vpn_feature.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ resource "sdwan_transport_wan_vpn_feature" "example" {
]
ipv6_static_routes = [
{
prefix = "2002::/16"
prefix = "2002::/16"
gateway = "nextHop"
next_hops = [
{
address = "2001:0:0:1::0"
Expand Down Expand Up @@ -144,11 +145,13 @@ Optional:

Optional:

- `nat` (String) IPv6 Nat
- `gateway` (String) Gateway
- Choices: `nextHop`, `null0`, `nat`
- `nat` (String) IPv6 Nat, Attribute conditional on `gateway` being equal to `nat`
- Choices: `NAT64`, `NAT66`
- `nat_variable` (String) Variable name
- `next_hops` (Attributes List) IPv6 Route Gateway Next Hop (see [below for nested schema](#nestedatt--ipv6_static_routes--next_hops))
- `null0` (Boolean) IPv6 Route Gateway Next Hop
- `next_hops` (Attributes List) IPv6 Route Gateway Next Hop, Attribute conditional on `gateway` being equal to `nextHop` (see [below for nested schema](#nestedatt--ipv6_static_routes--next_hops))
- `null0` (Boolean) IPv6 Route Gateway Next Hop, Attribute conditional on `gateway` being equal to `null0`
- `prefix` (String) Prefix
- `prefix_variable` (String) Variable name

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ resource "sdwan_transport_management_vpn_feature" "example" {
ipv6_static_routes = [
{
prefix = "2002::/16"
gateway = "next_hop"
gateway = "nextHop"
next_hops = [
{
address = "2001:0:0:1::1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ resource "sdwan_transport_wan_vpn_feature" "example" {
]
ipv6_static_routes = [
{
prefix = "2002::/16"
prefix = "2002::/16"
gateway = "nextHop"
next_hops = [
{
address = "2001:0:0:1::0"
Expand Down
10 changes: 10 additions & 0 deletions gen/definitions/profile_parcels/other_ucse.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,20 @@ attributes:
- model_name: lomType
tf_name: access_port_shared_type
data_path: [imc, access-port, sharedLom]
ignore_mandatory: true
conditional_attribute:
name: access_port_dedicated
value: false
type: Bool
example: ge1
- model_name: failOverType
tf_name: access_port_shared_failover_type
data_path: [imc, access-port, sharedLom]
ignore_mandatory: true
conditional_attribute:
name: access_port_dedicated
value: false
type: Bool
example: ge2
- model_name: address
tf_name: ipv4_address
Expand Down
2 changes: 2 additions & 0 deletions gen/definitions/profile_parcels/system_remote_access.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@ attributes:
example: false
- model_name: anyConnectEapAuth
tf_name: any_connect_eap_authentication_type
ignore_mandatory: true
conditional_attribute:
name: connection_type_ssl
value: false
type: Bool
example: user
minimum_test_value: '"user"'
# ==== Requires support for file upload ===
# - model_name: anyConnectProfileDownloadStatus
# tf_name: any_connect_eap_profile_download_status
Expand Down
6 changes: 3 additions & 3 deletions gen/definitions/profile_parcels/transport_management_vpn.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,15 @@ attributes:
type: String
tf_only: true
description: Gateway
enum_values: [next_hop, null0, nat]
example: next_hop
enum_values: [nextHop, null0, nat]
example: nextHop
- model_name: nextHop
tf_name: next_hops
data_path: [oneOfIpRoute, nextHopContainer]
mandatory: true
conditional_attribute:
name: gateway
value: next_hop
value: nextHop
attributes:
- model_name: address
id: true
Expand Down
18 changes: 18 additions & 0 deletions gen/definitions/profile_parcels/transport_wan_vpn.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -83,24 +83,42 @@ attributes:
- model_name: prefix
id: true
example: 2002::/16
- tf_name: gateway
type: String
tf_only: true
description: Gateway
enum_values: [nextHop, null0, nat]
example: nextHop
- model_name: nextHop
tf_name: next_hops
data_path: [oneOfIpRoute, nextHopContainer]
conditional_attribute:
name: gateway
value: nextHop
attributes:
- model_name: address
id: true
example: 2001:0:0:1::0
- model_name: distance
tf_name: administrative_distance
example: 1

- model_name: null0
data_path: [oneOfIpRoute]
exclude_test: true
conditional_attribute:
name: gateway
value: null0
example: true

- model_name: nat
data_path: [oneOfIpRoute]
exclude_test: true
conditional_attribute:
name: gateway
value: nat
example: NAT64

- model_name: service
tf_name: services
attributes:
Expand Down
3 changes: 2 additions & 1 deletion gen/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ type YamlConfigAttribute struct {
Reference bool `yaml:"reference"`
Variable bool `yaml:"variable"`
Mandatory bool `yaml:"mandatory"`
IgnoreMandatory bool `yaml:"ignore_mandatory"`
Optional bool `yaml:"optional"`
WriteOnly bool `yaml:"write_only"`
TfOnly bool `yaml:"tf_only"`
Expand Down Expand Up @@ -906,7 +907,7 @@ func parseProfileParcelAttribute(attr *YamlConfigAttribute, model gjson.Result,
} else if isOneOfAttribute {
attr.ExcludeNull = true
} else {
if !attr.Variable {
if !attr.Variable && !attr.IgnoreMandatory {
attr.Mandatory = true
}
}
Expand Down
1 change: 1 addition & 0 deletions gen/schema/schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ attribute:
reference: bool(required=False) # Indicates that the attribute is being used in the url path
variable: bool(required=False) # Indicates that this attribute can be provided as a feature template or profile parcel variable
mandatory: bool(required=False) # Set to true if the attribute is mandatory
ignore_mandatory: bool(required=False) # Set to true if schema mandatory value should be ignored
optional: bool(required=False) # Set to true if the attribute is optional
write_only: bool(required=False) # Set to true if the attribute is write-only, meaning we cannot read the value
tf_only: bool(required=False) # Set to true if this attribute is only used in Terraform but not added to payload
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func testAccDataSourceSdwanTransportManagementVPNProfileParcelConfig() string {
config += ` }]` + "\n"
config += ` ipv6_static_routes = [{` + "\n"
config += ` prefix = "2002::/16"` + "\n"
config += ` gateway = "next_hop"` + "\n"
config += ` gateway = "nextHop"` + "\n"
config += ` next_hops = [{` + "\n"
config += ` address = "2001:0:0:1::1"` + "\n"
config += ` administrative_distance = 1` + "\n"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,10 @@ func (d *TransportWANVPNProfileParcelDataSource) Schema(ctx context.Context, req
MarkdownDescription: helpers.NewAttributeDescription("Variable name").String,
Computed: true,
},
"gateway": schema.StringAttribute{
MarkdownDescription: "Gateway",
Computed: true,
},
"next_hops": schema.ListNestedAttribute{
MarkdownDescription: "IPv6 Route Gateway Next Hop",
Computed: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ func testAccDataSourceSdwanTransportWANVPNProfileParcelConfig() string {
config += ` }]` + "\n"
config += ` ipv6_static_routes = [{` + "\n"
config += ` prefix = "2002::/16"` + "\n"
config += ` gateway = "nextHop"` + "\n"
config += ` next_hops = [{` + "\n"
config += ` address = "2001:0:0:1::0"` + "\n"
config += ` administrative_distance = 1` + "\n"
Expand Down
4 changes: 2 additions & 2 deletions internal/provider/model_sdwan_other_ucse_feature.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,13 @@ func (data OtherUCSE) toBody(ctx context.Context) string {
}
}
if !data.AccessPortSharedType.IsNull() {
if true {
if true && data.AccessPortDedicated.ValueBool() == false {
body, _ = sjson.Set(body, path+"imc.access-port.sharedLom.lomType.optionType", "global")
body, _ = sjson.Set(body, path+"imc.access-port.sharedLom.lomType.value", data.AccessPortSharedType.ValueString())
}
}
if !data.AccessPortSharedFailoverType.IsNull() {
if true {
if true && data.AccessPortDedicated.ValueBool() == false {
body, _ = sjson.Set(body, path+"imc.access-port.sharedLom.failOverType.optionType", "global")
body, _ = sjson.Set(body, path+"imc.access-port.sharedLom.failOverType.value", data.AccessPortSharedFailoverType.ValueString())
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ func (data TransportManagementVPN) toBody(ctx context.Context) string {
itemBody, _ = sjson.Set(itemBody, "prefix.value", item.Prefix.ValueString())
}
}
if true && item.Gateway.ValueString() == "next_hop" {
if true && item.Gateway.ValueString() == "nextHop" {

for _, childItem := range item.NextHops {
itemChildBody := ""
Expand Down
9 changes: 5 additions & 4 deletions internal/provider/model_sdwan_transport_wan_vpn_feature.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ type TransportWANVPNIpv4StaticRoutes struct {
type TransportWANVPNIpv6StaticRoutes struct {
Prefix types.String `tfsdk:"prefix"`
PrefixVariable types.String `tfsdk:"prefix_variable"`
Gateway types.String `tfsdk:"gateway"`
NextHops []TransportWANVPNIpv6StaticRoutesNextHops `tfsdk:"next_hops"`
Null0 types.Bool `tfsdk:"null0"`
Nat types.String `tfsdk:"nat"`
Expand Down Expand Up @@ -354,7 +355,7 @@ func (data TransportWANVPN) toBody(ctx context.Context) string {
itemBody, _ = sjson.Set(itemBody, "prefix.value", item.Prefix.ValueString())
}
}
if true {
if true && item.Gateway.ValueString() == "nextHop" {

for _, childItem := range item.NextHops {
itemChildBody := ""
Expand Down Expand Up @@ -386,19 +387,19 @@ func (data TransportWANVPN) toBody(ctx context.Context) string {
}
}
if !item.Null0.IsNull() {
if true {
if true && item.Gateway.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.Gateway.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.Gateway.ValueString() == "nat" {
itemBody, _ = sjson.Set(itemBody, "oneOfIpRoute.nat.optionType", "global")
itemBody, _ = sjson.Set(itemBody, "oneOfIpRoute.nat.value", item.Nat.ValueString())
}
Expand Down
8 changes: 4 additions & 4 deletions internal/provider/resource_sdwan_other_ucse_feature.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,15 @@ func (r *OtherUCSEProfileParcelResource) Schema(ctx context.Context, req resourc
Optional: true,
},
"access_port_shared_type": schema.StringAttribute{
MarkdownDescription: helpers.NewAttributeDescription("").AddStringEnumDescription("ge1", "ge2", "ge3", "te2", "te3", "console", "failover").String,
Required: true,
MarkdownDescription: helpers.NewAttributeDescription(", Attribute conditional on `access_port_dedicated` being equal to `false`").AddStringEnumDescription("ge1", "ge2", "ge3", "te2", "te3", "console", "failover").String,
Optional: true,
Validators: []validator.String{
stringvalidator.OneOf("ge1", "ge2", "ge3", "te2", "te3", "console", "failover"),
},
},
"access_port_shared_failover_type": schema.StringAttribute{
MarkdownDescription: helpers.NewAttributeDescription("").AddStringEnumDescription("ge2", "te2").String,
Required: true,
MarkdownDescription: helpers.NewAttributeDescription(", Attribute conditional on `access_port_dedicated` being equal to `false`").AddStringEnumDescription("ge2", "te2").String,
Optional: true,
Validators: []validator.String{
stringvalidator.OneOf("ge2", "te2"),
},
Expand Down
2 changes: 0 additions & 2 deletions internal/provider/resource_sdwan_other_ucse_feature_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,6 @@ func testAccSdwanOtherUCSEProfileParcelConfig_minimum() string {
config += ` feature_profile_id = sdwan_other_feature_profile.test.id` + "\n"
config += ` bay = 2` + "\n"
config += ` slot = 0` + "\n"
config += ` access_port_shared_type = "ge1"` + "\n"
config += ` access_port_shared_failover_type = "ge2"` + "\n"
config += ` ipv4_address = "2.2.2.2/24"` + "\n"
config += ` default_gateway = "2.2.2.2"` + "\n"
config += `}` + "\n"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func (r *SystemRemoteAccessProfileParcelResource) Schema(ctx context.Context, re
},
"any_connect_eap_authentication_type": schema.StringAttribute{
MarkdownDescription: helpers.NewAttributeDescription(", Attribute conditional on `connection_type_ssl` being equal to `false`").AddStringEnumDescription("user", "device").String,
Required: true,
Optional: true,
Validators: []validator.String{
stringvalidator.OneOf("user", "device"),
},
Expand Down
Loading

0 comments on commit 4390d82

Please sign in to comment.