Skip to content

Commit cb07ce9

Browse files
committed
[ignore] template changes for lists
1 parent 447fc78 commit cb07ce9

File tree

2 files changed

+50
-16
lines changed

2 files changed

+50
-16
lines changed

gen/templates/resource.md.tmpl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,8 @@ All examples for the {{.ResourceNameAsDescription}} resource can be found in the
123123
{{- if eq .ValueType "bitmask"}}
124124
* `{{- overwriteProperty .PkgName .SnakeCaseName $.Definitions}}` ({{- .PropertyName}}) - (list) {{.Comment}}{{if and (ne $.Versions .Versions) (ne .Versions "")}} This attribute is supported in ACI versions: {{ .Versions}}{{- end}}
125125
{{- if .DefaultValue }}
126-
{{- if eq .DefaultValue "@aci_gen_default_value_overwrite_to_empty_string!"}}
127-
- Default: `""`
126+
{{- if eq .DefaultValue "@aci_gen_default_value_overwrite_to_empty_list!"}}
127+
- Default: `[]`
128128
{{- else}}
129129
- Default: `"{{ .DefaultValue }}"`
130130
{{- end}}
@@ -241,6 +241,8 @@ import {
241241
{{- if .DefaultValue }}
242242
{{- if eq .DefaultValue "@aci_gen_default_value_overwrite_to_empty_string!"}}
243243
{{ $indent }}- Default: `""`
244+
{{- else if eq .DefaultValue "@aci_gen_default_value_overwrite_to_empty_list!"}}
245+
{{ $indent }}- Default: `[]`
244246
{{- else}}
245247
{{ $indent }}- Default: `"{{ .DefaultValue }}"`
246248
{{- end}}

gen/templates/resource_test.go.tmpl

Lines changed: 46 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1290,6 +1290,11 @@ func TestAccResource{{.resourceClassName}}(t *testing.T) {
12901290
{{- else }}
12911291
{{- if eq $child_key "target_dn"}}
12921292
resource.TestCheckResourceAttr("aci_{{$.resourceName}}.test", "{{$key}}.{{$child_index}}.{{$child_key}}", "{{getTestTargetDn $.child_targets $key $child_value false nil $child_index false}}"),
1293+
{{- else if (isInterfaceSlice $child_value)}}
1294+
resource.TestCheckResourceAttr("aci_{{$.resourceName}}.test", "{{$key}}.{{$child_index}}.{{$child_key}}.#", "{{len $child_value}}"),
1295+
{{- range $index, $subvalue := $child_value}}
1296+
resource.TestCheckResourceAttr("aci_{{$.resourceName}}.test", "{{$key}}.{{$child_index}}.{{$child_key}}.{{$index}}", "{{$subvalue}}"),
1297+
{{- end}}
12931298
{{- else if and (ne $child_key "deletable_child") (ne $child_key "child_required")}}
12941299
resource.TestCheckResourceAttr("aci_{{$.resourceName}}.test", "{{$key}}.{{$child_index}}.{{$child_key}}", "{{$child_value}}"),
12951300
{{- end}}
@@ -1392,9 +1397,14 @@ func TestAccResource{{.resourceClassName}}(t *testing.T) {
13921397
{{- end }}),
13931398
{{- end }}
13941399
{{- else }}
1395-
{{- if eq $child_key "target_dn"}}
1400+
{{- if eq $child_key "target_dn"}}
13961401
resource.TestCheckResourceAttr("aci_{{$.resourceName}}.test", "{{$key}}.{{$child_index}}.{{$child_key}}", "{{getTestTargetDn $.child_targets $key $child_value false nil $child_index false}}"),
1397-
{{- else if and (ne $child_key "deletable_child") (ne $child_key "child_required")}}
1402+
{{- else if (isInterfaceSlice $child_value)}}
1403+
resource.TestCheckResourceAttr("aci_{{$.resourceName}}.test", "{{$key}}.{{$child_index}}.{{$child_key}}.#", "{{len $child_value}}"),
1404+
{{- range $index, $subvalue := $child_value}}
1405+
resource.TestCheckResourceAttr("aci_{{$.resourceName}}.test", "{{$key}}.{{$child_index}}.{{$child_key}}.{{$index}}", "{{$subvalue}}"),
1406+
{{- end}}
1407+
{{- else if and (ne $child_key "deletable_child") (ne $child_key "child_required")}}
13981408
resource.TestCheckResourceAttr("aci_{{$.resourceName}}.test", "{{$key}}.{{$child_index}}.{{$child_key}}", "{{$child_value}}"),
13991409
{{- end}}
14001410
{{- end}}
@@ -1496,9 +1506,14 @@ func TestAccResource{{.resourceClassName}}(t *testing.T) {
14961506
{{- end }}),
14971507
{{- end }}
14981508
{{- else }}
1499-
{{- if eq $child_key "target_dn"}}
1509+
{{- if eq $child_key "target_dn"}}
15001510
resource.TestCheckResourceAttr("aci_{{$.resourceName}}.test", "{{$key}}.0.{{$child_key}}", "{{getTestTargetDn $.child_targets $key $child_value false nil 1 false}}"),
1501-
{{- else}}
1511+
{{- else if (isInterfaceSlice $child_value)}}
1512+
resource.TestCheckResourceAttr("aci_{{$.resourceName}}.test", "{{$key}}.0.{{$child_key}}.#", "{{len $child_value}}"),
1513+
{{- range $index, $subvalue := $child_value}}
1514+
resource.TestCheckResourceAttr("aci_{{$.resourceName}}.test", "{{$key}}.0.{{$child_key}}.{{$index}}", "{{$subvalue}}"),
1515+
{{- end}}
1516+
{{- else}}
15021517
resource.TestCheckResourceAttr("aci_{{$.resourceName}}.test", "{{$key}}.0.{{$child_key}}", "{{$child_value}}"),
15031518
{{- end}}
15041519
{{- end}}
@@ -2508,6 +2523,12 @@ resource "aci_{{$.resourceName}}" "test" {
25082523
{{- else }}
25092524
{{- if eq $child_key "target_dn"}}{{$attributeValue := getTestTargetDn $.child_targets $key $child_value true nil $index false}}
25102525
{{$child_key}} = {{if isReference $attributeValue}}{{$attributeValue}}{{- else if isInterfaceSlice $attributeValue}}{{- if lt 0 (len $attributeValue)}}[{{fromInterfacesToString $attributeValue}}]{{else}}[]{{end}}{{else}}"{{$attributeValue}}"{{end}}
2526+
{{- else if (isInterfaceSlice $child_value)}}
2527+
{{- if lt 0 (len $child_value)}}
2528+
{{$child_key}} = [{{range $index, $subvalue := $child_value}}{{if lt $index (subtract (len $child_value) 1)}}"{{$subvalue}}", {{else}}"{{$subvalue}}"{{end}}{{end}}]
2529+
{{- else}}
2530+
{{$child_key}} = []
2531+
{{- end}}
25112532
{{- else if and (ne $child_key "deletable_child") (ne $child_key "child_required")}}
25122533
{{$child_key}} = "{{$child_value}}"
25132534
{{- end}}
@@ -2537,7 +2558,7 @@ resource "aci_{{$.resourceName}}" "test" {
25372558
{{- range $key, $value := $.resource_required}}
25382559
{{- if eq $key "target_dn" }}{{$attributeValue := getTestTargetDn $.targets $.resourceName $value true nil 0 false}}
25392560
{{$key}} = {{if isReference $attributeValue}}{{$attributeValue}}{{- else if isInterfaceSlice $attributeValue}}{{- if lt 0 (len $attributeValue)}}[{{fromInterfacesToString $attributeValue}}]{{else}}[]{{end}}{{else}}"{{$attributeValue}}"{{end}}
2540-
{{- else }}
2561+
{{- else }}
25412562
{{$key}} = "{{$value}}"
25422563
{{- end }}
25432564
{{- end}}
@@ -2610,7 +2631,13 @@ resource "aci_{{$.resourceName}}" "test" {
26102631
{{- else }}
26112632
{{- if eq $child_key "target_dn"}}{{$attributeValue := getTestTargetDn $.child_targets $key $child_value true nil 1 false}}
26122633
{{$child_key}} = {{if isReference $attributeValue}}{{$attributeValue}}{{- else if isInterfaceSlice $attributeValue}}{{- if lt 0 (len $attributeValue)}}[{{fromInterfacesToString $attributeValue}}]{{else}}[]{{end}}{{else}}"{{$attributeValue}}"{{end}}
2613-
{{- else }}
2634+
{{- else if (isInterfaceSlice $child_value)}}
2635+
{{- if lt 0 (len $child_value)}}
2636+
{{$child_key}} = [{{range $index, $subvalue := $child_value}}{{if lt $index (subtract (len $child_value) 1)}}"{{$subvalue}}", {{else}}"{{$subvalue}}"{{end}}{{end}}]
2637+
{{- else}}
2638+
{{$child_key}} = []
2639+
{{- end}}
2640+
{{- else }}
26142641
{{$child_key}} = "{{$child_value}}"
26152642
{{- end}}
26162643
{{- end}}
@@ -3170,16 +3197,16 @@ resource "aci_{{$.resourceName}}" "test" {
31703197
{{- end }}{{- end }}),
31713198
{{- end }}
31723199
{{- else }}
3173-
{{- if eq $child_key "target_dn"}}
3200+
{{- if eq $child_key "target_dn"}}
31743201
resource.TestCheckResourceAttr("{{$resourceName}}", "{{$inheritedKey}}.{{$key}}.{{$child_key}}", "{{getTestTargetDn $.child_targets $key $child_value false nil $child_index false}}"),
3175-
{{- else if (isInterfaceSlice $child_value)}}
3202+
{{- else if (isInterfaceSlice $child_value)}}
31763203
resource.TestCheckResourceAttr("{{$resourceName}}", "{{$inheritedKey}}.{{$key}}.{{$child_key}}.#", "{{len $child_value}}"),
3177-
{{- range $index, $subvalue := $child_value}}
3204+
{{- range $index, $subvalue := $child_value}}
31783205
resource.TestCheckResourceAttr("{{$resourceName}}", "{{$inheritedKey}}.{{$key}}.{{$child_key}}.{{$index}}", "{{$subvalue}}"),
3179-
{{- end}}
3180-
{{- else if and (ne $child_key "deletable_child") (ne $child_key "child_required")}}
3206+
{{- end}}
3207+
{{- else if and (ne $child_key "deletable_child") (ne $child_key "child_required")}}
31813208
resource.TestCheckResourceAttr("{{$resourceName}}", "{{$inheritedKey}}.{{$key}}.{{$child_key}}", "{{$child_value}}"),
3182-
{{- end}}
3209+
{{- end}}
31833210
{{- end}}
31843211
{{- end}}
31853212
{{- end }}
@@ -3196,9 +3223,14 @@ resource "aci_{{$.resourceName}}" "test" {
31963223
{{- end }}),
31973224
{{- end }}
31983225
{{- else }}
3199-
{{- if eq $child_key "target_dn"}}
3226+
{{- if eq $child_key "target_dn"}}
32003227
resource.TestCheckResourceAttr("{{$resourceName}}", "{{$inheritedKey}}.{{$key}}.{{$child_index}}.{{$child_key}}", "{{getTestTargetDn $.child_targets $key $child_value false nil $child_index false}}"),
3201-
{{- else if and (ne $child_key "deletable_child") (ne $child_key "child_required")}}
3228+
{{- else if (isInterfaceSlice $child_value)}}
3229+
resource.TestCheckResourceAttr("{{$resourceName}}", "{{$inheritedKey}}.{{$key}}.{{$child_key}}.#", "{{len $child_value}}"),
3230+
{{- range $index, $subvalue := $child_value}}
3231+
resource.TestCheckResourceAttr("{{$resourceName}}", "{{$inheritedKey}}.{{$key}}.{{$child_key}}.{{$index}}", "{{$subvalue}}"),
3232+
{{- end}}
3233+
{{- else if and (ne $child_key "deletable_child") (ne $child_key "child_required")}}
32023234
resource.TestCheckResourceAttr("{{$resourceName}}", "{{$inheritedKey}}.{{$key}}.{{$child_index}}.{{$child_key}}", "{{$child_value}}"),
32033235
{{- end}}
32043236
{{- end}}

0 commit comments

Comments
 (0)