diff --git a/gen/generator.go b/gen/generator.go index 930b2c41d..56a9e57f8 100644 --- a/gen/generator.go +++ b/gen/generator.go @@ -134,6 +134,8 @@ var templateFuncs = template.FuncMap{ "definedInList": DefinedInList, "keyExists": KeyExists, "isNewNamedClassAttributeMatch": IsNewNamedClassAttributeMatch, + "getRnFormat": GetRnFormat, + "identifierIsCustomType": IdentifierIsCustomType, } func ContainsRequired(properties map[string]Property) bool { @@ -211,6 +213,24 @@ func GetPropertyNameForLegacyAttribute(name string, legacyAttributes map[string] return "" } +func GetRnFormat(rnformat string, identifiers []interface{}) string { + if len(identifiers) > 0 { + for _, identifier := range identifiers { + rnformat = strings.ReplaceAll(rnformat, fmt.Sprintf("{%s}", identifier), "%s") + } + } + return rnformat +} + +func IdentifierIsCustomType(identifier string, properties map[string]Property) bool { + for propertyName, property := range properties { + if propertyName == identifier { + return property.HasCustomType + } + } + return false +} + func GetLegacyChildAttribute(className, overwriteProperty string, property Property, legacyAttributes map[string]LegacyAttribute, legacyBlocks []LegacyBlock) string { for _, legacyBlock := range legacyBlocks { diff --git a/gen/templates/custom_type.go.tmpl b/gen/templates/custom_type.go.tmpl index c123df12d..c979ce46d 100644 --- a/gen/templates/custom_type.go.tmpl +++ b/gen/templates/custom_type.go.tmpl @@ -112,6 +112,10 @@ func (v {{.ResourceClassName}}{{.Name}}StringValue) StringSemanticEquals(ctx con return priorMappedValue.Equal(newMappedValue), diags } +func (v {{.ResourceClassName}}{{.Name}}StringValue) NamedValueString() string { + return {{.ResourceClassName}}{{.Name}}ValueMap(basetypes.NewStringValue(v.ValueString())).ValueString() +} + func {{.ResourceClassName}}{{.Name}}ValueMap(value basetypes.StringValue) basetypes.StringValue { matchMap := map[string]string{ {{- range $key, $value := .ValidValuesMap}} diff --git a/gen/templates/datasource.go.tmpl b/gen/templates/datasource.go.tmpl index 5dacc4ae9..838dbe434 100644 --- a/gen/templates/datasource.go.tmpl +++ b/gen/templates/datasource.go.tmpl @@ -115,6 +115,9 @@ func (d *{{.ResourceClassName}}DataSource) Schema(ctx context.Context, req datas {{- range .Properties}} {{- if .IsNaming}} "{{overwriteProperty .PkgName .SnakeCaseName $.Definitions}}": schema.StringAttribute{ + {{- if .HasCustomType}} + CustomType: customTypes.{{.ResourceClassName}}{{.Name}}StringType{}, + {{- end}} Required: true, MarkdownDescription: `{{.Comment}}`, },{{else if eq .ValueType "bitmask"}} diff --git a/gen/templates/resource.go.tmpl b/gen/templates/resource.go.tmpl index 3e91d137c..68b078e4a 100644 --- a/gen/templates/resource.go.tmpl +++ b/gen/templates/resource.go.tmpl @@ -1999,17 +1999,7 @@ func getAndSet{{.ResourceClassName}}Attributes(ctx context.Context, diags *diag. } func get{{.ResourceClassName}}Rn(ctx context.Context, data *{{.ResourceClassName}}ResourceModel) string { - {{- if .IdentifiedBy}} - rn := "{{.RnFormat}}" - 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() - rn = strings.ReplaceAll(rn, fmt.Sprintf("{%s}", identifier), fieldValue) - } - return rn - {{- else}} - return "{{.RnFormat}}" - {{- end}} + return fmt.Sprintf("{{getRnFormat .RnFormat .IdentifiedBy}}", {{$i := 1}}{{$length := len .IdentifiedBy}}{{ range .IdentifiedBy}}data.{{capitalize .}}{{- if identifierIsCustomType . $.Properties}}.NamedValueString(){{else}}.ValueString(){{end}}{{ if ne $length $i}}{{$i = add $i 1}}, {{end}}{{- end}}) } {{ if .HasParent}} @@ -2138,7 +2128,11 @@ func get{{$.ResourceClassName}}{{ .ResourceClassName }}ChildPayloads(ctx context {{ .PkgName }}Identifier := {{ .ResourceClassName }}Identifier{} {{- range .Properties}} {{- if .IsNaming}} + {{- if .HasCustomType}} + {{ .PkgName }}Identifier.{{.Name}} = basetypes.NewStringValue({{ .PkgName }}.{{- if eq .Name "Id"}}{{.ResourceClassName}}.ValueString(){{ .Name }}{{- else}}{{.Name}}.ValueString(){{- end}}) + {{- else}} {{ .PkgName }}Identifier.{{.Name}} = {{ .PkgName }}.{{- if eq .Name "Id"}}{{.ResourceClassName}}{{ .Name }}{{- else}}{{.Name}}{{- end}} + {{- end}} {{- end}} {{- end}} {{ .PkgName }}Identifiers = append({{ .PkgName }}Identifiers, {{ .PkgName }}Identifier) @@ -2151,7 +2145,11 @@ func get{{$.ResourceClassName}}{{ .ResourceClassName }}ChildPayloads(ctx context if {{- range .Properties}} {{- if .IsNaming }} + {{- if .HasCustomType}} + {{ .PkgName }}Identifier.{{.Name}} == basetypes.NewStringValue({{ .PkgName }}.{{- if eq .Name "Id"}}{{.ResourceClassName}}.ValueString(){{ .Name }}{{- else}}{{.Name}}.ValueString(){{- end}}){{- if ne $length $i}} {{$i = add $i 1}} && {{- end}} + {{- else}} {{ .PkgName }}Identifier.{{.Name}} == {{ .PkgName }}.{{- if eq .Name "Id"}}{{.ResourceClassName}}{{ .Name }}{{- else}}{{.Name}}{{- end}}{{- if ne $length $i}} {{$i = add $i 1}} && {{- end}} + {{- end}} {{- end}} {{- end}} { delete = false diff --git a/internal/custom_types/fvAEPg_prio.go b/internal/custom_types/fvAEPg_prio.go index 3ba2c043a..96774f2c2 100644 --- a/internal/custom_types/fvAEPg_prio.go +++ b/internal/custom_types/fvAEPg_prio.go @@ -112,6 +112,10 @@ func (v FvAEPgPrioStringValue) StringSemanticEquals(ctx context.Context, newValu return priorMappedValue.Equal(newMappedValue), diags } +func (v FvAEPgPrioStringValue) NamedValueString() string { + return FvAEPgPrioValueMap(basetypes.NewStringValue(v.ValueString())).ValueString() +} + func FvAEPgPrioValueMap(value basetypes.StringValue) basetypes.StringValue { matchMap := map[string]string{ "0": "unspecified", diff --git a/internal/custom_types/fvRsConsIf_prio.go b/internal/custom_types/fvRsConsIf_prio.go index 80a9d7a7f..b75fd8fb1 100644 --- a/internal/custom_types/fvRsConsIf_prio.go +++ b/internal/custom_types/fvRsConsIf_prio.go @@ -112,6 +112,10 @@ func (v FvRsConsIfPrioStringValue) StringSemanticEquals(ctx context.Context, new return priorMappedValue.Equal(newMappedValue), diags } +func (v FvRsConsIfPrioStringValue) NamedValueString() string { + return FvRsConsIfPrioValueMap(basetypes.NewStringValue(v.ValueString())).ValueString() +} + func FvRsConsIfPrioValueMap(value basetypes.StringValue) basetypes.StringValue { matchMap := map[string]string{ "0": "unspecified", diff --git a/internal/custom_types/fvRsCons_prio.go b/internal/custom_types/fvRsCons_prio.go index eac53749f..fb89bddf4 100644 --- a/internal/custom_types/fvRsCons_prio.go +++ b/internal/custom_types/fvRsCons_prio.go @@ -112,6 +112,10 @@ func (v FvRsConsPrioStringValue) StringSemanticEquals(ctx context.Context, newVa return priorMappedValue.Equal(newMappedValue), diags } +func (v FvRsConsPrioStringValue) NamedValueString() string { + return FvRsConsPrioValueMap(basetypes.NewStringValue(v.ValueString())).ValueString() +} + func FvRsConsPrioValueMap(value basetypes.StringValue) basetypes.StringValue { matchMap := map[string]string{ "0": "unspecified", diff --git a/internal/custom_types/fvRsProv_prio.go b/internal/custom_types/fvRsProv_prio.go index 12d0a163a..e9c7b8302 100644 --- a/internal/custom_types/fvRsProv_prio.go +++ b/internal/custom_types/fvRsProv_prio.go @@ -112,6 +112,10 @@ func (v FvRsProvPrioStringValue) StringSemanticEquals(ctx context.Context, newVa return priorMappedValue.Equal(newMappedValue), diags } +func (v FvRsProvPrioStringValue) NamedValueString() string { + return FvRsProvPrioValueMap(basetypes.NewStringValue(v.ValueString())).ValueString() +} + func FvRsProvPrioValueMap(value basetypes.StringValue) basetypes.StringValue { matchMap := map[string]string{ "0": "unspecified", diff --git a/internal/custom_types/mgmtInstP_prio.go b/internal/custom_types/mgmtInstP_prio.go index 865f00953..a7c4f611a 100644 --- a/internal/custom_types/mgmtInstP_prio.go +++ b/internal/custom_types/mgmtInstP_prio.go @@ -112,6 +112,10 @@ func (v MgmtInstPPrioStringValue) StringSemanticEquals(ctx context.Context, newV return priorMappedValue.Equal(newMappedValue), diags } +func (v MgmtInstPPrioStringValue) NamedValueString() string { + return MgmtInstPPrioValueMap(basetypes.NewStringValue(v.ValueString())).ValueString() +} + func MgmtInstPPrioValueMap(value basetypes.StringValue) basetypes.StringValue { matchMap := map[string]string{ "0": "unspecified", diff --git a/internal/custom_types/mgmtRsOoBCons_prio.go b/internal/custom_types/mgmtRsOoBCons_prio.go index 38533a383..0a9ea98eb 100644 --- a/internal/custom_types/mgmtRsOoBCons_prio.go +++ b/internal/custom_types/mgmtRsOoBCons_prio.go @@ -112,6 +112,10 @@ func (v MgmtRsOoBConsPrioStringValue) StringSemanticEquals(ctx context.Context, return priorMappedValue.Equal(newMappedValue), diags } +func (v MgmtRsOoBConsPrioStringValue) NamedValueString() string { + return MgmtRsOoBConsPrioValueMap(basetypes.NewStringValue(v.ValueString())).ValueString() +} + func MgmtRsOoBConsPrioValueMap(value basetypes.StringValue) basetypes.StringValue { matchMap := map[string]string{ "0": "unspecified", diff --git a/internal/custom_types/netflowExporterPol_dscp.go b/internal/custom_types/netflowExporterPol_dscp.go index cb33a5b61..f5c041df0 100644 --- a/internal/custom_types/netflowExporterPol_dscp.go +++ b/internal/custom_types/netflowExporterPol_dscp.go @@ -112,6 +112,10 @@ func (v NetflowExporterPolDscpStringValue) StringSemanticEquals(ctx context.Cont return priorMappedValue.Equal(newMappedValue), diags } +func (v NetflowExporterPolDscpStringValue) NamedValueString() string { + return NetflowExporterPolDscpValueMap(basetypes.NewStringValue(v.ValueString())).ValueString() +} + func NetflowExporterPolDscpValueMap(value basetypes.StringValue) basetypes.StringValue { matchMap := map[string]string{ "0": "CS0", diff --git a/internal/custom_types/netflowExporterPol_dstPort.go b/internal/custom_types/netflowExporterPol_dstPort.go index 41e2988b1..09d5e6254 100644 --- a/internal/custom_types/netflowExporterPol_dstPort.go +++ b/internal/custom_types/netflowExporterPol_dstPort.go @@ -112,6 +112,10 @@ func (v NetflowExporterPolDstPortStringValue) StringSemanticEquals(ctx context.C return priorMappedValue.Equal(newMappedValue), diags } +func (v NetflowExporterPolDstPortStringValue) NamedValueString() string { + return NetflowExporterPolDstPortValueMap(basetypes.NewStringValue(v.ValueString())).ValueString() +} + func NetflowExporterPolDstPortValueMap(value basetypes.StringValue) basetypes.StringValue { matchMap := map[string]string{ "0": "unspecified", diff --git a/internal/custom_types/qosDppPol_be.go b/internal/custom_types/qosDppPol_be.go index b5c9de9b1..f9c5c5dad 100644 --- a/internal/custom_types/qosDppPol_be.go +++ b/internal/custom_types/qosDppPol_be.go @@ -112,6 +112,10 @@ func (v QosDppPolBeStringValue) StringSemanticEquals(ctx context.Context, newVal return priorMappedValue.Equal(newMappedValue), diags } +func (v QosDppPolBeStringValue) NamedValueString() string { + return QosDppPolBeValueMap(basetypes.NewStringValue(v.ValueString())).ValueString() +} + func QosDppPolBeValueMap(value basetypes.StringValue) basetypes.StringValue { matchMap := map[string]string{ "0xffffffffffffffff": "unspecified", diff --git a/internal/custom_types/qosDppPol_burst.go b/internal/custom_types/qosDppPol_burst.go index 942f7cf3d..75e8cccae 100644 --- a/internal/custom_types/qosDppPol_burst.go +++ b/internal/custom_types/qosDppPol_burst.go @@ -112,6 +112,10 @@ func (v QosDppPolBurstStringValue) StringSemanticEquals(ctx context.Context, new return priorMappedValue.Equal(newMappedValue), diags } +func (v QosDppPolBurstStringValue) NamedValueString() string { + return QosDppPolBurstValueMap(basetypes.NewStringValue(v.ValueString())).ValueString() +} + func QosDppPolBurstValueMap(value basetypes.StringValue) basetypes.StringValue { matchMap := map[string]string{ "0xffffffffffffffff": "unspecified", diff --git a/internal/custom_types/qosDppPol_conformMarkCos.go b/internal/custom_types/qosDppPol_conformMarkCos.go index 67790c37a..56f3c6115 100644 --- a/internal/custom_types/qosDppPol_conformMarkCos.go +++ b/internal/custom_types/qosDppPol_conformMarkCos.go @@ -112,6 +112,10 @@ func (v QosDppPolConformMarkCosStringValue) StringSemanticEquals(ctx context.Con return priorMappedValue.Equal(newMappedValue), diags } +func (v QosDppPolConformMarkCosStringValue) NamedValueString() string { + return QosDppPolConformMarkCosValueMap(basetypes.NewStringValue(v.ValueString())).ValueString() +} + func QosDppPolConformMarkCosValueMap(value basetypes.StringValue) basetypes.StringValue { matchMap := map[string]string{ "0xffff": "unspecified", diff --git a/internal/custom_types/qosDppPol_conformMarkDscp.go b/internal/custom_types/qosDppPol_conformMarkDscp.go index e97b3f30a..091e9c567 100644 --- a/internal/custom_types/qosDppPol_conformMarkDscp.go +++ b/internal/custom_types/qosDppPol_conformMarkDscp.go @@ -112,6 +112,10 @@ func (v QosDppPolConformMarkDscpStringValue) StringSemanticEquals(ctx context.Co return priorMappedValue.Equal(newMappedValue), diags } +func (v QosDppPolConformMarkDscpStringValue) NamedValueString() string { + return QosDppPolConformMarkDscpValueMap(basetypes.NewStringValue(v.ValueString())).ValueString() +} + func QosDppPolConformMarkDscpValueMap(value basetypes.StringValue) basetypes.StringValue { matchMap := map[string]string{ "0xffff": "unspecified", diff --git a/internal/custom_types/qosDppPol_exceedMarkCos.go b/internal/custom_types/qosDppPol_exceedMarkCos.go index 7cfa390bc..315fd7335 100644 --- a/internal/custom_types/qosDppPol_exceedMarkCos.go +++ b/internal/custom_types/qosDppPol_exceedMarkCos.go @@ -112,6 +112,10 @@ func (v QosDppPolExceedMarkCosStringValue) StringSemanticEquals(ctx context.Cont return priorMappedValue.Equal(newMappedValue), diags } +func (v QosDppPolExceedMarkCosStringValue) NamedValueString() string { + return QosDppPolExceedMarkCosValueMap(basetypes.NewStringValue(v.ValueString())).ValueString() +} + func QosDppPolExceedMarkCosValueMap(value basetypes.StringValue) basetypes.StringValue { matchMap := map[string]string{ "0xffff": "unspecified", diff --git a/internal/custom_types/qosDppPol_exceedMarkDscp.go b/internal/custom_types/qosDppPol_exceedMarkDscp.go index c4f9e16c8..efcb418e9 100644 --- a/internal/custom_types/qosDppPol_exceedMarkDscp.go +++ b/internal/custom_types/qosDppPol_exceedMarkDscp.go @@ -112,6 +112,10 @@ func (v QosDppPolExceedMarkDscpStringValue) StringSemanticEquals(ctx context.Con return priorMappedValue.Equal(newMappedValue), diags } +func (v QosDppPolExceedMarkDscpStringValue) NamedValueString() string { + return QosDppPolExceedMarkDscpValueMap(basetypes.NewStringValue(v.ValueString())).ValueString() +} + func QosDppPolExceedMarkDscpValueMap(value basetypes.StringValue) basetypes.StringValue { matchMap := map[string]string{ "0xffff": "unspecified", diff --git a/internal/custom_types/qosDppPol_violateMarkCos.go b/internal/custom_types/qosDppPol_violateMarkCos.go index a9db97dbc..c76e9856c 100644 --- a/internal/custom_types/qosDppPol_violateMarkCos.go +++ b/internal/custom_types/qosDppPol_violateMarkCos.go @@ -112,6 +112,10 @@ func (v QosDppPolViolateMarkCosStringValue) StringSemanticEquals(ctx context.Con return priorMappedValue.Equal(newMappedValue), diags } +func (v QosDppPolViolateMarkCosStringValue) NamedValueString() string { + return QosDppPolViolateMarkCosValueMap(basetypes.NewStringValue(v.ValueString())).ValueString() +} + func QosDppPolViolateMarkCosValueMap(value basetypes.StringValue) basetypes.StringValue { matchMap := map[string]string{ "0xffff": "unspecified", diff --git a/internal/custom_types/qosDppPol_violateMarkDscp.go b/internal/custom_types/qosDppPol_violateMarkDscp.go index 7870136ad..01fd9c7e2 100644 --- a/internal/custom_types/qosDppPol_violateMarkDscp.go +++ b/internal/custom_types/qosDppPol_violateMarkDscp.go @@ -112,6 +112,10 @@ func (v QosDppPolViolateMarkDscpStringValue) StringSemanticEquals(ctx context.Co return priorMappedValue.Equal(newMappedValue), diags } +func (v QosDppPolViolateMarkDscpStringValue) NamedValueString() string { + return QosDppPolViolateMarkDscpValueMap(basetypes.NewStringValue(v.ValueString())).ValueString() +} + func QosDppPolViolateMarkDscpValueMap(value basetypes.StringValue) basetypes.StringValue { matchMap := map[string]string{ "0xffff": "unspecified", diff --git a/internal/custom_types/vzOOBBrCP_prio.go b/internal/custom_types/vzOOBBrCP_prio.go index 8f5784fee..6e7561148 100644 --- a/internal/custom_types/vzOOBBrCP_prio.go +++ b/internal/custom_types/vzOOBBrCP_prio.go @@ -112,6 +112,10 @@ func (v VzOOBBrCPPrioStringValue) StringSemanticEquals(ctx context.Context, newV return priorMappedValue.Equal(newMappedValue), diags } +func (v VzOOBBrCPPrioStringValue) NamedValueString() string { + return VzOOBBrCPPrioValueMap(basetypes.NewStringValue(v.ValueString())).ValueString() +} + func VzOOBBrCPPrioValueMap(value basetypes.StringValue) basetypes.StringValue { matchMap := map[string]string{ "0": "unspecified", diff --git a/internal/custom_types/vzOOBBrCP_targetDscp.go b/internal/custom_types/vzOOBBrCP_targetDscp.go index 530e847cb..88110ef6b 100644 --- a/internal/custom_types/vzOOBBrCP_targetDscp.go +++ b/internal/custom_types/vzOOBBrCP_targetDscp.go @@ -112,6 +112,10 @@ func (v VzOOBBrCPTargetDscpStringValue) StringSemanticEquals(ctx context.Context return priorMappedValue.Equal(newMappedValue), diags } +func (v VzOOBBrCPTargetDscpStringValue) NamedValueString() string { + return VzOOBBrCPTargetDscpValueMap(basetypes.NewStringValue(v.ValueString())).ValueString() +} + func VzOOBBrCPTargetDscpValueMap(value basetypes.StringValue) basetypes.StringValue { matchMap := map[string]string{ "0": "CS0", diff --git a/internal/provider/resource_aci_access_interface_override.go b/internal/provider/resource_aci_access_interface_override.go index 554fed6d7..bead074ff 100644 --- a/internal/provider/resource_aci_access_interface_override.go +++ b/internal/provider/resource_aci_access_interface_override.go @@ -8,8 +8,6 @@ import ( "context" "encoding/json" "fmt" - "reflect" - "strings" "github.com/ciscoecosystem/aci-go-client/v2/client" "github.com/ciscoecosystem/aci-go-client/v2/container" @@ -711,13 +709,7 @@ func getAndSetInfraHPathSAttributes(ctx context.Context, diags *diag.Diagnostics } func getInfraHPathSRn(ctx context.Context, data *InfraHPathSResourceModel) string { - rn := "hpaths-{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) - } - return rn + return fmt.Sprintf("hpaths-%s", data.Name.ValueString()) } func setInfraHPathSParentDn(ctx context.Context, dn string, data *InfraHPathSResourceModel) { diff --git a/internal/provider/resource_aci_annotation.go b/internal/provider/resource_aci_annotation.go index 0954dfb73..0d157c89a 100644 --- a/internal/provider/resource_aci_annotation.go +++ b/internal/provider/resource_aci_annotation.go @@ -8,8 +8,6 @@ import ( "context" "encoding/json" "fmt" - "reflect" - "strings" "github.com/ciscoecosystem/aci-go-client/v2/client" "github.com/ciscoecosystem/aci-go-client/v2/container" @@ -321,13 +319,7 @@ func getAndSetTagAnnotationAttributes(ctx context.Context, diags *diag.Diagnosti } func getTagAnnotationRn(ctx context.Context, data *TagAnnotationResourceModel) string { - rn := "annotationKey-[{key}]" - for _, identifier := range []string{"key"} { - 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) - } - return rn + return fmt.Sprintf("annotationKey-[%s]", data.Key.ValueString()) } func setTagAnnotationParentDn(ctx context.Context, dn string, data *TagAnnotationResourceModel) { diff --git a/internal/provider/resource_aci_application_epg.go b/internal/provider/resource_aci_application_epg.go index 4110a42ba..a258f622d 100644 --- a/internal/provider/resource_aci_application_epg.go +++ b/internal/provider/resource_aci_application_epg.go @@ -8,8 +8,6 @@ import ( "context" "encoding/json" "fmt" - "reflect" - "strings" customTypes "github.com/CiscoDevNet/terraform-provider-aci/v2/internal/custom_types" "github.com/CiscoDevNet/terraform-provider-aci/v2/internal/validators" @@ -4701,13 +4699,7 @@ func getAndSetFvAEPgAttributes(ctx context.Context, diags *diag.Diagnostics, cli } func getFvAEPgRn(ctx context.Context, data *FvAEPgResourceModel) string { - rn := "epg-{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) - } - return rn + return fmt.Sprintf("epg-%s", data.Name.ValueString()) } func setFvAEPgParentDn(ctx context.Context, dn string, data *FvAEPgResourceModel) { diff --git a/internal/provider/resource_aci_bridge_domain.go b/internal/provider/resource_aci_bridge_domain.go index 53d8b7b86..03d60a9e5 100644 --- a/internal/provider/resource_aci_bridge_domain.go +++ b/internal/provider/resource_aci_bridge_domain.go @@ -8,8 +8,6 @@ import ( "context" "encoding/json" "fmt" - "reflect" - "strings" "github.com/ciscoecosystem/aci-go-client/v2/client" "github.com/ciscoecosystem/aci-go-client/v2/container" @@ -3553,13 +3551,7 @@ func getAndSetFvBDAttributes(ctx context.Context, diags *diag.Diagnostics, clien } func getFvBDRn(ctx context.Context, data *FvBDResourceModel) string { - rn := "BD-{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) - } - return rn + return fmt.Sprintf("BD-%s", data.Name.ValueString()) } func setFvBDParentDn(ctx context.Context, dn string, data *FvBDResourceModel) { diff --git a/internal/provider/resource_aci_certificate_authority.go b/internal/provider/resource_aci_certificate_authority.go index f5c087c11..a5164e85b 100644 --- a/internal/provider/resource_aci_certificate_authority.go +++ b/internal/provider/resource_aci_certificate_authority.go @@ -8,7 +8,6 @@ import ( "context" "encoding/json" "fmt" - "reflect" "strings" "github.com/ciscoecosystem/aci-go-client/v2/client" @@ -577,13 +576,7 @@ func getAndSetPkiTPAttributes(ctx context.Context, diags *diag.Diagnostics, clie } func getPkiTPRn(ctx context.Context, data *PkiTPResourceModel) string { - rn := "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) - } - return rn + return fmt.Sprintf("tp-%s", data.Name.ValueString()) } func setPkiTPParentDn(ctx context.Context, dn string, data *PkiTPResourceModel) { diff --git a/internal/provider/resource_aci_custom_qos_policy.go b/internal/provider/resource_aci_custom_qos_policy.go index e829fe128..e68c065bd 100644 --- a/internal/provider/resource_aci_custom_qos_policy.go +++ b/internal/provider/resource_aci_custom_qos_policy.go @@ -8,8 +8,6 @@ import ( "context" "encoding/json" "fmt" - "reflect" - "strings" "github.com/ciscoecosystem/aci-go-client/v2/client" "github.com/ciscoecosystem/aci-go-client/v2/container" @@ -541,13 +539,7 @@ func getAndSetQosCustomPolAttributes(ctx context.Context, diags *diag.Diagnostic } func getQosCustomPolRn(ctx context.Context, data *QosCustomPolResourceModel) string { - rn := "qoscustom-{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) - } - return rn + return fmt.Sprintf("qoscustom-%s", data.Name.ValueString()) } func setQosCustomPolParentDn(ctx context.Context, dn string, data *QosCustomPolResourceModel) { diff --git a/internal/provider/resource_aci_data_plane_policing_policy.go b/internal/provider/resource_aci_data_plane_policing_policy.go index 7f4575a60..9ec05062e 100644 --- a/internal/provider/resource_aci_data_plane_policing_policy.go +++ b/internal/provider/resource_aci_data_plane_policing_policy.go @@ -8,8 +8,6 @@ import ( "context" "encoding/json" "fmt" - "reflect" - "strings" customTypes "github.com/CiscoDevNet/terraform-provider-aci/v2/internal/custom_types" "github.com/CiscoDevNet/terraform-provider-aci/v2/internal/validators" @@ -930,13 +928,7 @@ func getAndSetQosDppPolAttributes(ctx context.Context, diags *diag.Diagnostics, } func getQosDppPolRn(ctx context.Context, data *QosDppPolResourceModel) string { - rn := "qosdpppol-{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) - } - return rn + return fmt.Sprintf("qosdpppol-%s", data.Name.ValueString()) } func setQosDppPolParentDn(ctx context.Context, dn string, data *QosDppPolResourceModel) { diff --git a/internal/provider/resource_aci_endpoint_security_group.go b/internal/provider/resource_aci_endpoint_security_group.go index 963ed4ef6..508a3c3cc 100644 --- a/internal/provider/resource_aci_endpoint_security_group.go +++ b/internal/provider/resource_aci_endpoint_security_group.go @@ -8,8 +8,6 @@ import ( "context" "encoding/json" "fmt" - "reflect" - "strings" customTypes "github.com/CiscoDevNet/terraform-provider-aci/v2/internal/custom_types" "github.com/CiscoDevNet/terraform-provider-aci/v2/internal/validators" @@ -2139,13 +2137,7 @@ func getAndSetFvESgAttributes(ctx context.Context, diags *diag.Diagnostics, clie } func getFvESgRn(ctx context.Context, data *FvESgResourceModel) string { - rn := "esg-{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) - } - return rn + return fmt.Sprintf("esg-%s", data.Name.ValueString()) } func setFvESgParentDn(ctx context.Context, dn string, data *FvESgResourceModel) { diff --git a/internal/provider/resource_aci_endpoint_tag_ip.go b/internal/provider/resource_aci_endpoint_tag_ip.go index 635fe9b67..fba9b361d 100644 --- a/internal/provider/resource_aci_endpoint_tag_ip.go +++ b/internal/provider/resource_aci_endpoint_tag_ip.go @@ -8,7 +8,6 @@ import ( "context" "encoding/json" "fmt" - "reflect" "strings" "github.com/ciscoecosystem/aci-go-client/v2/client" @@ -542,13 +541,7 @@ func getAndSetFvEpIpTagAttributes(ctx context.Context, diags *diag.Diagnostics, } func getFvEpIpTagRn(ctx context.Context, data *FvEpIpTagResourceModel) string { - rn := "eptags/epiptag-[{ip}]-{ctxName}" - for _, identifier := range []string{"ip", "ctxName"} { - 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) - } - return rn + return fmt.Sprintf("eptags/epiptag-[%s]-%s", data.Ip.ValueString(), data.CtxName.ValueString()) } func setFvEpIpTagParentDn(ctx context.Context, dn string, data *FvEpIpTagResourceModel) { diff --git a/internal/provider/resource_aci_endpoint_tag_mac.go b/internal/provider/resource_aci_endpoint_tag_mac.go index 5bf94e68e..47039bdd1 100644 --- a/internal/provider/resource_aci_endpoint_tag_mac.go +++ b/internal/provider/resource_aci_endpoint_tag_mac.go @@ -8,7 +8,6 @@ import ( "context" "encoding/json" "fmt" - "reflect" "strings" "github.com/ciscoecosystem/aci-go-client/v2/client" @@ -542,13 +541,7 @@ func getAndSetFvEpMacTagAttributes(ctx context.Context, diags *diag.Diagnostics, } func getFvEpMacTagRn(ctx context.Context, data *FvEpMacTagResourceModel) string { - rn := "eptags/epmactag-{mac}-[{bdName}]" - for _, identifier := range []string{"mac", "bdName"} { - 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) - } - return rn + return fmt.Sprintf("eptags/epmactag-%s-[%s]", data.Mac.ValueString(), data.BdName.ValueString()) } func setFvEpMacTagParentDn(ctx context.Context, dn string, data *FvEpMacTagResourceModel) { diff --git a/internal/provider/resource_aci_epg_useg_ad_group_attribute.go b/internal/provider/resource_aci_epg_useg_ad_group_attribute.go index cc7d4aa7a..ba8844413 100644 --- a/internal/provider/resource_aci_epg_useg_ad_group_attribute.go +++ b/internal/provider/resource_aci_epg_useg_ad_group_attribute.go @@ -8,8 +8,6 @@ import ( "context" "encoding/json" "fmt" - "reflect" - "strings" "github.com/ciscoecosystem/aci-go-client/v2/client" "github.com/ciscoecosystem/aci-go-client/v2/container" @@ -555,13 +553,7 @@ func getAndSetFvIdGroupAttrAttributes(ctx context.Context, diags *diag.Diagnosti } func getFvIdGroupAttrRn(ctx context.Context, data *FvIdGroupAttrResourceModel) string { - rn := "idgattr-[{selector}]" - for _, identifier := range []string{"selector"} { - 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) - } - return rn + return fmt.Sprintf("idgattr-[%s]", data.Selector.ValueString()) } func setFvIdGroupAttrParentDn(ctx context.Context, dn string, data *FvIdGroupAttrResourceModel) { diff --git a/internal/provider/resource_aci_epg_useg_block_statement.go b/internal/provider/resource_aci_epg_useg_block_statement.go index 09b195059..c899255b5 100644 --- a/internal/provider/resource_aci_epg_useg_block_statement.go +++ b/internal/provider/resource_aci_epg_useg_block_statement.go @@ -585,7 +585,7 @@ func getAndSetFvCrtrnAttributes(ctx context.Context, diags *diag.Diagnostics, cl } func getFvCrtrnRn(ctx context.Context, data *FvCrtrnResourceModel) string { - return "crtrn" + return fmt.Sprintf("crtrn") } func setFvCrtrnParentDn(ctx context.Context, dn string, data *FvCrtrnResourceModel) { diff --git a/internal/provider/resource_aci_epg_useg_dns_attribute.go b/internal/provider/resource_aci_epg_useg_dns_attribute.go index 4d6fabb58..14cbdab18 100644 --- a/internal/provider/resource_aci_epg_useg_dns_attribute.go +++ b/internal/provider/resource_aci_epg_useg_dns_attribute.go @@ -8,8 +8,6 @@ import ( "context" "encoding/json" "fmt" - "reflect" - "strings" "github.com/ciscoecosystem/aci-go-client/v2/client" "github.com/ciscoecosystem/aci-go-client/v2/container" @@ -555,13 +553,7 @@ func getAndSetFvDnsAttrAttributes(ctx context.Context, diags *diag.Diagnostics, } func getFvDnsAttrRn(ctx context.Context, data *FvDnsAttrResourceModel) string { - rn := "dnsattr-{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) - } - return rn + return fmt.Sprintf("dnsattr-%s", data.Name.ValueString()) } func setFvDnsAttrParentDn(ctx context.Context, dn string, data *FvDnsAttrResourceModel) { diff --git a/internal/provider/resource_aci_epg_useg_ip_attribute.go b/internal/provider/resource_aci_epg_useg_ip_attribute.go index 0788be715..fdc04df85 100644 --- a/internal/provider/resource_aci_epg_useg_ip_attribute.go +++ b/internal/provider/resource_aci_epg_useg_ip_attribute.go @@ -8,8 +8,6 @@ import ( "context" "encoding/json" "fmt" - "reflect" - "strings" "github.com/ciscoecosystem/aci-go-client/v2/client" "github.com/ciscoecosystem/aci-go-client/v2/container" @@ -573,13 +571,7 @@ func getAndSetFvIpAttrAttributes(ctx context.Context, diags *diag.Diagnostics, c } func getFvIpAttrRn(ctx context.Context, data *FvIpAttrResourceModel) string { - rn := "ipattr-{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) - } - return rn + return fmt.Sprintf("ipattr-%s", data.Name.ValueString()) } func setFvIpAttrParentDn(ctx context.Context, dn string, data *FvIpAttrResourceModel) { diff --git a/internal/provider/resource_aci_epg_useg_mac_attribute.go b/internal/provider/resource_aci_epg_useg_mac_attribute.go index 0a6fc9049..e632a5b9d 100644 --- a/internal/provider/resource_aci_epg_useg_mac_attribute.go +++ b/internal/provider/resource_aci_epg_useg_mac_attribute.go @@ -8,8 +8,6 @@ import ( "context" "encoding/json" "fmt" - "reflect" - "strings" "github.com/ciscoecosystem/aci-go-client/v2/client" "github.com/ciscoecosystem/aci-go-client/v2/container" @@ -554,13 +552,7 @@ func getAndSetFvMacAttrAttributes(ctx context.Context, diags *diag.Diagnostics, } func getFvMacAttrRn(ctx context.Context, data *FvMacAttrResourceModel) string { - rn := "macattr-{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) - } - return rn + return fmt.Sprintf("macattr-%s", data.Name.ValueString()) } func setFvMacAttrParentDn(ctx context.Context, dn string, data *FvMacAttrResourceModel) { diff --git a/internal/provider/resource_aci_epg_useg_sub_block_statement.go b/internal/provider/resource_aci_epg_useg_sub_block_statement.go index f00c05b54..0575c3061 100644 --- a/internal/provider/resource_aci_epg_useg_sub_block_statement.go +++ b/internal/provider/resource_aci_epg_useg_sub_block_statement.go @@ -8,8 +8,6 @@ import ( "context" "encoding/json" "fmt" - "reflect" - "strings" "github.com/ciscoecosystem/aci-go-client/v2/client" "github.com/ciscoecosystem/aci-go-client/v2/container" @@ -560,13 +558,7 @@ func getAndSetFvSCrtrnAttributes(ctx context.Context, diags *diag.Diagnostics, c } func getFvSCrtrnRn(ctx context.Context, data *FvSCrtrnResourceModel) string { - rn := "crtrn-{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) - } - return rn + return fmt.Sprintf("crtrn-%s", data.Name.ValueString()) } func setFvSCrtrnParentDn(ctx context.Context, dn string, data *FvSCrtrnResourceModel) { diff --git a/internal/provider/resource_aci_epg_useg_vm_attribute.go b/internal/provider/resource_aci_epg_useg_vm_attribute.go index 91a49c21a..0ce239f36 100644 --- a/internal/provider/resource_aci_epg_useg_vm_attribute.go +++ b/internal/provider/resource_aci_epg_useg_vm_attribute.go @@ -8,8 +8,6 @@ import ( "context" "encoding/json" "fmt" - "reflect" - "strings" "github.com/ciscoecosystem/aci-go-client/v2/client" "github.com/ciscoecosystem/aci-go-client/v2/container" @@ -618,13 +616,7 @@ func getAndSetFvVmAttrAttributes(ctx context.Context, diags *diag.Diagnostics, c } func getFvVmAttrRn(ctx context.Context, data *FvVmAttrResourceModel) string { - rn := "vmattr-{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) - } - return rn + return fmt.Sprintf("vmattr-%s", data.Name.ValueString()) } func setFvVmAttrParentDn(ctx context.Context, dn string, data *FvVmAttrResourceModel) { diff --git a/internal/provider/resource_aci_external_management_network_instance_profile.go b/internal/provider/resource_aci_external_management_network_instance_profile.go index beb1e1847..5752b3d9d 100644 --- a/internal/provider/resource_aci_external_management_network_instance_profile.go +++ b/internal/provider/resource_aci_external_management_network_instance_profile.go @@ -8,7 +8,6 @@ import ( "context" "encoding/json" "fmt" - "reflect" "strings" customTypes "github.com/CiscoDevNet/terraform-provider-aci/v2/internal/custom_types" @@ -616,13 +615,7 @@ func getAndSetMgmtInstPAttributes(ctx context.Context, diags *diag.Diagnostics, } func getMgmtInstPRn(ctx context.Context, data *MgmtInstPResourceModel) string { - rn := "tn-mgmt/extmgmt-default/instp-{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) - } - return rn + return fmt.Sprintf("tn-mgmt/extmgmt-default/instp-%s", data.Name.ValueString()) } func setMgmtInstPId(ctx context.Context, data *MgmtInstPResourceModel) { diff --git a/internal/provider/resource_aci_external_management_network_subnet.go b/internal/provider/resource_aci_external_management_network_subnet.go index d1a2bdd9f..c5e840833 100644 --- a/internal/provider/resource_aci_external_management_network_subnet.go +++ b/internal/provider/resource_aci_external_management_network_subnet.go @@ -8,8 +8,6 @@ import ( "context" "encoding/json" "fmt" - "reflect" - "strings" "github.com/ciscoecosystem/aci-go-client/v2/client" "github.com/ciscoecosystem/aci-go-client/v2/container" @@ -527,13 +525,7 @@ func getAndSetMgmtSubnetAttributes(ctx context.Context, diags *diag.Diagnostics, } func getMgmtSubnetRn(ctx context.Context, data *MgmtSubnetResourceModel) string { - rn := "subnet-[{ip}]" - for _, identifier := range []string{"ip"} { - 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) - } - return rn + return fmt.Sprintf("subnet-[%s]", data.Ip.ValueString()) } func setMgmtSubnetParentDn(ctx context.Context, dn string, data *MgmtSubnetResourceModel) { diff --git a/internal/provider/resource_aci_first_hop_security_policy.go b/internal/provider/resource_aci_first_hop_security_policy.go index 25633fa95..f009c3c4d 100644 --- a/internal/provider/resource_aci_first_hop_security_policy.go +++ b/internal/provider/resource_aci_first_hop_security_policy.go @@ -8,8 +8,6 @@ import ( "context" "encoding/json" "fmt" - "reflect" - "strings" "github.com/ciscoecosystem/aci-go-client/v2/client" "github.com/ciscoecosystem/aci-go-client/v2/container" @@ -857,13 +855,7 @@ func getAndSetFhsBDPolAttributes(ctx context.Context, diags *diag.Diagnostics, c } func getFhsBDPolRn(ctx context.Context, data *FhsBDPolResourceModel) string { - rn := "bdpol-{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) - } - return rn + return fmt.Sprintf("bdpol-%s", data.Name.ValueString()) } func setFhsBDPolParentDn(ctx context.Context, dn string, data *FhsBDPolResourceModel) { diff --git a/internal/provider/resource_aci_igmp_snooping_policy.go b/internal/provider/resource_aci_igmp_snooping_policy.go index eec5f715e..72ece44d7 100644 --- a/internal/provider/resource_aci_igmp_snooping_policy.go +++ b/internal/provider/resource_aci_igmp_snooping_policy.go @@ -8,7 +8,6 @@ import ( "context" "encoding/json" "fmt" - "reflect" "strings" "github.com/ciscoecosystem/aci-go-client/v2/client" @@ -674,13 +673,7 @@ func getAndSetIgmpSnoopPolAttributes(ctx context.Context, diags *diag.Diagnostic } func getIgmpSnoopPolRn(ctx context.Context, data *IgmpSnoopPolResourceModel) string { - rn := "snPol-{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) - } - return rn + return fmt.Sprintf("snPol-%s", data.Name.ValueString()) } func setIgmpSnoopPolParentDn(ctx context.Context, dn string, data *IgmpSnoopPolResourceModel) { diff --git a/internal/provider/resource_aci_key_ring.go b/internal/provider/resource_aci_key_ring.go index b68911190..e74fc7aa0 100644 --- a/internal/provider/resource_aci_key_ring.go +++ b/internal/provider/resource_aci_key_ring.go @@ -8,7 +8,6 @@ import ( "context" "encoding/json" "fmt" - "reflect" "strings" "github.com/ciscoecosystem/aci-go-client/v2/client" @@ -696,13 +695,7 @@ func getAndSetPkiKeyRingAttributes(ctx context.Context, diags *diag.Diagnostics, } func getPkiKeyRingRn(ctx context.Context, data *PkiKeyRingResourceModel) string { - rn := "keyring-{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) - } - return rn + return fmt.Sprintf("keyring-%s", data.Name.ValueString()) } func setPkiKeyRingParentDn(ctx context.Context, dn string, data *PkiKeyRingResourceModel) { diff --git a/internal/provider/resource_aci_l3out_consumer_label.go b/internal/provider/resource_aci_l3out_consumer_label.go index 91171f5d7..7d102c121 100644 --- a/internal/provider/resource_aci_l3out_consumer_label.go +++ b/internal/provider/resource_aci_l3out_consumer_label.go @@ -8,8 +8,6 @@ import ( "context" "encoding/json" "fmt" - "reflect" - "strings" "github.com/ciscoecosystem/aci-go-client/v2/client" "github.com/ciscoecosystem/aci-go-client/v2/container" @@ -730,13 +728,7 @@ func getAndSetL3extConsLblAttributes(ctx context.Context, diags *diag.Diagnostic } func getL3extConsLblRn(ctx context.Context, data *L3extConsLblResourceModel) string { - rn := "conslbl-{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) - } - return rn + return fmt.Sprintf("conslbl-%s", data.Name.ValueString()) } func setL3extConsLblParentDn(ctx context.Context, dn string, data *L3extConsLblResourceModel) { diff --git a/internal/provider/resource_aci_l3out_node_sid_profile.go b/internal/provider/resource_aci_l3out_node_sid_profile.go index 627cb19c1..b8feddaf7 100644 --- a/internal/provider/resource_aci_l3out_node_sid_profile.go +++ b/internal/provider/resource_aci_l3out_node_sid_profile.go @@ -8,8 +8,6 @@ import ( "context" "encoding/json" "fmt" - "reflect" - "strings" "github.com/ciscoecosystem/aci-go-client/v2/client" "github.com/ciscoecosystem/aci-go-client/v2/container" @@ -541,13 +539,7 @@ func getAndSetMplsNodeSidPAttributes(ctx context.Context, diags *diag.Diagnostic } func getMplsNodeSidPRn(ctx context.Context, data *MplsNodeSidPResourceModel) string { - rn := "nodesidp-{sidoffset}" - for _, identifier := range []string{"sidoffset"} { - 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) - } - return rn + return fmt.Sprintf("nodesidp-%s", data.Sidoffset.ValueString()) } func setMplsNodeSidPParentDn(ctx context.Context, dn string, data *MplsNodeSidPResourceModel) { diff --git a/internal/provider/resource_aci_l3out_provider_label.go b/internal/provider/resource_aci_l3out_provider_label.go index c3054d5c1..778800888 100644 --- a/internal/provider/resource_aci_l3out_provider_label.go +++ b/internal/provider/resource_aci_l3out_provider_label.go @@ -8,8 +8,6 @@ import ( "context" "encoding/json" "fmt" - "reflect" - "strings" "github.com/ciscoecosystem/aci-go-client/v2/client" "github.com/ciscoecosystem/aci-go-client/v2/container" @@ -560,13 +558,7 @@ func getAndSetL3extProvLblAttributes(ctx context.Context, diags *diag.Diagnostic } func getL3extProvLblRn(ctx context.Context, data *L3extProvLblResourceModel) string { - rn := "provlbl-{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) - } - return rn + return fmt.Sprintf("provlbl-%s", data.Name.ValueString()) } func setL3extProvLblParentDn(ctx context.Context, dn string, data *L3extProvLblResourceModel) { diff --git a/internal/provider/resource_aci_l3out_redistribute_policy.go b/internal/provider/resource_aci_l3out_redistribute_policy.go index a5ed0de64..3aecfa4ad 100644 --- a/internal/provider/resource_aci_l3out_redistribute_policy.go +++ b/internal/provider/resource_aci_l3out_redistribute_policy.go @@ -8,8 +8,6 @@ import ( "context" "encoding/json" "fmt" - "reflect" - "strings" "github.com/ciscoecosystem/aci-go-client/v2/client" "github.com/ciscoecosystem/aci-go-client/v2/container" @@ -505,13 +503,7 @@ func getAndSetL3extRsRedistributePolAttributes(ctx context.Context, diags *diag. } func getL3extRsRedistributePolRn(ctx context.Context, data *L3extRsRedistributePolResourceModel) string { - rn := "rsredistributePol-[{tnRtctrlProfileName}]-{src}" - for _, identifier := range []string{"tnRtctrlProfileName", "src"} { - 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) - } - return rn + return fmt.Sprintf("rsredistributePol-[%s]-%s", data.TnRtctrlProfileName.ValueString(), data.Src.ValueString()) } func setL3extRsRedistributePolParentDn(ctx context.Context, dn string, data *L3extRsRedistributePolResourceModel) { diff --git a/internal/provider/resource_aci_mld_snooping_policy.go b/internal/provider/resource_aci_mld_snooping_policy.go index d8c93fb5b..eaacc7b32 100644 --- a/internal/provider/resource_aci_mld_snooping_policy.go +++ b/internal/provider/resource_aci_mld_snooping_policy.go @@ -8,7 +8,6 @@ import ( "context" "encoding/json" "fmt" - "reflect" "strings" "github.com/ciscoecosystem/aci-go-client/v2/client" @@ -674,13 +673,7 @@ func getAndSetMldSnoopPolAttributes(ctx context.Context, diags *diag.Diagnostics } func getMldSnoopPolRn(ctx context.Context, data *MldSnoopPolResourceModel) string { - rn := "mldsnoopPol-{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) - } - return rn + return fmt.Sprintf("mldsnoopPol-%s", data.Name.ValueString()) } func setMldSnoopPolParentDn(ctx context.Context, dn string, data *MldSnoopPolResourceModel) { diff --git a/internal/provider/resource_aci_neighbor_discovery_interface_policy.go b/internal/provider/resource_aci_neighbor_discovery_interface_policy.go index 1c27c888e..05da6a2dc 100644 --- a/internal/provider/resource_aci_neighbor_discovery_interface_policy.go +++ b/internal/provider/resource_aci_neighbor_discovery_interface_policy.go @@ -8,7 +8,6 @@ import ( "context" "encoding/json" "fmt" - "reflect" "strings" "github.com/ciscoecosystem/aci-go-client/v2/client" @@ -724,13 +723,7 @@ func getAndSetNdIfPolAttributes(ctx context.Context, diags *diag.Diagnostics, cl } func getNdIfPolRn(ctx context.Context, data *NdIfPolResourceModel) string { - rn := "ndifpol-{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) - } - return rn + return fmt.Sprintf("ndifpol-%s", data.Name.ValueString()) } func setNdIfPolParentDn(ctx context.Context, dn string, data *NdIfPolResourceModel) { diff --git a/internal/provider/resource_aci_netflow_exporter_policy.go b/internal/provider/resource_aci_netflow_exporter_policy.go index 907050f5d..638baa94a 100644 --- a/internal/provider/resource_aci_netflow_exporter_policy.go +++ b/internal/provider/resource_aci_netflow_exporter_policy.go @@ -8,8 +8,6 @@ import ( "context" "encoding/json" "fmt" - "reflect" - "strings" customTypes "github.com/CiscoDevNet/terraform-provider-aci/v2/internal/custom_types" "github.com/CiscoDevNet/terraform-provider-aci/v2/internal/validators" @@ -813,13 +811,7 @@ func getAndSetNetflowExporterPolAttributes(ctx context.Context, diags *diag.Diag } func getNetflowExporterPolRn(ctx context.Context, data *NetflowExporterPolResourceModel) string { - rn := "exporterpol-{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) - } - return rn + return fmt.Sprintf("exporterpol-%s", data.Name.ValueString()) } func setNetflowExporterPolParentDn(ctx context.Context, dn string, data *NetflowExporterPolResourceModel) { diff --git a/internal/provider/resource_aci_netflow_monitor_policy.go b/internal/provider/resource_aci_netflow_monitor_policy.go index 01e19105a..662dafedc 100644 --- a/internal/provider/resource_aci_netflow_monitor_policy.go +++ b/internal/provider/resource_aci_netflow_monitor_policy.go @@ -8,8 +8,6 @@ import ( "context" "encoding/json" "fmt" - "reflect" - "strings" "github.com/ciscoecosystem/aci-go-client/v2/client" "github.com/ciscoecosystem/aci-go-client/v2/container" @@ -878,13 +876,7 @@ func getAndSetNetflowMonitorPolAttributes(ctx context.Context, diags *diag.Diagn } func getNetflowMonitorPolRn(ctx context.Context, data *NetflowMonitorPolResourceModel) string { - rn := "monitorpol-{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) - } - return rn + return fmt.Sprintf("monitorpol-%s", data.Name.ValueString()) } func setNetflowMonitorPolParentDn(ctx context.Context, dn string, data *NetflowMonitorPolResourceModel) { diff --git a/internal/provider/resource_aci_netflow_record_policy.go b/internal/provider/resource_aci_netflow_record_policy.go index 7db636671..f143181e9 100644 --- a/internal/provider/resource_aci_netflow_record_policy.go +++ b/internal/provider/resource_aci_netflow_record_policy.go @@ -8,7 +8,6 @@ import ( "context" "encoding/json" "fmt" - "reflect" "strings" "github.com/ciscoecosystem/aci-go-client/v2/client" @@ -598,13 +597,7 @@ func getAndSetNetflowRecordPolAttributes(ctx context.Context, diags *diag.Diagno } func getNetflowRecordPolRn(ctx context.Context, data *NetflowRecordPolResourceModel) string { - rn := "recordpol-{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) - } - return rn + return fmt.Sprintf("recordpol-%s", data.Name.ValueString()) } func setNetflowRecordPolParentDn(ctx context.Context, dn string, data *NetflowRecordPolResourceModel) { diff --git a/internal/provider/resource_aci_out_of_band_contract.go b/internal/provider/resource_aci_out_of_band_contract.go index 899354a06..2a1f16908 100644 --- a/internal/provider/resource_aci_out_of_band_contract.go +++ b/internal/provider/resource_aci_out_of_band_contract.go @@ -8,7 +8,6 @@ import ( "context" "encoding/json" "fmt" - "reflect" "strings" customTypes "github.com/CiscoDevNet/terraform-provider-aci/v2/internal/custom_types" @@ -610,13 +609,7 @@ func getAndSetVzOOBBrCPAttributes(ctx context.Context, diags *diag.Diagnostics, } func getVzOOBBrCPRn(ctx context.Context, data *VzOOBBrCPResourceModel) string { - rn := "tn-mgmt/oobbrc-{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) - } - return rn + return fmt.Sprintf("tn-mgmt/oobbrc-%s", data.Name.ValueString()) } func setVzOOBBrCPId(ctx context.Context, data *VzOOBBrCPResourceModel) { diff --git a/internal/provider/resource_aci_pim_route_map_entry.go b/internal/provider/resource_aci_pim_route_map_entry.go index fb6a96e87..48ea41393 100644 --- a/internal/provider/resource_aci_pim_route_map_entry.go +++ b/internal/provider/resource_aci_pim_route_map_entry.go @@ -8,8 +8,6 @@ import ( "context" "encoding/json" "fmt" - "reflect" - "strings" "github.com/ciscoecosystem/aci-go-client/v2/client" "github.com/ciscoecosystem/aci-go-client/v2/container" @@ -588,13 +586,7 @@ func getAndSetPimRouteMapEntryAttributes(ctx context.Context, diags *diag.Diagno } func getPimRouteMapEntryRn(ctx context.Context, data *PimRouteMapEntryResourceModel) string { - rn := "rtmapentry-{order}" - for _, identifier := range []string{"order"} { - 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) - } - return rn + return fmt.Sprintf("rtmapentry-%s", data.Order.ValueString()) } func setPimRouteMapEntryParentDn(ctx context.Context, dn string, data *PimRouteMapEntryResourceModel) { diff --git a/internal/provider/resource_aci_pim_route_map_policy.go b/internal/provider/resource_aci_pim_route_map_policy.go index 090efc0c6..db6a54797 100644 --- a/internal/provider/resource_aci_pim_route_map_policy.go +++ b/internal/provider/resource_aci_pim_route_map_policy.go @@ -8,8 +8,6 @@ import ( "context" "encoding/json" "fmt" - "reflect" - "strings" "github.com/ciscoecosystem/aci-go-client/v2/client" "github.com/ciscoecosystem/aci-go-client/v2/container" @@ -541,13 +539,7 @@ func getAndSetPimRouteMapPolAttributes(ctx context.Context, diags *diag.Diagnost } func getPimRouteMapPolRn(ctx context.Context, data *PimRouteMapPolResourceModel) string { - rn := "rtmap-{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) - } - return rn + return fmt.Sprintf("rtmap-%s", data.Name.ValueString()) } func setPimRouteMapPolParentDn(ctx context.Context, dn string, data *PimRouteMapPolResourceModel) { diff --git a/internal/provider/resource_aci_relation_from_bridge_domain_to_l3_outside.go b/internal/provider/resource_aci_relation_from_bridge_domain_to_l3_outside.go index c7e6bb8cb..9f667fea3 100644 --- a/internal/provider/resource_aci_relation_from_bridge_domain_to_l3_outside.go +++ b/internal/provider/resource_aci_relation_from_bridge_domain_to_l3_outside.go @@ -8,8 +8,6 @@ import ( "context" "encoding/json" "fmt" - "reflect" - "strings" "github.com/ciscoecosystem/aci-go-client/v2/client" "github.com/ciscoecosystem/aci-go-client/v2/container" @@ -485,13 +483,7 @@ func getAndSetFvRsBDToOutAttributes(ctx context.Context, diags *diag.Diagnostics } func getFvRsBDToOutRn(ctx context.Context, data *FvRsBDToOutResourceModel) string { - rn := "rsBDToOut-{tnL3extOutName}" - for _, identifier := range []string{"tnL3extOutName"} { - 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) - } - return rn + return fmt.Sprintf("rsBDToOut-%s", data.TnL3extOutName.ValueString()) } func setFvRsBDToOutParentDn(ctx context.Context, dn string, data *FvRsBDToOutResourceModel) { diff --git a/internal/provider/resource_aci_relation_from_bridge_domain_to_netflow_monitor_policy.go b/internal/provider/resource_aci_relation_from_bridge_domain_to_netflow_monitor_policy.go index 725b8d7fb..156d67840 100644 --- a/internal/provider/resource_aci_relation_from_bridge_domain_to_netflow_monitor_policy.go +++ b/internal/provider/resource_aci_relation_from_bridge_domain_to_netflow_monitor_policy.go @@ -8,8 +8,6 @@ import ( "context" "encoding/json" "fmt" - "reflect" - "strings" "github.com/ciscoecosystem/aci-go-client/v2/client" "github.com/ciscoecosystem/aci-go-client/v2/container" @@ -505,13 +503,7 @@ func getAndSetFvRsBDToNetflowMonitorPolAttributes(ctx context.Context, diags *di } func getFvRsBDToNetflowMonitorPolRn(ctx context.Context, data *FvRsBDToNetflowMonitorPolResourceModel) string { - rn := "rsBDToNetflowMonitorPol-[{tnNetflowMonitorPolName}]-{fltType}" - for _, identifier := range []string{"tnNetflowMonitorPolName", "fltType"} { - 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) - } - return rn + return fmt.Sprintf("rsBDToNetflowMonitorPol-[%s]-%s", data.TnNetflowMonitorPolName.ValueString(), data.FltType.ValueString()) } func setFvRsBDToNetflowMonitorPolParentDn(ctx context.Context, dn string, data *FvRsBDToNetflowMonitorPolResourceModel) { diff --git a/internal/provider/resource_aci_relation_from_l3out_consumer_label_to_external_epg.go b/internal/provider/resource_aci_relation_from_l3out_consumer_label_to_external_epg.go index 03768ae92..3b4597785 100644 --- a/internal/provider/resource_aci_relation_from_l3out_consumer_label_to_external_epg.go +++ b/internal/provider/resource_aci_relation_from_l3out_consumer_label_to_external_epg.go @@ -8,8 +8,6 @@ import ( "context" "encoding/json" "fmt" - "reflect" - "strings" "github.com/ciscoecosystem/aci-go-client/v2/client" "github.com/ciscoecosystem/aci-go-client/v2/container" @@ -485,13 +483,7 @@ func getAndSetL3extRsLblToInstPAttributes(ctx context.Context, diags *diag.Diagn } func getL3extRsLblToInstPRn(ctx context.Context, data *L3extRsLblToInstPResourceModel) string { - rn := "rslblToInstP-[{tDn}]" - for _, identifier := range []string{"tDn"} { - 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) - } - return rn + return fmt.Sprintf("rslblToInstP-[%s]", data.TDn.ValueString()) } func setL3extRsLblToInstPParentDn(ctx context.Context, dn string, data *L3extRsLblToInstPResourceModel) { diff --git a/internal/provider/resource_aci_relation_from_l3out_consumer_label_to_route_control_profile.go b/internal/provider/resource_aci_relation_from_l3out_consumer_label_to_route_control_profile.go index 2ffc2687a..d4b3c6d5e 100644 --- a/internal/provider/resource_aci_relation_from_l3out_consumer_label_to_route_control_profile.go +++ b/internal/provider/resource_aci_relation_from_l3out_consumer_label_to_route_control_profile.go @@ -8,8 +8,6 @@ import ( "context" "encoding/json" "fmt" - "reflect" - "strings" "github.com/ciscoecosystem/aci-go-client/v2/client" "github.com/ciscoecosystem/aci-go-client/v2/container" @@ -505,13 +503,7 @@ func getAndSetL3extRsLblToProfileAttributes(ctx context.Context, diags *diag.Dia } func getL3extRsLblToProfileRn(ctx context.Context, data *L3extRsLblToProfileResourceModel) string { - rn := "rslblToProfile-[{tDn}]-{direction}" - for _, identifier := range []string{"tDn", "direction"} { - 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) - } - return rn + return fmt.Sprintf("rslblToProfile-[%s]-%s", data.TDn.ValueString(), data.Direction.ValueString()) } func setL3extRsLblToProfileParentDn(ctx context.Context, dn string, data *L3extRsLblToProfileResourceModel) { diff --git a/internal/provider/resource_aci_relation_to_consumed_contract.go b/internal/provider/resource_aci_relation_to_consumed_contract.go index 891e075bc..2ccd23070 100644 --- a/internal/provider/resource_aci_relation_to_consumed_contract.go +++ b/internal/provider/resource_aci_relation_to_consumed_contract.go @@ -8,8 +8,6 @@ import ( "context" "encoding/json" "fmt" - "reflect" - "strings" customTypes "github.com/CiscoDevNet/terraform-provider-aci/v2/internal/custom_types" "github.com/CiscoDevNet/terraform-provider-aci/v2/internal/validators" @@ -510,13 +508,7 @@ func getAndSetFvRsConsAttributes(ctx context.Context, diags *diag.Diagnostics, c } func getFvRsConsRn(ctx context.Context, data *FvRsConsResourceModel) string { - rn := "rscons-{tnVzBrCPName}" - for _, identifier := range []string{"tnVzBrCPName"} { - 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) - } - return rn + return fmt.Sprintf("rscons-%s", data.TnVzBrCPName.ValueString()) } func setFvRsConsParentDn(ctx context.Context, dn string, data *FvRsConsResourceModel) { diff --git a/internal/provider/resource_aci_relation_to_consumed_out_of_band_contract.go b/internal/provider/resource_aci_relation_to_consumed_out_of_band_contract.go index 63abf329b..56524d264 100644 --- a/internal/provider/resource_aci_relation_to_consumed_out_of_band_contract.go +++ b/internal/provider/resource_aci_relation_to_consumed_out_of_band_contract.go @@ -8,8 +8,6 @@ import ( "context" "encoding/json" "fmt" - "reflect" - "strings" customTypes "github.com/CiscoDevNet/terraform-provider-aci/v2/internal/custom_types" "github.com/CiscoDevNet/terraform-provider-aci/v2/internal/validators" @@ -510,13 +508,7 @@ func getAndSetMgmtRsOoBConsAttributes(ctx context.Context, diags *diag.Diagnosti } func getMgmtRsOoBConsRn(ctx context.Context, data *MgmtRsOoBConsResourceModel) string { - rn := "rsooBCons-{tnVzOOBBrCPName}" - for _, identifier := range []string{"tnVzOOBBrCPName"} { - 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) - } - return rn + return fmt.Sprintf("rsooBCons-%s", data.TnVzOOBBrCPName.ValueString()) } func setMgmtRsOoBConsParentDn(ctx context.Context, dn string, data *MgmtRsOoBConsResourceModel) { diff --git a/internal/provider/resource_aci_relation_to_contract_master.go b/internal/provider/resource_aci_relation_to_contract_master.go index d8f536bfc..3365e3c29 100644 --- a/internal/provider/resource_aci_relation_to_contract_master.go +++ b/internal/provider/resource_aci_relation_to_contract_master.go @@ -8,8 +8,6 @@ import ( "context" "encoding/json" "fmt" - "reflect" - "strings" "github.com/ciscoecosystem/aci-go-client/v2/client" "github.com/ciscoecosystem/aci-go-client/v2/container" @@ -485,13 +483,7 @@ func getAndSetFvRsSecInheritedAttributes(ctx context.Context, diags *diag.Diagno } func getFvRsSecInheritedRn(ctx context.Context, data *FvRsSecInheritedResourceModel) string { - rn := "rssecInherited-[{tDn}]" - for _, identifier := range []string{"tDn"} { - 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) - } - return rn + return fmt.Sprintf("rssecInherited-[%s]", data.TDn.ValueString()) } func setFvRsSecInheritedParentDn(ctx context.Context, dn string, data *FvRsSecInheritedResourceModel) { diff --git a/internal/provider/resource_aci_relation_to_domain.go b/internal/provider/resource_aci_relation_to_domain.go index b9bd04bca..0109a259b 100644 --- a/internal/provider/resource_aci_relation_to_domain.go +++ b/internal/provider/resource_aci_relation_to_domain.go @@ -8,8 +8,6 @@ import ( "context" "encoding/json" "fmt" - "reflect" - "strings" "github.com/ciscoecosystem/aci-go-client/v2/client" "github.com/ciscoecosystem/aci-go-client/v2/container" @@ -853,13 +851,7 @@ func getAndSetFvRsDomAttAttributes(ctx context.Context, diags *diag.Diagnostics, } func getFvRsDomAttRn(ctx context.Context, data *FvRsDomAttResourceModel) string { - rn := "rsdomAtt-[{tDn}]" - for _, identifier := range []string{"tDn"} { - 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) - } - return rn + return fmt.Sprintf("rsdomAtt-[%s]", data.TDn.ValueString()) } func setFvRsDomAttParentDn(ctx context.Context, dn string, data *FvRsDomAttResourceModel) { diff --git a/internal/provider/resource_aci_relation_to_fibre_channel_path.go b/internal/provider/resource_aci_relation_to_fibre_channel_path.go index 4174c272f..fc9e98fd7 100644 --- a/internal/provider/resource_aci_relation_to_fibre_channel_path.go +++ b/internal/provider/resource_aci_relation_to_fibre_channel_path.go @@ -8,8 +8,6 @@ import ( "context" "encoding/json" "fmt" - "reflect" - "strings" "github.com/ciscoecosystem/aci-go-client/v2/client" "github.com/ciscoecosystem/aci-go-client/v2/container" @@ -532,13 +530,7 @@ func getAndSetFvRsFcPathAttAttributes(ctx context.Context, diags *diag.Diagnosti } func getFvRsFcPathAttRn(ctx context.Context, data *FvRsFcPathAttResourceModel) string { - rn := "rsfcPathAtt-[{tDn}]" - for _, identifier := range []string{"tDn"} { - 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) - } - return rn + return fmt.Sprintf("rsfcPathAtt-[%s]", data.TDn.ValueString()) } func setFvRsFcPathAttParentDn(ctx context.Context, dn string, data *FvRsFcPathAttResourceModel) { diff --git a/internal/provider/resource_aci_relation_to_imported_contract.go b/internal/provider/resource_aci_relation_to_imported_contract.go index 2319996b2..a4850f2d1 100644 --- a/internal/provider/resource_aci_relation_to_imported_contract.go +++ b/internal/provider/resource_aci_relation_to_imported_contract.go @@ -8,8 +8,6 @@ import ( "context" "encoding/json" "fmt" - "reflect" - "strings" customTypes "github.com/CiscoDevNet/terraform-provider-aci/v2/internal/custom_types" "github.com/CiscoDevNet/terraform-provider-aci/v2/internal/validators" @@ -510,13 +508,7 @@ func getAndSetFvRsConsIfAttributes(ctx context.Context, diags *diag.Diagnostics, } func getFvRsConsIfRn(ctx context.Context, data *FvRsConsIfResourceModel) string { - rn := "rsconsIf-{tnVzCPIfName}" - for _, identifier := range []string{"tnVzCPIfName"} { - 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) - } - return rn + return fmt.Sprintf("rsconsIf-%s", data.TnVzCPIfName.ValueString()) } func setFvRsConsIfParentDn(ctx context.Context, dn string, data *FvRsConsIfResourceModel) { diff --git a/internal/provider/resource_aci_relation_to_intra_epg_contract.go b/internal/provider/resource_aci_relation_to_intra_epg_contract.go index 97d8c6ca2..5981deacb 100644 --- a/internal/provider/resource_aci_relation_to_intra_epg_contract.go +++ b/internal/provider/resource_aci_relation_to_intra_epg_contract.go @@ -8,8 +8,6 @@ import ( "context" "encoding/json" "fmt" - "reflect" - "strings" "github.com/ciscoecosystem/aci-go-client/v2/client" "github.com/ciscoecosystem/aci-go-client/v2/container" @@ -485,13 +483,7 @@ func getAndSetFvRsIntraEpgAttributes(ctx context.Context, diags *diag.Diagnostic } func getFvRsIntraEpgRn(ctx context.Context, data *FvRsIntraEpgResourceModel) string { - rn := "rsintraEpg-{tnVzBrCPName}" - for _, identifier := range []string{"tnVzBrCPName"} { - 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) - } - return rn + return fmt.Sprintf("rsintraEpg-%s", data.TnVzBrCPName.ValueString()) } func setFvRsIntraEpgParentDn(ctx context.Context, dn string, data *FvRsIntraEpgResourceModel) { diff --git a/internal/provider/resource_aci_relation_to_netflow_exporter.go b/internal/provider/resource_aci_relation_to_netflow_exporter.go index 8f48ebf8b..6637d4b53 100644 --- a/internal/provider/resource_aci_relation_to_netflow_exporter.go +++ b/internal/provider/resource_aci_relation_to_netflow_exporter.go @@ -8,8 +8,6 @@ import ( "context" "encoding/json" "fmt" - "reflect" - "strings" "github.com/ciscoecosystem/aci-go-client/v2/client" "github.com/ciscoecosystem/aci-go-client/v2/container" @@ -485,13 +483,7 @@ func getAndSetNetflowRsMonitorToExporterAttributes(ctx context.Context, diags *d } func getNetflowRsMonitorToExporterRn(ctx context.Context, data *NetflowRsMonitorToExporterResourceModel) string { - rn := "rsmonitorToExporter-{tnNetflowExporterPolName}" - for _, identifier := range []string{"tnNetflowExporterPolName"} { - 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) - } - return rn + return fmt.Sprintf("rsmonitorToExporter-%s", data.TnNetflowExporterPolName.ValueString()) } func setNetflowRsMonitorToExporterParentDn(ctx context.Context, dn string, data *NetflowRsMonitorToExporterResourceModel) { diff --git a/internal/provider/resource_aci_relation_to_provided_contract.go b/internal/provider/resource_aci_relation_to_provided_contract.go index ed18c4656..6d78a606a 100644 --- a/internal/provider/resource_aci_relation_to_provided_contract.go +++ b/internal/provider/resource_aci_relation_to_provided_contract.go @@ -8,8 +8,6 @@ import ( "context" "encoding/json" "fmt" - "reflect" - "strings" customTypes "github.com/CiscoDevNet/terraform-provider-aci/v2/internal/custom_types" "github.com/CiscoDevNet/terraform-provider-aci/v2/internal/validators" @@ -527,13 +525,7 @@ func getAndSetFvRsProvAttributes(ctx context.Context, diags *diag.Diagnostics, c } func getFvRsProvRn(ctx context.Context, data *FvRsProvResourceModel) string { - rn := "rsprov-{tnVzBrCPName}" - for _, identifier := range []string{"tnVzBrCPName"} { - 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) - } - return rn + return fmt.Sprintf("rsprov-%s", data.TnVzBrCPName.ValueString()) } func setFvRsProvParentDn(ctx context.Context, dn string, data *FvRsProvResourceModel) { diff --git a/internal/provider/resource_aci_relation_to_static_leaf.go b/internal/provider/resource_aci_relation_to_static_leaf.go index 92e0f3248..e2b0fde5b 100644 --- a/internal/provider/resource_aci_relation_to_static_leaf.go +++ b/internal/provider/resource_aci_relation_to_static_leaf.go @@ -8,8 +8,6 @@ import ( "context" "encoding/json" "fmt" - "reflect" - "strings" "github.com/ciscoecosystem/aci-go-client/v2/client" "github.com/ciscoecosystem/aci-go-client/v2/container" @@ -548,13 +546,7 @@ func getAndSetFvRsNodeAttAttributes(ctx context.Context, diags *diag.Diagnostics } func getFvRsNodeAttRn(ctx context.Context, data *FvRsNodeAttResourceModel) string { - rn := "rsnodeAtt-[{tDn}]" - for _, identifier := range []string{"tDn"} { - 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) - } - return rn + return fmt.Sprintf("rsnodeAtt-[%s]", data.TDn.ValueString()) } func setFvRsNodeAttParentDn(ctx context.Context, dn string, data *FvRsNodeAttResourceModel) { diff --git a/internal/provider/resource_aci_relation_to_static_path.go b/internal/provider/resource_aci_relation_to_static_path.go index e2ab3a139..70a1d3b60 100644 --- a/internal/provider/resource_aci_relation_to_static_path.go +++ b/internal/provider/resource_aci_relation_to_static_path.go @@ -8,8 +8,6 @@ import ( "context" "encoding/json" "fmt" - "reflect" - "strings" "github.com/ciscoecosystem/aci-go-client/v2/client" "github.com/ciscoecosystem/aci-go-client/v2/container" @@ -562,13 +560,7 @@ func getAndSetFvRsPathAttAttributes(ctx context.Context, diags *diag.Diagnostics } func getFvRsPathAttRn(ctx context.Context, data *FvRsPathAttResourceModel) string { - rn := "rspathAtt-[{tDn}]" - for _, identifier := range []string{"tDn"} { - 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) - } - return rn + return fmt.Sprintf("rspathAtt-[%s]", data.TDn.ValueString()) } func setFvRsPathAttParentDn(ctx context.Context, dn string, data *FvRsPathAttResourceModel) { diff --git a/internal/provider/resource_aci_relation_to_taboo_contract.go b/internal/provider/resource_aci_relation_to_taboo_contract.go index b786c81f3..75d763d80 100644 --- a/internal/provider/resource_aci_relation_to_taboo_contract.go +++ b/internal/provider/resource_aci_relation_to_taboo_contract.go @@ -8,8 +8,6 @@ import ( "context" "encoding/json" "fmt" - "reflect" - "strings" "github.com/ciscoecosystem/aci-go-client/v2/client" "github.com/ciscoecosystem/aci-go-client/v2/container" @@ -485,13 +483,7 @@ func getAndSetFvRsProtByAttributes(ctx context.Context, diags *diag.Diagnostics, } func getFvRsProtByRn(ctx context.Context, data *FvRsProtByResourceModel) string { - rn := "rsprotBy-{tnVzTabooName}" - for _, identifier := range []string{"tnVzTabooName"} { - 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) - } - return rn + return fmt.Sprintf("rsprotBy-%s", data.TnVzTabooName.ValueString()) } func setFvRsProtByParentDn(ctx context.Context, dn string, data *FvRsProtByResourceModel) { diff --git a/internal/provider/resource_aci_relation_to_vrf_fallback_route_group.go b/internal/provider/resource_aci_relation_to_vrf_fallback_route_group.go index 6b14b3ebd..25f109d01 100644 --- a/internal/provider/resource_aci_relation_to_vrf_fallback_route_group.go +++ b/internal/provider/resource_aci_relation_to_vrf_fallback_route_group.go @@ -8,8 +8,6 @@ import ( "context" "encoding/json" "fmt" - "reflect" - "strings" "github.com/ciscoecosystem/aci-go-client/v2/client" "github.com/ciscoecosystem/aci-go-client/v2/container" @@ -485,13 +483,7 @@ func getAndSetL3extRsOutToFBRGroupAttributes(ctx context.Context, diags *diag.Di } func getL3extRsOutToFBRGroupRn(ctx context.Context, data *L3extRsOutToFBRGroupResourceModel) string { - rn := "rsoutToFBRGroup-[{tDn}]" - for _, identifier := range []string{"tDn"} { - 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) - } - return rn + return fmt.Sprintf("rsoutToFBRGroup-[%s]", data.TDn.ValueString()) } func setL3extRsOutToFBRGroupParentDn(ctx context.Context, dn string, data *L3extRsOutToFBRGroupResourceModel) { diff --git a/internal/provider/resource_aci_rogue_coop_exception.go b/internal/provider/resource_aci_rogue_coop_exception.go index 1b0268779..246c2af59 100644 --- a/internal/provider/resource_aci_rogue_coop_exception.go +++ b/internal/provider/resource_aci_rogue_coop_exception.go @@ -8,8 +8,6 @@ import ( "context" "encoding/json" "fmt" - "reflect" - "strings" "github.com/ciscoecosystem/aci-go-client/v2/client" "github.com/ciscoecosystem/aci-go-client/v2/container" @@ -527,13 +525,7 @@ func getAndSetFvRogueExceptionMacAttributes(ctx context.Context, diags *diag.Dia } func getFvRogueExceptionMacRn(ctx context.Context, data *FvRogueExceptionMacResourceModel) string { - rn := "rgexpmac-{mac}" - for _, identifier := range []string{"mac"} { - 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) - } - return rn + return fmt.Sprintf("rgexpmac-%s", data.Mac.ValueString()) } func setFvRogueExceptionMacParentDn(ctx context.Context, dn string, data *FvRogueExceptionMacResourceModel) { diff --git a/internal/provider/resource_aci_route_control_profile.go b/internal/provider/resource_aci_route_control_profile.go index e34abb2dc..3210ef650 100644 --- a/internal/provider/resource_aci_route_control_profile.go +++ b/internal/provider/resource_aci_route_control_profile.go @@ -8,8 +8,6 @@ import ( "context" "encoding/json" "fmt" - "reflect" - "strings" "github.com/ciscoecosystem/aci-go-client/v2/client" "github.com/ciscoecosystem/aci-go-client/v2/container" @@ -578,13 +576,7 @@ func getAndSetRtctrlProfileAttributes(ctx context.Context, diags *diag.Diagnosti } func getRtctrlProfileRn(ctx context.Context, data *RtctrlProfileResourceModel) string { - rn := "prof-{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) - } - return rn + return fmt.Sprintf("prof-%s", data.Name.ValueString()) } func setRtctrlProfileParentDn(ctx context.Context, dn string, data *RtctrlProfileResourceModel) { diff --git a/internal/provider/resource_aci_tag.go b/internal/provider/resource_aci_tag.go index d7fac2e88..ef7480ae2 100644 --- a/internal/provider/resource_aci_tag.go +++ b/internal/provider/resource_aci_tag.go @@ -8,8 +8,6 @@ import ( "context" "encoding/json" "fmt" - "reflect" - "strings" "github.com/ciscoecosystem/aci-go-client/v2/client" "github.com/ciscoecosystem/aci-go-client/v2/container" @@ -322,13 +320,7 @@ func getAndSetTagTagAttributes(ctx context.Context, diags *diag.Diagnostics, cli } func getTagTagRn(ctx context.Context, data *TagTagResourceModel) string { - rn := "tagKey-{key}" - for _, identifier := range []string{"key"} { - 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) - } - return rn + return fmt.Sprintf("tagKey-%s", data.Key.ValueString()) } func setTagTagParentDn(ctx context.Context, dn string, data *TagTagResourceModel) { diff --git a/internal/provider/resource_aci_trust_control_policy.go b/internal/provider/resource_aci_trust_control_policy.go index d346d8f86..adf294d06 100644 --- a/internal/provider/resource_aci_trust_control_policy.go +++ b/internal/provider/resource_aci_trust_control_policy.go @@ -8,8 +8,6 @@ import ( "context" "encoding/json" "fmt" - "reflect" - "strings" "github.com/ciscoecosystem/aci-go-client/v2/client" "github.com/ciscoecosystem/aci-go-client/v2/container" @@ -645,13 +643,7 @@ func getAndSetFhsTrustCtrlPolAttributes(ctx context.Context, diags *diag.Diagnos } func getFhsTrustCtrlPolRn(ctx context.Context, data *FhsTrustCtrlPolResourceModel) string { - rn := "trustctrlpol-{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) - } - return rn + return fmt.Sprintf("trustctrlpol-%s", data.Name.ValueString()) } func setFhsTrustCtrlPolParentDn(ctx context.Context, dn string, data *FhsTrustCtrlPolResourceModel) { diff --git a/internal/provider/resource_aci_vrf_fallback_route.go b/internal/provider/resource_aci_vrf_fallback_route.go index 95aeaf60c..3e70aeee3 100644 --- a/internal/provider/resource_aci_vrf_fallback_route.go +++ b/internal/provider/resource_aci_vrf_fallback_route.go @@ -8,8 +8,6 @@ import ( "context" "encoding/json" "fmt" - "reflect" - "strings" "github.com/ciscoecosystem/aci-go-client/v2/client" "github.com/ciscoecosystem/aci-go-client/v2/container" @@ -527,13 +525,7 @@ func getAndSetFvFBRouteAttributes(ctx context.Context, diags *diag.Diagnostics, } func getFvFBRouteRn(ctx context.Context, data *FvFBRouteResourceModel) string { - rn := "pfx-[{fbrPrefix}]" - for _, identifier := range []string{"fbrPrefix"} { - 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) - } - return rn + return fmt.Sprintf("pfx-[%s]", data.FbrPrefix.ValueString()) } func setFvFBRouteParentDn(ctx context.Context, dn string, data *FvFBRouteResourceModel) { diff --git a/internal/provider/resource_aci_vrf_fallback_route_group.go b/internal/provider/resource_aci_vrf_fallback_route_group.go index a441674fa..a5934dbb4 100644 --- a/internal/provider/resource_aci_vrf_fallback_route_group.go +++ b/internal/provider/resource_aci_vrf_fallback_route_group.go @@ -8,8 +8,6 @@ import ( "context" "encoding/json" "fmt" - "reflect" - "strings" "github.com/ciscoecosystem/aci-go-client/v2/client" "github.com/ciscoecosystem/aci-go-client/v2/container" @@ -755,13 +753,7 @@ func getAndSetFvFBRGroupAttributes(ctx context.Context, diags *diag.Diagnostics, } func getFvFBRGroupRn(ctx context.Context, data *FvFBRGroupResourceModel) string { - rn := "fbrg-{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) - } - return rn + return fmt.Sprintf("fbrg-%s", data.Name.ValueString()) } func setFvFBRGroupParentDn(ctx context.Context, dn string, data *FvFBRGroupResourceModel) { diff --git a/internal/provider/resource_aci_vrf_fallback_route_group_member.go b/internal/provider/resource_aci_vrf_fallback_route_group_member.go index d70c6bc3c..6d9c6e026 100644 --- a/internal/provider/resource_aci_vrf_fallback_route_group_member.go +++ b/internal/provider/resource_aci_vrf_fallback_route_group_member.go @@ -8,8 +8,6 @@ import ( "context" "encoding/json" "fmt" - "reflect" - "strings" "github.com/ciscoecosystem/aci-go-client/v2/client" "github.com/ciscoecosystem/aci-go-client/v2/container" @@ -527,13 +525,7 @@ func getAndSetFvFBRMemberAttributes(ctx context.Context, diags *diag.Diagnostics } func getFvFBRMemberRn(ctx context.Context, data *FvFBRMemberResourceModel) string { - rn := "nexthop-[{rnhAddr}]" - for _, identifier := range []string{"rnhAddr"} { - 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) - } - return rn + return fmt.Sprintf("nexthop-[%s]", data.RnhAddr.ValueString()) } func setFvFBRMemberParentDn(ctx context.Context, dn string, data *FvFBRMemberResourceModel) {