Skip to content

Commit

Permalink
Clean up some duplicate imports and typos (#3659)
Browse files Browse the repository at this point in the history
  • Loading branch information
thomas11 authored Oct 21, 2024
1 parent 13f1c55 commit 948ea95
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
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

0 comments on commit 948ea95

Please sign in to comment.