Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[minor_change] Added certificate_usage property to aci_certificate_authority (DCNE-222) #1294

Merged
merged 3 commits into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/resources/certificate_authority.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down
4 changes: 1 addition & 3 deletions gen/definitions/properties.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
19 changes: 16 additions & 3 deletions gen/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ func LookupTestValue(classPkgName, originalPropertyName string, testVars map[str
lookupValue = fmt.Sprintf(`"%s"`, val)
}
case []interface{}:
lookupValue = val
lookupValue = formatSlice(val)
}
}

Expand All @@ -468,7 +468,7 @@ func LookupTestValue(classPkgName, originalPropertyName string, testVars map[str
lookupValue = fmt.Sprintf(`"%s"`, val)
}
case []interface{}:
lookupValue = val
lookupValue = formatSlice(val)
}
}
}
Expand Down Expand Up @@ -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)
}
}
}
}
Expand All @@ -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)
Expand Down
16 changes: 8 additions & 8 deletions gen/templates/resource_example_all_attributes.tf.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -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}}
shrsr marked this conversation as resolved.
Show resolved Hide resolved
{{- else}}
{{overwriteProperty .PkgName .SnakeCaseName $.Definitions}} = {{lookupTestValue .PkgName .SnakeCaseName $.TestVars $.Definitions $.Properties}}
{{- end}}{{- end}}{{- end}}
Expand All @@ -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}}
}
Expand All @@ -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}}
}
Expand All @@ -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}}
Expand All @@ -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}}
}
Expand All @@ -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}}
}
Expand All @@ -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 }}
Expand Down
Loading