From 48f612de72ac623ba2368aadb759f5b6e5685055 Mon Sep 17 00:00:00 2001 From: Thomas Kappler Date: Mon, 6 Jan 2025 18:21:09 +0100 Subject: [PATCH] Remove unused schemagen code, cleanup (#3815) - **Small schema.go cleanups, remove unused endpoints collection** - **Remove unused warnings reporting** --- provider/pkg/gen/schema.go | 15 ++------ reports/genWarnings.json | 73 -------------------------------------- 2 files changed, 3 insertions(+), 85 deletions(-) delete mode 100644 reports/genWarnings.json diff --git a/provider/pkg/gen/schema.go b/provider/pkg/gen/schema.go index c06f7808ec05..06c95760114e 100644 --- a/provider/pkg/gen/schema.go +++ b/provider/pkg/gen/schema.go @@ -61,7 +61,6 @@ type GenerationResult struct { ForceNewTypes []ForceNewType TypeCaseConflicts CaseConflicts FlattenedPropertyConflicts map[string]map[string]struct{} - Endpoints openapi.Endpoints } // PulumiSchema will generate a Pulumi schema for the given Azure providers and resources map. @@ -276,13 +275,11 @@ func PulumiSchema(rootDir string, providerMap openapi.AzureProviders, versioning sort.Strings(providers) // Track some global data - warnings := []string{} var forceNewTypes []ForceNewType caseSensitiveTypes := newCaseSensitiveTokens() flattenedPropertyConflicts := map[string]map[string]struct{}{} - endpoints := openapi.Endpoints{} - exampleMap := make(map[string][]resources.AzureAPIExample) + for _, providerName := range providers { versionMap := providerMap[providerName] var versions []openapi.SdkVersion @@ -313,7 +310,6 @@ func PulumiSchema(rootDir string, providerMap openapi.AzureProviders, versioning caseSensitiveTypes: caseSensitiveTypes, rootDir: rootDir, flattenedPropertyConflicts: flattenedPropertyConflicts, - allEndpoints: endpoints, majorVersion: majorVersion, } @@ -348,7 +344,6 @@ func PulumiSchema(rootDir string, providerMap openapi.AzureProviders, versioning // Populate invokes. gen.genInvokes(items.Invokes) - warnings = append(warnings, gen.warnings...) forceNewTypes = append(forceNewTypes, gen.forceNewTypes...) } } @@ -412,7 +407,6 @@ version using infrastructure as code, which Pulumi then uses to drive the ARM AP ForceNewTypes: forceNewTypes, TypeCaseConflicts: caseSensitiveTypes.findCaseConflicts(), FlattenedPropertyConflicts: flattenedPropertyConflicts, - Endpoints: endpoints, }, nil } @@ -641,12 +635,10 @@ type packageGenerator struct { allSdkVersions []openapi.SdkVersion versioning Versioning caseSensitiveTypes caseSensitiveTokens - warnings []string // rootDir is used to resolve relative paths in the examples. rootDir string forceNewTypes []ForceNewType flattenedPropertyConflicts map[string]map[string]struct{} - allEndpoints openapi.Endpoints majorVersion int } @@ -781,7 +773,7 @@ func (g *packageGenerator) findResourceVariants(resource *openapi.ResourceSpec) } func (g *packageGenerator) makeTypeAlias(alias string, apiVersion openapi.SdkVersion) pschema.AliasSpec { - fqAlias := fmt.Sprintf("%s:%s:%s", g.pkg.Name, g.providerApiToModule(apiVersion), alias) + fqAlias := g.generateTok(alias, apiVersion) return pschema.AliasSpec{Type: &fqAlias} } @@ -808,7 +800,6 @@ func (g *packageGenerator) genResourceVariant(apiSpec *openapi.ResourceSpec, res inlineTypes: map[*openapi.ReferenceContext]codegen.StringSet{}, nestedResourceBodyRefs: nestedResourceBodyRefs, flattenedPropertyConflicts: map[string]struct{}{}, - allEndpoints: g.allEndpoints, } updateOp := path.Put @@ -1126,6 +1117,7 @@ func (g *packageGenerator) versionedModuleName() string { return fmt.Sprintf("%s/%s", versionedModule, g.sdkVersion) } +// providerApiToModule produces the module name from the provider name (g.provider), and the version if not empty, e.g. `compute/v20200701`. func (g *packageGenerator) providerApiToModule(apiVersion openapi.SdkVersion) string { if apiVersion == "" { return strings.ToLower(g.provider) @@ -1326,7 +1318,6 @@ type moduleGenerator struct { nestedResourceBodyRefs []string forceNewTypes []ForceNewType flattenedPropertyConflicts map[string]struct{} - allEndpoints openapi.Endpoints } func (m *moduleGenerator) escapeCSharpNames(typeName string, resourceResponse *propertyBag) { diff --git a/reports/genWarnings.json b/reports/genWarnings.json deleted file mode 100644 index 479980d387e8..000000000000 --- a/reports/genWarnings.json +++ /dev/null @@ -1,73 +0,0 @@ -[ - "Removing required 'id' from authenticationCertificates of azure-native:network:SubResource", - "Removing required 'id' from firewallPolicy of azure-native:network:SubResource", - "Removing required 'id' from publicIPAddress of azure-native:network:SubResource", - "Removing required 'id' from customIpPrefixParent of azure-native:network:SubResource", - "Removing required 'id' from dnsResolverOutboundEndpoints of azure-native:network:SubResource", - "Removing required 'id' from virtualNetwork of azure-native:network:SubResource", - "Removing required 'id' from expressRoutePort of azure-native:network:SubResource", - "Removing required 'id' from expressRouteCircuitPeering of azure-native:network:SubResource", - "Removing required 'id' from expressRouteCircuitPeering of azure-native:network:SubResource", - "Removing required 'id' from associatedRouteTable of azure-native:network:SubResource", - "Removing required 'id' from routeFilter of azure-native:network:SubResource", - "Removing required 'id' from associatedRouteTable of azure-native:network:SubResource", - "Removing required 'id' from basePolicy of azure-native:network:SubResource", - "Removing required 'id' from healthProbeSettings of azure-native:network:SubResource", - "Removing required 'id' from remoteVirtualNetwork of azure-native:network:SubResource", - "Removing required 'id' from subnet of azure-native:network:SubResource", - "Removing required 'id' from backendAddressPool of azure-native:network:SubResource", - "Removing required 'id' from natGateway of azure-native:network:SubResource", - "Removing required 'priority' from defaultSecurityRules of azure-native:network:SecurityRule", - "Removing required 'id' from loadBalancerFrontendIPConfiguration of azure-native:network:SubResource", - "Removing required 'priority' from securityRules of azure-native:network:SecurityRule", - "Removing required 'id' from loadBalancerFrontendIPConfiguration of azure-native:network:SubResource", - "Removing required 'id' from publicIpAddresses of azure-native:network:SubResource", - "Removing required 'id' from gatewayLoadBalancer of azure-native:network:SubResource", - "Removing required 'priority' from securityRules of azure-native:network:SecurityRule", - "Removing required 'id' from gatewayLoadBalancer of azure-native:network:SubResource", - "Removing required 'priority' from securityRules of azure-native:network:SecurityRule", - "Removing required 'id' from containerNetworkInterfaces of azure-native:network:SubResource", - "Removing required 'priority' from securityRules of azure-native:network:SecurityRule", - "Removing required 'priority' from securityRules of azure-native:network:SecurityRule", - "Removing required 'id' from virtualHub of azure-native:network:SubResource", - "Removing required 'id' from privateLinkResource of azure-native:network:SubResource", - "Removing required 'id' from subnet of azure-native:network:SubResource", - "Removing required 'id' from associatedRouteTable of azure-native:network:SubResource", - "Removing required 'id' from subnet of azure-native:network:SubResource", - "Removing required 'priority' from securityRules of azure-native:network:SecurityRule", - "Removing required 'id' from subnet of azure-native:network:SubResource", - "Removing required 'priority' from securityRules of azure-native:network:SecurityRule", - "Removing required 'id' from virtualNetwork of azure-native:network:SubResource", - "Removing required 'id' from ddosProtectionPlan of azure-native:network:SubResource", - "Removing required 'id' from customIPPrefix of azure-native:network:SubResource", - "Removing required 'id' from targetResource of azure-native:network:SubResource", - "Removing required 'id' from backendPool of azure-native:network:SubResource", - "Removing required 'id' from virtualHub of azure-native:network:SubResource", - "Removing required 'id' from subnet of azure-native:network:SubResource", - "Removing required 'priority' from securityRules of azure-native:network:SecurityRule", - "Removing required 'id' from azureFirewall of azure-native:network:SubResource", - "Removing required 'id' from hubVirtualNetworkConnection of azure-native:network:SubResource", - "Removing required 'id' from ddosProtectionPlan of azure-native:network:SubResource", - "Removing required 'priority' from securityRules of azure-native:network:SecurityRule", - "Removing required 'id' from ddosProtectionPlan of azure-native:network:SubResource", - "Removing required 'priority' from securityRules of azure-native:network:SecurityRule", - "Removing required 'id' from gatewayDefaultSite of azure-native:network:SubResource", - "Removing required 'id' from egressNatRules of azure-native:network:SubResource", - "Removing required 'id' from virtualNetwork of azure-native:network:SubResource", - "Removing required 'id' from remoteVirtualNetwork of azure-native:network:SubResource", - "Removing required 'id' from gatewayLoadBalancer of azure-native:network:SubResource", - "Removing required 'priority' from securityRules of azure-native:network:SecurityRule", - "Removing required 'id' from hostedGateway of azure-native:network:SubResource", - "Removing required 'id' from remoteVpnSite of azure-native:network:SubResource", - "Removing required 'id' from remoteVpnSite of azure-native:network:SubResource", - "Removing required 'id' from virtualWan of azure-native:network:SubResource", - "Removing required 'id' from registrationVirtualNetworks of azure-native:network:SubResource", - "Removing required 'id' from backendAddressPool of azure-native:network:SubResource", - "Removing required 'id' from targetResources of azure-native:network:SubResource", - "Removing required 'id' from dnsResolverOutboundEndpoints of azure-native:network/v20220701:SubResource", - "Removing required 'id' from virtualNetwork of azure-native:network/v20220701:SubResource", - "Removing required 'id' from subnet of azure-native:network/v20220701:SubResource", - "Removing required 'id' from subnet of azure-native:network/v20220701:SubResource", - "Removing required 'id' from virtualNetwork of azure-native:network/v20220701:SubResource", - "Removing required 'id' from subnet of azure-native:network/v20220701:SubResource" -] \ No newline at end of file