Switch to use module to key rename map
This commit is contained in:
parent
75675e7320
commit
fb1d50c174
|
@ -145,8 +145,8 @@ func (pkg *pkgContext) tokenToType(tok string) string {
|
|||
|
||||
if ok {
|
||||
renamed := false
|
||||
// First determine if there is an existing rename required for the pkg+type
|
||||
if renames, ok := modPkg.typeRenameMappings[pkg.pkg.Name]; ok {
|
||||
// First determine if there is an existing rename required for the module+type
|
||||
if renames, ok := modPkg.typeRenameMappings[mod]; ok {
|
||||
if newName, ok := renames[name]; ok {
|
||||
name = newName
|
||||
renamed = true
|
||||
|
@ -1669,7 +1669,7 @@ func generatePackageContextMap(tool string, pkg *schema.Package, goInfo GoPackag
|
|||
modToPkg: goInfo.ModuleToPackage,
|
||||
pkgImportAliases: goInfo.PackageImportAliases,
|
||||
packages: packages,
|
||||
typeRenameMappings: goInfo.PackageToTypeRenameMapping,
|
||||
typeRenameMappings: goInfo.ModuleToTypeRenameMapping,
|
||||
}
|
||||
packages[mod] = pack
|
||||
}
|
||||
|
|
|
@ -43,9 +43,9 @@ type GoPackageInfo struct {
|
|||
// These are typically used to support external references.
|
||||
GenerateResourceContainerTypes bool `json:"generateResourceContainerTypes,omitempty"`
|
||||
|
||||
// An optional mapping keyed by package name, storing a nested map keyed by schema types
|
||||
// An optional mapping keyed by module name, storing a nested map keyed by schema types
|
||||
// and the corresponding renamed version.
|
||||
PackageToTypeRenameMapping map[string]TypeRenameMapping `json:"packageToTypeRenameMapping,omitempty"`
|
||||
ModuleToTypeRenameMapping map[string]TypeRenameMapping `json:"moduleToTypeRenameMapping,omitempty"`
|
||||
}
|
||||
|
||||
type TypeRenameMapping map[string]string
|
||||
|
|
|
@ -73,8 +73,8 @@
|
|||
"csharp": {},
|
||||
"go": {
|
||||
"importBasePath": "github.com/pulumi/pulumi/pkg/v2/codegen/internal/test/testdata/simple-resource-schema/go/example",
|
||||
"packageToTypeRenameMapping": {
|
||||
"example": {
|
||||
"moduleToTypeRenameMapping": {
|
||||
"": {
|
||||
"OtherResourceOutput": "RenamedResourceOutput"
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue