Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prepare v3 version files #3847

Merged
merged 17 commits into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ dist/pulumi-azure-native_$(PROVIDER_VERSION)_checksums.txt: dist/$(PROVIDER)-v$(
@touch $@

.make/prebuild: .pulumi/bin/pulumi
cp -v versions/v${MAJOR_VERSION}-lock.json provider/pkg/versionLookup/
cp -v versions/v${MAJOR_VERSION}-lock.json provider/pkg/versionLookup/version-lock.json
@touch $@

define FAKE_MODULE
Expand Down
4 changes: 1 addition & 3 deletions provider/pkg/gen/exclude.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,9 @@ import (
// excludeResourcePatterns lists resources being skipped due to known codegen issues.
var excludeResourcePatterns = []string{
"azure-native:chaos:Experiment",
"azure-native:costmanagement:Budget",
"azure-native:costmanagement:Report",
"azure-native:datafactory:Pipeline", // go codegen goes full CPU and doesn't return

"azure-native:hybridcompute:GuestConfigurationHCRPAssignment", // python name mismatch
"azure-native:hybridcompute:GuestConfigurationHCRPAssignment", // python name mismatch
}
var excludeRegexes []*regexp.Regexp

Expand Down
17 changes: 12 additions & 5 deletions provider/pkg/gen/properties.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,14 @@ type genPropertiesVariant struct {
isType bool
// isResponse indicates that the properties are being generated for a response type.
isResponse bool
// isTopLevel indicates that the properties are being generated for a top-level resource rather than a referenced type.
isTopLevel bool
}

// noResponse returns a new copy of the variant with isResponse set to false.
func (v *genPropertiesVariant) noResponse() genPropertiesVariant {
// nestedWithoutResponse returns a new copy of the variant with isResponse set to false.
func (v *genPropertiesVariant) nestedWithoutResponse() genPropertiesVariant {
return genPropertiesVariant{
isTopLevel: false,
isOutput: v.isOutput,
isType: v.isType,
isResponse: false,
Expand Down Expand Up @@ -109,6 +112,10 @@ func (m *moduleGenerator) genProperties(resolvedSchema *openapi.Schema, variants
if clientName, ok := resolvedProperty.Extensions.GetString(extensionClientName); ok {
sdkName = firstToLower(clientName)
}
// Urn is a reserved word in our SDKs so we should avoid it on the resource itself.
if sdkName == "urn" && variants.isTopLevel {
sdkName = "urnValue"
}
// Change the name to lowerCamelCase.
sdkName = ToLowerCamel(sdkName)

Expand Down Expand Up @@ -137,7 +144,7 @@ func (m *moduleGenerator) genProperties(resolvedSchema *openapi.Schema, variants
}

if (ok && flatten && !isDict) || workaroundDelegatedNetworkBreakingChange {
bag, err := m.genProperties(resolvedProperty, variants.noResponse())
bag, err := m.genProperties(resolvedProperty, variants.nestedWithoutResponse())
if err != nil {
return nil, err
}
Expand All @@ -154,7 +161,7 @@ func (m *moduleGenerator) genProperties(resolvedSchema *openapi.Schema, variants
}
} else { // v3+: don't flatten when there are conflicts
if (ok && flatten && !isDict) || workaroundDelegatedNetworkBreakingChange {
bag, err := m.genProperties(resolvedProperty, variants.noResponse())
bag, err := m.genProperties(resolvedProperty, variants.nestedWithoutResponse())
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -210,7 +217,7 @@ func (m *moduleGenerator) genProperties(resolvedSchema *openapi.Schema, variants
return nil, fmt.Errorf("failed to resolve allOf schema %d: %w", i, err)
}

allOfProperties, err := m.genProperties(allOfSchema, variants.noResponse())
allOfProperties, err := m.genProperties(allOfSchema, variants.nestedWithoutResponse())
if err != nil {
return nil, fmt.Errorf("failed to generate allOf properties %d: %w", i, err)
}
Expand Down
2 changes: 2 additions & 0 deletions provider/pkg/gen/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -1418,6 +1418,7 @@ func (m *moduleGenerator) genMethodParameters(parameters []spec.Parameter, ctx *

// The body parameter is flattened, so that all its properties become the properties of the type.
props, err := m.genProperties(bodySchema, genPropertiesVariant{
isTopLevel: true,
isOutput: false,
isType: false,
isResponse: false,
Expand Down Expand Up @@ -1514,6 +1515,7 @@ func (m *moduleGenerator) genResponse(statusCodeResponses map[int]spec.Response,
}

result, err := m.genProperties(responseSchema, genPropertiesVariant{
isTopLevel: true,
isOutput: true,
isType: false,
isResponse: true,
Expand Down
3 changes: 3 additions & 0 deletions provider/pkg/resources/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,9 @@ var moduleNameOverridesWithAliases = map[string]map[string]string{
"privatedns": "PrivateDns",
"trafficmanager": "TrafficManager",
},
"DocumentDB": {
"mongocluster": "MongoCluster",
},
}

// getNameOverride returns a name override for a given folder name, and non-prefixed namespace.
Expand Down
2 changes: 1 addition & 1 deletion provider/pkg/versionLookup/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"encoding/json"
)

//go:embed v2-lock.json
//go:embed version-lock.json
var rawVersionLock []byte

// versionLock is a map from Azure provider name to resource name to API version.
Expand Down
Loading
Loading