Skip to content

Commit

Permalink
Add environment varaible test value options
Browse files Browse the repository at this point in the history
  • Loading branch information
seconroy committed Jul 2, 2024
1 parent 3b83c6d commit fd8d047
Show file tree
Hide file tree
Showing 37 changed files with 175 additions and 393 deletions.
10 changes: 2 additions & 8 deletions gen/definitions/profile_parcels/policy_object_class_map.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
name: Policy Object Class Map
rest_endpoint: /v1/feature-profile/sdwan/policy-object/%v/class
minimum_version: 20.12.0
test_tags: [SDWAN_2012]
test_tags: [SDWAN_2012, POLICY_OBJECT_FEATURE_TEMPLATE_ID]
attributes:
- tf_name: feature_profile_id
reference: true
type: String
mandatory: true
description: Feature Profile ID
example: f6dd22c8-0b4f-496c-9a0b-6813d1f8b8ac
test_value: sdwan_policy_object_feature_profile.test.id
test_env_name: POLICY_OBJECT_FEATURE_TEMPLATE_ID
- model_name: entries
mandatory: true
attributes:
Expand All @@ -19,9 +19,3 @@ attributes:
mandatory: true
example: 0
minimum_test_value: 0

test_prerequisites: |
resource "sdwan_policy_object_feature_profile" "test" {
name = "TF_TEST"
description = "Terraform test"
}
10 changes: 2 additions & 8 deletions gen/definitions/profile_parcels/policy_object_color.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
name: Policy Object Color
rest_endpoint: /v1/feature-profile/sdwan/policy-object/%v/color
minimum_version: 20.12.0
test_tags: [SDWAN_2012]
test_tags: [SDWAN_2012, POLICY_OBJECT_FEATURE_TEMPLATE_ID]
attributes:
- tf_name: feature_profile_id
reference: true
type: String
mandatory: true
description: Feature Profile ID
example: f6dd22c8-0b4f-496c-9a0b-6813d1f8b8ac
test_value: sdwan_policy_object_feature_profile.test.id
test_env_name: POLICY_OBJECT_FEATURE_TEMPLATE_ID
- model_name: entries
mandatory: true
attributes:
Expand All @@ -19,9 +19,3 @@ attributes:
mandatory: true
example: blue
minimum_test_value: '"blue"'

test_prerequisites: |
resource "sdwan_policy_object_feature_profile" "test" {
name = "TF_TEST"
description = "Terraform test"
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
name: Policy Object Data IPv6 Prefix
rest_endpoint: /v1/feature-profile/sdwan/policy-object/%v/data-ipv6-prefix
minimum_version: 20.12.0
test_tags: [SDWAN_2012]
test_tags: [SDWAN_2012, POLICY_OBJECT_FEATURE_TEMPLATE_ID]
attributes:
- tf_name: feature_profile_id
reference: true
type: String
mandatory: true
description: Feature Profile ID
example: f6dd22c8-0b4f-496c-9a0b-6813d1f8b8ac
test_value: sdwan_policy_object_feature_profile.test.id
test_env_name: POLICY_OBJECT_FEATURE_TEMPLATE_ID
- model_name: entries
mandatory: true
attributes:
Expand All @@ -23,9 +23,3 @@ attributes:
mandatory: true
example: 64
minimum_test_value: '64'

test_prerequisites: |
resource "sdwan_policy_object_feature_profile" "test" {
name = "TF_TEST"
description = "Terraform test"
}
12 changes: 3 additions & 9 deletions gen/definitions/profile_parcels/policy_object_data_prefix.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
name: Policy Object Data Prefix
rest_endpoint: /v1/feature-profile/sdwan/policy-object/%v/data-prefix
minimum_version: 20.12.0
test_tags: [SDWAN_2012]
test_tags: [SDWAN_2012, POLICY_OBJECT_FEATURE_TEMPLATE_ID]
attributes:
- tf_name: feature_profile_id
reference: true
type: String
mandatory: true
description: Feature Profile ID
example: f6dd22c8-0b4f-496c-9a0b-6813d1f8b8ac
test_value: sdwan_policy_object_feature_profile.test.id
test_env_name: POLICY_OBJECT_FEATURE_TEMPLATE_ID
- model_name: entries
mandatory: true
attributes:
Expand All @@ -22,10 +22,4 @@ attributes:
- model_name: ipv4PrefixLength
mandatory: true
example: 8
minimum_test_value: '8'

test_prerequisites: |
resource "sdwan_policy_object_feature_profile" "test" {
name = "TF_TEST"
description = "Terraform test"
}
minimum_test_value: '8'
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,17 @@
name: Policy Object Expanded Community
rest_endpoint: /v1/feature-profile/sdwan/policy-object/%v/expanded-community
minimum_version: 20.12.0
test_tags: [SDWAN_2012]
test_tags: [SDWAN_2012, POLICY_OBJECT_FEATURE_TEMPLATE_ID]
attributes:
- tf_name: feature_profile_id
reference: true
type: String
mandatory: true
description: Feature Profile ID
example: f6dd22c8-0b4f-496c-9a0b-6813d1f8b8ac
test_value: sdwan_policy_object_feature_profile.test.id
test_env_name: POLICY_OBJECT_FEATURE_TEMPLATE_ID
- model_name: expandedCommunityList
tf_name: expanded_community_lists
id: true
mandatory: true
example: abcd

test_prerequisites: |
resource "sdwan_policy_object_feature_profile" "test" {
name = "TF_TEST"
description = "Terraform test"
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
name: Policy Object Extended Community
rest_endpoint: /v1/feature-profile/sdwan/policy-object/%v/ext-community
minimum_version: 20.12.0
test_tags: [SDWAN_2012]
test_tags: [SDWAN_2012, POLICY_OBJECT_FEATURE_TEMPLATE_ID]
attributes:
- tf_name: feature_profile_id
reference: true
type: String
mandatory: true
description: Feature Profile ID
example: f6dd22c8-0b4f-496c-9a0b-6813d1f8b8ac
test_value: sdwan_policy_object_feature_profile.test.id
test_env_name: POLICY_OBJECT_FEATURE_TEMPLATE_ID
- model_name: entries
mandatory: true
attributes:
Expand All @@ -20,9 +20,3 @@ attributes:
mandatory: true
example: "soo 10.0.0.1:30"
minimum_test_value: '"soo 10.0.0.1:30"'

test_prerequisites: |
resource "sdwan_policy_object_feature_profile" "test" {
name = "TF_TEST"
description = "Terraform test"
}
10 changes: 2 additions & 8 deletions gen/definitions/profile_parcels/policy_object_ipv6_prefix.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
name: Policy Object IPv6 Prefix
rest_endpoint: /v1/feature-profile/sdwan/policy-object/%v/ipv6-prefix
minimum_version: 20.12.0
test_tags: [SDWAN_2012]
test_tags: [SDWAN_2012, POLICY_OBJECT_FEATURE_TEMPLATE_ID]
attributes:
- tf_name: feature_profile_id
reference: true
type: String
mandatory: true
description: Feature Profile ID
example: f6dd22c8-0b4f-496c-9a0b-6813d1f8b8ac
test_value: sdwan_policy_object_feature_profile.test.id
test_env_name: POLICY_OBJECT_FEATURE_TEMPLATE_ID
- model_name: entries
mandatory: true
attributes:
Expand All @@ -28,9 +28,3 @@ attributes:
example: 100
- model_name: geRangePrefixLength
example: 70

test_prerequisites: |
resource "sdwan_policy_object_feature_profile" "test" {
name = "TF_TEST"
description = "Terraform test"
}
10 changes: 2 additions & 8 deletions gen/definitions/profile_parcels/policy_object_mirror.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
name: Policy Object Mirror
rest_endpoint: /v1/feature-profile/sdwan/policy-object/%v/mirror
minimum_version: 20.12.0
test_tags: [SDWAN_2012]
test_tags: [SDWAN_2012, POLICY_OBJECT_FEATURE_TEMPLATE_ID]
attributes:
- tf_name: feature_profile_id
reference: true
type: String
mandatory: true
description: Feature Profile ID
example: f6dd22c8-0b4f-496c-9a0b-6813d1f8b8ac
test_value: sdwan_policy_object_feature_profile.test.id
test_env_name: POLICY_OBJECT_FEATURE_TEMPLATE_ID
- model_name: entries
mandatory: true
attributes:
Expand All @@ -26,9 +26,3 @@ attributes:
mandatory: true
example: 10.0.0.2
minimum_test_value: '"10.0.0.2"'

test_prerequisites: |
resource "sdwan_policy_object_feature_profile" "test" {
name = "TF_TEST"
description = "Terraform test"
}
10 changes: 2 additions & 8 deletions gen/definitions/profile_parcels/policy_object_policer.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
name: Policy Object Policer
rest_endpoint: /v1/feature-profile/sdwan/policy-object/%v/policer
minimum_version: 20.12.0
test_tags: [SDWAN_2012]
test_tags: [SDWAN_2012, POLICY_OBJECT_FEATURE_TEMPLATE_ID]
attributes:
- tf_name: feature_profile_id
reference: true
type: String
mandatory: true
description: Feature Profile ID
example: f6dd22c8-0b4f-496c-9a0b-6813d1f8b8ac
test_value: sdwan_policy_object_feature_profile.test.id
test_env_name: POLICY_OBJECT_FEATURE_TEMPLATE_ID
- model_name: entries
mandatory: true
attributes:
Expand All @@ -32,9 +32,3 @@ attributes:
mandatory: true
example: 60000
minimum_test_value: '60000'

test_prerequisites: |
resource "sdwan_policy_object_feature_profile" "test" {
name = "TF_TEST"
description = "Terraform test"
}
10 changes: 2 additions & 8 deletions gen/definitions/profile_parcels/policy_object_prefix.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
name: Policy Object Prefix
rest_endpoint: /v1/feature-profile/sdwan/policy-object/%v/prefix
minimum_version: 20.12.0
test_tags: [SDWAN_2012]
test_tags: [SDWAN_2012, POLICY_OBJECT_FEATURE_TEMPLATE_ID]
attributes:
- tf_name: feature_profile_id
reference: true
type: String
mandatory: true
description: Feature Profile ID
example: f6dd22c8-0b4f-496c-9a0b-6813d1f8b8ac
test_value: sdwan_policy_object_feature_profile.test.id
test_env_name: POLICY_OBJECT_FEATURE_TEMPLATE_ID
- model_name: entries
mandatory: true
attributes:
Expand All @@ -28,9 +28,3 @@ attributes:
example: 24
- model_name: geRangePrefixLength
example: 16

test_prerequisites: |
resource "sdwan_policy_object_feature_profile" "test" {
name = "TF_TEST"
description = "Terraform test"
}
10 changes: 2 additions & 8 deletions gen/definitions/profile_parcels/policy_object_tloc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
name: Policy Object TLOC
rest_endpoint: /v1/feature-profile/sdwan/policy-object/%v/tloc
minimum_version: 20.12.0
test_tags: [SDWAN_2012]
test_tags: [SDWAN_2012, POLICY_OBJECT_FEATURE_TEMPLATE_ID]
attributes:
- tf_name: feature_profile_id
reference: true
type: String
mandatory: true
description: Feature Profile ID
example: f6dd22c8-0b4f-496c-9a0b-6813d1f8b8ac
test_value: sdwan_policy_object_feature_profile.test.id
test_env_name: POLICY_OBJECT_FEATURE_TEMPLATE_ID
- model_name: entries
mandatory: true
attributes:
Expand All @@ -30,9 +30,3 @@ attributes:
minimum_test_value: '"gre"'
- model_name: preference
example: 33

test_prerequisites: |
resource "sdwan_policy_object_feature_profile" "test" {
name = "TF_TEST"
description = "Terraform test"
}
1 change: 1 addition & 0 deletions gen/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ type YamlConfigAttribute struct {
Value string `yaml:"value"`
TestValue string `yaml:"test_value"`
MinimumTestValue string `yaml:"minimum_test_value"`
TestEnvName string `yaml:"test_env_name"`
AlwaysInclude bool `yaml:"always_include"`
Attributes []YamlConfigAttribute `yaml:"attributes"`
ConditionalAttribute YamlConfigConditionalAttribute `yaml:"conditional_attribute"`
Expand Down
1 change: 1 addition & 0 deletions gen/schema/schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ attribute:
value: any(str(), int(), bool(), required=False) # Hardcoded value for the attribute
test_value: str(required=False) # Value used for acceptance test
minimum_test_value: any(str(), int(), bool(), num(), required=False) # Value used for "minimum" resource acceptance test
test_env_name: str(required=False) # Environment variable name for viable containing resource ID used for testing
always_include: bool(required=False) # Include attribute always in payload
attributes: list(include('attribute'), required=False) # List of attributes, only relevant if type is "List" or "Set"
conditional_attribute: include('conditional_attribute', required=False) # Add attribute to payload only if condition is true
Expand Down
18 changes: 9 additions & 9 deletions gen/templates/profile_parcels/data_source_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,10 @@ func testAccDataSourceSdwan{{camelCase .Name}}ProfileParcelConfig() string {
{{- if and (not .ExcludeTest) (not .Value)}}
{{- if len .TestTags}}
if {{range $i, $e := .TestTags}}{{if $i}} || {{end}}os.Getenv("{{$e}}") != ""{{end}} {
config += ` {{.TfName}} = {{if .TestValue}}{{.TestValue}}{{else}}{{if eq .Type "String"}}"{{.Example}}"{{else if isStringListSet .}}["{{.Example}}"]{{else if isInt64ListSet .}}[{{.Example}}]{{else}}{{.Example}}{{end}}{{end}}` + "\n"
config += ` {{.TfName}} = {{if .TestEnvName}}` + os.Getenv("{{.TestEnvName}}") + `{{else if .TestValue}}{{.TestValue}}{{else}}{{if eq .Type "String"}}"{{.Example}}"{{else if isStringListSet .}}["{{.Example}}"]{{else if isInt64ListSet .}}[{{.Example}}]{{else}}{{.Example}}{{end}}{{end}}` + "\n"
}
{{- else}}
config += ` {{.TfName}} = {{if .TestValue}}{{.TestValue}}{{else}}{{if eq .Type "String"}}"{{.Example}}"{{else if isStringListSet .}}["{{.Example}}"]{{else if isInt64ListSet .}}[{{.Example}}]{{else}}{{.Example}}{{end}}{{end}}` + "\n"
config += ` {{.TfName}} = {{if .TestEnvName}}` + os.Getenv("{{.TestEnvName}}") + `{{else if .TestValue}}{{.TestValue}}{{else}}{{if eq .Type "String"}}"{{.Example}}"{{else if isStringListSet .}}["{{.Example}}"]{{else if isInt64ListSet .}}[{{.Example}}]{{else}}{{.Example}}{{end}}{{end}}` + "\n"
{{- end}}
{{- end}}
{{- end}}
Expand All @@ -174,10 +174,10 @@ func testAccDataSourceSdwan{{camelCase .Name}}ProfileParcelConfig() string {
{{- else}}
{{- if len .TestTags}}
if {{range $i, $e := .TestTags}}{{if $i}} || {{end}}os.Getenv("{{$e}}") != ""{{end}} {
config += ` {{.TfName}} = {{if .TestValue}}{{.TestValue}}{{else}}{{if eq .Type "String"}}"{{.Example}}"{{else if isStringListSet .}}["{{.Example}}"]{{else if isInt64ListSet .}}[{{.Example}}]{{else}}{{.Example}}{{end}}{{end}}` + "\n"
config += ` {{.TfName}} = {{if .TestEnvName}}` + os.Getenv("{{.TestEnvName}}") + `{{else if .TestValue}}{{.TestValue}}{{else}}{{if eq .Type "String"}}"{{.Example}}"{{else if isStringListSet .}}["{{.Example}}"]{{else if isInt64ListSet .}}[{{.Example}}]{{else}}{{.Example}}{{end}}{{end}}` + "\n"
}
{{- else}}
config += ` {{.TfName}} = {{if .TestValue}}{{.TestValue}}{{else}}{{if eq .Type "String"}}"{{.Example}}"{{else if isStringListSet .}}["{{.Example}}"]{{else if isInt64ListSet .}}[{{.Example}}]{{else}}{{.Example}}{{end}}{{end}}` + "\n"
config += ` {{.TfName}} = {{if .TestEnvName}}` + os.Getenv("{{.TestEnvName}}") + `{{else if .TestValue}}{{.TestValue}}{{else}}{{if eq .Type "String"}}"{{.Example}}"{{else if isStringListSet .}}["{{.Example}}"]{{else if isInt64ListSet .}}[{{.Example}}]{{else}}{{.Example}}{{end}}{{end}}` + "\n"
{{- end}}
{{- end}}
{{- end}}
Expand All @@ -189,10 +189,10 @@ func testAccDataSourceSdwan{{camelCase .Name}}ProfileParcelConfig() string {
{{- else}}
{{- if len .TestTags}}
if {{range $i, $e := .TestTags}}{{if $i}} || {{end}}os.Getenv("{{$e}}") != ""{{end}} {
config += ` {{.TfName}} = {{if .TestValue}}{{.TestValue}}{{else}}{{if eq .Type "String"}}"{{.Example}}"{{else if isStringListSet .}}["{{.Example}}"]{{else if isInt64ListSet .}}[{{.Example}}]{{else}}{{.Example}}{{end}}{{end}}` + "\n"
config += ` {{.TfName}} = {{if .TestEnvName}}` + os.Getenv("{{.TestEnvName}}") + `{{else if .TestValue}}{{.TestValue}}{{else}}{{if eq .Type "String"}}"{{.Example}}"{{else if isStringListSet .}}["{{.Example}}"]{{else if isInt64ListSet .}}[{{.Example}}]{{else}}{{.Example}}{{end}}{{end}}` + "\n"
}
{{- else}}
config += ` {{.TfName}} = {{if .TestValue}}{{.TestValue}}{{else}}{{if eq .Type "String"}}"{{.Example}}"{{else if isStringListSet .}}["{{.Example}}"]{{else if isInt64ListSet .}}[{{.Example}}]{{else}}{{.Example}}{{end}}{{end}}` + "\n"
config += ` {{.TfName}} = {{if .TestEnvName}}` + os.Getenv("{{.TestEnvName}}") + `{{else if .TestValue}}{{.TestValue}}{{else}}{{if eq .Type "String"}}"{{.Example}}"{{else if isStringListSet .}}["{{.Example}}"]{{else if isInt64ListSet .}}[{{.Example}}]{{else}}{{.Example}}{{end}}{{end}}` + "\n"
{{- end}}
{{- end}}
{{- end}}
Expand All @@ -204,10 +204,10 @@ func testAccDataSourceSdwan{{camelCase .Name}}ProfileParcelConfig() string {
{{- else}}
{{- if len .TestTags}}
if {{range $i, $e := .TestTags}}{{if $i}} || {{end}}os.Getenv("{{$e}}") != ""{{end}} {
config += ` {{.TfName}} = {{if .TestValue}}{{.TestValue}}{{else}}{{if eq .Type "String"}}"{{.Example}}"{{else if isStringListSet .}}["{{.Example}}"]{{else if isInt64ListSet .}}[{{.Example}}]{{else}}{{.Example}}{{end}}{{end}}` + "\n"
config += ` {{.TfName}} = {{if .TestEnvName}}` + os.Getenv("{{.TestEnvName}}") + `{{else if .TestValue}}{{.TestValue}}{{else}}{{if eq .Type "String"}}"{{.Example}}"{{else if isStringListSet .}}["{{.Example}}"]{{else if isInt64ListSet .}}[{{.Example}}]{{else}}{{.Example}}{{end}}{{end}}` + "\n"
}
{{- else}}
config += ` {{.TfName}} = {{if .TestValue}}{{.TestValue}}{{else}}{{if eq .Type "String"}}"{{.Example}}"{{else if isStringListSet .}}["{{.Example}}"]{{else if isInt64ListSet .}}[{{.Example}}]{{else}}{{.Example}}{{end}}{{end}}` + "\n"
config += ` {{.TfName}} = {{if .TestEnvName}}` + os.Getenv("{{.TestEnvName}}") + `{{else if .TestValue}}{{.TestValue}}{{else}}{{if eq .Type "String"}}"{{.Example}}"{{else if isStringListSet .}}["{{.Example}}"]{{else if isInt64ListSet .}}[{{.Example}}]{{else}}{{.Example}}{{end}}{{end}}` + "\n"
{{- end}}
{{- end}}
{{- end}}
Expand All @@ -219,7 +219,7 @@ func testAccDataSourceSdwan{{camelCase .Name}}ProfileParcelConfig() string {
id = sdwan_{{snakeCase $name}}_profile_parcel.test.id
{{- range .Attributes}}
{{- if .Reference}}
{{.TfName}} = {{if .TestValue}}{{.TestValue}}{{else}}{{if eq .Type "String"}}"{{.Example}}"{{else if isStringListSet .}}["{{.Example}}"]{{else if isInt64ListSet .}}[{{.Example}}]{{else}}{{.Example}}{{end}}{{end}}
{{.TfName}} = {{if .TestEnvName}}` + os.Getenv("{{.TestEnvName}}") + `{{else if .TestValue}}{{.TestValue}}{{else}}{{if eq .Type "String"}}"{{.Example}}"{{else if isStringListSet .}}["{{.Example}}"]{{else if isInt64ListSet .}}[{{.Example}}]{{else}}{{.Example}}{{end}}{{end}}
{{- end}}
{{- end}}
}
Expand Down
Loading

0 comments on commit fd8d047

Please sign in to comment.