diff --git a/pkg/codegen/dotnet/gen.go b/pkg/codegen/dotnet/gen.go
index e2ab8dd01fce..47965fc51296 100644
--- a/pkg/codegen/dotnet/gen.go
+++ b/pkg/codegen/dotnet/gen.go
@@ -27,7 +27,6 @@ import (
"path"
"path/filepath"
"reflect"
- "sort"
"strconv"
"strings"
"unicode"
@@ -1304,8 +1303,6 @@ func (mod *modContext) genResource(w io.Writer, r *schema.Resource) error {
}
func (mod *modContext) genFunctionFileCode(f *schema.Function) (string, error) {
- imports := map[string]codegen.StringSet{}
- mod.getImports(f, imports)
buffer := &bytes.Buffer{}
importStrings := mod.pulumiImports()
@@ -1315,9 +1312,6 @@ func (mod *modContext) genFunctionFileCode(f *schema.Function) (string, error) {
if nonStandardNamespace {
importStrings = append(importStrings, mod.namespaceName)
}
- for _, i := range imports {
- importStrings = append(importStrings, i.SortedValues()...)
- }
// We need to qualify input types when we are not in the same module as them.
if nonStandardNamespace {
@@ -1679,128 +1673,6 @@ func (mod *modContext) pulumiImports() []string {
return pulumiImports
}
-func (mod *modContext) getTypeImports(t schema.Type, recurse bool, imports map[string]codegen.StringSet, seen codegen.Set) {
- mod.getTypeImportsForResource(t, recurse, imports, seen, nil)
-}
-
-func (mod *modContext) getTypeImportsForResource(t schema.Type, recurse bool, imports map[string]codegen.StringSet, seen codegen.Set, res *schema.Resource) {
- if seen.Has(t) {
- return
- }
- seen.Add(t)
-
- switch t := t.(type) {
- case *schema.OptionalType:
- mod.getTypeImports(t.ElementType, recurse, imports, seen)
- return
- case *schema.InputType:
- mod.getTypeImports(t.ElementType, recurse, imports, seen)
- return
- case *schema.ArrayType:
- mod.getTypeImports(t.ElementType, recurse, imports, seen)
- return
- case *schema.MapType:
- mod.getTypeImports(t.ElementType, recurse, imports, seen)
- return
- case *schema.ObjectType:
- for _, p := range t.Properties {
- mod.getTypeImports(p.Type, recurse, imports, seen)
- }
- return
- case *schema.ResourceType:
- // If it's an external resource, we'll be using fully-qualified type names, so there's no need
- // for an import.
- if t.Resource != nil && !codegen.PkgEquals(t.Resource.PackageReference, mod.pkg) {
- return
- }
-
- // Don't import itself.
- if t.Resource == res {
- return
- }
-
- modName, name, modPath := mod.pkg.TokenToModule(t.Token), tokenToName(t.Token), ""
- if modName != mod.mod {
- mp, err := filepath.Rel(mod.mod, modName)
- contract.Assert(err == nil)
- if path.Base(mp) == "." {
- mp = path.Dir(mp)
- }
- modPath = filepath.ToSlash(mp)
- }
- if len(modPath) == 0 {
- return
- }
- if imports[modPath] == nil {
- imports[modPath] = codegen.NewStringSet()
- }
- imports[modPath].Add(name)
- return
- case *schema.TokenType:
- return
- case *schema.UnionType:
- for _, e := range t.ElementTypes {
- mod.getTypeImports(e, recurse, imports, seen)
- }
- return
- default:
- return
- }
-}
-
-func (mod *modContext) getImports(member interface{}, imports map[string]codegen.StringSet) {
- mod.getImportsForResource(member, imports, nil)
-}
-
-func (mod *modContext) getImportsForResource(member interface{}, imports map[string]codegen.StringSet, res *schema.Resource) {
- seen := codegen.Set{}
- switch member := member.(type) {
- case *schema.ObjectType:
- for _, p := range member.Properties {
- mod.getTypeImports(p.Type, true, imports, seen)
- }
- return
- case *schema.ResourceType:
- mod.getTypeImports(member, true, imports, seen)
- return
- case *schema.Resource:
- for _, p := range member.Properties {
- mod.getTypeImportsForResource(p.Type, false, imports, seen, res)
- }
- for _, p := range member.InputProperties {
- mod.getTypeImportsForResource(p.Type, false, imports, seen, res)
- }
- for _, method := range member.Methods {
- if method.Function.Inputs != nil {
- for _, p := range method.Function.Inputs.Properties {
- mod.getTypeImportsForResource(p.Type, false, imports, seen, res)
- }
- }
- if method.Function.Outputs != nil {
- for _, p := range method.Function.Outputs.Properties {
- mod.getTypeImportsForResource(p.Type, false, imports, seen, res)
- }
- }
- }
- return
- case *schema.Function:
- if member.Inputs != nil {
- mod.getTypeImports(member.Inputs, false, imports, seen)
- }
- if member.Outputs != nil {
- mod.getTypeImports(member.Outputs, false, imports, seen)
- }
- return
- case []*schema.Property:
- for _, p := range member {
- mod.getTypeImports(p.Type, false, imports, seen)
- }
- return
- default:
- return
- }
-}
-
func (mod *modContext) genHeader(w io.Writer, using []string) {
fmt.Fprintf(w, "// *** WARNING: this file was generated by %v. ***\n", mod.tool)
fmt.Fprintf(w, "// *** Do not edit by hand unless you're certain you know what you are doing! ***\n")
@@ -2045,17 +1917,8 @@ func (mod *modContext) gen(fs codegen.Fs) error {
continue
}
- imports := map[string]codegen.StringSet{}
- mod.getImportsForResource(r, imports, r)
-
buffer := &bytes.Buffer{}
- var additionalImports []string
- for _, i := range imports {
- additionalImports = append(additionalImports, i.SortedValues()...)
- }
- sort.Strings(additionalImports)
importStrings := mod.pulumiImports()
- importStrings = append(importStrings, additionalImports...)
mod.genHeader(buffer, importStrings)
if err := mod.genResource(buffer, r); err != nil {
diff --git a/pkg/codegen/testing/test/sdk_driver.go b/pkg/codegen/testing/test/sdk_driver.go
index 398563c5ae96..ee31e0530a40 100644
--- a/pkg/codegen/testing/test/sdk_driver.go
+++ b/pkg/codegen/testing/test/sdk_driver.go
@@ -84,7 +84,7 @@ var allLanguages = codegen.NewStringSet("python/any", "nodejs/any", "dotnet/any"
var PulumiPulumiSDKTests = []*SDKTest{
{
Directory: "naming-collisions",
- Description: "Schema with types that could potentially produce collisions (go).",
+ Description: "Schema with types that could potentially produce collisions.",
},
{
Directory: "dash-named-schema",
diff --git a/pkg/codegen/testing/test/testdata/naming-collisions/docs/_index.md b/pkg/codegen/testing/test/testdata/naming-collisions/docs/_index.md
index 164eea971dd0..1805a60c7b23 100644
--- a/pkg/codegen/testing/test/testdata/naming-collisions/docs/_index.md
+++ b/pkg/codegen/testing/test/testdata/naming-collisions/docs/_index.md
@@ -1,6 +1,6 @@
---
title: "example"
-title_tag: "example.example"
+title_tag: "example Package"
meta_desc: ""
layout: api
no_edit_this_page: true
@@ -11,8 +11,14 @@ no_edit_this_page: true
+
Modules
+
+
Resources
+ - MainComponent
- Provider
- Resource
- ResourceInput
diff --git a/pkg/codegen/testing/test/testdata/naming-collisions/docs/codegen-manifest.json b/pkg/codegen/testing/test/testdata/naming-collisions/docs/codegen-manifest.json
index 8f38aed747b4..06272297720a 100644
--- a/pkg/codegen/testing/test/testdata/naming-collisions/docs/codegen-manifest.json
+++ b/pkg/codegen/testing/test/testdata/naming-collisions/docs/codegen-manifest.json
@@ -1,6 +1,10 @@
{
"emittedFiles": [
"_index.md",
+ "maincomponent/_index.md",
+ "mod/_index.md",
+ "mod/component/_index.md",
+ "mod/component2/_index.md",
"provider/_index.md",
"resource/_index.md",
"resourceinput/_index.md"
diff --git a/pkg/codegen/testing/test/testdata/naming-collisions/docs/maincomponent/_index.md b/pkg/codegen/testing/test/testdata/naming-collisions/docs/maincomponent/_index.md
new file mode 100644
index 000000000000..3db224a80cc0
--- /dev/null
+++ b/pkg/codegen/testing/test/testdata/naming-collisions/docs/maincomponent/_index.md
@@ -0,0 +1,366 @@
+
+---
+title: "MainComponent"
+title_tag: "example.MainComponent"
+meta_desc: "Documentation for the example.MainComponent resource with examples, input properties, output properties, lookup functions, and supporting types."
+layout: api
+no_edit_this_page: true
+---
+
+
+
+
+
+
+
+
+
+## Create MainComponent Resource {#create}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+type: example:MainComponent
+properties: # The arguments to resource properties.
+options: # Bag of options to control resource's behavior.
+
+
+
+
+
+
+
+
+-
+ name
+
+ string
+
+ - The unique name of the resource.
-
+ args
+
+ MainComponentArgs
+
+ - The arguments to resource properties.
-
+ opts
+
+ CustomResourceOptions
+
+ - Bag of options to control resource's behavior.
+
+
+
+
+
+
+
+-
+ resource_name
+
+ str
+
+ - The unique name of the resource.
-
+ args
+
+ MainComponentArgs
+
+ - The arguments to resource properties.
-
+ opts
+
+ ResourceOptions
+
+ - Bag of options to control resource's behavior.
+
+
+
+
+
+
+
+-
+ ctx
+
+ Context
+
+ - Context object for the current deployment.
-
+ name
+
+ string
+
+ - The unique name of the resource.
-
+ args
+
+ MainComponentArgs
+
+ - The arguments to resource properties.
-
+ opts
+
+ ResourceOption
+
+ - Bag of options to control resource's behavior.
+
+
+
+
+
+
+
+-
+ name
+
+ string
+
+ - The unique name of the resource.
-
+ args
+
+ MainComponentArgs
+
+ - The arguments to resource properties.
-
+ opts
+
+ CustomResourceOptions
+
+ - Bag of options to control resource's behavior.
+
+
+
+
+
+
+
+-
+ name
+
+ String
+
+ - The unique name of the resource.
-
+ args
+
+ MainComponentArgs
+
+ - The arguments to resource properties.
-
+ options
+
+ CustomResourceOptions
+
+ - Bag of options to control resource's behavior.
+
+
+
+
+## MainComponent Resource Properties {#properties}
+
+To learn more about resource properties and how to use them, see [Inputs and Outputs](/docs/intro/concepts/inputs-outputs) in the Architecture and Concepts docs.
+
+### Inputs
+
+The MainComponent resource accepts the following [input](/docs/intro/concepts/inputs-outputs) properties:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+### Outputs
+
+All [input](#inputs) properties are implicitly available as output properties. Additionally, the MainComponent resource produces the following output properties:
+
+
+
+
+
+-
+
+Id
+
+
+ string
+
+ The provider-assigned unique ID for this managed resource.
+
+
+
+
+
+
+-
+
+Id
+
+
+ string
+
+ The provider-assigned unique ID for this managed resource.
+
+
+
+
+
+
+-
+
+id
+
+
+ String
+
+ The provider-assigned unique ID for this managed resource.
+
+
+
+
+
+
+-
+
+id
+
+
+ string
+
+ The provider-assigned unique ID for this managed resource.
+
+
+
+
+
+
+-
+
+id
+
+
+ str
+
+ The provider-assigned unique ID for this managed resource.
+
+
+
+
+
+
+-
+
+id
+
+
+ String
+
+ The provider-assigned unique ID for this managed resource.
+
+
+
+
+
+
+
+
+
+
+
+Package Details
+
+ - Repository
+
+ - License
+
+
+
diff --git a/pkg/codegen/testing/test/testdata/naming-collisions/docs/mod/_index.md b/pkg/codegen/testing/test/testdata/naming-collisions/docs/mod/_index.md
new file mode 100644
index 000000000000..8538946db9ea
--- /dev/null
+++ b/pkg/codegen/testing/test/testdata/naming-collisions/docs/mod/_index.md
@@ -0,0 +1,29 @@
+---
+title: "mod"
+title_tag: "example.mod"
+meta_desc: "Explore the resources and functions of the example.mod module."
+layout: api
+no_edit_this_page: true
+---
+
+
+
+
+Explore the resources and functions of the example.mod module.
+
+Resources
+
+
+Package Details
+
+ - Repository
+
+ - License
+
+ - Version
+ - 0.0.1
+
+
diff --git a/pkg/codegen/testing/test/testdata/naming-collisions/docs/mod/component/_index.md b/pkg/codegen/testing/test/testdata/naming-collisions/docs/mod/component/_index.md
new file mode 100644
index 000000000000..83affe1480d4
--- /dev/null
+++ b/pkg/codegen/testing/test/testdata/naming-collisions/docs/mod/component/_index.md
@@ -0,0 +1,464 @@
+
+---
+title: "Component"
+title_tag: "example.mod.Component"
+meta_desc: "Documentation for the example.mod.Component resource with examples, input properties, output properties, lookup functions, and supporting types."
+layout: api
+no_edit_this_page: true
+---
+
+
+
+
+
+
+
+
+
+## Create Component Resource {#create}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+public Component(String name, ComponentArgs args)
+public Component(String name, ComponentArgs args, CustomResourceOptions options)
+
+
+
+
+
+
+type: example:mod:Component
+properties: # The arguments to resource properties.
+options: # Bag of options to control resource's behavior.
+
+
+
+
+
+
+
+
+-
+ name
+
+ string
+
+ - The unique name of the resource.
-
+ args
+
+ ComponentArgs
+
+ - The arguments to resource properties.
-
+ opts
+
+ CustomResourceOptions
+
+ - Bag of options to control resource's behavior.
+
+
+
+
+
+
+
+-
+ resource_name
+
+ str
+
+ - The unique name of the resource.
-
+ args
+
+ ComponentArgs
+
+ - The arguments to resource properties.
-
+ opts
+
+ ResourceOptions
+
+ - Bag of options to control resource's behavior.
+
+
+
+
+
+
+
+-
+ ctx
+
+ Context
+
+ - Context object for the current deployment.
-
+ name
+
+ string
+
+ - The unique name of the resource.
-
+ args
+
+ ComponentArgs
+
+ - The arguments to resource properties.
-
+ opts
+
+ ResourceOption
+
+ - Bag of options to control resource's behavior.
+
+
+
+
+
+
+
+-
+ name
+
+ string
+
+ - The unique name of the resource.
-
+ args
+
+ ComponentArgs
+
+ - The arguments to resource properties.
-
+ opts
+
+ CustomResourceOptions
+
+ - Bag of options to control resource's behavior.
+
+
+
+
+
+
+
+-
+ name
+
+ String
+
+ - The unique name of the resource.
-
+ args
+
+ ComponentArgs
+
+ - The arguments to resource properties.
-
+ options
+
+ CustomResourceOptions
+
+ - Bag of options to control resource's behavior.
+
+
+
+
+## Component Resource Properties {#properties}
+
+To learn more about resource properties and how to use them, see [Inputs and Outputs](/docs/intro/concepts/inputs-outputs) in the Architecture and Concepts docs.
+
+### Inputs
+
+The Component resource accepts the following [input](/docs/intro/concepts/inputs-outputs) properties:
+
+
+
+
+
+-
+
+Local
+
+
+ Pulumi.Example.Mod.Component2
+
+ -
+
+Main
+
+
+ Pulumi.Example.MainComponent
+
+
+
+
+
+
+
+-
+
+Local
+
+
+ Component2
+
+ -
+
+Main
+
+
+ MainComponent
+
+
+
+
+
+
+
+-
+
+local
+
+
+ Component2
+
+ -
+
+main
+
+
+ MainComponent
+
+
+
+
+
+
+
+-
+
+local
+
+
+ Component2
+
+ -
+
+main
+
+
+ MainComponent
+
+
+
+
+
+
+
+-
+
+local
+
+
+ Component2
+
+ -
+
+main
+
+
+ MainComponent
+
+
+
+
+
+
+
+-
+
+local
+
+
+ example::Component2
+
+ -
+
+main
+
+
+ example:MainComponent
+
+
+
+
+
+
+### Outputs
+
+All [input](#inputs) properties are implicitly available as output properties. Additionally, the Component resource produces the following output properties:
+
+
+
+
+
+-
+
+Id
+
+
+ string
+
+ The provider-assigned unique ID for this managed resource.
+
+
+
+
+
+
+-
+
+Id
+
+
+ string
+
+ The provider-assigned unique ID for this managed resource.
+
+
+
+
+
+
+-
+
+id
+
+
+ String
+
+ The provider-assigned unique ID for this managed resource.
+
+
+
+
+
+
+-
+
+id
+
+
+ string
+
+ The provider-assigned unique ID for this managed resource.
+
+
+
+
+
+
+-
+
+id
+
+
+ str
+
+ The provider-assigned unique ID for this managed resource.
+
+
+
+
+
+
+-
+
+id
+
+
+ String
+
+ The provider-assigned unique ID for this managed resource.
+
+
+
+
+
+
+
+
+
+
+
+Package Details
+
+ - Repository
+
+ - License
+
+
+
diff --git a/pkg/codegen/testing/test/testdata/naming-collisions/docs/mod/component2/_index.md b/pkg/codegen/testing/test/testdata/naming-collisions/docs/mod/component2/_index.md
new file mode 100644
index 000000000000..dc6ff8de1e9f
--- /dev/null
+++ b/pkg/codegen/testing/test/testdata/naming-collisions/docs/mod/component2/_index.md
@@ -0,0 +1,366 @@
+
+---
+title: "Component2"
+title_tag: "example.mod.Component2"
+meta_desc: "Documentation for the example.mod.Component2 resource with examples, input properties, output properties, lookup functions, and supporting types."
+layout: api
+no_edit_this_page: true
+---
+
+
+
+
+
+
+
+
+
+## Create Component2 Resource {#create}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+type: example:mod:Component2
+properties: # The arguments to resource properties.
+options: # Bag of options to control resource's behavior.
+
+
+
+
+
+
+
+
+-
+ name
+
+ string
+
+ - The unique name of the resource.
-
+ args
+
+ Component2Args
+
+ - The arguments to resource properties.
-
+ opts
+
+ CustomResourceOptions
+
+ - Bag of options to control resource's behavior.
+
+
+
+
+
+
+
+-
+ resource_name
+
+ str
+
+ - The unique name of the resource.
-
+ args
+
+ Component2Args
+
+ - The arguments to resource properties.
-
+ opts
+
+ ResourceOptions
+
+ - Bag of options to control resource's behavior.
+
+
+
+
+
+
+
+-
+ ctx
+
+ Context
+
+ - Context object for the current deployment.
-
+ name
+
+ string
+
+ - The unique name of the resource.
-
+ args
+
+ Component2Args
+
+ - The arguments to resource properties.
-
+ opts
+
+ ResourceOption
+
+ - Bag of options to control resource's behavior.
+
+
+
+
+
+
+
+-
+ name
+
+ string
+
+ - The unique name of the resource.
-
+ args
+
+ Component2Args
+
+ - The arguments to resource properties.
-
+ opts
+
+ CustomResourceOptions
+
+ - Bag of options to control resource's behavior.
+
+
+
+
+
+
+
+-
+ name
+
+ String
+
+ - The unique name of the resource.
-
+ args
+
+ Component2Args
+
+ - The arguments to resource properties.
-
+ options
+
+ CustomResourceOptions
+
+ - Bag of options to control resource's behavior.
+
+
+
+
+## Component2 Resource Properties {#properties}
+
+To learn more about resource properties and how to use them, see [Inputs and Outputs](/docs/intro/concepts/inputs-outputs) in the Architecture and Concepts docs.
+
+### Inputs
+
+The Component2 resource accepts the following [input](/docs/intro/concepts/inputs-outputs) properties:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+### Outputs
+
+All [input](#inputs) properties are implicitly available as output properties. Additionally, the Component2 resource produces the following output properties:
+
+
+
+
+
+-
+
+Id
+
+
+ string
+
+ The provider-assigned unique ID for this managed resource.
+
+
+
+
+
+
+-
+
+Id
+
+
+ string
+
+ The provider-assigned unique ID for this managed resource.
+
+
+
+
+
+
+-
+
+id
+
+
+ String
+
+ The provider-assigned unique ID for this managed resource.
+
+
+
+
+
+
+-
+
+id
+
+
+ string
+
+ The provider-assigned unique ID for this managed resource.
+
+
+
+
+
+
+-
+
+id
+
+
+ str
+
+ The provider-assigned unique ID for this managed resource.
+
+
+
+
+
+
+-
+
+id
+
+
+ String
+
+ The provider-assigned unique ID for this managed resource.
+
+
+
+
+
+
+
+
+
+
+
+Package Details
+
+ - Repository
+
+ - License
+
+
+
diff --git a/pkg/codegen/testing/test/testdata/naming-collisions/dotnet/MainComponent.cs b/pkg/codegen/testing/test/testdata/naming-collisions/dotnet/MainComponent.cs
new file mode 100644
index 000000000000..3e8cfe27fec9
--- /dev/null
+++ b/pkg/codegen/testing/test/testdata/naming-collisions/dotnet/MainComponent.cs
@@ -0,0 +1,64 @@
+// *** WARNING: this file was generated by test. ***
+// *** Do not edit by hand unless you're certain you know what you are doing! ***
+
+using System;
+using System.Collections.Generic;
+using System.Collections.Immutable;
+using System.Threading.Tasks;
+using Pulumi.Serialization;
+
+namespace Pulumi.Example
+{
+ [ExampleResourceType("example::MainComponent")]
+ public partial class MainComponent : global::Pulumi.CustomResource
+ {
+ ///
+ /// Create a MainComponent resource with the given unique name, arguments, and options.
+ ///
+ ///
+ /// The unique name of the resource
+ /// The arguments used to populate this resource's properties
+ /// A bag of options that control this resource's behavior
+ public MainComponent(string name, MainComponentArgs? args = null, CustomResourceOptions? options = null)
+ : base("example::MainComponent", name, args ?? new MainComponentArgs(), MakeResourceOptions(options, ""))
+ {
+ }
+
+ private MainComponent(string name, Input id, CustomResourceOptions? options = null)
+ : base("example::MainComponent", name, null, MakeResourceOptions(options, id))
+ {
+ }
+
+ private static CustomResourceOptions MakeResourceOptions(CustomResourceOptions? options, Input? id)
+ {
+ var defaultOptions = new CustomResourceOptions
+ {
+ Version = Utilities.Version,
+ };
+ var merged = CustomResourceOptions.Merge(defaultOptions, options);
+ // Override the ID if one was specified for consistency with other language SDKs.
+ merged.Id = id ?? merged.Id;
+ return merged;
+ }
+ ///
+ /// Get an existing MainComponent resource's state with the given name, ID, and optional extra
+ /// properties used to qualify the lookup.
+ ///
+ ///
+ /// The unique name of the resulting resource.
+ /// The unique provider ID of the resource to lookup.
+ /// A bag of options that control this resource's behavior
+ public static MainComponent Get(string name, Input id, CustomResourceOptions? options = null)
+ {
+ return new MainComponent(name, id, options);
+ }
+ }
+
+ public sealed class MainComponentArgs : global::Pulumi.ResourceArgs
+ {
+ public MainComponentArgs()
+ {
+ }
+ public static new MainComponentArgs Empty => new MainComponentArgs();
+ }
+}
diff --git a/pkg/codegen/testing/test/testdata/naming-collisions/dotnet/Mod/Component.cs b/pkg/codegen/testing/test/testdata/naming-collisions/dotnet/Mod/Component.cs
new file mode 100644
index 000000000000..cbc5b0458082
--- /dev/null
+++ b/pkg/codegen/testing/test/testdata/naming-collisions/dotnet/Mod/Component.cs
@@ -0,0 +1,70 @@
+// *** WARNING: this file was generated by test. ***
+// *** Do not edit by hand unless you're certain you know what you are doing! ***
+
+using System;
+using System.Collections.Generic;
+using System.Collections.Immutable;
+using System.Threading.Tasks;
+using Pulumi.Serialization;
+
+namespace Pulumi.Example.Mod
+{
+ [ExampleResourceType("example:mod:Component")]
+ public partial class Component : global::Pulumi.CustomResource
+ {
+ ///
+ /// Create a Component resource with the given unique name, arguments, and options.
+ ///
+ ///
+ /// The unique name of the resource
+ /// The arguments used to populate this resource's properties
+ /// A bag of options that control this resource's behavior
+ public Component(string name, ComponentArgs? args = null, CustomResourceOptions? options = null)
+ : base("example:mod:Component", name, args ?? new ComponentArgs(), MakeResourceOptions(options, ""))
+ {
+ }
+
+ private Component(string name, Input id, CustomResourceOptions? options = null)
+ : base("example:mod:Component", name, null, MakeResourceOptions(options, id))
+ {
+ }
+
+ private static CustomResourceOptions MakeResourceOptions(CustomResourceOptions? options, Input? id)
+ {
+ var defaultOptions = new CustomResourceOptions
+ {
+ Version = Utilities.Version,
+ };
+ var merged = CustomResourceOptions.Merge(defaultOptions, options);
+ // Override the ID if one was specified for consistency with other language SDKs.
+ merged.Id = id ?? merged.Id;
+ return merged;
+ }
+ ///
+ /// Get an existing Component resource's state with the given name, ID, and optional extra
+ /// properties used to qualify the lookup.
+ ///
+ ///
+ /// The unique name of the resulting resource.
+ /// The unique provider ID of the resource to lookup.
+ /// A bag of options that control this resource's behavior
+ public static Component Get(string name, Input id, CustomResourceOptions? options = null)
+ {
+ return new Component(name, id, options);
+ }
+ }
+
+ public sealed class ComponentArgs : global::Pulumi.ResourceArgs
+ {
+ [Input("local")]
+ public Input? Local { get; set; }
+
+ [Input("main")]
+ public Input? Main { get; set; }
+
+ public ComponentArgs()
+ {
+ }
+ public static new ComponentArgs Empty => new ComponentArgs();
+ }
+}
diff --git a/pkg/codegen/testing/test/testdata/naming-collisions/dotnet/Mod/Component2.cs b/pkg/codegen/testing/test/testdata/naming-collisions/dotnet/Mod/Component2.cs
new file mode 100644
index 000000000000..9eeb2ea30909
--- /dev/null
+++ b/pkg/codegen/testing/test/testdata/naming-collisions/dotnet/Mod/Component2.cs
@@ -0,0 +1,64 @@
+// *** WARNING: this file was generated by test. ***
+// *** Do not edit by hand unless you're certain you know what you are doing! ***
+
+using System;
+using System.Collections.Generic;
+using System.Collections.Immutable;
+using System.Threading.Tasks;
+using Pulumi.Serialization;
+
+namespace Pulumi.Example.Mod
+{
+ [ExampleResourceType("example:mod:Component2")]
+ public partial class Component2 : global::Pulumi.CustomResource
+ {
+ ///
+ /// Create a Component2 resource with the given unique name, arguments, and options.
+ ///
+ ///
+ /// The unique name of the resource
+ /// The arguments used to populate this resource's properties
+ /// A bag of options that control this resource's behavior
+ public Component2(string name, Component2Args? args = null, CustomResourceOptions? options = null)
+ : base("example:mod:Component2", name, args ?? new Component2Args(), MakeResourceOptions(options, ""))
+ {
+ }
+
+ private Component2(string name, Input id, CustomResourceOptions? options = null)
+ : base("example:mod:Component2", name, null, MakeResourceOptions(options, id))
+ {
+ }
+
+ private static CustomResourceOptions MakeResourceOptions(CustomResourceOptions? options, Input? id)
+ {
+ var defaultOptions = new CustomResourceOptions
+ {
+ Version = Utilities.Version,
+ };
+ var merged = CustomResourceOptions.Merge(defaultOptions, options);
+ // Override the ID if one was specified for consistency with other language SDKs.
+ merged.Id = id ?? merged.Id;
+ return merged;
+ }
+ ///
+ /// Get an existing Component2 resource's state with the given name, ID, and optional extra
+ /// properties used to qualify the lookup.
+ ///
+ ///
+ /// The unique name of the resulting resource.
+ /// The unique provider ID of the resource to lookup.
+ /// A bag of options that control this resource's behavior
+ public static Component2 Get(string name, Input id, CustomResourceOptions? options = null)
+ {
+ return new Component2(name, id, options);
+ }
+ }
+
+ public sealed class Component2Args : global::Pulumi.ResourceArgs
+ {
+ public Component2Args()
+ {
+ }
+ public static new Component2Args Empty => new Component2Args();
+ }
+}
diff --git a/pkg/codegen/testing/test/testdata/naming-collisions/dotnet/Mod/README.md b/pkg/codegen/testing/test/testdata/naming-collisions/dotnet/Mod/README.md
new file mode 100644
index 000000000000..e69de29bb2d1
diff --git a/pkg/codegen/testing/test/testdata/naming-collisions/dotnet/codegen-manifest.json b/pkg/codegen/testing/test/testdata/naming-collisions/dotnet/codegen-manifest.json
index 1518ba188758..0a5b5b680de2 100644
--- a/pkg/codegen/testing/test/testdata/naming-collisions/dotnet/codegen-manifest.json
+++ b/pkg/codegen/testing/test/testdata/naming-collisions/dotnet/codegen-manifest.json
@@ -1,6 +1,10 @@
{
"emittedFiles": [
"Enums.cs",
+ "MainComponent.cs",
+ "Mod/Component.cs",
+ "Mod/Component2.cs",
+ "Mod/README.md",
"Provider.cs",
"Pulumi.Example.csproj",
"README.md",
diff --git a/pkg/codegen/testing/test/testdata/naming-collisions/go/codegen-manifest.json b/pkg/codegen/testing/test/testdata/naming-collisions/go/codegen-manifest.json
index 265b5ccfe435..b92de6f0e9ab 100644
--- a/pkg/codegen/testing/test/testdata/naming-collisions/go/codegen-manifest.json
+++ b/pkg/codegen/testing/test/testdata/naming-collisions/go/codegen-manifest.json
@@ -2,6 +2,10 @@
"emittedFiles": [
"example/doc.go",
"example/init.go",
+ "example/mainComponent.go",
+ "example/mod/component.go",
+ "example/mod/component2.go",
+ "example/mod/init.go",
"example/provider.go",
"example/pulumi-plugin.json",
"example/pulumiEnums.go",
diff --git a/pkg/codegen/testing/test/testdata/naming-collisions/go/example/init.go b/pkg/codegen/testing/test/testdata/naming-collisions/go/example/init.go
index 718b035d0a1f..f2c78c82eb99 100644
--- a/pkg/codegen/testing/test/testdata/naming-collisions/go/example/init.go
+++ b/pkg/codegen/testing/test/testdata/naming-collisions/go/example/init.go
@@ -20,6 +20,8 @@ func (m *module) Version() semver.Version {
func (m *module) Construct(ctx *pulumi.Context, name, typ, urn string) (r pulumi.Resource, err error) {
switch typ {
+ case "example::MainComponent":
+ r = &MainComponent{}
case "example::Resource":
r = &Resource{}
case "example::ResourceInput":
diff --git a/pkg/codegen/testing/test/testdata/naming-collisions/go/example/mainComponent.go b/pkg/codegen/testing/test/testdata/naming-collisions/go/example/mainComponent.go
new file mode 100644
index 000000000000..08092beb6752
--- /dev/null
+++ b/pkg/codegen/testing/test/testdata/naming-collisions/go/example/mainComponent.go
@@ -0,0 +1,102 @@
+// Code generated by test DO NOT EDIT.
+// *** WARNING: Do not edit by hand unless you're certain you know what you are doing! ***
+
+package example
+
+import (
+ "context"
+ "reflect"
+
+ "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
+)
+
+type MainComponent struct {
+ pulumi.CustomResourceState
+}
+
+// NewMainComponent registers a new resource with the given unique name, arguments, and options.
+func NewMainComponent(ctx *pulumi.Context,
+ name string, args *MainComponentArgs, opts ...pulumi.ResourceOption) (*MainComponent, error) {
+ if args == nil {
+ args = &MainComponentArgs{}
+ }
+
+ var resource MainComponent
+ err := ctx.RegisterResource("example::MainComponent", name, args, &resource, opts...)
+ if err != nil {
+ return nil, err
+ }
+ return &resource, nil
+}
+
+// GetMainComponent gets an existing MainComponent 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 GetMainComponent(ctx *pulumi.Context,
+ name string, id pulumi.IDInput, state *MainComponentState, opts ...pulumi.ResourceOption) (*MainComponent, error) {
+ var resource MainComponent
+ err := ctx.ReadResource("example::MainComponent", name, id, state, &resource, opts...)
+ if err != nil {
+ return nil, err
+ }
+ return &resource, nil
+}
+
+// Input properties used for looking up and filtering MainComponent resources.
+type mainComponentState struct {
+}
+
+type MainComponentState struct {
+}
+
+func (MainComponentState) ElementType() reflect.Type {
+ return reflect.TypeOf((*mainComponentState)(nil)).Elem()
+}
+
+type mainComponentArgs struct {
+}
+
+// The set of arguments for constructing a MainComponent resource.
+type MainComponentArgs struct {
+}
+
+func (MainComponentArgs) ElementType() reflect.Type {
+ return reflect.TypeOf((*mainComponentArgs)(nil)).Elem()
+}
+
+type MainComponentInput interface {
+ pulumi.Input
+
+ ToMainComponentOutput() MainComponentOutput
+ ToMainComponentOutputWithContext(ctx context.Context) MainComponentOutput
+}
+
+func (*MainComponent) ElementType() reflect.Type {
+ return reflect.TypeOf((**MainComponent)(nil)).Elem()
+}
+
+func (i *MainComponent) ToMainComponentOutput() MainComponentOutput {
+ return i.ToMainComponentOutputWithContext(context.Background())
+}
+
+func (i *MainComponent) ToMainComponentOutputWithContext(ctx context.Context) MainComponentOutput {
+ return pulumi.ToOutputWithContext(ctx, i).(MainComponentOutput)
+}
+
+type MainComponentOutput struct{ *pulumi.OutputState }
+
+func (MainComponentOutput) ElementType() reflect.Type {
+ return reflect.TypeOf((**MainComponent)(nil)).Elem()
+}
+
+func (o MainComponentOutput) ToMainComponentOutput() MainComponentOutput {
+ return o
+}
+
+func (o MainComponentOutput) ToMainComponentOutputWithContext(ctx context.Context) MainComponentOutput {
+ return o
+}
+
+func init() {
+ pulumi.RegisterInputType(reflect.TypeOf((*MainComponentInput)(nil)).Elem(), &MainComponent{})
+ pulumi.RegisterOutputType(MainComponentOutput{})
+}
diff --git a/pkg/codegen/testing/test/testdata/naming-collisions/go/example/mod/component.go b/pkg/codegen/testing/test/testdata/naming-collisions/go/example/mod/component.go
new file mode 100644
index 000000000000..ad5677ea10e8
--- /dev/null
+++ b/pkg/codegen/testing/test/testdata/naming-collisions/go/example/mod/component.go
@@ -0,0 +1,107 @@
+// Code generated by test DO NOT EDIT.
+// *** WARNING: Do not edit by hand unless you're certain you know what you are doing! ***
+
+package mod
+
+import (
+ "context"
+ "reflect"
+
+ "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
+ "naming-collisions/example"
+)
+
+type Component struct {
+ pulumi.CustomResourceState
+}
+
+// NewComponent registers a new resource with the given unique name, arguments, and options.
+func NewComponent(ctx *pulumi.Context,
+ name string, args *ComponentArgs, opts ...pulumi.ResourceOption) (*Component, error) {
+ if args == nil {
+ args = &ComponentArgs{}
+ }
+
+ var resource Component
+ err := ctx.RegisterResource("example:mod:Component", name, args, &resource, opts...)
+ if err != nil {
+ return nil, err
+ }
+ return &resource, nil
+}
+
+// GetComponent gets an existing Component 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 GetComponent(ctx *pulumi.Context,
+ name string, id pulumi.IDInput, state *ComponentState, opts ...pulumi.ResourceOption) (*Component, error) {
+ var resource Component
+ err := ctx.ReadResource("example:mod:Component", name, id, state, &resource, opts...)
+ if err != nil {
+ return nil, err
+ }
+ return &resource, nil
+}
+
+// Input properties used for looking up and filtering Component resources.
+type componentState struct {
+}
+
+type ComponentState struct {
+}
+
+func (ComponentState) ElementType() reflect.Type {
+ return reflect.TypeOf((*componentState)(nil)).Elem()
+}
+
+type componentArgs struct {
+ Local *Component2 `pulumi:"local"`
+ Main *example.MainComponent `pulumi:"main"`
+}
+
+// The set of arguments for constructing a Component resource.
+type ComponentArgs struct {
+ Local Component2Input
+ Main example.MainComponentInput
+}
+
+func (ComponentArgs) ElementType() reflect.Type {
+ return reflect.TypeOf((*componentArgs)(nil)).Elem()
+}
+
+type ComponentInput interface {
+ pulumi.Input
+
+ ToComponentOutput() ComponentOutput
+ ToComponentOutputWithContext(ctx context.Context) ComponentOutput
+}
+
+func (*Component) ElementType() reflect.Type {
+ return reflect.TypeOf((**Component)(nil)).Elem()
+}
+
+func (i *Component) ToComponentOutput() ComponentOutput {
+ return i.ToComponentOutputWithContext(context.Background())
+}
+
+func (i *Component) ToComponentOutputWithContext(ctx context.Context) ComponentOutput {
+ return pulumi.ToOutputWithContext(ctx, i).(ComponentOutput)
+}
+
+type ComponentOutput struct{ *pulumi.OutputState }
+
+func (ComponentOutput) ElementType() reflect.Type {
+ return reflect.TypeOf((**Component)(nil)).Elem()
+}
+
+func (o ComponentOutput) ToComponentOutput() ComponentOutput {
+ return o
+}
+
+func (o ComponentOutput) ToComponentOutputWithContext(ctx context.Context) ComponentOutput {
+ return o
+}
+
+func init() {
+ pulumi.RegisterInputType(reflect.TypeOf((*ComponentInput)(nil)).Elem(), &Component{})
+ pulumi.RegisterOutputType(ComponentOutput{})
+}
diff --git a/pkg/codegen/testing/test/testdata/naming-collisions/go/example/mod/component2.go b/pkg/codegen/testing/test/testdata/naming-collisions/go/example/mod/component2.go
new file mode 100644
index 000000000000..d021635682b2
--- /dev/null
+++ b/pkg/codegen/testing/test/testdata/naming-collisions/go/example/mod/component2.go
@@ -0,0 +1,102 @@
+// Code generated by test DO NOT EDIT.
+// *** WARNING: Do not edit by hand unless you're certain you know what you are doing! ***
+
+package mod
+
+import (
+ "context"
+ "reflect"
+
+ "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
+)
+
+type Component2 struct {
+ pulumi.CustomResourceState
+}
+
+// NewComponent2 registers a new resource with the given unique name, arguments, and options.
+func NewComponent2(ctx *pulumi.Context,
+ name string, args *Component2Args, opts ...pulumi.ResourceOption) (*Component2, error) {
+ if args == nil {
+ args = &Component2Args{}
+ }
+
+ var resource Component2
+ err := ctx.RegisterResource("example:mod:Component2", name, args, &resource, opts...)
+ if err != nil {
+ return nil, err
+ }
+ return &resource, nil
+}
+
+// GetComponent2 gets an existing Component2 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 GetComponent2(ctx *pulumi.Context,
+ name string, id pulumi.IDInput, state *Component2State, opts ...pulumi.ResourceOption) (*Component2, error) {
+ var resource Component2
+ err := ctx.ReadResource("example:mod:Component2", name, id, state, &resource, opts...)
+ if err != nil {
+ return nil, err
+ }
+ return &resource, nil
+}
+
+// Input properties used for looking up and filtering Component2 resources.
+type component2State struct {
+}
+
+type Component2State struct {
+}
+
+func (Component2State) ElementType() reflect.Type {
+ return reflect.TypeOf((*component2State)(nil)).Elem()
+}
+
+type component2Args struct {
+}
+
+// The set of arguments for constructing a Component2 resource.
+type Component2Args struct {
+}
+
+func (Component2Args) ElementType() reflect.Type {
+ return reflect.TypeOf((*component2Args)(nil)).Elem()
+}
+
+type Component2Input interface {
+ pulumi.Input
+
+ ToComponent2Output() Component2Output
+ ToComponent2OutputWithContext(ctx context.Context) Component2Output
+}
+
+func (*Component2) ElementType() reflect.Type {
+ return reflect.TypeOf((**Component2)(nil)).Elem()
+}
+
+func (i *Component2) ToComponent2Output() Component2Output {
+ return i.ToComponent2OutputWithContext(context.Background())
+}
+
+func (i *Component2) ToComponent2OutputWithContext(ctx context.Context) Component2Output {
+ return pulumi.ToOutputWithContext(ctx, i).(Component2Output)
+}
+
+type Component2Output struct{ *pulumi.OutputState }
+
+func (Component2Output) ElementType() reflect.Type {
+ return reflect.TypeOf((**Component2)(nil)).Elem()
+}
+
+func (o Component2Output) ToComponent2Output() Component2Output {
+ return o
+}
+
+func (o Component2Output) ToComponent2OutputWithContext(ctx context.Context) Component2Output {
+ return o
+}
+
+func init() {
+ pulumi.RegisterInputType(reflect.TypeOf((*Component2Input)(nil)).Elem(), &Component2{})
+ pulumi.RegisterOutputType(Component2Output{})
+}
diff --git a/pkg/codegen/testing/test/testdata/naming-collisions/go/example/mod/init.go b/pkg/codegen/testing/test/testdata/naming-collisions/go/example/mod/init.go
new file mode 100644
index 000000000000..b41a5e52629b
--- /dev/null
+++ b/pkg/codegen/testing/test/testdata/naming-collisions/go/example/mod/init.go
@@ -0,0 +1,46 @@
+// Code generated by test DO NOT EDIT.
+// *** WARNING: Do not edit by hand unless you're certain you know what you are doing! ***
+
+package mod
+
+import (
+ "fmt"
+
+ "github.com/blang/semver"
+ "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
+ "naming-collisions/example"
+)
+
+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 "example:mod:Component":
+ r = &Component{}
+ case "example:mod:Component2":
+ r = &Component2{}
+ 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 := example.PkgVersion()
+ if err != nil {
+ version = semver.Version{Major: 1}
+ }
+ pulumi.RegisterResourceModule(
+ "example",
+ "mod",
+ &module{version},
+ )
+}
diff --git a/pkg/codegen/testing/test/testdata/naming-collisions/nodejs/codegen-manifest.json b/pkg/codegen/testing/test/testdata/naming-collisions/nodejs/codegen-manifest.json
index 8742bace2e66..be6e08fb76b8 100644
--- a/pkg/codegen/testing/test/testdata/naming-collisions/nodejs/codegen-manifest.json
+++ b/pkg/codegen/testing/test/testdata/naming-collisions/nodejs/codegen-manifest.json
@@ -2,6 +2,10 @@
"emittedFiles": [
"README.md",
"index.ts",
+ "mainComponent.ts",
+ "mod/component.ts",
+ "mod/component2.ts",
+ "mod/index.ts",
"package.json",
"provider.ts",
"resource.ts",
diff --git a/pkg/codegen/testing/test/testdata/naming-collisions/nodejs/index.ts b/pkg/codegen/testing/test/testdata/naming-collisions/nodejs/index.ts
index 3800243e08d5..649f54b62aaa 100644
--- a/pkg/codegen/testing/test/testdata/naming-collisions/nodejs/index.ts
+++ b/pkg/codegen/testing/test/testdata/naming-collisions/nodejs/index.ts
@@ -5,6 +5,11 @@ import * as pulumi from "@pulumi/pulumi";
import * as utilities from "./utilities";
// Export members:
+export { MainComponentArgs } from "./mainComponent";
+export type MainComponent = import("./mainComponent").MainComponent;
+export const MainComponent: typeof import("./mainComponent").MainComponent = null as any;
+utilities.lazyLoad(exports, ["MainComponent"], () => require("./mainComponent"));
+
export { ProviderArgs } from "./provider";
export type Provider = import("./provider").Provider;
export const Provider: typeof import("./provider").Provider = null as any;
@@ -25,9 +30,11 @@ utilities.lazyLoad(exports, ["ResourceInput"], () => require("./resourceInput"))
export * from "./types/enums";
// Export sub-modules:
+import * as mod from "./mod";
import * as types from "./types";
export {
+ mod,
types,
};
@@ -35,6 +42,8 @@ const _module = {
version: utilities.getVersion(),
construct: (name: string, type: string, urn: string): pulumi.Resource => {
switch (type) {
+ case "example::MainComponent":
+ return new MainComponent(name, undefined, { urn })
case "example::Resource":
return new Resource(name, undefined, { urn })
case "example::ResourceInput":
diff --git a/pkg/codegen/testing/test/testdata/naming-collisions/nodejs/mainComponent.ts b/pkg/codegen/testing/test/testdata/naming-collisions/nodejs/mainComponent.ts
new file mode 100644
index 000000000000..857380e01098
--- /dev/null
+++ b/pkg/codegen/testing/test/testdata/naming-collisions/nodejs/mainComponent.ts
@@ -0,0 +1,57 @@
+// *** WARNING: this file was generated by test. ***
+// *** Do not edit by hand unless you're certain you know what you are doing! ***
+
+import * as pulumi from "@pulumi/pulumi";
+import * as utilities from "./utilities";
+
+export class MainComponent extends pulumi.CustomResource {
+ /**
+ * Get an existing MainComponent resource's state with the given name, ID, and optional extra
+ * properties used to qualify the lookup.
+ *
+ * @param name The _unique_ name of the resulting resource.
+ * @param id The _unique_ provider ID of the resource to lookup.
+ * @param opts Optional settings to control the behavior of the CustomResource.
+ */
+ public static get(name: string, id: pulumi.Input, opts?: pulumi.CustomResourceOptions): MainComponent {
+ return new MainComponent(name, undefined as any, { ...opts, id: id });
+ }
+
+ /** @internal */
+ public static readonly __pulumiType = 'example::MainComponent';
+
+ /**
+ * Returns true if the given object is an instance of MainComponent. This is designed to work even
+ * when multiple copies of the Pulumi SDK have been loaded into the same process.
+ */
+ public static isInstance(obj: any): obj is MainComponent {
+ if (obj === undefined || obj === null) {
+ return false;
+ }
+ return obj['__pulumiType'] === MainComponent.__pulumiType;
+ }
+
+
+ /**
+ * Create a MainComponent resource with the given unique name, arguments, and options.
+ *
+ * @param name The _unique_ name of the resource.
+ * @param args The arguments to use to populate this resource's properties.
+ * @param opts A bag of options that control this resource's behavior.
+ */
+ constructor(name: string, args?: MainComponentArgs, opts?: pulumi.CustomResourceOptions) {
+ let resourceInputs: pulumi.Inputs = {};
+ opts = opts || {};
+ if (!opts.id) {
+ } else {
+ }
+ opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
+ super(MainComponent.__pulumiType, name, resourceInputs, opts);
+ }
+}
+
+/**
+ * The set of arguments for constructing a MainComponent resource.
+ */
+export interface MainComponentArgs {
+}
diff --git a/pkg/codegen/testing/test/testdata/naming-collisions/nodejs/mod/component.ts b/pkg/codegen/testing/test/testdata/naming-collisions/nodejs/mod/component.ts
new file mode 100644
index 000000000000..b038677d3ddf
--- /dev/null
+++ b/pkg/codegen/testing/test/testdata/naming-collisions/nodejs/mod/component.ts
@@ -0,0 +1,64 @@
+// *** WARNING: this file was generated by test. ***
+// *** Do not edit by hand unless you're certain you know what you are doing! ***
+
+import * as pulumi from "@pulumi/pulumi";
+import * as utilities from "../utilities";
+
+import {MainComponent} from "..";
+import {Component2} from "./index";
+
+export class Component extends pulumi.CustomResource {
+ /**
+ * Get an existing Component resource's state with the given name, ID, and optional extra
+ * properties used to qualify the lookup.
+ *
+ * @param name The _unique_ name of the resulting resource.
+ * @param id The _unique_ provider ID of the resource to lookup.
+ * @param opts Optional settings to control the behavior of the CustomResource.
+ */
+ public static get(name: string, id: pulumi.Input, opts?: pulumi.CustomResourceOptions): Component {
+ return new Component(name, undefined as any, { ...opts, id: id });
+ }
+
+ /** @internal */
+ public static readonly __pulumiType = 'example:mod:Component';
+
+ /**
+ * Returns true if the given object is an instance of Component. This is designed to work even
+ * when multiple copies of the Pulumi SDK have been loaded into the same process.
+ */
+ public static isInstance(obj: any): obj is Component {
+ if (obj === undefined || obj === null) {
+ return false;
+ }
+ return obj['__pulumiType'] === Component.__pulumiType;
+ }
+
+
+ /**
+ * Create a Component resource with the given unique name, arguments, and options.
+ *
+ * @param name The _unique_ name of the resource.
+ * @param args The arguments to use to populate this resource's properties.
+ * @param opts A bag of options that control this resource's behavior.
+ */
+ constructor(name: string, args?: ComponentArgs, opts?: pulumi.CustomResourceOptions) {
+ let resourceInputs: pulumi.Inputs = {};
+ opts = opts || {};
+ if (!opts.id) {
+ resourceInputs["local"] = args ? args.local : undefined;
+ resourceInputs["main"] = args ? args.main : undefined;
+ } else {
+ }
+ opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
+ super(Component.__pulumiType, name, resourceInputs, opts);
+ }
+}
+
+/**
+ * The set of arguments for constructing a Component resource.
+ */
+export interface ComponentArgs {
+ local?: pulumi.Input;
+ main?: pulumi.Input;
+}
diff --git a/pkg/codegen/testing/test/testdata/naming-collisions/nodejs/mod/component2.ts b/pkg/codegen/testing/test/testdata/naming-collisions/nodejs/mod/component2.ts
new file mode 100644
index 000000000000..52746711009b
--- /dev/null
+++ b/pkg/codegen/testing/test/testdata/naming-collisions/nodejs/mod/component2.ts
@@ -0,0 +1,57 @@
+// *** WARNING: this file was generated by test. ***
+// *** Do not edit by hand unless you're certain you know what you are doing! ***
+
+import * as pulumi from "@pulumi/pulumi";
+import * as utilities from "../utilities";
+
+export class Component2 extends pulumi.CustomResource {
+ /**
+ * Get an existing Component2 resource's state with the given name, ID, and optional extra
+ * properties used to qualify the lookup.
+ *
+ * @param name The _unique_ name of the resulting resource.
+ * @param id The _unique_ provider ID of the resource to lookup.
+ * @param opts Optional settings to control the behavior of the CustomResource.
+ */
+ public static get(name: string, id: pulumi.Input, opts?: pulumi.CustomResourceOptions): Component2 {
+ return new Component2(name, undefined as any, { ...opts, id: id });
+ }
+
+ /** @internal */
+ public static readonly __pulumiType = 'example:mod:Component2';
+
+ /**
+ * Returns true if the given object is an instance of Component2. This is designed to work even
+ * when multiple copies of the Pulumi SDK have been loaded into the same process.
+ */
+ public static isInstance(obj: any): obj is Component2 {
+ if (obj === undefined || obj === null) {
+ return false;
+ }
+ return obj['__pulumiType'] === Component2.__pulumiType;
+ }
+
+
+ /**
+ * Create a Component2 resource with the given unique name, arguments, and options.
+ *
+ * @param name The _unique_ name of the resource.
+ * @param args The arguments to use to populate this resource's properties.
+ * @param opts A bag of options that control this resource's behavior.
+ */
+ constructor(name: string, args?: Component2Args, opts?: pulumi.CustomResourceOptions) {
+ let resourceInputs: pulumi.Inputs = {};
+ opts = opts || {};
+ if (!opts.id) {
+ } else {
+ }
+ opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
+ super(Component2.__pulumiType, name, resourceInputs, opts);
+ }
+}
+
+/**
+ * The set of arguments for constructing a Component2 resource.
+ */
+export interface Component2Args {
+}
diff --git a/pkg/codegen/testing/test/testdata/naming-collisions/nodejs/mod/index.ts b/pkg/codegen/testing/test/testdata/naming-collisions/nodejs/mod/index.ts
new file mode 100644
index 000000000000..ef5ee59ad102
--- /dev/null
+++ b/pkg/codegen/testing/test/testdata/naming-collisions/nodejs/mod/index.ts
@@ -0,0 +1,32 @@
+// *** WARNING: this file was generated by test. ***
+// *** Do not edit by hand unless you're certain you know what you are doing! ***
+
+import * as pulumi from "@pulumi/pulumi";
+import * as utilities from "../utilities";
+
+// Export members:
+export { ComponentArgs } from "./component";
+export type Component = import("./component").Component;
+export const Component: typeof import("./component").Component = null as any;
+utilities.lazyLoad(exports, ["Component"], () => require("./component"));
+
+export { Component2Args } from "./component2";
+export type Component2 = import("./component2").Component2;
+export const Component2: typeof import("./component2").Component2 = null as any;
+utilities.lazyLoad(exports, ["Component2"], () => require("./component2"));
+
+
+const _module = {
+ version: utilities.getVersion(),
+ construct: (name: string, type: string, urn: string): pulumi.Resource => {
+ switch (type) {
+ case "example:mod:Component":
+ return new Component(name, undefined, { urn })
+ case "example:mod:Component2":
+ return new Component2(name, undefined, { urn })
+ default:
+ throw new Error(`unknown resource type ${type}`);
+ }
+ },
+};
+pulumi.runtime.registerResourceModule("example", "mod", _module)
diff --git a/pkg/codegen/testing/test/testdata/naming-collisions/nodejs/tsconfig.json b/pkg/codegen/testing/test/testdata/naming-collisions/nodejs/tsconfig.json
index 580c6b03ddba..41516b009096 100644
--- a/pkg/codegen/testing/test/testdata/naming-collisions/nodejs/tsconfig.json
+++ b/pkg/codegen/testing/test/testdata/naming-collisions/nodejs/tsconfig.json
@@ -14,6 +14,10 @@
},
"files": [
"index.ts",
+ "mainComponent.ts",
+ "mod/component.ts",
+ "mod/component2.ts",
+ "mod/index.ts",
"provider.ts",
"resource.ts",
"resourceInput.ts",
diff --git a/pkg/codegen/testing/test/testdata/naming-collisions/python/codegen-manifest.json b/pkg/codegen/testing/test/testdata/naming-collisions/python/codegen-manifest.json
index 128fa05a6af1..c61dc52f7214 100644
--- a/pkg/codegen/testing/test/testdata/naming-collisions/python/codegen-manifest.json
+++ b/pkg/codegen/testing/test/testdata/naming-collisions/python/codegen-manifest.json
@@ -4,6 +4,10 @@
"pulumi_example/__init__.py",
"pulumi_example/_enums.py",
"pulumi_example/_utilities.py",
+ "pulumi_example/main_component.py",
+ "pulumi_example/mod/__init__.py",
+ "pulumi_example/mod/component.py",
+ "pulumi_example/mod/component2.py",
"pulumi_example/provider.py",
"pulumi_example/pulumi-plugin.json",
"pulumi_example/py.typed",
diff --git a/pkg/codegen/testing/test/testdata/naming-collisions/python/pulumi_example/__init__.py b/pkg/codegen/testing/test/testdata/naming-collisions/python/pulumi_example/__init__.py
index 1ac75b8368a8..159293b6a47c 100644
--- a/pkg/codegen/testing/test/testdata/naming-collisions/python/pulumi_example/__init__.py
+++ b/pkg/codegen/testing/test/testdata/naming-collisions/python/pulumi_example/__init__.py
@@ -6,9 +6,18 @@
import typing
# Export this package's modules as members:
from ._enums import *
+from .main_component import *
from .provider import *
from .resource import *
from .resource_input import *
+
+# Make subpackages available:
+if typing.TYPE_CHECKING:
+ import pulumi_example.mod as __mod
+ mod = __mod
+else:
+ mod = _utilities.lazy_import('pulumi_example.mod')
+
_utilities.register(
resource_modules="""
[
@@ -17,9 +26,19 @@
"mod": "",
"fqn": "pulumi_example",
"classes": {
+ "example::MainComponent": "MainComponent",
"example::Resource": "Resource",
"example::ResourceInput": "ResourceInput"
}
+ },
+ {
+ "pkg": "example",
+ "mod": "mod",
+ "fqn": "pulumi_example.mod",
+ "classes": {
+ "example:mod:Component": "Component",
+ "example:mod:Component2": "Component2"
+ }
}
]
""",
diff --git a/pkg/codegen/testing/test/testdata/naming-collisions/python/pulumi_example/main_component.py b/pkg/codegen/testing/test/testdata/naming-collisions/python/pulumi_example/main_component.py
new file mode 100644
index 000000000000..8b043e62a8a7
--- /dev/null
+++ b/pkg/codegen/testing/test/testdata/naming-collisions/python/pulumi_example/main_component.py
@@ -0,0 +1,89 @@
+# coding=utf-8
+# *** WARNING: this file was generated by test. ***
+# *** Do not edit by hand unless you're certain you know what you are doing! ***
+
+import copy
+import warnings
+import pulumi
+import pulumi.runtime
+from typing import Any, Mapping, Optional, Sequence, Union, overload
+from . import _utilities
+
+__all__ = ['MainComponentArgs', 'MainComponent']
+
+@pulumi.input_type
+class MainComponentArgs:
+ def __init__(__self__):
+ """
+ The set of arguments for constructing a MainComponent resource.
+ """
+ pass
+
+
+class MainComponent(pulumi.CustomResource):
+ @overload
+ def __init__(__self__,
+ resource_name: str,
+ opts: Optional[pulumi.ResourceOptions] = None,
+ __props__=None):
+ """
+ Create a MainComponent resource with the given unique name, props, and options.
+ :param str resource_name: The name of the resource.
+ :param pulumi.ResourceOptions opts: Options for the resource.
+ """
+ ...
+ @overload
+ def __init__(__self__,
+ resource_name: str,
+ args: Optional[MainComponentArgs] = None,
+ opts: Optional[pulumi.ResourceOptions] = None):
+ """
+ Create a MainComponent resource with the given unique name, props, and options.
+ :param str resource_name: The name of the resource.
+ :param MainComponentArgs args: The arguments to use to populate this resource's properties.
+ :param pulumi.ResourceOptions opts: Options for the resource.
+ """
+ ...
+ def __init__(__self__, resource_name: str, *args, **kwargs):
+ resource_args, opts = _utilities.get_resource_args_opts(MainComponentArgs, pulumi.ResourceOptions, *args, **kwargs)
+ if resource_args is not None:
+ __self__._internal_init(resource_name, opts, **resource_args.__dict__)
+ else:
+ __self__._internal_init(resource_name, *args, **kwargs)
+
+ def _internal_init(__self__,
+ resource_name: str,
+ opts: Optional[pulumi.ResourceOptions] = None,
+ __props__=None):
+ opts = pulumi.ResourceOptions.merge(_utilities.get_resource_opts_defaults(), opts)
+ if not isinstance(opts, pulumi.ResourceOptions):
+ raise TypeError('Expected resource options to be a ResourceOptions instance')
+ if opts.id is None:
+ if __props__ is not None:
+ raise TypeError('__props__ is only valid when passed in combination with a valid opts.id to get an existing resource')
+ __props__ = MainComponentArgs.__new__(MainComponentArgs)
+
+ super(MainComponent, __self__).__init__(
+ 'example::MainComponent',
+ resource_name,
+ __props__,
+ opts)
+
+ @staticmethod
+ def get(resource_name: str,
+ id: pulumi.Input[str],
+ opts: Optional[pulumi.ResourceOptions] = None) -> 'MainComponent':
+ """
+ Get an existing MainComponent resource's state with the given name, id, and optional extra
+ properties used to qualify the lookup.
+
+ :param str resource_name: The unique name of the resulting resource.
+ :param pulumi.Input[str] id: The unique provider ID of the resource to lookup.
+ :param pulumi.ResourceOptions opts: Options for the resource.
+ """
+ opts = pulumi.ResourceOptions.merge(opts, pulumi.ResourceOptions(id=id))
+
+ __props__ = MainComponentArgs.__new__(MainComponentArgs)
+
+ return MainComponent(resource_name, opts=opts, __props__=__props__)
+
diff --git a/pkg/codegen/testing/test/testdata/naming-collisions/python/pulumi_example/mod/__init__.py b/pkg/codegen/testing/test/testdata/naming-collisions/python/pulumi_example/mod/__init__.py
new file mode 100644
index 000000000000..a5ec9ef89732
--- /dev/null
+++ b/pkg/codegen/testing/test/testdata/naming-collisions/python/pulumi_example/mod/__init__.py
@@ -0,0 +1,9 @@
+# coding=utf-8
+# *** WARNING: this file was generated by test. ***
+# *** Do not edit by hand unless you're certain you know what you are doing! ***
+
+from .. import _utilities
+import typing
+# Export this package's modules as members:
+from .component import *
+from .component2 import *
diff --git a/pkg/codegen/testing/test/testdata/naming-collisions/python/pulumi_example/mod/component.py b/pkg/codegen/testing/test/testdata/naming-collisions/python/pulumi_example/mod/component.py
new file mode 100644
index 000000000000..4864a4cd76c9
--- /dev/null
+++ b/pkg/codegen/testing/test/testdata/naming-collisions/python/pulumi_example/mod/component.py
@@ -0,0 +1,120 @@
+# coding=utf-8
+# *** WARNING: this file was generated by test. ***
+# *** Do not edit by hand unless you're certain you know what you are doing! ***
+
+import copy
+import warnings
+import pulumi
+import pulumi.runtime
+from typing import Any, Mapping, Optional, Sequence, Union, overload
+from .. import _utilities
+from ..component2 import Component2
+from ..main_component import MainComponent
+
+__all__ = ['ComponentArgs', 'Component']
+
+@pulumi.input_type
+class ComponentArgs:
+ def __init__(__self__, *,
+ local: Optional[pulumi.Input['Component2']] = None,
+ main: Optional[pulumi.Input['MainComponent']] = None):
+ """
+ The set of arguments for constructing a Component resource.
+ """
+ if local is not None:
+ pulumi.set(__self__, "local", local)
+ if main is not None:
+ pulumi.set(__self__, "main", main)
+
+ @property
+ @pulumi.getter
+ def local(self) -> Optional[pulumi.Input['Component2']]:
+ return pulumi.get(self, "local")
+
+ @local.setter
+ def local(self, value: Optional[pulumi.Input['Component2']]):
+ pulumi.set(self, "local", value)
+
+ @property
+ @pulumi.getter
+ def main(self) -> Optional[pulumi.Input['MainComponent']]:
+ return pulumi.get(self, "main")
+
+ @main.setter
+ def main(self, value: Optional[pulumi.Input['MainComponent']]):
+ pulumi.set(self, "main", value)
+
+
+class Component(pulumi.CustomResource):
+ @overload
+ def __init__(__self__,
+ resource_name: str,
+ opts: Optional[pulumi.ResourceOptions] = None,
+ local: Optional[pulumi.Input['Component2']] = None,
+ main: Optional[pulumi.Input['MainComponent']] = None,
+ __props__=None):
+ """
+ Create a Component resource with the given unique name, props, and options.
+ :param str resource_name: The name of the resource.
+ :param pulumi.ResourceOptions opts: Options for the resource.
+ """
+ ...
+ @overload
+ def __init__(__self__,
+ resource_name: str,
+ args: Optional[ComponentArgs] = None,
+ opts: Optional[pulumi.ResourceOptions] = None):
+ """
+ Create a Component resource with the given unique name, props, and options.
+ :param str resource_name: The name of the resource.
+ :param ComponentArgs args: The arguments to use to populate this resource's properties.
+ :param pulumi.ResourceOptions opts: Options for the resource.
+ """
+ ...
+ def __init__(__self__, resource_name: str, *args, **kwargs):
+ resource_args, opts = _utilities.get_resource_args_opts(ComponentArgs, pulumi.ResourceOptions, *args, **kwargs)
+ if resource_args is not None:
+ __self__._internal_init(resource_name, opts, **resource_args.__dict__)
+ else:
+ __self__._internal_init(resource_name, *args, **kwargs)
+
+ def _internal_init(__self__,
+ resource_name: str,
+ opts: Optional[pulumi.ResourceOptions] = None,
+ local: Optional[pulumi.Input['Component2']] = None,
+ main: Optional[pulumi.Input['MainComponent']] = None,
+ __props__=None):
+ opts = pulumi.ResourceOptions.merge(_utilities.get_resource_opts_defaults(), opts)
+ if not isinstance(opts, pulumi.ResourceOptions):
+ raise TypeError('Expected resource options to be a ResourceOptions instance')
+ if opts.id is None:
+ if __props__ is not None:
+ raise TypeError('__props__ is only valid when passed in combination with a valid opts.id to get an existing resource')
+ __props__ = ComponentArgs.__new__(ComponentArgs)
+
+ __props__.__dict__["local"] = local
+ __props__.__dict__["main"] = main
+ super(Component, __self__).__init__(
+ 'example:mod:Component',
+ resource_name,
+ __props__,
+ opts)
+
+ @staticmethod
+ def get(resource_name: str,
+ id: pulumi.Input[str],
+ opts: Optional[pulumi.ResourceOptions] = None) -> 'Component':
+ """
+ Get an existing Component resource's state with the given name, id, and optional extra
+ properties used to qualify the lookup.
+
+ :param str resource_name: The unique name of the resulting resource.
+ :param pulumi.Input[str] id: The unique provider ID of the resource to lookup.
+ :param pulumi.ResourceOptions opts: Options for the resource.
+ """
+ opts = pulumi.ResourceOptions.merge(opts, pulumi.ResourceOptions(id=id))
+
+ __props__ = ComponentArgs.__new__(ComponentArgs)
+
+ return Component(resource_name, opts=opts, __props__=__props__)
+
diff --git a/pkg/codegen/testing/test/testdata/naming-collisions/python/pulumi_example/mod/component2.py b/pkg/codegen/testing/test/testdata/naming-collisions/python/pulumi_example/mod/component2.py
new file mode 100644
index 000000000000..882a51cf1a83
--- /dev/null
+++ b/pkg/codegen/testing/test/testdata/naming-collisions/python/pulumi_example/mod/component2.py
@@ -0,0 +1,89 @@
+# coding=utf-8
+# *** WARNING: this file was generated by test. ***
+# *** Do not edit by hand unless you're certain you know what you are doing! ***
+
+import copy
+import warnings
+import pulumi
+import pulumi.runtime
+from typing import Any, Mapping, Optional, Sequence, Union, overload
+from .. import _utilities
+
+__all__ = ['Component2Args', 'Component2']
+
+@pulumi.input_type
+class Component2Args:
+ def __init__(__self__):
+ """
+ The set of arguments for constructing a Component2 resource.
+ """
+ pass
+
+
+class Component2(pulumi.CustomResource):
+ @overload
+ def __init__(__self__,
+ resource_name: str,
+ opts: Optional[pulumi.ResourceOptions] = None,
+ __props__=None):
+ """
+ Create a Component2 resource with the given unique name, props, and options.
+ :param str resource_name: The name of the resource.
+ :param pulumi.ResourceOptions opts: Options for the resource.
+ """
+ ...
+ @overload
+ def __init__(__self__,
+ resource_name: str,
+ args: Optional[Component2Args] = None,
+ opts: Optional[pulumi.ResourceOptions] = None):
+ """
+ Create a Component2 resource with the given unique name, props, and options.
+ :param str resource_name: The name of the resource.
+ :param Component2Args args: The arguments to use to populate this resource's properties.
+ :param pulumi.ResourceOptions opts: Options for the resource.
+ """
+ ...
+ def __init__(__self__, resource_name: str, *args, **kwargs):
+ resource_args, opts = _utilities.get_resource_args_opts(Component2Args, pulumi.ResourceOptions, *args, **kwargs)
+ if resource_args is not None:
+ __self__._internal_init(resource_name, opts, **resource_args.__dict__)
+ else:
+ __self__._internal_init(resource_name, *args, **kwargs)
+
+ def _internal_init(__self__,
+ resource_name: str,
+ opts: Optional[pulumi.ResourceOptions] = None,
+ __props__=None):
+ opts = pulumi.ResourceOptions.merge(_utilities.get_resource_opts_defaults(), opts)
+ if not isinstance(opts, pulumi.ResourceOptions):
+ raise TypeError('Expected resource options to be a ResourceOptions instance')
+ if opts.id is None:
+ if __props__ is not None:
+ raise TypeError('__props__ is only valid when passed in combination with a valid opts.id to get an existing resource')
+ __props__ = Component2Args.__new__(Component2Args)
+
+ super(Component2, __self__).__init__(
+ 'example:mod:Component2',
+ resource_name,
+ __props__,
+ opts)
+
+ @staticmethod
+ def get(resource_name: str,
+ id: pulumi.Input[str],
+ opts: Optional[pulumi.ResourceOptions] = None) -> 'Component2':
+ """
+ Get an existing Component2 resource's state with the given name, id, and optional extra
+ properties used to qualify the lookup.
+
+ :param str resource_name: The unique name of the resulting resource.
+ :param pulumi.Input[str] id: The unique provider ID of the resource to lookup.
+ :param pulumi.ResourceOptions opts: Options for the resource.
+ """
+ opts = pulumi.ResourceOptions.merge(opts, pulumi.ResourceOptions(id=id))
+
+ __props__ = Component2Args.__new__(Component2Args)
+
+ return Component2(resource_name, opts=opts, __props__=__props__)
+
diff --git a/pkg/codegen/testing/test/testdata/naming-collisions/schema.json b/pkg/codegen/testing/test/testdata/naming-collisions/schema.json
index 7cafda06d866..679f85474b47 100644
--- a/pkg/codegen/testing/test/testdata/naming-collisions/schema.json
+++ b/pkg/codegen/testing/test/testdata/naming-collisions/schema.json
@@ -56,6 +56,23 @@
}
}
},
+ "example:mod:Component": {
+ "component": true,
+ "inputProperties": {
+ "main": {
+ "$ref": "#/resources/example::MainComponent"
+ },
+ "local": {
+ "$ref": "#/resources/example:mod:Component2"
+ }
+ }
+ },
+ "example:mod:Component2": {
+ "component": true
+ },
+ "example::MainComponent": {
+ "component": true
+ },
"example::ResourceInput": {
"properties": {
"bar": {
@@ -72,7 +89,7 @@
]
},
"go": {
- "importBasePath": "github.com/pulumi/pulumi/pkg/v3/codegen/testing/test/testdata/input-collision/go/example",
+ "importBasePath": "naming-collisions/example",
"generateExtraInputTypes": true
},
"nodejs": {