diff --git a/docs/resources/certificate_authority.md b/docs/resources/certificate_authority.md index 6da15b8da..9d11ab7ad 100644 --- a/docs/resources/certificate_authority.md +++ b/docs/resources/certificate_authority.md @@ -105,7 +105,7 @@ hvcNAQELBQADgYEAOmvre+5tgZ0+F3DgsfxNQqLTrGiBgGCIymPkP/cBXXkNuJyl KU0Td2OpVyo0eLqjoX5u2G90IBWzhyjFbo+CcKMrSVKj1YOdG0E3OuiJf00= -----END CERTIFICATE----- EOT - certificate_usage = test_value + certificate_usage = ["WebSvcOrAuth"] description = "description_1" name = "test_name" name_alias = "name_alias_1" @@ -145,7 +145,7 @@ hvcNAQELBQADgYEAOmvre+5tgZ0+F3DgsfxNQqLTrGiBgGCIymPkP/cBXXkNuJyl KU0Td2OpVyo0eLqjoX5u2G90IBWzhyjFbo+CcKMrSVKj1YOdG0E3OuiJf00= -----END CERTIFICATE----- EOT - certificate_usage = test_value + certificate_usage = ["WebSvcOrAuth"] description = "description_1" name = "test_name" name_alias = "name_alias_1" diff --git a/examples/resources/aci_certificate_authority/resource-all-attributes.tf b/examples/resources/aci_certificate_authority/resource-all-attributes.tf index 16253f016..eee01b325 100644 --- a/examples/resources/aci_certificate_authority/resource-all-attributes.tf +++ b/examples/resources/aci_certificate_authority/resource-all-attributes.tf @@ -17,7 +17,7 @@ hvcNAQELBQADgYEAOmvre+5tgZ0+F3DgsfxNQqLTrGiBgGCIymPkP/cBXXkNuJyl KU0Td2OpVyo0eLqjoX5u2G90IBWzhyjFbo+CcKMrSVKj1YOdG0E3OuiJf00= -----END CERTIFICATE----- EOT - certificate_usage = test_value + certificate_usage = ["WebSvcOrAuth"] description = "description_1" name = "test_name" name_alias = "name_alias_1" @@ -57,7 +57,7 @@ hvcNAQELBQADgYEAOmvre+5tgZ0+F3DgsfxNQqLTrGiBgGCIymPkP/cBXXkNuJyl KU0Td2OpVyo0eLqjoX5u2G90IBWzhyjFbo+CcKMrSVKj1YOdG0E3OuiJf00= -----END CERTIFICATE----- EOT - certificate_usage = test_value + certificate_usage = ["WebSvcOrAuth"] description = "description_1" name = "test_name" name_alias = "name_alias_1" diff --git a/gen/definitions/properties.yaml b/gen/definitions/properties.yaml index 68d40b191..c39fdf1fe 100644 --- a/gen/definitions/properties.yaml +++ b/gen/definitions/properties.yaml @@ -200,12 +200,10 @@ pkiTP: overwrites: cert_usage: "certificate_usage" cert_chain: "certificate_chain" - ignores: - - "certUsage" resource_required: - "certChain" ignore_properties_in_test: - certUsage: "" + certUsage: ["WebSvcOrAuth"] documentation: certUsage: "The certificate usage of the Certificate Authority object." test_values: diff --git a/gen/generator.go b/gen/generator.go index 56a9e57f8..cf100302d 100644 --- a/gen/generator.go +++ b/gen/generator.go @@ -450,7 +450,7 @@ func LookupTestValue(classPkgName, originalPropertyName string, testVars map[str lookupValue = fmt.Sprintf(`"%s"`, val) } case []interface{}: - lookupValue = val + lookupValue = formatSlice(val) } } @@ -468,7 +468,7 @@ func LookupTestValue(classPkgName, originalPropertyName string, testVars map[str lookupValue = fmt.Sprintf(`"%s"`, val) } case []interface{}: - lookupValue = val + lookupValue = formatSlice(val) } } } @@ -1805,7 +1805,12 @@ func ignoreTestProperty(propertyName, classPkgName string, definitions Definitio if key.(string) == "ignore_properties_in_test" { for k, v := range value.(map[interface{}]interface{}) { if k.(string) == propertyName { - return true, v.(string) + switch val := v.(type) { + case []interface{}: + return true, formatSlice(val) + default: + return true, fmt.Sprintf(`"%s"`, val) + } } } } @@ -1815,6 +1820,14 @@ func ignoreTestProperty(propertyName, classPkgName string, definitions Definitio return false, "" } +func formatSlice(slice []interface{}) string { + formattedSlice := make([]string, len(slice)) + for i, v := range slice { + formattedSlice[i] = fmt.Sprintf("\"%v\"", v) + } + return fmt.Sprintf("[%v]", strings.Join(formattedSlice, ", ")) +} + func updateVersionMismatched(model *Model, classVersion, propertyVersion, propertyName string) { classVersionResult := providerFunctions.ParseVersion(classVersion) propertyVersionResult := providerFunctions.ParseVersion(propertyVersion) diff --git a/gen/templates/resource_example_all_attributes.tf.tmpl b/gen/templates/resource_example_all_attributes.tf.tmpl index 9535bd7d9..65b7d0363 100644 --- a/gen/templates/resource_example_all_attributes.tf.tmpl +++ b/gen/templates/resource_example_all_attributes.tf.tmpl @@ -18,9 +18,7 @@ resource "aci_{{$.ResourceName}}" "full_example_{{getResourceName $key $.Definit {{- end}} {{- end}} {{- else if .IgnoreInTest}} - {{overwriteProperty .PkgName .SnakeCaseName $.Definitions}} = "{{.IgnoreInTestExampleValue}}" - {{- else if eq .ValueType "bitmask"}}{{ $bitmaskTestValue := lookupTestValue .PkgName .SnakeCaseName $.TestVars $.Definitions $.Properties}} - {{overwriteProperty .PkgName .SnakeCaseName $.Definitions}} = [{{range $index, $value := $bitmaskTestValue}}{{if lt $index (subtract (len $bitmaskTestValue) 1)}}"{{$value}}",{{else}}"{{$value}}"{{end}}{{end}}] + {{overwriteProperty .PkgName .SnakeCaseName $.Definitions}} = {{.IgnoreInTestExampleValue}} {{- else}} {{overwriteProperty .PkgName .SnakeCaseName $.Definitions}} = {{lookupTestValue .PkgName .SnakeCaseName $.TestVars $.Definitions $.Properties}} {{- end}}{{- end}}{{- end}} @@ -35,7 +33,7 @@ resource "aci_{{$.ResourceName}}" "full_example_{{getResourceName $key $.Definit {{- break}} {{- end}} {{- else if .IgnoreInTest}} - {{overwriteProperty .PkgName .SnakeCaseName $.Definitions}} = "{{.IgnoreInTestExampleValue}}" + {{overwriteProperty .PkgName .SnakeCaseName $.Definitions}} = {{.IgnoreInTestExampleValue}} {{- else}} {{overwriteProperty .PkgName .SnakeCaseName $.Definitions}} = "{{lookupChildTestValue .PkgName $ChildResourceName .SnakeCaseName $.TestVars 0 $.Definitions}}"{{- end}}{{ end}}{{- end}} } @@ -49,7 +47,7 @@ resource "aci_{{$.ResourceName}}" "full_example_{{getResourceName $key $.Definit {{- break}} {{- end}} {{- else if .IgnoreInTest}} - {{overwriteProperty .PkgName .SnakeCaseName $.Definitions}} = "{{.IgnoreInTestExampleValue}}" + {{overwriteProperty .PkgName .SnakeCaseName $.Definitions}} = {{.IgnoreInTestExampleValue}} {{- else}} {{overwriteProperty .PkgName .SnakeCaseName $.Definitions}} = "{{lookupChildTestValue .PkgName $ChildResourceName .SnakeCaseName $.TestVars 0 $.Definitions}}"{{- end}}{{ end}}{{- end}} } @@ -69,7 +67,7 @@ resource "aci_{{$.ResourceName}}" "full_example" { {{- else if eq .SnakeCaseName "t_dn" }} {{overwriteProperty .PkgName .SnakeCaseName $.Definitions}} = {{lookupTestValue .PkgName .SnakeCaseName $.TestVars $.Definitions $.Properties | replace ".test_0.id" ".example.id"}} {{- else if .IgnoreInTest}} - {{overwriteProperty .PkgName .SnakeCaseName $.Definitions}} = "{{.IgnoreInTestExampleValue}}" + {{overwriteProperty .PkgName .SnakeCaseName $.Definitions}} = {{.IgnoreInTestExampleValue}} {{- else}} {{overwriteProperty .PkgName .SnakeCaseName $.Definitions}} = {{lookupTestValue .PkgName .SnakeCaseName $.TestVars $.Definitions $.Properties}} {{- end}}{{- end}}{{- end}} @@ -81,7 +79,7 @@ resource "aci_{{$.ResourceName}}" "full_example" { {{- else if eq .SnakeCaseName "t_dn" }}{{$attributeVale := getTestTargetDn $.TestVars.child_targets $ChildResourceName "target_dn_0" true nil 0 true | replace "test_0" "example_2" }} target_dn = {{if containsString $attributeVale "."}}{{$attributeVale}}{{else}}"{{$attributeVale}}"{{end}} {{- else if .IgnoreInTest}} - {{overwriteProperty .PkgName .SnakeCaseName $.Definitions}} = "{{.IgnoreInTestExampleValue}}" + {{overwriteProperty .PkgName .SnakeCaseName $.Definitions}} = {{.IgnoreInTestExampleValue}} {{- else}} {{overwriteProperty .PkgName .SnakeCaseName $.Definitions}} = "{{lookupChildTestValue .PkgName $ChildResourceName .SnakeCaseName $.TestVars 0 $.Definitions}}"{{- end}}{{ end}}{{- end}} } @@ -92,7 +90,7 @@ resource "aci_{{$.ResourceName}}" "full_example" { {{- else if eq .SnakeCaseName "t_dn" }}{{$attributeVale := getTestTargetDn $.TestVars.child_targets $ChildResourceName "target_dn_0" true nil 0 true | replace "test_0" "example_2" }} target_dn = {{if containsString $attributeVale "."}}{{$attributeVale}}{{else}}"{{$attributeVale}}"{{end}} {{- else if .IgnoreInTest}} - {{overwriteProperty .PkgName .SnakeCaseName $.Definitions}} = "{{.IgnoreInTestExampleValue}}" + {{overwriteProperty .PkgName .SnakeCaseName $.Definitions}} = {{.IgnoreInTestExampleValue}} {{- else}} {{overwriteProperty .PkgName .SnakeCaseName $.Definitions}} = "{{lookupChildTestValue .PkgName $ChildResourceName .SnakeCaseName $.TestVars 0 $.Definitions}}"{{- end}}{{ end}}{{- end}} } @@ -115,6 +113,8 @@ resource "aci_{{$topContext.ResourceName}}" {{- if ne $formatValue.ContainedBy " {{- range $topContext.Properties }} {{- if ne .NamedPropertyClass ""}} {{overwriteProperty .PkgName .SnakeCaseName $.Definitions}} = aci_{{getResourceName .NamedPropertyClass $.Definitions}}.example.name + {{- else if .IgnoreInTest }} + {{overwriteProperty .PkgName .SnakeCaseName $.Definitions}} = {{.IgnoreInTestExampleValue}} {{- else}} {{overwriteProperty .PkgName .SnakeCaseName $.Definitions}} = {{lookupTestValue .PkgName .SnakeCaseName $.TestVars $.Definitions $.Properties}} {{- end }}