Skip to content

Commit

Permalink
Restructure v3 modules (#3918)
Browse files Browse the repository at this point in the history
Addresses the most prominent cases from
#690

These changes have been previewed against the [temporary
`v3-module-restructure-preview`
branch](https://github.com/pulumi/pulumi-azure-native/commits/v3-module-restructure-preview/)
to be able to see the impact of each rename. Individual commits are
linked below and show the files moving and the old-module aliases being
added to each resource.

- Rename `Cache` into `Redis` and `RedisEnterprise` ([Generate after
Cache module
rename](39e385e))
- Rename `Devices` into `IoTHub` and `DeviceProvisioningServices`
([Generate after Devices module
rename](addb542))
- Rename `DocumentDB` to `CosmosDB` ([Generate after CosmosDB module
rename](b2937c7))
- Rename `Insights` into `Monitor` and `ApplicationInsights`
([Regenerate after Insights module
rename](a900bbd))
  • Loading branch information
danielrbradley authored Jan 31, 2025
1 parent f1cae56 commit d9f3429
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 29 deletions.
46 changes: 26 additions & 20 deletions provider/pkg/resources/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ func GetModuleName(majorVersion uint64, filePath, apiUri string) (ModuleNaming,
// Start with extracting the namespace from the folder path. If the folder name is explicitly listed,
// use it as the module name. This is the new style we use for newer resources after 1.0. Older
// resources to be migrated as part of https://github.com/pulumi/pulumi-azure-native/issues/690.
if override, hasOverride := getNameOverride(majorVersion, specFolderName, namespaceWithoutPrefixFromSpecFilePath); hasOverride {
if override, hasOverride := getNameOverride(majorVersion, specFolderName); hasOverride {
return ModuleNaming{
ResolvedName: override,
SpecFolderName: specFolderName,
Expand All @@ -318,29 +318,37 @@ func GetModuleName(majorVersion uint64, filePath, apiUri string) (ModuleNaming,
}, nil
}

var modulesNamedByFolder = map[string]ModuleName{
var v2ModulesNamedByFolder = map[string]ModuleName{
"videoanalyzer": "VideoAnalyzer",
"webpubsub": "WebPubSub",
}

var moduleNameOverridesWithAliases = map[string]map[string]string{
"Network": {
"dns": "Dns",
"dnsresolver": "DnsResolver",
"frontdoor": "FrontDoor",
"privatedns": "PrivateDns",
"trafficmanager": "TrafficManager",
},
"DocumentDB": {
"mongocluster": "MongoCluster",
},
var v3ModulesNamedByFolder = map[string]ModuleName{
// "Network":
"dns": "Dns",
"dnsresolver": "DnsResolver",
"frontdoor": "FrontDoor",
"privatedns": "PrivateDns",
"trafficmanager": "TrafficManager",
// Cache:
"redis": "Redis",
"redisenterprise": "RedisEnterprise",
// Devices:
"iothub": "IoTHub",
"deviceprovisioningservices": "DeviceProvisioningServices",
// "DocumentDB":
"cosmos-db": "CosmosDB",
"mongocluster": "MongoCluster",
// Insights:
"monitor": "Monitor",
"applicationinsights": "ApplicationInsights",
}

// getNameOverride returns a name override for a given folder name, and non-prefixed namespace.
// The second return value is true if an override is found.
func getNameOverride(majorVersion uint64, specFolderName, namespaceWithoutPrefix string) (ModuleName, bool) {
func getNameOverride(majorVersion uint64, specFolderName string) (ModuleName, bool) {
// For the cases below, we use folder (SDK) moduleName for module names instead of the ARM moduleName.
if moduleName, ok := modulesNamedByFolder[specFolderName]; ok {
if moduleName, ok := v2ModulesNamedByFolder[specFolderName]; ok {
return moduleName, true
}
// Disable additional rules for v2 and below.
Expand All @@ -349,10 +357,8 @@ func getNameOverride(majorVersion uint64, specFolderName, namespaceWithoutPrefix
return "", false
}
// New rules for v3 and above which include aliases back to the original namespace.
if namespaceOverrides, ok := moduleNameOverridesWithAliases[namespaceWithoutPrefix]; ok {
if folderName, ok := namespaceOverrides[specFolderName]; ok {
return ModuleName(folderName), true
}
if moduleName, ok := v3ModulesNamedByFolder[specFolderName]; ok {
return moduleName, true
}
return "", false
}
Expand Down Expand Up @@ -412,7 +418,7 @@ func findNamespaceWithoutPrefixFromPath(path, defaultValue string) string {
return defaultValue
}

var folderModulePattern = regexp.MustCompile(`.*/specification/([a-zA-Z]+)/resource-manager/.*`)
var folderModulePattern = regexp.MustCompile(`.*/specification/([a-zA-Z-]+)/resource-manager/.*`)

func getSpecFolderName(path string) string {
subMatches := folderModulePattern.FindStringSubmatch(path)
Expand Down
21 changes: 12 additions & 9 deletions versions/v3-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@ AppComplianceAutomation:
AppConfiguration:
exclusions:
listConfigurationStoreKeyValue: "2020-06-01" # was renamed to KeyValues_ListByConfigurationStore, endpoint from listKeyValue to keyValues
ApplicationInsights:
explicit: true
notes: |
Each API version only includes changed resources so no benefit in tracking a version
Path: /azure-rest-api-specs/specification/applicationinsights/resource-manager/Microsoft.Insights
Docs: https://learn.microsoft.com/en-us/rest/api/application-insights/
AppPlatform:
notes: |
AppPlatform is also called "Azure Spring Apps".
Expand Down Expand Up @@ -397,14 +403,6 @@ HybridNetwork:
notes: |
https://learn.microsoft.com/en-us/rest/api/hybridnetwork/
ImportExport:
Insights:
explicit: true
notes: |
Each API version only includes changed resources so no benefit in tracking a version
Path: /azure-rest-api-specs/specification/applicationinsights/resource-manager/Microsoft.Insights
Docs: https://learn.microsoft.com/en-us/rest/api/application-insights/
- Components and Web Tests pinned on 2015-05-01
- Workbooks pinned on 2021-08-01
Intune:
expectTracking: preview
notes: Only preview versions
Expand Down Expand Up @@ -531,8 +529,13 @@ MobileNetwork:
notes: |
https://learn.microsoft.com/en-us/rest/api/mobilenetwork/mobile-networks
Monitor:
explicit: true
notes: |
This is *not* Azure Monitor
Each API version only includes changed resources so no benefit in tracking a version
Docs: https://learn.microsoft.com/en-us/rest/api/monitor/
This was previously known as Insights (included in the namespace), which is now referred to as "Classic Insights".
This has more recently been renamed to "Monitor", with the addition of the Microsoft.Monitor namespace.
The new Monitor namespace contains a "Workspace" resource to which the "classic" insights resources are parented to to modernize them.
NetApp:
Network:
explicit: true
Expand Down

0 comments on commit d9f3429

Please sign in to comment.