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

Clean up some duplicate imports and typos #3659

Merged
merged 1 commit into from
Oct 21, 2024
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
7 changes: 3 additions & 4 deletions provider/pkg/gen/merging.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"github.com/pkg/errors"
"github.com/pulumi/pulumi/pkg/v3/codegen"
"github.com/pulumi/pulumi/pkg/v3/codegen/schema"
pschema "github.com/pulumi/pulumi/pkg/v3/codegen/schema"
"github.com/pulumi/pulumi/sdk/v3/go/common/util/contract"
)

Expand All @@ -21,7 +20,7 @@ func mergeTypes(t1 schema.ComplexTypeSpec, t2 schema.ComplexTypeSpec, isOutput b
}

if !isOutput {
// Check that every required property of T1 and T2 exists in T1 and has the same type (for intputs only).
// Check that every required property of T1 and T2 exists in T1 and has the same type (for inputs only).
t1Required := codegen.NewStringSet(t1.Required...)
t2Required := codegen.NewStringSet(t2.Required...)
t1Only := t1Required.Subtract(t2Required)
Expand All @@ -43,7 +42,7 @@ func mergeTypes(t1 schema.ComplexTypeSpec, t2 schema.ComplexTypeSpec, isOutput b
if t1.Properties == nil && t2.Properties == nil {
return &t1, nil
}
mergedProperties := map[string]pschema.PropertySpec{}
mergedProperties := map[string]schema.PropertySpec{}
for name, p := range t1.Properties {
mergedProperties[name] = p
}
Expand All @@ -65,7 +64,7 @@ func mergeTypes(t1 schema.ComplexTypeSpec, t2 schema.ComplexTypeSpec, isOutput b
return &merged, nil
}

func mergePropertySpec(p1, p2 pschema.PropertySpec) (*pschema.PropertySpec, error) {
func mergePropertySpec(p1, p2 schema.PropertySpec) (*schema.PropertySpec, error) {
mergedTypeSpec, err := mergeTypeSpec(p1.TypeSpec, p2.TypeSpec)
if err != nil {
return nil, err
Expand Down
13 changes: 6 additions & 7 deletions provider/pkg/resources/customresources/customresources.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,10 @@ import (
azureEnv "github.com/Azure/go-autorest/autorest/azure"
"github.com/pulumi/pulumi-azure-native/v2/provider/pkg/azure"
"github.com/pulumi/pulumi-azure-native/v2/provider/pkg/provider/crud"
"github.com/pulumi/pulumi-azure-native/v2/provider/pkg/resources"

. "github.com/pulumi/pulumi-azure-native/v2/provider/pkg/resources"
"github.com/pulumi/pulumi/pkg/v3/codegen"
"github.com/pulumi/pulumi/pkg/v3/codegen/schema"
pschema "github.com/pulumi/pulumi/pkg/v3/codegen/schema"
"github.com/pulumi/pulumi/sdk/v3/go/common/resource"
)

Expand Down Expand Up @@ -82,7 +81,7 @@ type ResourceDefinition struct {
// ApplySchemas applies custom schema modifications to the given package.
// These modifications should never overlap with each other, but we apply in a deterministic order to ensure
// that the end result of the modifications is consistent.
func ApplySchemas(pkg *pschema.PackageSpec, meta *resources.AzureAPIMetadata) error {
func ApplySchemas(pkg *schema.PackageSpec, meta *AzureAPIMetadata) error {
for _, path := range codegen.SortedKeys(featureLookup) {
r := featureLookup[path]
if err := r.ApplySchema(pkg, meta); err != nil {
Expand All @@ -92,20 +91,20 @@ func ApplySchemas(pkg *pschema.PackageSpec, meta *resources.AzureAPIMetadata) er
return nil
}

func (r *CustomResource) ApplySchema(pkg *pschema.PackageSpec, meta *resources.AzureAPIMetadata) error {
func (r *CustomResource) ApplySchema(pkg *schema.PackageSpec, meta *AzureAPIMetadata) error {
if r.tok == "" || r.Schema == nil {
return nil
}

existingResource, resourceAlreadyExists := pkg.Resources[r.tok]
var originalResource *ResourceDefinition
types := map[string]pschema.ComplexTypeSpec{} // Hoist scope for easy lookup when checking if the type is new.
types := map[string]schema.ComplexTypeSpec{} // Hoist scope for easy lookup when checking if the type is new.
if resourceAlreadyExists {
resourceMeta, resourceMetadataFound := meta.Resources[r.tok]
if !resourceMetadataFound {
return fmt.Errorf("metadata for resource %s not found", r.tok)
}
resources.VisitResourceTypes(pkg, r.tok, func(tok string, t pschema.ComplexTypeSpec) {
VisitResourceTypes(pkg, r.tok, func(tok string, t schema.ComplexTypeSpec) {
// Capture referenced schema types
types[tok] = t
})
Expand Down Expand Up @@ -286,7 +285,7 @@ func MetaTypeOverrides() map[string]AzureAPIType {
// createCrudClient creates a CRUD client for the given resource type, looking up the fully
// qualified `resourceToken` like "azure-native:web:WebApp" via `lookupResource`.
func createCrudClient(
crudClientFactory crud.ResourceCrudClientFactory, lookupResource resources.ResourceLookupFunc, resourceToken string,
crudClientFactory crud.ResourceCrudClientFactory, lookupResource ResourceLookupFunc, resourceToken string,
) (crud.ResourceCrudClient, error) {
res, ok, err := lookupResource(webAppResourceType)
if err != nil {
Expand Down
Loading