diff --git a/changelog/pending/20221103--sdkgen-go--allow-resource-names-that-conflict-with-additional-types.yaml b/changelog/pending/20221103--sdkgen-go--allow-resource-names-that-conflict-with-additional-types.yaml new file mode 100644 index 000000000000..0c2b38418ca6 --- /dev/null +++ b/changelog/pending/20221103--sdkgen-go--allow-resource-names-that-conflict-with-additional-types.yaml @@ -0,0 +1,4 @@ +changes: +- type: fix + scope: sdkgen/go + description: Allow resource names that conflict with additional types. diff --git a/pkg/codegen/go/gen.go b/pkg/codegen/go/gen.go index 5e1597aa5cbf..f820ff771d7c 100644 --- a/pkg/codegen/go/gen.go +++ b/pkg/codegen/go/gen.go @@ -3223,6 +3223,10 @@ func generatePackageContextMap(tool string, pkg *schema.Package, goInfo GoPackag names = append(names, cgstrings.Camel(rawResourceName(r))+suffix+"State") names = append(names, "Get"+rawResourceName(r)+suffix) } + if goInfo.GenerateResourceContainerTypes && !r.IsProvider { + names = append(names, rawResourceName(r)+suffix+"Array") + names = append(names, rawResourceName(r)+suffix+"Map") + } return names } diff --git a/pkg/codegen/testing/test/testdata/go-nested-collections/go/codegen-manifest.json b/pkg/codegen/testing/test/testdata/go-nested-collections/go/codegen-manifest.json index 7bd728dc38c3..d7ea23ad8016 100644 --- a/pkg/codegen/testing/test/testdata/go-nested-collections/go/codegen-manifest.json +++ b/pkg/codegen/testing/test/testdata/go-nested-collections/go/codegen-manifest.json @@ -3,6 +3,10 @@ "repro/doc.go", "repro/foo.go", "repro/init.go", + "repro/overlap/consumer.go", + "repro/overlap/init.go", + "repro/overlap/someType.go", + "repro/overlap/someTypeMap.go", "repro/provider.go", "repro/pulumi-plugin.json", "repro/pulumiTypes.go", diff --git a/pkg/codegen/testing/test/testdata/go-nested-collections/go/repro/overlap/consumer.go b/pkg/codegen/testing/test/testdata/go-nested-collections/go/repro/overlap/consumer.go new file mode 100644 index 000000000000..c400067c9d71 --- /dev/null +++ b/pkg/codegen/testing/test/testdata/go-nested-collections/go/repro/overlap/consumer.go @@ -0,0 +1,200 @@ +// Code generated by test DO NOT EDIT. +// *** WARNING: Do not edit by hand unless you're certain you know what you are doing! *** + +package overlap + +import ( + "context" + "reflect" + + "github.com/pulumi/pulumi/sdk/v3/go/pulumi" +) + +type Consumer struct { + pulumi.CustomResourceState +} + +// NewConsumer registers a new resource with the given unique name, arguments, and options. +func NewConsumer(ctx *pulumi.Context, + name string, args *ConsumerArgs, opts ...pulumi.ResourceOption) (*Consumer, error) { + if args == nil { + args = &ConsumerArgs{} + } + + var resource Consumer + err := ctx.RegisterResource("repro:overlap:Consumer", name, args, &resource, opts...) + if err != nil { + return nil, err + } + return &resource, nil +} + +// GetConsumer gets an existing Consumer resource's state with the given name, ID, and optional +// state properties that are used to uniquely qualify the lookup (nil if not required). +func GetConsumer(ctx *pulumi.Context, + name string, id pulumi.IDInput, state *ConsumerState, opts ...pulumi.ResourceOption) (*Consumer, error) { + var resource Consumer + err := ctx.ReadResource("repro:overlap:Consumer", name, id, state, &resource, opts...) + if err != nil { + return nil, err + } + return &resource, nil +} + +// Input properties used for looking up and filtering Consumer resources. +type consumerState struct { +} + +type ConsumerState struct { +} + +func (ConsumerState) ElementType() reflect.Type { + return reflect.TypeOf((*consumerState)(nil)).Elem() +} + +type consumerArgs struct { + Typ map[string]*SomeType `pulumi:"typ"` + TypM *SomeTypeMap `pulumi:"typM"` +} + +// The set of arguments for constructing a Consumer resource. +type ConsumerArgs struct { + Typ SomeTypeMapInput + TypM SomeTypeMapInput +} + +func (ConsumerArgs) ElementType() reflect.Type { + return reflect.TypeOf((*consumerArgs)(nil)).Elem() +} + +type ConsumerInput interface { + pulumi.Input + + ToConsumerOutput() ConsumerOutput + ToConsumerOutputWithContext(ctx context.Context) ConsumerOutput +} + +func (*Consumer) ElementType() reflect.Type { + return reflect.TypeOf((**Consumer)(nil)).Elem() +} + +func (i *Consumer) ToConsumerOutput() ConsumerOutput { + return i.ToConsumerOutputWithContext(context.Background()) +} + +func (i *Consumer) ToConsumerOutputWithContext(ctx context.Context) ConsumerOutput { + return pulumi.ToOutputWithContext(ctx, i).(ConsumerOutput) +} + +// ConsumerArrayInput is an input type that accepts ConsumerArray and ConsumerArrayOutput values. +// You can construct a concrete instance of `ConsumerArrayInput` via: +// +// ConsumerArray{ ConsumerArgs{...} } +type ConsumerArrayInput interface { + pulumi.Input + + ToConsumerArrayOutput() ConsumerArrayOutput + ToConsumerArrayOutputWithContext(context.Context) ConsumerArrayOutput +} + +type ConsumerArray []ConsumerInput + +func (ConsumerArray) ElementType() reflect.Type { + return reflect.TypeOf((*[]*Consumer)(nil)).Elem() +} + +func (i ConsumerArray) ToConsumerArrayOutput() ConsumerArrayOutput { + return i.ToConsumerArrayOutputWithContext(context.Background()) +} + +func (i ConsumerArray) ToConsumerArrayOutputWithContext(ctx context.Context) ConsumerArrayOutput { + return pulumi.ToOutputWithContext(ctx, i).(ConsumerArrayOutput) +} + +// ConsumerMapInput is an input type that accepts ConsumerMap and ConsumerMapOutput values. +// You can construct a concrete instance of `ConsumerMapInput` via: +// +// ConsumerMap{ "key": ConsumerArgs{...} } +type ConsumerMapInput interface { + pulumi.Input + + ToConsumerMapOutput() ConsumerMapOutput + ToConsumerMapOutputWithContext(context.Context) ConsumerMapOutput +} + +type ConsumerMap map[string]ConsumerInput + +func (ConsumerMap) ElementType() reflect.Type { + return reflect.TypeOf((*map[string]*Consumer)(nil)).Elem() +} + +func (i ConsumerMap) ToConsumerMapOutput() ConsumerMapOutput { + return i.ToConsumerMapOutputWithContext(context.Background()) +} + +func (i ConsumerMap) ToConsumerMapOutputWithContext(ctx context.Context) ConsumerMapOutput { + return pulumi.ToOutputWithContext(ctx, i).(ConsumerMapOutput) +} + +type ConsumerOutput struct{ *pulumi.OutputState } + +func (ConsumerOutput) ElementType() reflect.Type { + return reflect.TypeOf((**Consumer)(nil)).Elem() +} + +func (o ConsumerOutput) ToConsumerOutput() ConsumerOutput { + return o +} + +func (o ConsumerOutput) ToConsumerOutputWithContext(ctx context.Context) ConsumerOutput { + return o +} + +type ConsumerArrayOutput struct{ *pulumi.OutputState } + +func (ConsumerArrayOutput) ElementType() reflect.Type { + return reflect.TypeOf((*[]*Consumer)(nil)).Elem() +} + +func (o ConsumerArrayOutput) ToConsumerArrayOutput() ConsumerArrayOutput { + return o +} + +func (o ConsumerArrayOutput) ToConsumerArrayOutputWithContext(ctx context.Context) ConsumerArrayOutput { + return o +} + +func (o ConsumerArrayOutput) Index(i pulumi.IntInput) ConsumerOutput { + return pulumi.All(o, i).ApplyT(func(vs []interface{}) *Consumer { + return vs[0].([]*Consumer)[vs[1].(int)] + }).(ConsumerOutput) +} + +type ConsumerMapOutput struct{ *pulumi.OutputState } + +func (ConsumerMapOutput) ElementType() reflect.Type { + return reflect.TypeOf((*map[string]*Consumer)(nil)).Elem() +} + +func (o ConsumerMapOutput) ToConsumerMapOutput() ConsumerMapOutput { + return o +} + +func (o ConsumerMapOutput) ToConsumerMapOutputWithContext(ctx context.Context) ConsumerMapOutput { + return o +} + +func (o ConsumerMapOutput) MapIndex(k pulumi.StringInput) ConsumerOutput { + return pulumi.All(o, k).ApplyT(func(vs []interface{}) *Consumer { + return vs[0].(map[string]*Consumer)[vs[1].(string)] + }).(ConsumerOutput) +} + +func init() { + pulumi.RegisterInputType(reflect.TypeOf((*ConsumerInput)(nil)).Elem(), &Consumer{}) + pulumi.RegisterInputType(reflect.TypeOf((*ConsumerArrayInput)(nil)).Elem(), ConsumerArray{}) + pulumi.RegisterInputType(reflect.TypeOf((*ConsumerMapInput)(nil)).Elem(), ConsumerMap{}) + pulumi.RegisterOutputType(ConsumerOutput{}) + pulumi.RegisterOutputType(ConsumerArrayOutput{}) + pulumi.RegisterOutputType(ConsumerMapOutput{}) +} diff --git a/pkg/codegen/testing/test/testdata/go-nested-collections/go/repro/overlap/init.go b/pkg/codegen/testing/test/testdata/go-nested-collections/go/repro/overlap/init.go new file mode 100644 index 000000000000..ade43ad784b1 --- /dev/null +++ b/pkg/codegen/testing/test/testdata/go-nested-collections/go/repro/overlap/init.go @@ -0,0 +1,48 @@ +// Code generated by test DO NOT EDIT. +// *** WARNING: Do not edit by hand unless you're certain you know what you are doing! *** + +package overlap + +import ( + "fmt" + + "github.com/blang/semver" + "github.com/pulumi/pulumi/sdk/v3/go/pulumi" + "go-nested-collections/repro" +) + +type module struct { + version semver.Version +} + +func (m *module) Version() semver.Version { + return m.version +} + +func (m *module) Construct(ctx *pulumi.Context, name, typ, urn string) (r pulumi.Resource, err error) { + switch typ { + case "repro:overlap:Consumer": + r = &Consumer{} + case "repro:overlap:SomeType": + r = &SomeType{} + case "repro:overlap:SomeTypeMap": + r = &SomeTypeMapResource{} + default: + return nil, fmt.Errorf("unknown resource type: %s", typ) + } + + err = ctx.RegisterResource(typ, name, nil, r, pulumi.URN_(urn)) + return +} + +func init() { + version, err := repro.PkgVersion() + if err != nil { + version = semver.Version{Major: 1} + } + pulumi.RegisterResourceModule( + "repro", + "overlap", + &module{version}, + ) +} diff --git a/pkg/codegen/testing/test/testdata/go-nested-collections/go/repro/overlap/someType.go b/pkg/codegen/testing/test/testdata/go-nested-collections/go/repro/overlap/someType.go new file mode 100644 index 000000000000..38b1ccfb9750 --- /dev/null +++ b/pkg/codegen/testing/test/testdata/go-nested-collections/go/repro/overlap/someType.go @@ -0,0 +1,196 @@ +// Code generated by test DO NOT EDIT. +// *** WARNING: Do not edit by hand unless you're certain you know what you are doing! *** + +package overlap + +import ( + "context" + "reflect" + + "github.com/pulumi/pulumi/sdk/v3/go/pulumi" +) + +type SomeType struct { + pulumi.CustomResourceState +} + +// NewSomeType registers a new resource with the given unique name, arguments, and options. +func NewSomeType(ctx *pulumi.Context, + name string, args *SomeTypeArgs, opts ...pulumi.ResourceOption) (*SomeType, error) { + if args == nil { + args = &SomeTypeArgs{} + } + + var resource SomeType + err := ctx.RegisterResource("repro:overlap:SomeType", name, args, &resource, opts...) + if err != nil { + return nil, err + } + return &resource, nil +} + +// GetSomeType gets an existing SomeType resource's state with the given name, ID, and optional +// state properties that are used to uniquely qualify the lookup (nil if not required). +func GetSomeType(ctx *pulumi.Context, + name string, id pulumi.IDInput, state *SomeTypeState, opts ...pulumi.ResourceOption) (*SomeType, error) { + var resource SomeType + err := ctx.ReadResource("repro:overlap:SomeType", name, id, state, &resource, opts...) + if err != nil { + return nil, err + } + return &resource, nil +} + +// Input properties used for looking up and filtering SomeType resources. +type someTypeState struct { +} + +type SomeTypeState struct { +} + +func (SomeTypeState) ElementType() reflect.Type { + return reflect.TypeOf((*someTypeState)(nil)).Elem() +} + +type someTypeArgs struct { +} + +// The set of arguments for constructing a SomeType resource. +type SomeTypeArgs struct { +} + +func (SomeTypeArgs) ElementType() reflect.Type { + return reflect.TypeOf((*someTypeArgs)(nil)).Elem() +} + +type SomeTypeInput interface { + pulumi.Input + + ToSomeTypeOutput() SomeTypeOutput + ToSomeTypeOutputWithContext(ctx context.Context) SomeTypeOutput +} + +func (*SomeType) ElementType() reflect.Type { + return reflect.TypeOf((**SomeType)(nil)).Elem() +} + +func (i *SomeType) ToSomeTypeOutput() SomeTypeOutput { + return i.ToSomeTypeOutputWithContext(context.Background()) +} + +func (i *SomeType) ToSomeTypeOutputWithContext(ctx context.Context) SomeTypeOutput { + return pulumi.ToOutputWithContext(ctx, i).(SomeTypeOutput) +} + +// SomeTypeArrayInput is an input type that accepts SomeTypeArray and SomeTypeArrayOutput values. +// You can construct a concrete instance of `SomeTypeArrayInput` via: +// +// SomeTypeArray{ SomeTypeArgs{...} } +type SomeTypeArrayInput interface { + pulumi.Input + + ToSomeTypeArrayOutput() SomeTypeArrayOutput + ToSomeTypeArrayOutputWithContext(context.Context) SomeTypeArrayOutput +} + +type SomeTypeArray []SomeTypeInput + +func (SomeTypeArray) ElementType() reflect.Type { + return reflect.TypeOf((*[]*SomeType)(nil)).Elem() +} + +func (i SomeTypeArray) ToSomeTypeArrayOutput() SomeTypeArrayOutput { + return i.ToSomeTypeArrayOutputWithContext(context.Background()) +} + +func (i SomeTypeArray) ToSomeTypeArrayOutputWithContext(ctx context.Context) SomeTypeArrayOutput { + return pulumi.ToOutputWithContext(ctx, i).(SomeTypeArrayOutput) +} + +// SomeTypeMapInput is an input type that accepts SomeTypeMap and SomeTypeMapOutput values. +// You can construct a concrete instance of `SomeTypeMapInput` via: +// +// SomeTypeMap{ "key": SomeTypeArgs{...} } +type SomeTypeMapInput interface { + pulumi.Input + + ToSomeTypeMapOutput() SomeTypeMapOutput + ToSomeTypeMapOutputWithContext(context.Context) SomeTypeMapOutput +} + +type SomeTypeMap map[string]SomeTypeInput + +func (SomeTypeMap) ElementType() reflect.Type { + return reflect.TypeOf((*map[string]*SomeType)(nil)).Elem() +} + +func (i SomeTypeMap) ToSomeTypeMapOutput() SomeTypeMapOutput { + return i.ToSomeTypeMapOutputWithContext(context.Background()) +} + +func (i SomeTypeMap) ToSomeTypeMapOutputWithContext(ctx context.Context) SomeTypeMapOutput { + return pulumi.ToOutputWithContext(ctx, i).(SomeTypeMapOutput) +} + +type SomeTypeOutput struct{ *pulumi.OutputState } + +func (SomeTypeOutput) ElementType() reflect.Type { + return reflect.TypeOf((**SomeType)(nil)).Elem() +} + +func (o SomeTypeOutput) ToSomeTypeOutput() SomeTypeOutput { + return o +} + +func (o SomeTypeOutput) ToSomeTypeOutputWithContext(ctx context.Context) SomeTypeOutput { + return o +} + +type SomeTypeArrayOutput struct{ *pulumi.OutputState } + +func (SomeTypeArrayOutput) ElementType() reflect.Type { + return reflect.TypeOf((*[]*SomeType)(nil)).Elem() +} + +func (o SomeTypeArrayOutput) ToSomeTypeArrayOutput() SomeTypeArrayOutput { + return o +} + +func (o SomeTypeArrayOutput) ToSomeTypeArrayOutputWithContext(ctx context.Context) SomeTypeArrayOutput { + return o +} + +func (o SomeTypeArrayOutput) Index(i pulumi.IntInput) SomeTypeOutput { + return pulumi.All(o, i).ApplyT(func(vs []interface{}) *SomeType { + return vs[0].([]*SomeType)[vs[1].(int)] + }).(SomeTypeOutput) +} + +type SomeTypeMapOutput struct{ *pulumi.OutputState } + +func (SomeTypeMapOutput) ElementType() reflect.Type { + return reflect.TypeOf((*map[string]*SomeType)(nil)).Elem() +} + +func (o SomeTypeMapOutput) ToSomeTypeMapOutput() SomeTypeMapOutput { + return o +} + +func (o SomeTypeMapOutput) ToSomeTypeMapOutputWithContext(ctx context.Context) SomeTypeMapOutput { + return o +} + +func (o SomeTypeMapOutput) MapIndex(k pulumi.StringInput) SomeTypeOutput { + return pulumi.All(o, k).ApplyT(func(vs []interface{}) *SomeType { + return vs[0].(map[string]*SomeType)[vs[1].(string)] + }).(SomeTypeOutput) +} + +func init() { + pulumi.RegisterInputType(reflect.TypeOf((*SomeTypeInput)(nil)).Elem(), &SomeType{}) + pulumi.RegisterInputType(reflect.TypeOf((*SomeTypeArrayInput)(nil)).Elem(), SomeTypeArray{}) + pulumi.RegisterInputType(reflect.TypeOf((*SomeTypeMapInput)(nil)).Elem(), SomeTypeMap{}) + pulumi.RegisterOutputType(SomeTypeOutput{}) + pulumi.RegisterOutputType(SomeTypeArrayOutput{}) + pulumi.RegisterOutputType(SomeTypeMapOutput{}) +} diff --git a/pkg/codegen/testing/test/testdata/go-nested-collections/go/repro/overlap/someTypeMap.go b/pkg/codegen/testing/test/testdata/go-nested-collections/go/repro/overlap/someTypeMap.go new file mode 100644 index 000000000000..7577e52de2c3 --- /dev/null +++ b/pkg/codegen/testing/test/testdata/go-nested-collections/go/repro/overlap/someTypeMap.go @@ -0,0 +1,196 @@ +// Code generated by test DO NOT EDIT. +// *** WARNING: Do not edit by hand unless you're certain you know what you are doing! *** + +package overlap + +import ( + "context" + "reflect" + + "github.com/pulumi/pulumi/sdk/v3/go/pulumi" +) + +type SomeTypeMapResource struct { + pulumi.CustomResourceState +} + +// NewSomeTypeMapResource registers a new resource with the given unique name, arguments, and options. +func NewSomeTypeMapResource(ctx *pulumi.Context, + name string, args *SomeTypeMapResourceArgs, opts ...pulumi.ResourceOption) (*SomeTypeMapResource, error) { + if args == nil { + args = &SomeTypeMapResourceArgs{} + } + + var resource SomeTypeMapResource + err := ctx.RegisterResource("repro:overlap:SomeTypeMap", name, args, &resource, opts...) + if err != nil { + return nil, err + } + return &resource, nil +} + +// GetSomeTypeMapResource gets an existing SomeTypeMapResource resource's state with the given name, ID, and optional +// state properties that are used to uniquely qualify the lookup (nil if not required). +func GetSomeTypeMapResource(ctx *pulumi.Context, + name string, id pulumi.IDInput, state *SomeTypeMapResourceState, opts ...pulumi.ResourceOption) (*SomeTypeMapResource, error) { + var resource SomeTypeMapResource + err := ctx.ReadResource("repro:overlap:SomeTypeMap", name, id, state, &resource, opts...) + if err != nil { + return nil, err + } + return &resource, nil +} + +// Input properties used for looking up and filtering SomeTypeMapResource resources. +type someTypeMapResourceState struct { +} + +type SomeTypeMapResourceState struct { +} + +func (SomeTypeMapResourceState) ElementType() reflect.Type { + return reflect.TypeOf((*someTypeMapResourceState)(nil)).Elem() +} + +type someTypeMapResourceArgs struct { +} + +// The set of arguments for constructing a SomeTypeMapResource resource. +type SomeTypeMapResourceArgs struct { +} + +func (SomeTypeMapResourceArgs) ElementType() reflect.Type { + return reflect.TypeOf((*someTypeMapResourceArgs)(nil)).Elem() +} + +type SomeTypeMapResourceInput interface { + pulumi.Input + + ToSomeTypeMapResourceOutput() SomeTypeMapResourceOutput + ToSomeTypeMapResourceOutputWithContext(ctx context.Context) SomeTypeMapResourceOutput +} + +func (*SomeTypeMapResource) ElementType() reflect.Type { + return reflect.TypeOf((**SomeTypeMapResource)(nil)).Elem() +} + +func (i *SomeTypeMapResource) ToSomeTypeMapResourceOutput() SomeTypeMapResourceOutput { + return i.ToSomeTypeMapResourceOutputWithContext(context.Background()) +} + +func (i *SomeTypeMapResource) ToSomeTypeMapResourceOutputWithContext(ctx context.Context) SomeTypeMapResourceOutput { + return pulumi.ToOutputWithContext(ctx, i).(SomeTypeMapResourceOutput) +} + +// SomeTypeMapResourceArrayInput is an input type that accepts SomeTypeMapResourceArray and SomeTypeMapResourceArrayOutput values. +// You can construct a concrete instance of `SomeTypeMapResourceArrayInput` via: +// +// SomeTypeMapResourceArray{ SomeTypeMapResourceArgs{...} } +type SomeTypeMapResourceArrayInput interface { + pulumi.Input + + ToSomeTypeMapResourceArrayOutput() SomeTypeMapResourceArrayOutput + ToSomeTypeMapResourceArrayOutputWithContext(context.Context) SomeTypeMapResourceArrayOutput +} + +type SomeTypeMapResourceArray []SomeTypeMapResourceInput + +func (SomeTypeMapResourceArray) ElementType() reflect.Type { + return reflect.TypeOf((*[]*SomeTypeMapResource)(nil)).Elem() +} + +func (i SomeTypeMapResourceArray) ToSomeTypeMapResourceArrayOutput() SomeTypeMapResourceArrayOutput { + return i.ToSomeTypeMapResourceArrayOutputWithContext(context.Background()) +} + +func (i SomeTypeMapResourceArray) ToSomeTypeMapResourceArrayOutputWithContext(ctx context.Context) SomeTypeMapResourceArrayOutput { + return pulumi.ToOutputWithContext(ctx, i).(SomeTypeMapResourceArrayOutput) +} + +// SomeTypeMapResourceMapInput is an input type that accepts SomeTypeMapResourceMap and SomeTypeMapResourceMapOutput values. +// You can construct a concrete instance of `SomeTypeMapResourceMapInput` via: +// +// SomeTypeMapResourceMap{ "key": SomeTypeMapResourceArgs{...} } +type SomeTypeMapResourceMapInput interface { + pulumi.Input + + ToSomeTypeMapResourceMapOutput() SomeTypeMapResourceMapOutput + ToSomeTypeMapResourceMapOutputWithContext(context.Context) SomeTypeMapResourceMapOutput +} + +type SomeTypeMapResourceMap map[string]SomeTypeMapResourceInput + +func (SomeTypeMapResourceMap) ElementType() reflect.Type { + return reflect.TypeOf((*map[string]*SomeTypeMapResource)(nil)).Elem() +} + +func (i SomeTypeMapResourceMap) ToSomeTypeMapResourceMapOutput() SomeTypeMapResourceMapOutput { + return i.ToSomeTypeMapResourceMapOutputWithContext(context.Background()) +} + +func (i SomeTypeMapResourceMap) ToSomeTypeMapResourceMapOutputWithContext(ctx context.Context) SomeTypeMapResourceMapOutput { + return pulumi.ToOutputWithContext(ctx, i).(SomeTypeMapResourceMapOutput) +} + +type SomeTypeMapResourceOutput struct{ *pulumi.OutputState } + +func (SomeTypeMapResourceOutput) ElementType() reflect.Type { + return reflect.TypeOf((**SomeTypeMapResource)(nil)).Elem() +} + +func (o SomeTypeMapResourceOutput) ToSomeTypeMapResourceOutput() SomeTypeMapResourceOutput { + return o +} + +func (o SomeTypeMapResourceOutput) ToSomeTypeMapResourceOutputWithContext(ctx context.Context) SomeTypeMapResourceOutput { + return o +} + +type SomeTypeMapResourceArrayOutput struct{ *pulumi.OutputState } + +func (SomeTypeMapResourceArrayOutput) ElementType() reflect.Type { + return reflect.TypeOf((*[]*SomeTypeMapResource)(nil)).Elem() +} + +func (o SomeTypeMapResourceArrayOutput) ToSomeTypeMapResourceArrayOutput() SomeTypeMapResourceArrayOutput { + return o +} + +func (o SomeTypeMapResourceArrayOutput) ToSomeTypeMapResourceArrayOutputWithContext(ctx context.Context) SomeTypeMapResourceArrayOutput { + return o +} + +func (o SomeTypeMapResourceArrayOutput) Index(i pulumi.IntInput) SomeTypeMapResourceOutput { + return pulumi.All(o, i).ApplyT(func(vs []interface{}) *SomeTypeMapResource { + return vs[0].([]*SomeTypeMapResource)[vs[1].(int)] + }).(SomeTypeMapResourceOutput) +} + +type SomeTypeMapResourceMapOutput struct{ *pulumi.OutputState } + +func (SomeTypeMapResourceMapOutput) ElementType() reflect.Type { + return reflect.TypeOf((*map[string]*SomeTypeMapResource)(nil)).Elem() +} + +func (o SomeTypeMapResourceMapOutput) ToSomeTypeMapResourceMapOutput() SomeTypeMapResourceMapOutput { + return o +} + +func (o SomeTypeMapResourceMapOutput) ToSomeTypeMapResourceMapOutputWithContext(ctx context.Context) SomeTypeMapResourceMapOutput { + return o +} + +func (o SomeTypeMapResourceMapOutput) MapIndex(k pulumi.StringInput) SomeTypeMapResourceOutput { + return pulumi.All(o, k).ApplyT(func(vs []interface{}) *SomeTypeMapResource { + return vs[0].(map[string]*SomeTypeMapResource)[vs[1].(string)] + }).(SomeTypeMapResourceOutput) +} + +func init() { + pulumi.RegisterInputType(reflect.TypeOf((*SomeTypeMapResourceInput)(nil)).Elem(), &SomeTypeMapResource{}) + pulumi.RegisterInputType(reflect.TypeOf((*SomeTypeMapResourceArrayInput)(nil)).Elem(), SomeTypeMapResourceArray{}) + pulumi.RegisterInputType(reflect.TypeOf((*SomeTypeMapResourceMapInput)(nil)).Elem(), SomeTypeMapResourceMap{}) + pulumi.RegisterOutputType(SomeTypeMapResourceOutput{}) + pulumi.RegisterOutputType(SomeTypeMapResourceArrayOutput{}) + pulumi.RegisterOutputType(SomeTypeMapResourceMapOutput{}) +} diff --git a/pkg/codegen/testing/test/testdata/go-nested-collections/schema.json b/pkg/codegen/testing/test/testdata/go-nested-collections/schema.json index 58dc952a6e92..6594b7e0f692 100644 --- a/pkg/codegen/testing/test/testdata/go-nested-collections/schema.json +++ b/pkg/codegen/testing/test/testdata/go-nested-collections/schema.json @@ -17,6 +17,21 @@ } } } + }, + "repro:overlap:SomeType": {}, + "repro:overlap:SomeTypeMap": {}, + "repro:overlap:Consumer": { + "inputProperties": { + "typM": { + "$ref": "#/resources/repro:overlap:SomeTypeMap" + }, + "typ": { + "type": "object", + "additionalProperties": { + "$ref": "#/resources/repro:overlap:SomeType" + } + } + } } }, "types": { @@ -30,7 +45,7 @@ "language": { "go": { "generateResourceContainerTypes": true, - "importBasePath": "go-plain-ref-repro/repro", + "importBasePath": "go-nested-collections/repro", "liftSingleValueMethodReturns": true } }