Skip to content

Commit

Permalink
[ignore] Fix examples for target_dns in resources
Browse files Browse the repository at this point in the history
  • Loading branch information
akinross committed Jul 2, 2024
1 parent 230b9de commit 32589bb
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 16 deletions.
2 changes: 1 addition & 1 deletion docs/resources/endpoint_security_group.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ resource "aci_endpoint_security_group" "full_example_application_profile" {
relation_to_contract_masters = [
{
annotation = "annotation_1"
target_dn = "target_dn_0"
target_dn = aci_endpoint_security_group.example_2.id
}
]
annotations = [
Expand Down
8 changes: 4 additions & 4 deletions docs/resources/relation_to_contract_master.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ The configuration snippet below creates a Relation To Contract Master with only
resource "aci_relation_to_contract_master" "example_application_epg" {
parent_dn = aci_application_epg.example.id
target_dn = aci_endpoint_security_group.example.id
target_dn = aci_application_epg.example_2.id
}
resource "aci_relation_to_contract_master" "example_endpoint_security_group" {
parent_dn = aci_endpoint_security_group.example.id
target_dn = aci_endpoint_security_group.example.id
target_dn = aci_endpoint_security_group.example_2.id
}
```
Expand All @@ -59,7 +59,7 @@ The configuration snippet below shows all possible attributes of the Relation To
resource "aci_relation_to_contract_master" "full_example_application_epg" {
parent_dn = aci_application_epg.example.id
annotation = "annotation"
target_dn = aci_endpoint_security_group.example.id
target_dn = aci_application_epg.example_2.id
annotations = [
{
key = "key_0"
Expand All @@ -77,7 +77,7 @@ resource "aci_relation_to_contract_master" "full_example_application_epg" {
resource "aci_relation_to_contract_master" "full_example_endpoint_security_group" {
parent_dn = aci_endpoint_security_group.example.id
annotation = "annotation"
target_dn = aci_endpoint_security_group.example.id
target_dn = aci_endpoint_security_group.example_2.id
annotations = [
{
key = "key_0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ resource "aci_endpoint_security_group" "full_example_application_profile" {
relation_to_contract_masters = [
{
annotation = "annotation_1"
target_dn = "target_dn_0"
target_dn = aci_endpoint_security_group.example_2.id
}
]
annotations = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
resource "aci_relation_to_contract_master" "full_example_application_epg" {
parent_dn = aci_application_epg.example.id
annotation = "annotation"
target_dn = aci_endpoint_security_group.example.id
target_dn = aci_application_epg.example_2.id
annotations = [
{
key = "key_0"
Expand All @@ -20,7 +20,7 @@ resource "aci_relation_to_contract_master" "full_example_application_epg" {
resource "aci_relation_to_contract_master" "full_example_endpoint_security_group" {
parent_dn = aci_endpoint_security_group.example.id
annotation = "annotation"
target_dn = aci_endpoint_security_group.example.id
target_dn = aci_endpoint_security_group.example_2.id
annotations = [
{
key = "key_0"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@

resource "aci_relation_to_contract_master" "example_application_epg" {
parent_dn = aci_application_epg.example.id
target_dn = aci_endpoint_security_group.example.id
target_dn = aci_application_epg.example_2.id
}

resource "aci_relation_to_contract_master" "example_endpoint_security_group" {
parent_dn = aci_endpoint_security_group.example.id
target_dn = aci_endpoint_security_group.example.id
target_dn = aci_endpoint_security_group.example_2.id
}
11 changes: 8 additions & 3 deletions gen/templates/resource_example.tf.tmpl
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
{{- if .DocumentationExamples}}{{- range $key := .DocumentationExamples}}
{{- if .DocumentationExamples}}{{$parentIndex := 0}}{{- range $key := .DocumentationExamples}}
resource "aci_{{$.ResourceName}}" "example_{{getResourceName $key $.Definitions}}" {
{{- if $.HasParent}}
parent_dn = {{createParentDnValue $key "example" $.Definitions}}
{{- end}}
{{- range $.Properties}}{{- if .IsRequired}}{{- if ne .NamedPropertyClass ""}}
{{overwriteProperty .PkgName .SnakeCaseName $.Definitions}} = aci_{{getResourceName .NamedPropertyClass $.Definitions}}.example.name
{{- else if eq .SnakeCaseName "t_dn" }}
{{overwriteProperty .PkgName .SnakeCaseName $.Definitions}} = {{lookupTestValue .PkgName .SnakeCaseName $.TestVars $.Definitions | replace ".test_0.id" ".example.id"}}
{{- else if eq .SnakeCaseName "t_dn" }}{{$attributeKey := overwriteProperty .PkgName .SnakeCaseName $.Definitions}}
{{- range $index, $testParent := $.TestVars.parents }}
{{- if eq $index $parentIndex }}
{{$attributeKey}} = {{getTestTargetDn $.TestVars.targets $.TestVars.resourceName "" true $testParent.target_classes $index | replace "test" "example" | replace "_0" "" | replace "_1" "_2" }}
{{- $parentIndex = add $parentIndex 1 }}{{- break}}
{{- end}}
{{- end}}
{{- else}}
{{overwriteProperty .PkgName .SnakeCaseName $.Definitions}} = "{{lookupTestValue .PkgName .SnakeCaseName $.TestVars $.Definitions}}"{{- end}}{{- end}}
{{- end}}
Expand Down
16 changes: 13 additions & 3 deletions gen/templates/resource_example_all_attributes.tf.tmpl
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
{{- if .DocumentationExamples}}{{- range $key := .DocumentationExamples}}
{{- if .DocumentationExamples}}{{$parentIndex := 0}}{{- range $key := .DocumentationExamples}}
resource "aci_{{$.ResourceName}}" "full_example_{{getResourceName $key $.Definitions}}" {
{{- if $.HasParent}}
parent_dn = {{createParentDnValue $key "example" $.Definitions}}
{{- end}}
{{- range $.Properties}}{{- if ne .NamedPropertyClass ""}}
{{overwriteProperty .PkgName .SnakeCaseName $.Definitions}} = aci_{{getResourceName .NamedPropertyClass $.Definitions}}.example.name
{{- else if eq .SnakeCaseName "t_dn" }}
{{overwriteProperty .PkgName .SnakeCaseName $.Definitions}} = {{lookupTestValue .PkgName .SnakeCaseName $.TestVars $.Definitions | replace ".test_0.id" ".example.id"}}
{{- else if eq .SnakeCaseName "t_dn" }}{{$attributeKey := overwriteProperty .PkgName .SnakeCaseName $.Definitions}}
{{- range $index, $testParent := $.TestVars.parents }}
{{- if eq $index $parentIndex }}
{{$attributeKey}} = {{getTestTargetDn $.TestVars.targets $.TestVars.resourceName "" true $testParent.target_classes $index | replace "test" "example" | replace "_0" "" | replace "_1" "_2" }}
{{- $parentIndex = add $parentIndex 1 }}{{- break}}
{{- end}}
{{- end}}
{{- else if eq .ValueType "bitmask"}}{{ $bitmaskTestValue := lookupTestValue .PkgName .SnakeCaseName $.TestVars $.Definitions}}
{{overwriteProperty .PkgName .SnakeCaseName $.Definitions}} = [{{range $index, $value := $bitmaskTestValue}}{{if lt $index (substract (len $bitmaskTestValue) 1)}}"{{$value}}",{{else}}"{{$value}}"{{end}}{{end}}]
{{- else}}
Expand All @@ -16,6 +21,11 @@ resource "aci_{{$.ResourceName}}" "full_example_{{getResourceName $key $.Definit
{{$ChildResourceName}} = [
{ {{- range .Properties}}{{- if ne .NamedPropertyClass ""}}
{{overwriteProperty .PkgName .SnakeCaseName $.Definitions}} = aci_{{getResourceName .NamedPropertyClass $.Definitions}}.example.name
{{- else if eq .SnakeCaseName "t_dn" }}
{{- range $index, $testParent := $.TestVars.parents }}
target_dn = {{getTestTargetDn $.TestVars.child_targets $ChildResourceName "target_dn_0" true nil 0 | replace "test_0" "example_2" }}
{{- break}}
{{- end}}
{{- else}}
{{overwriteProperty .PkgName .SnakeCaseName $.Definitions}} = "{{lookupChildTestValue .PkgName $ChildResourceName .SnakeCaseName $.TestVars 0 $.Definitions}}"{{- end}}{{ end}}
}
Expand Down

0 comments on commit 32589bb

Please sign in to comment.