From 960ba96cbfbbb885c4e5a2a49f4a4b38615a8168 Mon Sep 17 00:00:00 2001 From: Shreyas Date: Mon, 4 Mar 2024 15:54:11 -0500 Subject: [PATCH] [minor_change] Addition of logic to run tests on only cloud apics based on platform flavors in the meta --- docs/data-sources/annotation.md | 1 + docs/data-sources/certificate_authority.md | 9 +- docs/resources/annotation.md | 1 + docs/resources/certificate_authority.md | 33 +- .../aci_certificate_authority/data-source.tf | 5 + .../resource-all-attributes.tf | 17 + .../aci_certificate_authority/resource.tf | 8 +- gen/definitions/classes.yaml | 43 +- gen/definitions/properties.yaml | 15 - gen/generator.go | 325 ++++++++-- gen/meta/cloudCertStore.json | 587 ++++++++++++++++++ gen/templates/datasource_test.go.tmpl | 4 +- gen/templates/resource.go.tmpl | 55 ++ gen/templates/resource_example.tf.tmpl | 7 +- gen/templates/resource_test.go.tmpl | 64 +- gen/templates/testvars.yaml.tmpl | 41 +- gen/testvars/fvEpIpTag.yaml | 4 +- gen/testvars/fvEpMacTag.yaml | 4 +- gen/testvars/l3extConsLbl.yaml | 3 +- gen/testvars/l3extRsRedistributePol.yaml | 3 +- gen/testvars/mgmtInstP.yaml | 4 +- gen/testvars/mgmtRsOoBCons.yaml | 3 +- gen/testvars/mgmtSubnet.yaml | 3 +- gen/testvars/pimRouteMapEntry.yaml | 3 +- gen/testvars/pimRouteMapPol.yaml | 3 +- gen/testvars/pkiTP.yaml | 17 +- gen/testvars/tagAnnotation.yaml | 13 +- gen/testvars/vzOOBBrCP.yaml | 4 +- go.mod | 1 + go.sum | 2 + .../data_source_aci_annotation_test.go | 4 +- ...a_source_aci_certificate_authority_test.go | 57 +- .../data_source_aci_endpoint_tag_ip_test.go | 2 +- .../data_source_aci_endpoint_tag_mac_test.go | 2 +- ...anagement_network_instance_profile_test.go | 2 +- ...external_management_network_subnet_test.go | 2 +- ...ta_source_aci_l3out_consumer_label_test.go | 2 +- ...urce_aci_l3out_redistribute_policy_test.go | 2 +- ...ta_source_aci_out_of_band_contract_test.go | 2 +- ...ata_source_aci_pim_route_map_entry_test.go | 2 +- ...ta_source_aci_pim_route_map_policy_test.go | 2 +- ...n_to_consumed_out_of_band_contract_test.go | 2 +- .../data_source_aci_rest_managed_test.go | 2 +- internal/provider/provider.go | 22 +- internal/provider/provider_test.go | 34 +- .../provider/resource_aci_annotation_test.go | 92 +-- .../resource_aci_certificate_authority.go | 87 +-- ...resource_aci_certificate_authority_test.go | 445 ++++++++++++- .../resource_aci_endpoint_tag_ip_test.go | 4 +- .../resource_aci_endpoint_tag_mac_test.go | 4 +- ...anagement_network_instance_profile_test.go | 2 +- ...external_management_network_subnet_test.go | 2 +- .../resource_aci_l3out_consumer_label_test.go | 2 +- ...urce_aci_l3out_redistribute_policy_test.go | 2 +- .../resource_aci_out_of_band_contract_test.go | 2 +- .../resource_aci_pim_route_map_entry_test.go | 2 +- .../resource_aci_pim_route_map_policy_test.go | 2 +- ...n_to_consumed_out_of_band_contract_test.go | 2 +- .../resource_aci_rest_managed_test.go | 24 +- internal/provider/test_constants.go | 2 +- 60 files changed, 1678 insertions(+), 417 deletions(-) create mode 100644 gen/meta/cloudCertStore.json diff --git a/docs/data-sources/annotation.md b/docs/data-sources/annotation.md index b11520950..a69991f7a 100644 --- a/docs/data-sources/annotation.md +++ b/docs/data-sources/annotation.md @@ -53,6 +53,7 @@ data "aci_annotation" "example_application_epg" { ### Required ### * `parent_dn` - (string) The distinguished name (DN) of the parent object, possible resources: + - [aci_certificate_store](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/certificate_store) ([cloudCertStore](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/cloudCertStore/overview)) - [aci_application_epg](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/application_epg) ([fvAEPg](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/fvAEPg/overview)) - [aci_endpoint_tag_ip](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/endpoint_tag_ip) ([fvEpIpTag](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/fvEpIpTag/overview)) - [aci_endpoint_tag_mac](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/endpoint_tag_mac) ([fvEpMacTag](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/fvEpMacTag/overview)) diff --git a/docs/data-sources/certificate_authority.md b/docs/data-sources/certificate_authority.md index 7004b0080..6aa2a4c9b 100644 --- a/docs/data-sources/certificate_authority.md +++ b/docs/data-sources/certificate_authority.md @@ -31,6 +31,11 @@ Data source for Certificate Authority ```hcl +data "aci_certificate_authority" "example_certificate_store" { + parent_dn = aci_certificate_store.example.id + name = "test_name" +} + data "aci_certificate_authority" "example_public_key_management" { parent_dn = aci_public_key_management.example.id name = "test_name" @@ -43,10 +48,8 @@ data "aci_certificate_authority" "example_public_key_management" { ### Required ### * `parent_dn` - (string) The distinguished name (DN) of the parent object, possible resources: + - [aci_certificate_store](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/certificate_store) ([cloudCertStore](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/cloudCertStore/overview)) - [aci_public_key_management](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/public_key_management) ([pkiEp](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/pkiEp/overview)) - - The distinquised name (DN) of classes below can be used but currently there is no available resource for it: - - [cloudCertStore](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/cloudCertStore/overview) - * `name` (name) - (string) The name of the Certificate Authority object. ### Read-Only ### diff --git a/docs/resources/annotation.md b/docs/resources/annotation.md index a9e7b6cd0..04673e8b6 100644 --- a/docs/resources/annotation.md +++ b/docs/resources/annotation.md @@ -62,6 +62,7 @@ All examples for the Annotation resource can be found in the [examples](https:// ### Required ### * `parent_dn` - (string) The distinguished name (DN) of the parent object, possible resources: + - [aci_certificate_store](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/certificate_store) ([cloudCertStore](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/cloudCertStore/overview)) - [aci_application_epg](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/application_epg) ([fvAEPg](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/fvAEPg/overview)) - [aci_endpoint_tag_ip](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/endpoint_tag_ip) ([fvEpIpTag](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/fvEpIpTag/overview)) - [aci_endpoint_tag_mac](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/endpoint_tag_mac) ([fvEpMacTag](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/fvEpMacTag/overview)) diff --git a/docs/resources/certificate_authority.md b/docs/resources/certificate_authority.md index a3b580f26..27d9c8322 100644 --- a/docs/resources/certificate_authority.md +++ b/docs/resources/certificate_authority.md @@ -35,8 +35,14 @@ The configuration snippet below creates a Certificate Authority with only requir ```hcl +resource "aci_certificate_authority" "example_certificate_store" { + parent_dn = aci_certificate_store.example.id + cert_chain = "< Policies -> Protocol -> Endpoint Tags -> Endpoint IP" sub_category: "Tenant Policies" -======= -commHttps: - include: true - -# pkiKeyRing: -# contained_by: -# - "polUni" -# rn_prepend: "userext/pkiext" -# dn_formats: -# #- "uni/tn-{name}/certstore/tp-{name}" -# - "uni/userext/pkiext/tp-{name}" - -# cloudCertStore: -# rn_format: "uni/tn-{name}" - -# pkiKeyRing: -# parent_dn: -# - "uni/userext/pkiext" pkiTP: - # contained_by: - # - "pkiEp" - parent_dn: - - "uni/userext/pkiext" - -# aaaUserEp: -# contained_by: -# - "polUni" -# rn_prepend: "uni" -# dn_formats: -# - "uni/userext" - ->>>>>>> b2f52a6d ([minor_change] Addition of new generated resource and data source for pkiTP) + multi_parents: + - rn_prepend: "certstore" + contained_by: "fvTenant" + test_type: "cloud" + - rn_prepend: "uni/userext/pkiext" + contained_by: "polUni" + test_type: "both" + # - contained_by: + # - "pkiEp" + \ No newline at end of file diff --git a/gen/definitions/properties.yaml b/gen/definitions/properties.yaml index d4d80080b..12db2cc00 100644 --- a/gen/definitions/properties.yaml +++ b/gen/definitions/properties.yaml @@ -138,16 +138,8 @@ tagAnnotation: test_values: default: value: "test_value" - parents: - - class_name: "commHttps" - parent_dependency: "commPol" - - class_name: "commPol" - parent_dependency: "" pkiTP: - parents: - - parent_dn: "uni/userext/pkiext" - - is_explicit_parent_dn: true resource_required: - "certChain" test_values: @@ -202,11 +194,4 @@ pkiTP: KU0Td2OpVyo0eLqjoX5u2G90IBWzhyjFbo+CcKMrSVKj1YOdG0E3OuiJf00= -----END_CERTIFICATE----- EOT - -# pkiKeyRing: -# test_values: -# default: -# regen: "no" -# all: -# regen: "no" \ No newline at end of file diff --git a/gen/generator.go b/gen/generator.go index e823592d7..3f337caa3 100644 --- a/gen/generator.go +++ b/gen/generator.go @@ -112,6 +112,7 @@ var duplicateLabels = []string{} var resourceNames = map[string]string{} var rnPrefix = map[string]string{} var targetRelationalPropertyClasses = map[string]string{} +var testCloudApic, testApic []interface{} func GetResourceNameAsDescription(s string) string { return cases.Title(language.English).String(strings.ReplaceAll(s, "_", " ")) @@ -248,6 +249,17 @@ func FromInterfacesToString(identifiedBy []interface{}) string { return fmt.Sprintf("\"%s\"", strings.Join(identifiers, "\", \"")) } +func addGetTestClassificationFunc(testType []TestClassification) { + templateFuncs["getTestType"] = func(parent string) string { + for _, testClassification := range testType { + if testClassification.ImmediateParent == parent { + return testClassification.TestClassification + } + } + return "both" + } +} + // Renders the templates and writes a file to the output directory func renderTemplate(templateName, outputFileName, outputPath string, outputData interface{}) { templateData, err := os.ReadFile(fmt.Sprintf("%s/%s", templatePath, templateName)) @@ -311,10 +323,18 @@ func getClassModels(definitions Definitions) map[string]Model { pkgNames = append(pkgNames, strings.TrimSuffix(file.Name(), path.Ext(file.Name()))) } for _, pkgName := range pkgNames { - classModel := Model{PkgName: pkgName} classModel.setClassModel(metaPath, false, definitions, []string{}, pkgNames) classModels[pkgName] = classModel + + apicType, _ := classModel.PlatformFlavors["apicType"] + for _, value := range apicType { + if value.(string) == "capic" { + testCloudApic = append(testCloudApic, pkgName) + } else if value.(string) == "apic" { + testApic = append(testApic, pkgName) + } + } } return classModels } @@ -429,7 +449,7 @@ func migrateLegacyDocumentation() { // Container function to clean all directories properly func cleanDirectories() { cleanDirectory(docsPath, []string{"resources", "data-sources"}) - cleanDirectory(providerPath, []string{"provider_test.go", "utils.go", "test_constants.go", "resource_aci_rest_managed.go", "resource_aci_rest_managed_test.go", "data_source_aci_rest_managed.go", "data_source_aci_rest_managed_test.go"}) + cleanDirectory(providerPath, []string{"provider_test.go", "utils.go", "test_constants.go", "resource_aci_rest_managed.go", "resource_aci_rest_managed_test.go", "data_source_aci_rest_managed.go", "data_source_aci_rest_managed_test.go", "annotation_unsupported.go"}) cleanDirectory(resourcesDocsPath, []string{}) cleanDirectory(datasourcesDocsPath, []string{}) cleanDirectory(testVarsPath, []string{}) @@ -552,7 +572,22 @@ func main() { renderTemplate("annotation_unsupported.go.tmpl", "annotation_unsupported.go", providerPath, annotationUnsupported) } for _, model := range classModels { + predecessorPaths := calculatePredecessors(nil, model.PkgName, classModels) + testType := GetOverwriteTestType(model.PkgName, definitions) + foundValidTestType := false + for _, test := range testType { + if test.TestClassification != "none" { + model.TestType = testType + foundValidTestType = true + break + } + } + if !foundValidTestType { + model.TestType = classifyTests(model.PkgName, predecessorPaths, testCloudApic, testApic) + } + log.Printf("HERE test types for class %v and its paths %v are %v", model.PkgName, predecessorPaths, model.TestType) + addGetTestClassificationFunc(model.TestType) // Only render resources and datasources when the class has a unique identifier or is marked as include in the classes definitions YAML file if len(model.IdentifiedBy) > 0 || model.Include { @@ -578,7 +613,7 @@ func main() { // Set the documentation specific information for the resource // This is done to ensure references can be made to parent/child resources and output amounts can be restricted setDocumentationData(&model, definitions) - setExplicitParentDns(&model) + setParentDnOptional(&model) // Render the testvars file for the resource // First generate run would not mean the file is correct from beginning since some testvars would need to be manually overwritten in the properties definitions YAML file @@ -615,6 +650,90 @@ func main() { } +type TestClassification struct { + ImmediateParent string + TestClassification string +} + +func classifyTests(classPkgName string, paths [][]string, cloudApic []interface{}, apic []interface{}) []TestClassification { + contains := func(list []interface{}, item string) bool { + for _, listItem := range list { + if listItem == item { + return true + } + } + return false + } + + var testClassifications []TestClassification + immediateParent := classPkgName + foundInCloud := false + foundInApic := false + if contains(cloudApic, classPkgName) { + foundInCloud = true + } else if contains(apic, classPkgName) { + foundInApic = true + } + + for _, path := range paths { + if len(path) == 0 { + continue + } + immediateParent = path[0] + if !foundInCloud && !foundInApic { + for _, item := range path { + if contains(cloudApic, item) { + foundInCloud = true + break + } + if contains(apic, item) { + foundInApic = true + } + } + } + var testClassification string + if foundInCloud { + testClassification = "cloud" + } else if foundInApic { + testClassification = "apic" + } else { + testClassification = "both" + } + + testClassifications = append(testClassifications, TestClassification{ + ImmediateParent: immediateParent, + TestClassification: testClassification, + }) + + //Reset the flags + foundInCloud = false + foundInApic = false + + } + + return testClassifications +} + +func calculatePredecessors(predecessor []string, classPkgName string, classModels map[string]Model) [][]string { + var results [][]string + for _, model := range classModels { + if model.PkgName == classPkgName { + for _, classInContained := range model.ContainedBy { + newPredecessor := make([]string, len(predecessor)) + copy(newPredecessor, predecessor) + newPredecessor = append(newPredecessor, classInContained) + paths := calculatePredecessors(newPredecessor, classInContained, classModels) + results = append(results, paths...) + } + break + } + } + if len(results) == 0 { + return [][]string{predecessor} + } + return results +} + // A Model that represents the provider type ProviderModel struct { Example string @@ -633,45 +752,49 @@ type Metadata struct { // A Model represents a ACI class // All information is retrieved directly or deduced from the metadata type Model struct { - PkgName string - Label string - Name string - RnFormat string - RnPrepend string - Comment string - ResourceClassName string - ResourceName string - ResourceNameDocReference string - ChildResourceName string - ExampleDataSource string - ExampleResource string - ExampleResourceFull string - SubCategory string - RelationshipClass string - RelationshipResourceName string - Versions string - ChildClasses []string - ContainedBy []string - Contains []string - DocumentationDnFormats []string - DocumentationParentDns []string - DocumentationExamples []string - DocumentationChildren []string - ResourceNotes []string - ResourceWarnings []string - DatasourceNotes []string - DatasourceWarnings []string - Parents []string - UiLocations []string - ExplicitParentDns []string - IdentifiedBy []interface{} - DnFormats []interface{} - Properties map[string]Property - NamedProperties map[string]Property - Children map[string]Model - Configuration map[string]interface{} - TestVars map[string]interface{} - Definitions Definitions + PkgName string + Label string + Name string + RnFormat string + RnPrepend string + Comment string + ResourceClassName string + ResourceName string + ResourceNameDocReference string + ChildResourceName string + ExampleDataSource string + ExampleResource string + ExampleResourceFull string + SubCategory string + RelationshipClass string + RelationshipResourceName string + Versions string + TestType []TestClassification + ChildClasses []string + ContainedBy []string + Contains []string + DocumentationDnFormats []string + DocumentationParentDns []string + DocumentationExamples []string + DocumentationChildren []string + ResourceNotes []string + ResourceWarnings []string + DatasourceNotes []string + DatasourceWarnings []string + Parents []string + UiLocations []string + RnFormatMap map[string]string + IdentifiedBy []interface{} + DnFormats []interface{} + PlatformFlavors map[string][]interface{} + MultiParentFormats map[string]string + MultiParentFormatsTestTypes map[string]string + Properties map[string]Property + NamedProperties map[string]Property + Children map[string]Model + Configuration map[string]interface{} + TestVars map[string]interface{} + Definitions Definitions // Below booleans are used during template rendering to determine correct rendering the go code AllowDelete bool AllowChildDelete bool @@ -687,6 +810,7 @@ type Model struct { HasNamedProperties bool HasChildNamedProperties bool Include bool + ParentDnOptional bool } // A Property represents a ACI class property @@ -740,6 +864,7 @@ func (m *Model) setClassModel(metaPath string, child bool, definitions Definitio m.SetClassLabel(classDetails, child) m.SetClassName(classDetails) m.SetClassRnFormat(classDetails) + m.SetClassRnFormatList(classDetails) m.SetClassDnFormats(classDetails) m.SetClassIdentifiers(classDetails) m.SetClassInclude() @@ -751,6 +876,7 @@ func (m *Model) setClassModel(metaPath string, child bool, definitions Definitio m.SetClassProperties(classDetails) m.SetClassChildren(classDetails, pkgNames) m.SetResourceNotesAndWarnigns(m.PkgName, definitions) + m.SetApicType(classDetails) } /* @@ -949,6 +1075,14 @@ func (m *Model) SetResourceNotesAndWarnigns(classPkgName string, definitions Def } } +func (m *Model) SetApicType(classDetails interface{}) { + platform := make(map[string][]interface{}) + if platformFlavors, ok := classDetails.(map[string]interface{})["platformFlavors"].([]interface{}); ok { + platform["apicType"] = platformFlavors + m.PlatformFlavors = platform + } +} + // Determine if a class is allowed to be deleted as defined in the classes.yaml file // Flag created to ensure classes that only classes allowed to be deleted are deleted func AllowClassDelete(classPkgName string, definitions Definitions) bool { @@ -1340,6 +1474,93 @@ func (m *Model) GetOverwriteRnFormat(rnFormat string) { } } +func GetOverwriteTestType(classPkgName string, definitions Definitions) []TestClassification { + var testClassifications []TestClassification + if v, ok := definitions.Classes[classPkgName]; ok { + for key, value := range v.(map[interface{}]interface{}) { + if key.(string) == "test_type" { + testClassifications = append(testClassifications, TestClassification{ + ImmediateParent: classPkgName, + TestClassification: value.(string), + }) + return testClassifications + } + } + } + testClassifications = append(testClassifications, TestClassification{ + ImmediateParent: classPkgName, + TestClassification: "none", + }) + return testClassifications +} + +func GetMultiParentFormats(classPkgName string, definitions Definitions) (map[string]interface{}, map[string]string) { + multiParents := make(map[string]interface{}) + testTypes := make(map[string]string) + var containedBy, rnPrepend, testType string + if v, ok := definitions.Classes[classPkgName]; ok { + for key, value := range v.(map[interface{}]interface{}) { + if key.(string) == "multi_parents" { + for _, pair := range value.([]interface{}) { + pairMap, _ := pair.(map[interface{}]interface{}) + for pair1, pair2 := range pairMap { + switch pair1 { + case "contained_by": + containedBy = pair2.(string) + case "rn_prepend": + rnPrepend = pair2.(string) + case "test_type": + testType = pair2.(string) + } + } + multiParents[containedBy] = rnPrepend + testTypes[containedBy] = testType + } + } + } + } + return multiParents, testTypes +} + +func GetResourceIdentifier(classPkgName string, definitions Definitions) string { + if v, ok := definitions.Classes[classPkgName]; ok { + for key, value := range v.(map[interface{}]interface{}) { + if key.(string) == "resource_identifier" { + return value.(string) + } + } + } + return resourceNames[classPkgName] +} + +func (m *Model) SetClassRnFormatList(classDetails interface{}) { + rnFormat := classDetails.(map[string]interface{})["rnFormat"].(string) + multiParentFormats := make(map[string]string) + getMultiParentFormats, getTestType := GetMultiParentFormats(m.PkgName, m.Definitions) + rnFormatMap := make(map[string]string) + for parentClass, rnPrepend := range getMultiParentFormats { + resourceIdentifier := GetResourceIdentifier(parentClass, m.Definitions) + rnFormatMap[resourceIdentifier] = fmt.Sprintf("%s/%s", rnPrepend, rnFormat) + if rn_prep, ok := rnPrepend.(interface{}); ok { + multiParentFormats[parentClass] = rn_prep.(string) + } + } + + m.RnFormatMap = rnFormatMap + m.MultiParentFormats = multiParentFormats + m.MultiParentFormatsTestTypes = getTestType +} + +func setParentDnOptional(m *Model) { + getMultiParentFormats, _ := GetMultiParentFormats(m.PkgName, m.Definitions) + for parent, _ := range getMultiParentFormats { + if parent == "polUni" { + m.ParentDnOptional = true + break + } + } +} + // Determine if possible dn formats in terraform documentation should be overwritten by dn formats from the classes.yaml file func GetOverwriteDnFormats(dnFormats []interface{}, classPkgName string, definitions Definitions) []interface{} { if v, ok := definitions.Classes[classPkgName]; ok { @@ -1353,7 +1574,6 @@ func GetOverwriteDnFormats(dnFormats []interface{}, classPkgName string, definit } // Determine if possible dn formats in terraform documentation should be overwritten by dn formats from the classes.yaml file -<<<<<<< HEAD func GetOverwriteExampleClasses(classPkgName string, definitions Definitions) []interface{} { overwriteExampleClasses := []interface{}{} if v, ok := definitions.Classes[classPkgName]; ok { @@ -1364,7 +1584,8 @@ func GetOverwriteExampleClasses(classPkgName string, definitions Definitions) [] } } return overwriteExampleClasses -======= +} + func GetOverwriteParentDn(classPkgName string, definitions Definitions) []interface{} { var parentDn []interface{} if v, ok := definitions.Classes[classPkgName]; ok { @@ -1377,14 +1598,6 @@ func GetOverwriteParentDn(classPkgName string, definitions Definitions) []interf return parentDn } -func setExplicitParentDns(m *Model) { - for _, parentDn := range GetOverwriteParentDn(m.PkgName, m.Definitions) { - log.Println(parentDn.(string)) - m.ExplicitParentDns = append(m.ExplicitParentDns, parentDn.(string)) - } ->>>>>>> b2f52a6d ([minor_change] Addition of new generated resource and data source for pkiTP) -} - // Set variables that are used during the rendering of the example and documentation templates func setDocumentationData(m *Model, definitions Definitions) { UiLocations := []string{} @@ -1450,8 +1663,7 @@ func setDocumentationData(m *Model, definitions Definitions) { // TODO add overwrite to provide which documentation examples to be included docsExampleAmount := m.Configuration["docs_examples_amount"].(int) -<<<<<<< HEAD - if len(m.ContainedBy) >= docsExampleAmount { + if len(m.ContainedBy) > docsExampleAmount { overwriteExampleClasses := GetOverwriteExampleClasses(m.PkgName, definitions) if len(overwriteExampleClasses) > 0 { for _, exampleClass := range overwriteExampleClasses { @@ -1461,11 +1673,6 @@ func setDocumentationData(m *Model, definitions Definitions) { for _, resourceDetails := range resourcesFound[0:docsExampleAmount] { m.DocumentationExamples = append(m.DocumentationExamples, resourceDetails[1]) } -======= - if len(m.ContainedBy) > docsExampleAmount { - for _, resourceDetails := range resourcesFound[0:docsExampleAmount] { - m.DocumentationExamples = append(m.DocumentationExamples, resourceDetails[1]) ->>>>>>> b2f52a6d ([minor_change] Addition of new generated resource and data source for pkiTP) } } else { for _, resourceDetails := range resourcesFound { diff --git a/gen/meta/cloudCertStore.json b/gen/meta/cloudCertStore.json new file mode 100644 index 000000000..96e945231 --- /dev/null +++ b/gen/meta/cloudCertStore.json @@ -0,0 +1,587 @@ +{ + "cloud:CertStore": { + "contains": { + "aaa:RbacAnnotation": "", + "fault:Counts": "", + "health:Inst": "", + "pki:KeyRing": "", + "pki:TP": "", + "tag:Annotation": "", + "tag:Tag": "" + }, + "rnMap": { + "annotationKey-": "tag:Annotation", + "fltCnts": "fault:Counts", + "health": "health:Inst", + "keyring-": "pki:KeyRing", + "rbacDom-": "aaa:RbacAnnotation", + "tagKey-": "tag:Tag", + "tp-": "pki:TP" + }, + "identifiedBy": [ + + ], + "rnFormat": "certstore", + "containedBy": { + "fv:Tenant": "" + }, + "superClasses": [ + "cloud:ACertStore", + "naming:NamedObject" + ], + "subClasses": { + + }, + "relationFrom": { + + }, + "relationTo": { + + }, + "dnFormats": [ + "uni/tn-{name}/certstore" + ], + "writeAccess": [ + "admin", + "nw-svc-policy" + ], + "readAccess": [ + "aaa", + "admin", + "nw-svc-policy" + ], + "faults": { + + }, + "events": { + "E4216577": "creation||cloud:CertStore", + "E4216578": "modification||cloud:CertStore", + "E4216579": "deletion||cloud:CertStore" + }, + "stats": { + + }, + "isAbstract": false, + "isConfigurable": true, + "isContextRoot": false, + "isDeprecated": false, + "isHidden": false, + "isEncrypted": false, + "isExportable": true, + "isPersistent": true, + "isSubjectToQuota": false, + "isObservable": true, + "hasStats": false, + "isStat": false, + "isFaultable": false, + "isDomainable": false, + "isHealthScorable": true, + "shouldCollectHealthStats": false, + "healthCollectionSource": "faults", + "hasEventRules": false, + "abstractionLayer": "logical", + "apicNxProcessing": false, + "monitoringPolicySource": "Parent", + "isCreatableDeletable": "always", + "platformFlavors": [ + "capic" + ], + "classId": "15191", + "className": "CertStore", + "classPkg": "cloud", + "featureTag": "", + "moCategory": "Regular", + "label": "Certificate Store", + "properties": { + "annotation": { + "comment": [ + "User annotation. Suggested format orchestrator:value" + ], + "isConfigurable": true, + "propGlobalId": "51999", + "propLocalId": "8719", + "label": "Annotation", + "baseType": "string:Basic", + "modelType": "mo:Annotation", + "needsPropDelimiters": false, + "uitype": "string", + "createOnly": false, + "readWrite": true, + "readOnly": false, + "isNaming": false, + "secure": false, + "implicit": false, + "mandatory": false, + "isOverride": false, + "isLike": false, + "validators": [ + {"min" : 0, "max": 128, + "regexs": [ + {"regex" : "^[a-zA-Z0-9_.:-]+$", "type": "include"} + ] + } + ], + "platformFlavors": [ + + ], + "isDeprecated": false, + "isHidden": false + }, + "childAction": { + "comment": [ + "Delete or ignore. For internal use only." + ], + "isConfigurable": false, + "propGlobalId": "4", + "propLocalId": "5", + "label": "childAction", + "baseType": "scalar:Bitmask32", + "modelType": "mo:ModificationChildAction", + "needsPropDelimiters": false, + "uitype": "bitmask", + "createOnly": false, + "readWrite": false, + "readOnly": true, + "isNaming": false, + "secure": false, + "implicit": true, + "mandatory": false, + "isOverride": false, + "isLike": false, + "validValues": [ + { "value": "16384", "localName": "deleteAll", + "platformFlavors": [ + + ], + "label": "deleteAll "}, + { "value": "8192", "localName": "deleteNonPresent", + "platformFlavors": [ + + ], + "label": "deleteNonPresent "}, + { "value": "4096", "localName": "ignore", + "platformFlavors": [ + + ], + "label": "ignore "} + ], + "platformFlavors": [ + + ], + "isDeprecated": false, + "isHidden": false + }, + "dn": { + "comment": [ + "A tag or metadata is a non-hierarchical keyword or term assigned to the fabric module." + ], + "isConfigurable": false, + "propGlobalId": "1", + "propLocalId": "2", + "label": "dn", + "baseType": "reference:BinRef", + "modelType": "reference:BinRef", + "needsPropDelimiters": true, + "uitype": "auto", + "createOnly": false, + "readWrite": false, + "readOnly": true, + "isNaming": false, + "secure": false, + "implicit": true, + "mandatory": false, + "isOverride": false, + "isLike": false, + "platformFlavors": [ + + ], + "isDeprecated": false, + "isHidden": false + }, + "extMngdBy": { + "comment": [ + "Indicates which orchestrator is managing this MO" + ], + "isConfigurable": false, + "propGlobalId": "52000", + "propLocalId": "8023", + "label": "Managed By", + "baseType": "scalar:Bitmask32", + "modelType": "mo:ExtMngdByType", + "needsPropDelimiters": false, + "uitype": "bitmask", + "createOnly": false, + "readWrite": false, + "readOnly": true, + "isNaming": false, + "secure": false, + "implicit": true, + "mandatory": false, + "isOverride": false, + "isLike": false, + "validValues": [ + { "value": "undefined", "localName": "defaultValue", + "platformFlavors": [ + + ], + "label": " "}, + { "value": "1", "localName": "msc", + "platformFlavors": [ + + ], + "label": "msc "}, + { "value": "0", "localName": "undefined", + "platformFlavors": [ + + ], + "label": "undefined "} + ], + "default": "undefined", + "platformFlavors": [ + + ], + "isDeprecated": false, + "isHidden": false + }, + "lcOwn": { + "comment": [ + "A value that indicates how this object was created. For internal use only." + ], + "isConfigurable": false, + "propGlobalId": "9", + "propLocalId": "9", + "label": "lcOwn", + "baseType": "scalar:Enum8", + "modelType": "mo:Owner", + "needsPropDelimiters": false, + "uitype": "enum", + "createOnly": false, + "readWrite": false, + "readOnly": true, + "isNaming": false, + "secure": false, + "implicit": true, + "mandatory": false, + "isOverride": false, + "isLike": false, + "validValues": [ + { "value": "local", "localName": "defaultValue", + "platformFlavors": [ + + ], + "label": " "}, + { "value": "4", "localName": "implicit", + "platformFlavors": [ + + ], + "label": "Implicit "}, + { "value": "0", "localName": "local", + "platformFlavors": [ + + ], + "label": "Local "}, + { "value": "1", "localName": "policy", + "platformFlavors": [ + + ], + "label": "Policy "}, + { "value": "2", "localName": "replica", + "platformFlavors": [ + + ], + "label": "Replica "}, + { "value": "3", "localName": "resolveOnBehalf", + "platformFlavors": [ + + ], + "label": "ResolvedOnBehalf "} + ], + "default": "local", + "platformFlavors": [ + + ], + "isDeprecated": false, + "isHidden": false + }, + "modTs": { + "comment": [ + "The time when this object was last modified." + ], + "isConfigurable": false, + "propGlobalId": "7", + "propLocalId": "7", + "label": "modTs", + "baseType": "scalar:Date", + "modelType": "mo:TStamp", + "needsPropDelimiters": false, + "uitype": "auto", + "createOnly": false, + "readWrite": false, + "readOnly": true, + "isNaming": false, + "secure": false, + "implicit": true, + "mandatory": false, + "isOverride": false, + "isLike": false, + "validValues": [ + { "value": "never", "localName": "defaultValue", + "platformFlavors": [ + + ], + "label": " "}, + { "value": "0", "localName": "never", + "platformFlavors": [ + + ], + "label": "never "} + ], + "default": "never", + "platformFlavors": [ + + ], + "isDeprecated": false, + "isHidden": false + }, + "monPolDn": { + "comment": [ + "The monitoring policy attached to this observable object." + ], + "isConfigurable": false, + "propGlobalId": "52687", + "propLocalId": "228", + "label": "Monitoring policy", + "baseType": "reference:BinRef", + "modelType": "reference:BinRef", + "needsPropDelimiters": true, + "uitype": "auto", + "createOnly": false, + "readWrite": false, + "readOnly": true, + "isNaming": false, + "secure": false, + "implicit": true, + "mandatory": false, + "isOverride": false, + "isLike": false, + "platformFlavors": [ + + ], + "isDeprecated": false, + "isHidden": false + }, + "name": { + "comment": [ + "The name of the object." + ], + "isConfigurable": true, + "propGlobalId": "5577", + "propLocalId": "13", + "label": "Name", + "baseType": "string:Basic", + "modelType": "naming:Name", + "needsPropDelimiters": false, + "uitype": "string", + "createOnly": false, + "readWrite": true, + "readOnly": false, + "isNaming": false, + "secure": false, + "implicit": false, + "mandatory": false, + "isOverride": false, + "isLike": true, + "likeProp": "naming:Named:name", + "validators": [ + {"min" : 0, "max": 16, + "regexs": [ + {"regex" : "^[a-zA-Z0-9_.:-]+$", "type": "include"} + ] + } + ], + "platformFlavors": [ + + ], + "isDeprecated": false, + "isHidden": false + }, + "nameAlias": { + "isConfigurable": true, + "propGlobalId": "28417", + "propLocalId": "6719", + "label": "Display Name", + "baseType": "string:Basic", + "modelType": "naming:NameAlias", + "needsPropDelimiters": false, + "uitype": "string", + "createOnly": false, + "readWrite": true, + "readOnly": false, + "isNaming": false, + "secure": false, + "implicit": false, + "mandatory": false, + "isOverride": false, + "isLike": false, + "validators": [ + {"min" : 0, "max": 63, + "regexs": [ + {"regex" : "^[a-zA-Z0-9_.-]+$", "type": "include"} + ] + } + ], + "platformFlavors": [ + + ], + "isDeprecated": false, + "isHidden": false + }, + "rn": { + "comment": [ + "Identifies an object from its siblings within the context of its parent object. The distinguished name contains a sequence of relative names." + ], + "isConfigurable": false, + "propGlobalId": "2", + "propLocalId": "3", + "label": "rn", + "baseType": "reference:BinRN", + "modelType": "reference:BinRN", + "needsPropDelimiters": true, + "uitype": "auto", + "createOnly": false, + "readWrite": false, + "readOnly": true, + "isNaming": false, + "secure": false, + "implicit": true, + "mandatory": false, + "isOverride": false, + "isLike": false, + "platformFlavors": [ + + ], + "isDeprecated": false, + "isHidden": false + }, + "status": { + "comment": [ + "The upgrade status. This property is for internal use only." + ], + "isConfigurable": false, + "propGlobalId": "3", + "propLocalId": "4", + "label": "status", + "baseType": "scalar:Bitmask32", + "modelType": "mo:ModificationStatus", + "needsPropDelimiters": false, + "uitype": "bitmask", + "createOnly": false, + "readWrite": false, + "readOnly": true, + "isNaming": false, + "secure": false, + "implicit": true, + "mandatory": false, + "isOverride": false, + "isLike": false, + "validValues": [ + { "value": "2", "localName": "created", + "platformFlavors": [ + + ], + "comment": [ + "In a setter method: specifies that an object should be created. An error is returned if the object already exists. \nIn the return value of a setter method: indicates that an object has been created. \n" + ], + "label": "created "}, + { "value": "8", "localName": "deleted", + "platformFlavors": [ + + ], + "comment": [ + "In a setter method: specifies that an object should be deleted. \nIn the return value of a setter method: indicates that an object has been deleted.\n" + ], + "label": "deleted "}, + { "value": "4", "localName": "modified", + "platformFlavors": [ + + ], + "comment": [ + "In a setter method: specifies that an object should be modified \nIn the return value of a setter method: indicates that an object has been modified.\n" + ], + "label": "modified "} + ], + "platformFlavors": [ + + ], + "isDeprecated": false, + "isHidden": false + }, + "uid": { + "comment": [ + "A unique identifier for this object." + ], + "isConfigurable": false, + "propGlobalId": "8", + "propLocalId": "8", + "label": "uid", + "baseType": "scalar:Uint16", + "modelType": "scalar:Uint16", + "needsPropDelimiters": false, + "uitype": "auto", + "createOnly": false, + "readWrite": false, + "readOnly": true, + "isNaming": false, + "secure": false, + "implicit": true, + "mandatory": false, + "isOverride": false, + "isLike": false, + "platformFlavors": [ + + ], + "isDeprecated": false, + "isHidden": false + }, + "userdom": { + "isConfigurable": true, + "propGlobalId": "60657", + "propLocalId": "13244", + "label": "userdom", + "baseType": "string:Basic", + "modelType": "mo:UserDomType", + "needsPropDelimiters": false, + "uitype": "string", + "createOnly": false, + "readWrite": true, + "readOnly": false, + "isNaming": false, + "secure": false, + "implicit": false, + "mandatory": false, + "isOverride": false, + "isLike": false, + "validators": [ + {"min" : 0, "max": 1024, + "regexs": [ + {"regex" : "^[a-zA-Z0-9_.:-]+$", "type": "include"} + ] + } + ], + "validValues": [ + { "value": "all", "localName": "defaultValue", + "platformFlavors": [ + + ], + "label": " "} + ], + "default": "all", + "platformFlavors": [ + + ], + "isDeprecated": false, + "isHidden": false + } + } + } +} diff --git a/gen/templates/datasource_test.go.tmpl b/gen/templates/datasource_test.go.tmpl index c2aaa152a..326baaa16 100644 --- a/gen/templates/datasource_test.go.tmpl +++ b/gen/templates/datasource_test.go.tmpl @@ -16,7 +16,7 @@ import ( func TestAccDataSource{{$.resourceClassName}}With{{capitalize .class_name}} (t *testing.T) { resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, + PreCheck: func() { testAccPreCheck(t, "{{.test_type}}") }, ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, Steps: []resource.TestStep{ { @@ -43,7 +43,7 @@ func TestAccDataSource{{$.resourceClassName}}With{{capitalize .class_name}} (t * func TestAccDataSource{{.resourceClassName}}(t *testing.T) { resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, + PreCheck: func() { testAccPreCheck(t, "{{.test_type}}") }, ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, Steps: []resource.TestStep{ { diff --git a/gen/templates/resource.go.tmpl b/gen/templates/resource.go.tmpl index 82f5e95f8..c4efe609c 100644 --- a/gen/templates/resource.go.tmpl +++ b/gen/templates/resource.go.tmpl @@ -121,7 +121,11 @@ func (r *{{.ResourceClassName}}Resource) Schema(ctx context.Context, req resourc }, {{- if .HasParent}} "parent_dn": schema.StringAttribute{ + {{- if .ParentDnOptional}} + Optional: true, + {{- else}} Required: true, + {{- end}} MarkdownDescription: "The distinguished name (DN) of the parent object.", PlanModifiers: []planmodifier.String{ stringplanmodifier.UseStateForUnknown(), @@ -565,6 +569,56 @@ func getAndSet{{.ResourceClassName}}Attributes(ctx context.Context, diags *diag. } } +{{ if gt (len .RnFormatMap) 0}} +func get{{.ResourceClassName}}Rn(ctx context.Context, data *{{.ResourceClassName}}ResourceModel) map[string]string { + rn_map := map[string]string{ {{- range $key, $value := .RnFormatMap }}"{{ $key }}": "{{ $value }}",{{- end }} } + for _, identifier := range []string{ {{- fromInterfacesToString .IdentifiedBy}} } { + fieldName := fmt.Sprintf("%s%s", strings.ToUpper(identifier[:1]), identifier[1:]) + fieldValue := reflect.ValueOf(data).Elem().FieldByName(fieldName).Interface().(basetypes.StringValue).ValueString() + for parent_identifier, rn_prepend := range rn_map { + rn_map[parent_identifier] = strings.ReplaceAll(rn_prepend, fmt.Sprintf("{%s}", identifier), fieldValue) + } + } + return rn_map +} + +func set{{.ResourceClassName}}ParentDn(ctx context.Context, dn string, data *{{.ResourceClassName}}ResourceModel) { + bracketIndex := 0 + rnIndex := 0 + for i := len(dn) - 1; i >= 0; i-- { + if string(dn[i]) == "]" { + bracketIndex = bracketIndex + 1 + } else if string(dn[i]) == "[" { + bracketIndex = bracketIndex - 1 + } else if string(dn[i]) == "/" && bracketIndex == 0 { + rnIndex = i + break + } + } + rn_map := map[string]string{ {{- range $key, $value := .RnFormatMap }}"{{ $key }}": "{{ $value }}",{{- end }} } + parentDn := dn[:rnIndex] + for parent_identifier, rn_prepend := range rn_map { + if strings.Contains(parentDn, parent_identifier) && parent_identifier != "" { + parentDn = parentDn[:strings.Index(parentDn, "/"+rn_prepend)] + data.ParentDn = basetypes.NewStringValue(parentDn) + } + break + } + +} + +func set{{.ResourceClassName}}Id(ctx context.Context, data *{{.ResourceClassName}}ResourceModel) { + rn_map := get{{.ResourceClassName}}Rn(ctx, data) + for parent_identifier, rn_prepend := range rn_map { + if data.ParentDn.ValueString() == "" && parent_identifier == "" { + data.Id = types.StringValue(fmt.Sprintf("%s", rn_prepend)) + } else if parent_identifier != "" && strings.Contains(data.ParentDn.ValueString(), parent_identifier){ + data.Id = types.StringValue(fmt.Sprintf("%s/%s", data.ParentDn.ValueString(), rn_prepend)) + } + } +} + +{{- else}} func get{{.ResourceClassName}}Rn(ctx context.Context, data *{{.ResourceClassName}}ResourceModel) string { {{- if .IdentifiedBy}} rn := "{{.RnFormat}}" @@ -611,6 +665,7 @@ func set{{.ResourceClassName}}Id(ctx context.Context, data *{{.ResourceClassName data.Id = types.StringValue(fmt.Sprintf("%s/%s", strings.Split([]string{ {{- fromInterfacesToString .DnFormats}} }[0], "/")[0], rn)) {{- end}} } +{{- end}} {{ range .Children}} func get{{$.ResourceClassName}}{{ .ResourceClassName }}ChildPayloads(ctx context.Context, diags *diag.Diagnostics, data *{{$.ResourceClassName}}ResourceModel, {{.PkgName}}Plan, {{.PkgName}}State []{{.ResourceClassName}}{{$.ResourceClassName}}ResourceModel) []map[string]interface{} { diff --git a/gen/templates/resource_example.tf.tmpl b/gen/templates/resource_example.tf.tmpl index aaec75a62..8cb4e3d4f 100644 --- a/gen/templates/resource_example.tf.tmpl +++ b/gen/templates/resource_example.tf.tmpl @@ -1,13 +1,8 @@ {{- if .DocumentationExamples}}{{- range $key := .DocumentationExamples}} resource "aci_{{$.ResourceName}}" "example_{{getResourceName $key $.Definitions}}" { - {{- if and $.HasParent (not $.ExplicitParentDns)}} + {{- if $.HasParent}} parent_dn = {{createParentDnValue $key "example" $.Definitions}} {{- end}} - {{- if $.ExplicitParentDns}} - {{- range $.ExplicitParentDns}} - parent_dn = "{{.}}" - {{- end}} - {{- end}} {{- range $.Properties}}{{- if .IsRequired}}{{- if ne .NamedPropertyClass ""}} {{overwriteProperty .PkgName .SnakeCaseName $.Definitions}} = aci_{{getResourceName .NamedPropertyClass $.Definitions}}.example.name {{- else}} diff --git a/gen/templates/resource_test.go.tmpl b/gen/templates/resource_test.go.tmpl index f42e9b4f0..91803629a 100644 --- a/gen/templates/resource_test.go.tmpl +++ b/gen/templates/resource_test.go.tmpl @@ -31,7 +31,7 @@ func TestAccResource{{$.resourceClassName}}With{{capitalize .class_name}}(t *tes {{- end}} {{- end}} PreCheck: func() { - testAccPreCheck(t) + testAccPreCheck(t, "{{.test_type}}") {{- if $found_cert }} time.Sleep(10 * time.Second) {{- end }} @@ -149,7 +149,11 @@ PreCheck: func() { ExpectNonEmptyPlan: {{.class_in_parent}}, Check: resource.ComposeAggregateTestCheckFunc( {{- range $key, $value := $.resource_required}} + {{- if contains $value "<>>>>>> b2f52a6d ([minor_change] Addition of new generated resource and data source for pkiTP) {{- end}} {{- end}} @@ -61,24 +55,33 @@ children: {{ end}} - {{ range .Properties}}{{overwriteProperty .PkgName .SnakeCaseName $.Definitions}}: {{$length := len .ValidValues}}{{if ge $length 2}}"{{ index .ValidValues 1 }}"{{else if not .IsNaming}}"{{overwriteProperty .PkgName .SnakeCaseName $.Definitions}}_2"{{- else}}"{{$name}}_2"{{- end}} {{ end}}{{- end}}{{- end}} -{{- if and .ContainedBy (not .ExplicitParentDns) }} +{{- if and .ContainedBy (not .RnFormatMap)}} parents: - {{- $index := 0}}{{- range $key := .DocumentationExamples}}{{$parentDependency := getParentTestDependencies $.PkgName $index $.Definitions}} + {{- $index := 0}}{{- range $key := .DocumentationExamples}}{{$parentDependency := getParentTestDependencies $.PkgName $index $.Definitions}}{{$testType := getTestType $key}} - class_name: "{{ $key }}" parent_dependency: "{{$parentDependency.parent_dependency}}" parent_dn: "{{createParentDnValue $key "test" $.Definitions}}" class_in_parent: {{$parentDependency.class_in_parent}}{{$index = add $index 1}} + test_type: {{$testType}} {{- end}} {{- end}} -{{- if .ExplicitParentDns}} +{{- if .MultiParentFormats}} parents: -{{- $index := 0}}{{- range $key := .DocumentationExamples}}{{$parentDependency := getParentTestDependencies $.PkgName $index $.Definitions}} - - class_name: "{{ $key }}" - parent_dependency: "{{$parentDependency.parent_dependency}}" - class_in_parent: {{$parentDependency.class_in_parent}}{{$index = add $index 1}} - {{- end}} -{{- range .ExplicitParentDns}} - parent_dn: "{{.}}" - is_explicit_parent_dn: true - {{- end}} - {{- end}} \ No newline at end of file +{{- $topContext := . }} +{{- range $key, $value := .MultiParentFormats }} + {{$parentDependency := getParentTestDependencies $topContext.PkgName 0 $topContext.Definitions}} + - class_name: "{{ $key }}" + parent_dependency: "{{$parentDependency.parent_dependency}}" + parent_dn: "{{createParentDnValue $key "test" $topContext.Definitions}}" + class_in_parent: false + {{- $testType := index $topContext.MultiParentFormatsTestTypes $key }} + {{- if $testType }} + test_type: {{$testType}} + {{- end}} +{{- end}} +{{- end}} + +{{- if and (not .ContainedBy) (not .RnFormatMap)}} +{{$testType := getTestType $.PkgName}} +test_type: {{$testType}} +{{- end}} diff --git a/gen/testvars/fvEpIpTag.yaml b/gen/testvars/fvEpIpTag.yaml index 1d63f0465..ed07f502e 100644 --- a/gen/testvars/fvEpIpTag.yaml +++ b/gen/testvars/fvEpIpTag.yaml @@ -7,7 +7,6 @@ default: id_attribute: "0" name: "" name_alias: "" - datasource_non_existing: vrf_name: "non_existing_ctx_name" ip: "10.0.1.2" @@ -18,7 +17,7 @@ datasource_required: resource_required: vrf_name: "test_ctx_name" - ip: "10.0.0.2" + ip: "10.0.0.2" all: annotation: "annotation" @@ -39,3 +38,4 @@ parents: parent_dependency: "" parent_dn: "aci_tenant.test.id" class_in_parent: false + test_type: apic diff --git a/gen/testvars/fvEpMacTag.yaml b/gen/testvars/fvEpMacTag.yaml index 78c2c6f72..90a0134a3 100644 --- a/gen/testvars/fvEpMacTag.yaml +++ b/gen/testvars/fvEpMacTag.yaml @@ -7,7 +7,6 @@ default: id_attribute: "0" name: "" name_alias: "" - datasource_non_existing: bd_name: "non_existing_bd_name" mac: "00:00:00:00:00:01" @@ -18,7 +17,7 @@ datasource_required: resource_required: bd_name: "test_bd_name" - mac: "00:00:00:00:00:01" + mac: "00:00:00:00:00:01" all: annotation: "annotation" @@ -39,3 +38,4 @@ parents: parent_dependency: "" parent_dn: "aci_tenant.test.id" class_in_parent: false + test_type: apic diff --git a/gen/testvars/l3extConsLbl.yaml b/gen/testvars/l3extConsLbl.yaml index 0d57cf25b..26d3ab7ab 100644 --- a/gen/testvars/l3extConsLbl.yaml +++ b/gen/testvars/l3extConsLbl.yaml @@ -40,4 +40,5 @@ parents: - class_name: "l3extOut" parent_dependency: "" parent_dn: "aci_l3_outside.test.id" - class_in_parent: false \ No newline at end of file + class_in_parent: false + test_type: apic diff --git a/gen/testvars/l3extRsRedistributePol.yaml b/gen/testvars/l3extRsRedistributePol.yaml index cac8ec2a4..d84284747 100644 --- a/gen/testvars/l3extRsRedistributePol.yaml +++ b/gen/testvars/l3extRsRedistributePol.yaml @@ -33,4 +33,5 @@ parents: - class_name: "l3extOut" parent_dependency: "fvTenant" parent_dn: "aci_l3_outside.test.id" - class_in_parent: true \ No newline at end of file + class_in_parent: true + test_type: apic diff --git a/gen/testvars/mgmtInstP.yaml b/gen/testvars/mgmtInstP.yaml index 416458d3b..98e1143b1 100644 --- a/gen/testvars/mgmtInstP.yaml +++ b/gen/testvars/mgmtInstP.yaml @@ -38,4 +38,6 @@ children: - key: "annotations_2" value: "value_2" - \ No newline at end of file + + +test_type: both diff --git a/gen/testvars/mgmtRsOoBCons.yaml b/gen/testvars/mgmtRsOoBCons.yaml index dca91b968..a57d89f54 100644 --- a/gen/testvars/mgmtRsOoBCons.yaml +++ b/gen/testvars/mgmtRsOoBCons.yaml @@ -30,4 +30,5 @@ parents: - class_name: "mgmtInstP" parent_dependency: "" parent_dn: "aci_external_management_network_instance_profile.test.id" - class_in_parent: true \ No newline at end of file + class_in_parent: true + test_type: both diff --git a/gen/testvars/mgmtSubnet.yaml b/gen/testvars/mgmtSubnet.yaml index 7847957af..093a70866 100644 --- a/gen/testvars/mgmtSubnet.yaml +++ b/gen/testvars/mgmtSubnet.yaml @@ -34,4 +34,5 @@ parents: - class_name: "mgmtInstP" parent_dependency: "" parent_dn: "aci_external_management_network_instance_profile.test.id" - class_in_parent: false \ No newline at end of file + class_in_parent: false + test_type: both diff --git a/gen/testvars/pimRouteMapEntry.yaml b/gen/testvars/pimRouteMapEntry.yaml index 8f26b067c..3d63a6a35 100644 --- a/gen/testvars/pimRouteMapEntry.yaml +++ b/gen/testvars/pimRouteMapEntry.yaml @@ -42,4 +42,5 @@ parents: - class_name: "pimRouteMapPol" parent_dependency: "fvTenant" parent_dn: "aci_pim_route_map_policy.test.id" - class_in_parent: false \ No newline at end of file + class_in_parent: false + test_type: both diff --git a/gen/testvars/pimRouteMapPol.yaml b/gen/testvars/pimRouteMapPol.yaml index 6cd7caa86..380b31d91 100644 --- a/gen/testvars/pimRouteMapPol.yaml +++ b/gen/testvars/pimRouteMapPol.yaml @@ -36,4 +36,5 @@ parents: - class_name: "fvTenant" parent_dependency: "" parent_dn: "aci_tenant.test.id" - class_in_parent: false \ No newline at end of file + class_in_parent: false + test_type: both diff --git a/gen/testvars/pkiTP.yaml b/gen/testvars/pkiTP.yaml index 8e09668a6..ce6c08716 100644 --- a/gen/testvars/pkiTP.yaml +++ b/gen/testvars/pkiTP.yaml @@ -36,8 +36,15 @@ children: value: "value_2" parents: - - class_name: "pkiEp" - parent_dependency: "" - class_in_parent: false - parent_dn: "uni/userext/pkiext" - is_explicit_parent_dn: true \ No newline at end of file + + - class_name: "fvTenant" + parent_dependency: "" + parent_dn: "aci_tenant.test.id" + class_in_parent: false + test_type: cloud + + - class_name: "polUni" + parent_dependency: "" + parent_dn: "aci_.test.id" + class_in_parent: false + test_type: both diff --git a/gen/testvars/tagAnnotation.yaml b/gen/testvars/tagAnnotation.yaml index b4e2cbdf6..29453c0e5 100644 --- a/gen/testvars/tagAnnotation.yaml +++ b/gen/testvars/tagAnnotation.yaml @@ -18,22 +18,13 @@ all: value: "value" parents: -<<<<<<< HEAD - class_name: "fvTenant" parent_dependency: "" parent_dn: "aci_tenant.test.id" class_in_parent: false + test_type: both - class_name: "fvAEPg" parent_dependency: "" parent_dn: "aci_application_epg.test.id" class_in_parent: false -======= - - class_name: "fvAEPg" - parent_dependency: "commPol" - parent_dn: "aci_application_epg.test.id" - class_in_parent: false - - class_name: "fvTenant" - parent_dependency: "" - parent_dn: "aci_tenant.test.id" - class_in_parent: false ->>>>>>> b2f52a6d ([minor_change] Addition of new generated resource and data source for pkiTP) + test_type: both diff --git a/gen/testvars/vzOOBBrCP.yaml b/gen/testvars/vzOOBBrCP.yaml index f5265f7c9..36b96fd61 100644 --- a/gen/testvars/vzOOBBrCP.yaml +++ b/gen/testvars/vzOOBBrCP.yaml @@ -39,4 +39,6 @@ children: - key: "annotations_2" value: "value_2" - \ No newline at end of file + + +test_type: both diff --git a/go.mod b/go.mod index a3636aea6..68e1d938f 100644 --- a/go.mod +++ b/go.mod @@ -19,6 +19,7 @@ require ( github.com/ProtonMail/go-crypto v0.0.0-20230828082145-3c4c8a2d2371 // indirect github.com/agext/levenshtein v1.2.2 // indirect github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect + github.com/ciscoecosystem/aci-go-client v1.54.0 // indirect github.com/cloudflare/circl v1.3.7 // indirect github.com/fatih/color v1.13.0 // indirect github.com/golang/protobuf v1.5.3 // indirect diff --git a/go.sum b/go.sum index c2c7a2693..ed4f02a39 100644 --- a/go.sum +++ b/go.sum @@ -28,6 +28,8 @@ github.com/bufbuild/protocompile v0.4.0 h1:LbFKd2XowZvQ/kajzguUp2DC9UEIQhIq77fZZ github.com/bwesterb/go-ristretto v1.2.3/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/ciscoecosystem/aci-go-client v1.54.0 h1:fZYJPnj9JXFPN0PFD5O71l1Ejnre/UfZgo3YFh83eqE= +github.com/ciscoecosystem/aci-go-client v1.54.0/go.mod h1:/ftFFEXD2Ozajs8Zc/Xw/s6bG5+d3DWQzMAifyxu/Es= github.com/ciscoecosystem/aci-go-client/v2 v2.26.0 h1:mqg8TESEchmhiIhbri+VAE7UasBl4ywIpgh6j9uiscg= github.com/ciscoecosystem/aci-go-client/v2 v2.26.0/go.mod h1:0uk5hiHANgXo+0h+Z8dFBriB7hHnI0PSGVUm7/20bt4= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= diff --git a/internal/provider/data_source_aci_annotation_test.go b/internal/provider/data_source_aci_annotation_test.go index a7c9df9d7..7b8d364ef 100644 --- a/internal/provider/data_source_aci_annotation_test.go +++ b/internal/provider/data_source_aci_annotation_test.go @@ -14,7 +14,7 @@ import ( func TestAccDataSourceTagAnnotationWithFvTenant(t *testing.T) { resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, + PreCheck: func() { testAccPreCheck(t, "both") }, ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, Steps: []resource.TestStep{ { @@ -35,7 +35,7 @@ func TestAccDataSourceTagAnnotationWithFvTenant(t *testing.T) { func TestAccDataSourceTagAnnotationWithFvAEPg(t *testing.T) { resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, + PreCheck: func() { testAccPreCheck(t, "both") }, ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, Steps: []resource.TestStep{ { diff --git a/internal/provider/data_source_aci_certificate_authority_test.go b/internal/provider/data_source_aci_certificate_authority_test.go index dded60343..e503ff2d6 100644 --- a/internal/provider/data_source_aci_certificate_authority_test.go +++ b/internal/provider/data_source_aci_certificate_authority_test.go @@ -11,14 +11,14 @@ import ( "github.com/hashicorp/terraform-plugin-testing/helper/resource" ) -func TestAccDataSourcePkiTPWithPkiEp(t *testing.T) { +func TestAccDataSourcePkiTPWithFvTenant(t *testing.T) { resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, + PreCheck: func() { testAccPreCheck(t, "cloud") }, ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, Steps: []resource.TestStep{ { - Config: testConfigPkiTPDataSourceDependencyWithPkiEp, + Config: testConfigPkiTPDataSourceDependencyWithFvTenant, ExpectNonEmptyPlan: false, Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr("data.aci_certificate_authority.test", "name", "test_name"), @@ -31,24 +31,65 @@ func TestAccDataSourcePkiTPWithPkiEp(t *testing.T) { ), }, { - Config: testConfigPkiTPNotExistingPkiEp, + Config: testConfigPkiTPNotExistingFvTenant, ExpectError: regexp.MustCompile("Failed to read aci_certificate_authority data source"), }, }, }) } +func TestAccDataSourcePkiTPWithPolUni(t *testing.T) { -const testConfigPkiTPDataSourceDependencyWithPkiEp = testConfigPkiTPMinDependencyWithPkiEp + ` + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t, "both") }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + { + Config: testConfigPkiTPDataSourceDependencyWithPolUni, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("data.aci_certificate_authority.test", "name", "test_name"), + resource.TestCheckResourceAttr("data.aci_certificate_authority.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("data.aci_certificate_authority.test", "cert_chain", "<>>>>>> b2f52a6d ([minor_change] Addition of new generated resource and data source for pkiTP) func TestAccResourceTagAnnotationWithFvTenant(t *testing.T) { resource.Test(t, resource.TestCase{ PreCheck: func() { - testAccPreCheck(t) + testAccPreCheck(t, "both") }, ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, Steps: []resource.TestStep{ @@ -129,9 +69,10 @@ func TestAccResourceTagAnnotationWithFvTenant(t *testing.T) { } func TestAccResourceTagAnnotationWithFvAEPg(t *testing.T) { -<<<<<<< HEAD resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, + PreCheck: func() { + testAccPreCheck(t, "both") + }, ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, Steps: []resource.TestStep{ // Create with minimum config and verify default APIC values @@ -183,31 +124,6 @@ func TestAccResourceTagAnnotationWithFvAEPg(t *testing.T) { }, }) } -======= -const testConfigTagAnnotationMinDependencyWithFvAEPg = testConfigFvAEPgMinDependencyWithCommPol + ` -resource "aci_annotation" "test" { - parent_dn = aci_application_epg.test.id - key = "test_key" - value = "test_value" -} -` - -const testConfigTagAnnotationAllDependencyWithFvAEPg = testConfigFvAEPgMinDependencyWithCommPol + ` -resource "aci_annotation" "test" { - parent_dn = aci_application_epg.test.id - key = "test_key" - value = "value" -} -` - -const testConfigTagAnnotationResetDependencyWithFvAEPg = testConfigFvAEPgMinDependencyWithCommPol + ` -resource "aci_annotation" "test" { - parent_dn = aci_application_epg.test.id - key = "test_key" - value = "test_value" -} -` ->>>>>>> b2f52a6d ([minor_change] Addition of new generated resource and data source for pkiTP) const testConfigTagAnnotationMinDependencyWithFvTenant = testConfigFvTenantMin + ` resource "aci_annotation" "test" { diff --git a/internal/provider/resource_aci_certificate_authority.go b/internal/provider/resource_aci_certificate_authority.go index 2d4824c7e..f7f4b092d 100644 --- a/internal/provider/resource_aci_certificate_authority.go +++ b/internal/provider/resource_aci_certificate_authority.go @@ -84,7 +84,7 @@ func (r *PkiTPResource) Schema(ctx context.Context, req resource.SchemaRequest, }, }, "parent_dn": schema.StringAttribute{ - Required: true, + Optional: true, MarkdownDescription: "The distinguished name (DN) of the parent object.", PlanModifiers: []planmodifier.String{ stringplanmodifier.UseStateForUnknown(), @@ -230,7 +230,7 @@ func (r *PkiTPResource) Create(ctx context.Context, req resource.CreateRequest, return } - doPkiTPRequest(ctx, &resp.Diagnostics, r.client, fmt.Sprintf("api/mo/%s.json", data.Id.ValueString()), "POST", jsonPayload) + DoRestRequest(ctx, &resp.Diagnostics, r.client, fmt.Sprintf("api/mo/%s.json", data.Id.ValueString()), "POST", jsonPayload) if resp.Diagnostics.HasError() { return } @@ -292,7 +292,7 @@ func (r *PkiTPResource) Update(ctx context.Context, req resource.UpdateRequest, return } - doPkiTPRequest(ctx, &resp.Diagnostics, r.client, fmt.Sprintf("api/mo/%s.json", data.Id.ValueString()), "POST", jsonPayload) + DoRestRequest(ctx, &resp.Diagnostics, r.client, fmt.Sprintf("api/mo/%s.json", data.Id.ValueString()), "POST", jsonPayload) if resp.Diagnostics.HasError() { return @@ -317,11 +317,11 @@ func (r *PkiTPResource) Delete(ctx context.Context, req resource.DeleteRequest, } tflog.Debug(ctx, fmt.Sprintf("Delete of resource aci_certificate_authority with id '%s'", data.Id.ValueString())) - jsonPayload := getPkiTPDeleteJsonPayload(ctx, &resp.Diagnostics, data) + jsonPayload := GetDeleteJsonPayload(ctx, &resp.Diagnostics, "pkiTP", data.Id.ValueString()) if resp.Diagnostics.HasError() { return } - doPkiTPRequest(ctx, &resp.Diagnostics, r.client, fmt.Sprintf("api/mo/%s.json", data.Id.ValueString()), "POST", jsonPayload) + DoRestRequest(ctx, &resp.Diagnostics, r.client, fmt.Sprintf("api/mo/%s.json", data.Id.ValueString()), "POST", jsonPayload) if resp.Diagnostics.HasError() { return } @@ -340,7 +340,7 @@ func (r *PkiTPResource) ImportState(ctx context.Context, req resource.ImportStat } func getAndSetPkiTPAttributes(ctx context.Context, diags *diag.Diagnostics, client *client.Client, data *PkiTPResourceModel) { - requestData := doPkiTPRequest(ctx, diags, client, fmt.Sprintf("api/mo/%s.json?rsp-subtree=children&rsp-subtree-class=%s", data.Id.ValueString(), "pkiTP,tagAnnotation"), "GET", nil) + requestData := DoRestRequest(ctx, diags, client, fmt.Sprintf("api/mo/%s.json?rsp-subtree=children&rsp-subtree-class=%s", data.Id.ValueString(), "pkiTP,tagAnnotation"), "GET", nil) if diags.HasError() { return @@ -413,14 +413,16 @@ func getAndSetPkiTPAttributes(ctx context.Context, diags *diag.Diagnostics, clie } } -func getPkiTPRn(ctx context.Context, data *PkiTPResourceModel) string { - rn := "tp-{name}" +func getPkiTPRn(ctx context.Context, data *PkiTPResourceModel) map[string]string { + rn_map := map[string]string{"": "uni/userext/pkiext/tp-{name}", "tn": "certstore/tp-{name}"} for _, identifier := range []string{"name"} { fieldName := fmt.Sprintf("%s%s", strings.ToUpper(identifier[:1]), identifier[1:]) fieldValue := reflect.ValueOf(data).Elem().FieldByName(fieldName).Interface().(basetypes.StringValue).ValueString() - rn = strings.ReplaceAll(rn, fmt.Sprintf("{%s}", identifier), fieldValue) + for parent_identifier, rn_prepend := range rn_map { + rn_map[parent_identifier] = strings.ReplaceAll(rn_prepend, fmt.Sprintf("{%s}", identifier), fieldValue) + } } - return rn + return rn_map } func setPkiTPParentDn(ctx context.Context, dn string, data *PkiTPResourceModel) { @@ -436,12 +438,27 @@ func setPkiTPParentDn(ctx context.Context, dn string, data *PkiTPResourceModel) break } } - data.ParentDn = basetypes.NewStringValue(dn[:rnIndex]) + rn_map := map[string]string{"": "uni/userext/pkiext/tp-{name}", "tn": "certstore/tp-{name}"} + parentDn := dn[:rnIndex] + for parent_identifier, rn_prepend := range rn_map { + if strings.Contains(parentDn, parent_identifier) && parent_identifier != "" { + parentDn = parentDn[:strings.Index(parentDn, "/"+rn_prepend)] + data.ParentDn = basetypes.NewStringValue(parentDn) + } + break + } + } func setPkiTPId(ctx context.Context, data *PkiTPResourceModel) { - rn := getPkiTPRn(ctx, data) - data.Id = types.StringValue(fmt.Sprintf("%s/%s", data.ParentDn.ValueString(), rn)) + rn_map := getPkiTPRn(ctx, data) + for parent_identifier, rn_prepend := range rn_map { + if data.ParentDn.ValueString() == "" && parent_identifier == "" { + data.Id = types.StringValue(fmt.Sprintf("%s", rn_prepend)) + } else if parent_identifier != "" && strings.Contains(data.ParentDn.ValueString(), parent_identifier) { + data.Id = types.StringValue(fmt.Sprintf("%s/%s", data.ParentDn.ValueString(), rn_prepend)) + } + } } func getPkiTPTagAnnotationChildPayloads(ctx context.Context, diags *diag.Diagnostics, data *PkiTPResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationPkiTPResourceModel) []map[string]interface{} { @@ -538,47 +555,3 @@ func getPkiTPCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, dat } return jsonPayload } - -func getPkiTPDeleteJsonPayload(ctx context.Context, diags *diag.Diagnostics, data *PkiTPResourceModel) *container.Container { - - jsonString := fmt.Sprintf(`{"pkiTP":{"attributes":{"dn": "%s","status": "deleted"}}}`, data.Id.ValueString()) - jsonPayload, err := container.ParseJSON([]byte(jsonString)) - if err != nil { - diags.AddError( - "Construction of json payload failed", - fmt.Sprintf("Err: %s. Please report this issue to the provider developers.", err), - ) - return nil - } - return jsonPayload -} - -func doPkiTPRequest(ctx context.Context, diags *diag.Diagnostics, client *client.Client, path, method string, payload *container.Container) *container.Container { - - restRequest, err := client.MakeRestRequest(method, path, payload, true) - if err != nil { - diags.AddError( - "Creation of rest request failed", - fmt.Sprintf("Err: %s. Please report this issue to the provider developers.", err), - ) - return nil - } - - cont, restResponse, err := client.Do(restRequest) - - if restResponse != nil && restResponse.StatusCode != 200 { - diags.AddError( - fmt.Sprintf("The %s rest request failed", strings.ToLower(method)), - fmt.Sprintf("Response: %s, err: %s. Please report this issue to the provider developers.", cont.Data().(map[string]interface{})["imdata"], err), - ) - return nil - } else if err != nil { - diags.AddError( - fmt.Sprintf("The %s rest request failed", strings.ToLower(method)), - fmt.Sprintf("Err: %s. Please report this issue to the provider developers.", err), - ) - return nil - } - - return cont -} diff --git a/internal/provider/resource_aci_certificate_authority_test.go b/internal/provider/resource_aci_certificate_authority_test.go index 4ac74d0d2..3b483a5f2 100644 --- a/internal/provider/resource_aci_certificate_authority_test.go +++ b/internal/provider/resource_aci_certificate_authority_test.go @@ -11,18 +11,18 @@ import ( "github.com/hashicorp/terraform-plugin-testing/helper/resource" ) -func TestAccResourcePkiTPWithPkiEp(t *testing.T) { +func TestAccResourcePkiTPWithFvTenant(t *testing.T) { resource.Test(t, resource.TestCase{ PreCheck: func() { - testAccPreCheck(t) + testAccPreCheck(t, "cloud") time.Sleep(10 * time.Second) }, ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, Steps: []resource.TestStep{ // Create with minimum config and verify default APIC values { - Config: testConfigPkiTPMinDependencyWithPkiEp, + Config: testConfigPkiTPMinDependencyWithFvTenant, ExpectNonEmptyPlan: false, Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr("aci_certificate_authority.test", "name", "test_name"), @@ -36,7 +36,7 @@ func TestAccResourcePkiTPWithPkiEp(t *testing.T) { }, // Update with all config and verify default APIC values { - Config: testConfigPkiTPAllDependencyWithPkiEp, + Config: testConfigPkiTPAllDependencyWithFvTenant, ExpectNonEmptyPlan: false, Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr("aci_certificate_authority.test", "name", "test_name"), @@ -50,7 +50,7 @@ func TestAccResourcePkiTPWithPkiEp(t *testing.T) { }, // Update with minimum config and verify config is unchanged { - Config: testConfigPkiTPMinDependencyWithPkiEp, + Config: testConfigPkiTPMinDependencyWithFvTenant, ExpectNonEmptyPlan: false, Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr("aci_certificate_authority.test", "cert_chain", "-----BEGIN CERTIFICATE-----\nMIICODCCAaGgAwIBAgIJAIt8XMntue0VMA0GCSqGSIb3DQEBCwUAMDQxDjAMBgNV\nBAMMBUFkbWluMRUwEwYDVQQKDAxZb3VyIENvbXBhbnkxCzAJBgNVBAYTAlVTMCAX\nDTE4MDEwOTAwNTk0NFoYDzIxMTcxMjE2MDA1OTQ0WjA0MQ4wDAYDVQQDDAVBZG1p\nbjEVMBMGA1UECgwMWW91ciBDb21wYW55MQswCQYDVQQGEwJVUzCBnzANBgkqhkiG\n9w0BAQEFAAOBjQAwgYkCgYEAohG/7axtt7CbSaMP7r+2mhTKbNgh0Ww36C7Ta14i\nv+VmLyKkQHnXinKGhp6uy3Nug+15a+eIu7CrgpBVMQeCiWfsnwRocKcQJWIYDrWl\nXHxGQn31yYKR6mylE7Dcj3rMFybnyhezr5D8GcP85YRPmwG9H2hO/0Y1FUnWu9Iw\nAQkCAwEAAaNQME4wHQYDVR0OBBYEFD0jLXfpkrU/ChzRvfruRs/fy1VXMB8GA1Ud\nIwQYMBaAFD0jLXfpkrU/ChzRvfruRs/fy1VXMAwGA1UdEwQFMAMBAf8wDQYJKoZI\nhvcNAQELBQADgYEAOmvre+5tgZ0+F3DgsfxNQqLTrGiBgGCIymPkP/cBXXkNuJyl\n3ac7tArHQc7WEA4U2R2rZbEq8FC3UJJm4nUVtCPvEh3G9OhN2xwYev79yt6pIn/l\nKU0Td2OpVyo0eLqjoX5u2G90IBWzhyjFbo+CcKMrSVKj1YOdG0E3OuiJf00=\n-----END CERTIFICATE-----\n"), @@ -59,7 +59,7 @@ func TestAccResourcePkiTPWithPkiEp(t *testing.T) { }, // Update with empty strings config or default value { - Config: testConfigPkiTPResetDependencyWithPkiEp, + Config: testConfigPkiTPResetDependencyWithFvTenant, ExpectNonEmptyPlan: false, Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr("aci_certificate_authority.test", "cert_chain", "-----BEGIN CERTIFICATE-----\nMIICODCCAaGgAwIBAgIJAIt8XMntue0VMA0GCSqGSIb3DQEBCwUAMDQxDjAMBgNV\nBAMMBUFkbWluMRUwEwYDVQQKDAxZb3VyIENvbXBhbnkxCzAJBgNVBAYTAlVTMCAX\nDTE4MDEwOTAwNTk0NFoYDzIxMTcxMjE2MDA1OTQ0WjA0MQ4wDAYDVQQDDAVBZG1p\nbjEVMBMGA1UECgwMWW91ciBDb21wYW55MQswCQYDVQQGEwJVUzCBnzANBgkqhkiG\n9w0BAQEFAAOBjQAwgYkCgYEAohG/7axtt7CbSaMP7r+2mhTKbNgh0Ww36C7Ta14i\nv+VmLyKkQHnXinKGhp6uy3Nug+15a+eIu7CrgpBVMQeCiWfsnwRocKcQJWIYDrWl\nXHxGQn31yYKR6mylE7Dcj3rMFybnyhezr5D8GcP85YRPmwG9H2hO/0Y1FUnWu9Iw\nAQkCAwEAAaNQME4wHQYDVR0OBBYEFD0jLXfpkrU/ChzRvfruRs/fy1VXMB8GA1Ud\nIwQYMBaAFD0jLXfpkrU/ChzRvfruRs/fy1VXMAwGA1UdEwQFMAMBAf8wDQYJKoZI\nhvcNAQELBQADgYEAOmvre+5tgZ0+F3DgsfxNQqLTrGiBgGCIymPkP/cBXXkNuJyl\n3ac7tArHQc7WEA4U2R2rZbEq8FC3UJJm4nUVtCPvEh3G9OhN2xwYev79yt6pIn/l\nKU0Td2OpVyo0eLqjoX5u2G90IBWzhyjFbo+CcKMrSVKj1YOdG0E3OuiJf00=\n-----END CERTIFICATE-----\n"), @@ -88,10 +88,10 @@ func TestAccResourcePkiTPWithPkiEp(t *testing.T) { }, // Update with children { - Config: testConfigPkiTPChildrenDependencyWithPkiEp, + Config: testConfigPkiTPChildrenDependencyWithFvTenant, ExpectNonEmptyPlan: false, Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr("aci_certificate_authority.test", "cert_chain", "<