",
+ "defaultInfo": {
+ "environment": ["PULUMI_THE_QUESTION"]
+ }
+ },
+ "thinker": {
+ "description": "To ask and answer",
+ "type": "string",
+ "default": "not a good interaction"
+ },
+ "other": {
+ "$ref": "#/types/example:index:HelmReleaseSettings"
+ },
+ "plainOther": {
+ "description": "Test how plain types interact",
+ "$ref": "#/types/example:index:HelmReleaseSettings",
+ "plain": true
+ },
+ "recursive": {
+ "$ref": "#/types/example:index:LayeredType"
+ }
+ },
+ "required": ["other", "thinker"]
+ },
+ "example:index:KubeClientSettings": {
+ "description": "Options for tuning the Kubernetes client used by a Provider.",
+ "properties": {
+ "burst": {
+ "type": "integer",
+ "description": "Maximum burst for throttle. Default value is 10.",
+ "defaultInfo": {
+ "environment": ["PULUMI_K8S_CLIENT_BURST"]
+ }
+ },
+ "qps": {
+ "type": "number",
+ "description": "Maximum queries per second (QPS) to the API server from this client. Default value is 5.",
+ "defaultInfo": {
+ "environment": ["PULUMI_K8S_CLIENT_QPS"]
+ }
+ },
+ "recTest": {
+ "$ref": "#/types/example:index:KubeClientSettings"
+ }
+ },
+ "type": "object"
+ }
+ },
+
+ "functions": {
+ "mypkg::funcWithAllOptionalInputs": {
+ "description": "Check codegen of functions with all optional inputs.",
+ "inputs": {
+ "type": "object",
+ "properties": {
+ "a": {
+ "$ref": "#/types/example:index:HelmReleaseSettings",
+ "description": "Property A"
+ },
+ "b": {
+ "type": "string",
+ "description": "Property B",
+ "default": "defValue"
+ }
+ }
+ },
+ "outputs": {
+ "properties": {
+ "r": {
+ "type": "string"
+ }
+ },
+ "type": "object",
+ "required": ["r"]
+ }
+ }
+ },
+
+ "language": {
+ "csharp": {
+ "packageReferences": {
+ "Pulumi": "3.12"
+ }
+ },
+ "go": {
+ "importBasePath": "plain-object-defaults/example"
+ },
+ "nodejs": {
+ "dependencies": {
+ "@pulumi/pulumi": "^3.12"
+ },
+ "devDependencies": {
+ "typescript": "^3.7.0"
+ }
+ },
+ "python": {}
+ }
+}
diff --git a/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/docs/_index.md b/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/docs/_index.md
new file mode 100644
index 000000000..6d0011cb6
--- /dev/null
+++ b/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/docs/_index.md
@@ -0,0 +1,41 @@
+---
+title: "example"
+title_tag: "example Package"
+meta_desc: ""
+layout: api
+no_edit_this_page: true
+---
+
+
+
+
+
+
+Modules
+
+
+Resources
+
+
+Functions
+
+
+Package Details
+
+ - Repository
+
+ - License
+
+ - Version
+ - 0.0.1
+
+
diff --git a/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/docs/codegen-manifest.json b/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/docs/codegen-manifest.json
new file mode 100644
index 000000000..ca9c36628
--- /dev/null
+++ b/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/docs/codegen-manifest.json
@@ -0,0 +1,11 @@
+{
+ "emittedFiles": [
+ "_index.md",
+ "foo/_index.md",
+ "funcwithalloptionalinputs/_index.md",
+ "mod1/_index.md",
+ "mod2/_index.md",
+ "moduletest/_index.md",
+ "provider/_index.md"
+ ]
+}
diff --git a/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/docs/foo/_index.md b/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/docs/foo/_index.md
new file mode 100644
index 000000000..bb03aef01
--- /dev/null
+++ b/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/docs/foo/_index.md
@@ -0,0 +1,849 @@
+
+---
+title: "Foo"
+title_tag: "example.Foo"
+meta_desc: "Documentation for the example.Foo resource with examples, input properties, output properties, lookup functions, and supporting types."
+layout: api
+no_edit_this_page: true
+---
+
+
+
+
+
+
+test new feature with resoruces
+
+
+
+
+## Create a Foo Resource {#create}
+{{< chooser language "typescript,python,go,csharp" / >}}
+
+
+{{% choosable language nodejs %}}
+
+{{% /choosable %}}
+
+{{% choosable language python %}}
+@overload
+def Foo(resource_name: str,
+ opts: Optional[ResourceOptions] = None,
+ argument: Optional[str] = None,
+ backup_kube_client_settings: Optional[KubeClientSettingsArgs] = None,
+ kube_client_settings: Optional[KubeClientSettingsArgs] = None,
+ settings: Optional[LayeredTypeArgs] = None)
+@overload
+def Foo(resource_name: str,
+ args: FooArgs,
+ opts: Optional[ResourceOptions] = None)
+{{% /choosable %}}
+
+{{% choosable language go %}}
+
+{{% /choosable %}}
+
+{{% choosable language csharp %}}
+
+{{% /choosable %}}
+
+{{% choosable language nodejs %}}
+
+-
+ name
+
+ string
+
+ - The unique name of the resource.
-
+ args
+
+ FooArgs
+
+ - The arguments to resource properties.
-
+ opts
+
+ CustomResourceOptions
+
+ - Bag of options to control resource's behavior.
+
+{{% /choosable %}}
+
+{{% choosable language python %}}
+
+-
+ resource_name
+
+ str
+
+ - The unique name of the resource.
-
+ args
+
+ FooArgs
+
+ - The arguments to resource properties.
-
+ opts
+
+ ResourceOptions
+
+ - Bag of options to control resource's behavior.
+
+{{% /choosable %}}
+
+{{% choosable language go %}}
+
+-
+ ctx
+
+ Context
+
+ - Context object for the current deployment.
-
+ name
+
+ string
+
+ - The unique name of the resource.
-
+ args
+
+ FooArgs
+
+ - The arguments to resource properties.
-
+ opts
+
+ ResourceOption
+
+ - Bag of options to control resource's behavior.
+
+{{% /choosable %}}
+
+{{% choosable language csharp %}}
+
+-
+ name
+
+ string
+
+ - The unique name of the resource.
-
+ args
+
+ FooArgs
+
+ - The arguments to resource properties.
-
+ opts
+
+ CustomResourceOptions
+
+ - Bag of options to control resource's behavior.
+
+{{% /choosable %}}
+
+## Foo Resource Properties {#properties}
+
+To learn more about resource properties and how to use them, see [Inputs and Outputs]({{< relref "/docs/intro/concepts/inputs-outputs" >}}) in the Architecture and Concepts docs.
+
+### Inputs
+
+The Foo resource accepts the following [input]({{< relref "/docs/intro/concepts/inputs-outputs" >}}) properties:
+
+
+
+{{% choosable language csharp %}}
+-
+
+BackupKubeClientSettings
+
+
+ KubeClientSettingsArgs
+
+ - {{% md %}}Options for tuning the Kubernetes client used by a Provider.{{% /md %}}
-
+
+Argument
+
+
+ string
+
+ - {{% md %}}{{% /md %}}
-
+
+KubeClientSettings
+
+
+ KubeClientSettingsArgs
+
+ - {{% md %}}Options for tuning the Kubernetes client used by a Provider.{{% /md %}}
-
+
+Settings
+
+
+ LayeredTypeArgs
+
+ - {{% md %}}describing things{{% /md %}}
+{{% /choosable %}}
+
+{{% choosable language go %}}
+-
+
+BackupKubeClientSettings
+
+
+ KubeClientSettingsArgs
+
+ - {{% md %}}Options for tuning the Kubernetes client used by a Provider.{{% /md %}}
-
+
+Argument
+
+
+ string
+
+ - {{% md %}}{{% /md %}}
-
+
+KubeClientSettings
+
+
+ KubeClientSettingsArgs
+
+ - {{% md %}}Options for tuning the Kubernetes client used by a Provider.{{% /md %}}
-
+
+Settings
+
+
+ LayeredTypeArgs
+
+ - {{% md %}}describing things{{% /md %}}
+{{% /choosable %}}
+
+{{% choosable language nodejs %}}
+-
+
+backupKubeClientSettings
+
+
+ KubeClientSettingsArgs
+
+ - {{% md %}}Options for tuning the Kubernetes client used by a Provider.{{% /md %}}
-
+
+argument
+
+
+ string
+
+ - {{% md %}}{{% /md %}}
-
+
+kubeClientSettings
+
+
+ KubeClientSettingsArgs
+
+ - {{% md %}}Options for tuning the Kubernetes client used by a Provider.{{% /md %}}
-
+
+settings
+
+
+ LayeredTypeArgs
+
+ - {{% md %}}describing things{{% /md %}}
+{{% /choosable %}}
+
+{{% choosable language python %}}
+-
+
+backup_kube_client_settings
+
+
+ KubeClientSettingsArgs
+
+ - {{% md %}}Options for tuning the Kubernetes client used by a Provider.{{% /md %}}
-
+
+argument
+
+
+ str
+
+ - {{% md %}}{{% /md %}}
-
+
+kube_client_settings
+
+
+ KubeClientSettingsArgs
+
+ - {{% md %}}Options for tuning the Kubernetes client used by a Provider.{{% /md %}}
-
+
+settings
+
+
+ LayeredTypeArgs
+
+ - {{% md %}}describing things{{% /md %}}
+{{% /choosable %}}
+
+
+### Outputs
+
+All [input](#inputs) properties are implicitly available as output properties. Additionally, the Foo resource produces the following output properties:
+
+
+
+{{% choosable language csharp %}}
+-
+
+Id
+
+
+ string
+
+ - {{% md %}}The provider-assigned unique ID for this managed resource.{{% /md %}}
-
+
+DefaultKubeClientSettings
+
+
+ KubeClientSettings
+
+ - {{% md %}}A test for plain types{{% /md %}}
+{{% /choosable %}}
+
+{{% choosable language go %}}
+-
+
+Id
+
+
+ string
+
+ - {{% md %}}The provider-assigned unique ID for this managed resource.{{% /md %}}
-
+
+DefaultKubeClientSettings
+
+
+ KubeClientSettings
+
+ - {{% md %}}A test for plain types{{% /md %}}
+{{% /choosable %}}
+
+{{% choosable language nodejs %}}
+-
+
+id
+
+
+ string
+
+ - {{% md %}}The provider-assigned unique ID for this managed resource.{{% /md %}}
-
+
+defaultKubeClientSettings
+
+
+ KubeClientSettings
+
+ - {{% md %}}A test for plain types{{% /md %}}
+{{% /choosable %}}
+
+{{% choosable language python %}}
+-
+
+id
+
+
+ str
+
+ - {{% md %}}The provider-assigned unique ID for this managed resource.{{% /md %}}
-
+
+default_kube_client_settings
+
+
+ KubeClientSettings
+
+ - {{% md %}}A test for plain types{{% /md %}}
+{{% /choosable %}}
+
+
+
+
+
+
+
+## Supporting Types
+
+
+
+HelmReleaseSettings
+
+{{% choosable language csharp %}}
+-
+
+RequiredArg
+
+
+ string
+
+ - {{% md %}}to test required args{{% /md %}}
-
+
+Driver
+
+
+ string
+
+ - {{% md %}}The backend storage driver for Helm. Values are: configmap, secret, memory, sql.{{% /md %}}
-
+
+PluginsPath
+
+
+ string
+
+ - {{% md %}}The path to the helm plugins directory.{{% /md %}}
+{{% /choosable %}}
+
+{{% choosable language go %}}
+-
+
+RequiredArg
+
+
+ string
+
+ - {{% md %}}to test required args{{% /md %}}
-
+
+Driver
+
+
+ string
+
+ - {{% md %}}The backend storage driver for Helm. Values are: configmap, secret, memory, sql.{{% /md %}}
-
+
+PluginsPath
+
+
+ string
+
+ - {{% md %}}The path to the helm plugins directory.{{% /md %}}
+{{% /choosable %}}
+
+{{% choosable language nodejs %}}
+-
+
+requiredArg
+
+
+ string
+
+ - {{% md %}}to test required args{{% /md %}}
-
+
+driver
+
+
+ string
+
+ - {{% md %}}The backend storage driver for Helm. Values are: configmap, secret, memory, sql.{{% /md %}}
-
+
+pluginsPath
+
+
+ string
+
+ - {{% md %}}The path to the helm plugins directory.{{% /md %}}
+{{% /choosable %}}
+
+{{% choosable language python %}}
+-
+
+required_arg
+
+
+ str
+
+ - {{% md %}}to test required args{{% /md %}}
-
+
+driver
+
+
+ str
+
+ - {{% md %}}The backend storage driver for Helm. Values are: configmap, secret, memory, sql.{{% /md %}}
-
+
+plugins_path
+
+
+ str
+
+ - {{% md %}}The path to the helm plugins directory.{{% /md %}}
+{{% /choosable %}}
+
+KubeClientSettings
+
+{{% choosable language csharp %}}
+-
+
+Burst
+
+
+ int
+
+ - {{% md %}}Maximum burst for throttle. Default value is 10.{{% /md %}}
-
+
+Qps
+
+
+ double
+
+ - {{% md %}}Maximum queries per second (QPS) to the API server from this client. Default value is 5.{{% /md %}}
-
+
+RecTest
+
+
+ KubeClientSettings
+
+ - {{% md %}}{{% /md %}}
+{{% /choosable %}}
+
+{{% choosable language go %}}
+-
+
+Burst
+
+
+ int
+
+ - {{% md %}}Maximum burst for throttle. Default value is 10.{{% /md %}}
-
+
+Qps
+
+
+ float64
+
+ - {{% md %}}Maximum queries per second (QPS) to the API server from this client. Default value is 5.{{% /md %}}
-
+
+RecTest
+
+
+ KubeClientSettings
+
+ - {{% md %}}{{% /md %}}
+{{% /choosable %}}
+
+{{% choosable language nodejs %}}
+-
+
+burst
+
+
+ number
+
+ - {{% md %}}Maximum burst for throttle. Default value is 10.{{% /md %}}
-
+
+qps
+
+
+ number
+
+ - {{% md %}}Maximum queries per second (QPS) to the API server from this client. Default value is 5.{{% /md %}}
-
+
+recTest
+
+
+ KubeClientSettings
+
+ - {{% md %}}{{% /md %}}
+{{% /choosable %}}
+
+{{% choosable language python %}}
+-
+
+burst
+
+
+ int
+
+ - {{% md %}}Maximum burst for throttle. Default value is 10.{{% /md %}}
-
+
+qps
+
+
+ float
+
+ - {{% md %}}Maximum queries per second (QPS) to the API server from this client. Default value is 5.{{% /md %}}
-
+
+rec_test
+
+
+ KubeClientSettings
+
+ - {{% md %}}{{% /md %}}
+{{% /choosable %}}
+
+LayeredType
+
+{{% choosable language csharp %}}
+-
+
+Other
+
+
+ HelmReleaseSettings
+
+ - {{% md %}}{{% /md %}}
-
+
+Thinker
+
+
+ string
+
+ - {{% md %}}To ask and answer{{% /md %}}
-
+
+Answer
+
+
+ double
+
+ - {{% md %}}The answer to the question{{% /md %}}
-
+
+PlainOther
+
+
+ HelmReleaseSettings
+
+ - {{% md %}}Test how plain types interact{{% /md %}}
-
+
+Question
+
+
+ string
+
+ - {{% md %}}The question already answered{{% /md %}}
-
+
+Recursive
+
+
+ LayeredType
+
+ - {{% md %}}{{% /md %}}
+{{% /choosable %}}
+
+{{% choosable language go %}}
+-
+
+Other
+
+
+ HelmReleaseSettings
+
+ - {{% md %}}{{% /md %}}
-
+
+Thinker
+
+
+ string
+
+ - {{% md %}}To ask and answer{{% /md %}}
-
+
+Answer
+
+
+ float64
+
+ - {{% md %}}The answer to the question{{% /md %}}
-
+
+PlainOther
+
+
+ HelmReleaseSettings
+
+ - {{% md %}}Test how plain types interact{{% /md %}}
-
+
+Question
+
+
+ string
+
+ - {{% md %}}The question already answered{{% /md %}}
-
+
+Recursive
+
+
+ LayeredType
+
+ - {{% md %}}{{% /md %}}
+{{% /choosable %}}
+
+{{% choosable language nodejs %}}
+-
+
+other
+
+
+ HelmReleaseSettings
+
+ - {{% md %}}{{% /md %}}
-
+
+thinker
+
+
+ string
+
+ - {{% md %}}To ask and answer{{% /md %}}
-
+
+answer
+
+
+ number
+
+ - {{% md %}}The answer to the question{{% /md %}}
-
+
+plainOther
+
+
+ HelmReleaseSettings
+
+ - {{% md %}}Test how plain types interact{{% /md %}}
-
+
+question
+
+
+ string
+
+ - {{% md %}}The question already answered{{% /md %}}
-
+
+recursive
+
+
+ LayeredType
+
+ - {{% md %}}{{% /md %}}
+{{% /choosable %}}
+
+{{% choosable language python %}}
+-
+
+other
+
+
+ HelmReleaseSettings
+
+ - {{% md %}}{{% /md %}}
-
+
+thinker
+
+
+ str
+
+ - {{% md %}}To ask and answer{{% /md %}}
-
+
+answer
+
+
+ float
+
+ - {{% md %}}The answer to the question{{% /md %}}
-
+
+plain_other
+
+
+ HelmReleaseSettings
+
+ - {{% md %}}Test how plain types interact{{% /md %}}
-
+
+question
+
+
+ str
+
+ - {{% md %}}The question already answered{{% /md %}}
-
+
+recursive
+
+
+ LayeredType
+
+ - {{% md %}}{{% /md %}}
+{{% /choosable %}}
+
+
+Package Details
+
+ - Repository
+
+ - License
+
+
+
diff --git a/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/docs/funcwithalloptionalinputs/_index.md b/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/docs/funcwithalloptionalinputs/_index.md
new file mode 100644
index 000000000..7eb89ca47
--- /dev/null
+++ b/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/docs/funcwithalloptionalinputs/_index.md
@@ -0,0 +1,348 @@
+
+---
+title: "funcWithAllOptionalInputs"
+title_tag: "example.funcWithAllOptionalInputs"
+meta_desc: "Documentation for the example.funcWithAllOptionalInputs function with examples, input properties, output properties, and supporting types."
+layout: api
+no_edit_this_page: true
+---
+
+
+
+
+
+
+Check codegen of functions with all optional inputs.
+
+
+
+
+## Using funcWithAllOptionalInputs {#using}
+
+Two invocation forms are available. The direct form accepts plain
+arguments and either blocks until the result value is available, or
+returns a Promise-wrapped result. The output form accepts
+Input-wrapped arguments and returns an Output-wrapped result.
+
+{{< chooser language "typescript,python,go,csharp" / >}}
+
+
+{{% choosable language nodejs %}}
+
+{{% /choosable %}}
+
+
+{{% choosable language python %}}
+def func_with_all_optional_inputs(a: Optional[HelmReleaseSettings] = None,
+ b: Optional[str] = None,
+ opts: Optional[InvokeOptions] = None) -> FuncWithAllOptionalInputsResult
+def func_with_all_optional_inputs_output(a: Optional[pulumi.Input[HelmReleaseSettingsArgs]] = None,
+ b: Optional[pulumi.Input[str]] = None,
+ opts: Optional[InvokeOptions] = None) -> Output[FuncWithAllOptionalInputsResult]
+{{% /choosable %}}
+
+
+{{% choosable language go %}}
+
+
+> Note: This function is named `FuncWithAllOptionalInputs` in the Go SDK.
+
+{{% /choosable %}}
+
+
+{{% choosable language csharp %}}
+
+{{% /choosable %}}
+
+
+
+The following arguments are supported:
+
+
+{{% choosable language csharp %}}
+-
+
+A
+
+
+ HelmReleaseSettings
+
+ - {{% md %}}Property A{{% /md %}}
-
+
+B
+
+
+ string
+
+ - {{% md %}}Property B{{% /md %}}
+{{% /choosable %}}
+
+{{% choosable language go %}}
+-
+
+A
+
+
+ HelmReleaseSettings
+
+ - {{% md %}}Property A{{% /md %}}
-
+
+B
+
+
+ string
+
+ - {{% md %}}Property B{{% /md %}}
+{{% /choosable %}}
+
+{{% choosable language nodejs %}}
+-
+
+a
+
+
+ HelmReleaseSettings
+
+ - {{% md %}}Property A{{% /md %}}
-
+
+b
+
+
+ string
+
+ - {{% md %}}Property B{{% /md %}}
+{{% /choosable %}}
+
+{{% choosable language python %}}
+-
+
+a
+
+
+ HelmReleaseSettings
+
+ - {{% md %}}Property A{{% /md %}}
-
+
+b
+
+
+ str
+
+ - {{% md %}}Property B{{% /md %}}
+{{% /choosable %}}
+
+
+
+
+## funcWithAllOptionalInputs Result {#result}
+
+The following output properties are available:
+
+
+
+{{% choosable language csharp %}}
+-
+
+R
+
+
+ string
+
+ - {{% md %}}{{% /md %}}
+{{% /choosable %}}
+
+{{% choosable language go %}}
+-
+
+R
+
+
+ string
+
+ - {{% md %}}{{% /md %}}
+{{% /choosable %}}
+
+{{% choosable language nodejs %}}
+-
+
+r
+
+
+ string
+
+ - {{% md %}}{{% /md %}}
+{{% /choosable %}}
+
+{{% choosable language python %}}
+-
+
+r
+
+
+ str
+
+ - {{% md %}}{{% /md %}}
+{{% /choosable %}}
+
+
+
+
+## Supporting Types
+
+
+HelmReleaseSettings
+
+
+
+{{% choosable language csharp %}}
+-
+
+RequiredArg
+
+
+ string
+
+ - {{% md %}}to test required args{{% /md %}}
-
+
+Driver
+
+
+ string
+
+ - {{% md %}}The backend storage driver for Helm. Values are: configmap, secret, memory, sql.{{% /md %}}
-
+
+PluginsPath
+
+
+ string
+
+ - {{% md %}}The path to the helm plugins directory.{{% /md %}}
+{{% /choosable %}}
+
+{{% choosable language go %}}
+-
+
+RequiredArg
+
+
+ string
+
+ - {{% md %}}to test required args{{% /md %}}
-
+
+Driver
+
+
+ string
+
+ - {{% md %}}The backend storage driver for Helm. Values are: configmap, secret, memory, sql.{{% /md %}}
-
+
+PluginsPath
+
+
+ string
+
+ - {{% md %}}The path to the helm plugins directory.{{% /md %}}
+{{% /choosable %}}
+
+{{% choosable language nodejs %}}
+-
+
+requiredArg
+
+
+ string
+
+ - {{% md %}}to test required args{{% /md %}}
-
+
+driver
+
+
+ string
+
+ - {{% md %}}The backend storage driver for Helm. Values are: configmap, secret, memory, sql.{{% /md %}}
-
+
+pluginsPath
+
+
+ string
+
+ - {{% md %}}The path to the helm plugins directory.{{% /md %}}
+{{% /choosable %}}
+
+{{% choosable language python %}}
+-
+
+required_arg
+
+
+ str
+
+ - {{% md %}}to test required args{{% /md %}}
-
+
+driver
+
+
+ str
+
+ - {{% md %}}The backend storage driver for Helm. Values are: configmap, secret, memory, sql.{{% /md %}}
-
+
+plugins_path
+
+
+ str
+
+ - {{% md %}}The path to the helm plugins directory.{{% /md %}}
+{{% /choosable %}}
+
+
+
+
+
+Package Details
+
+ - Repository
+
+ - License
+
+
+
diff --git a/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/docs/mod1/_index.md b/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/docs/mod1/_index.md
new file mode 100644
index 000000000..6cce9b58f
--- /dev/null
+++ b/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/docs/mod1/_index.md
@@ -0,0 +1,23 @@
+---
+title: "mod1"
+title_tag: "example.mod1"
+meta_desc: "Explore the resources and functions of the example.mod1 module."
+layout: api
+no_edit_this_page: true
+---
+
+
+
+
+Explore the resources and functions of the example.mod1 module.
+
+Package Details
+
+ - Repository
+
+ - License
+
+ - Version
+ - 0.0.1
+
+
diff --git a/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/docs/mod2/_index.md b/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/docs/mod2/_index.md
new file mode 100644
index 000000000..0ac60b7cc
--- /dev/null
+++ b/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/docs/mod2/_index.md
@@ -0,0 +1,23 @@
+---
+title: "mod2"
+title_tag: "example.mod2"
+meta_desc: "Explore the resources and functions of the example.mod2 module."
+layout: api
+no_edit_this_page: true
+---
+
+
+
+
+Explore the resources and functions of the example.mod2 module.
+
+Package Details
+
+ - Repository
+
+ - License
+
+ - Version
+ - 0.0.1
+
+
diff --git a/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/docs/moduletest/_index.md b/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/docs/moduletest/_index.md
new file mode 100644
index 000000000..5d9d70a46
--- /dev/null
+++ b/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/docs/moduletest/_index.md
@@ -0,0 +1,557 @@
+
+---
+title: "ModuleTest"
+title_tag: "example.ModuleTest"
+meta_desc: "Documentation for the example.ModuleTest resource with examples, input properties, output properties, lookup functions, and supporting types."
+layout: api
+no_edit_this_page: true
+---
+
+
+
+
+
+
+
+
+
+## Create a ModuleTest Resource {#create}
+{{< chooser language "typescript,python,go,csharp" / >}}
+
+
+{{% choosable language nodejs %}}
+
+{{% /choosable %}}
+
+{{% choosable language python %}}
+
+{{% /choosable %}}
+
+{{% choosable language go %}}
+
+{{% /choosable %}}
+
+{{% choosable language csharp %}}
+
+{{% /choosable %}}
+
+{{% choosable language nodejs %}}
+
+-
+ name
+
+ string
+
+ - The unique name of the resource.
-
+ args
+
+ ModuleTestArgs
+
+ - The arguments to resource properties.
-
+ opts
+
+ CustomResourceOptions
+
+ - Bag of options to control resource's behavior.
+
+{{% /choosable %}}
+
+{{% choosable language python %}}
+
+-
+ resource_name
+
+ str
+
+ - The unique name of the resource.
-
+ args
+
+ ModuleTestArgs
+
+ - The arguments to resource properties.
-
+ opts
+
+ ResourceOptions
+
+ - Bag of options to control resource's behavior.
+
+{{% /choosable %}}
+
+{{% choosable language go %}}
+
+-
+ ctx
+
+ Context
+
+ - Context object for the current deployment.
-
+ name
+
+ string
+
+ - The unique name of the resource.
-
+ args
+
+ ModuleTestArgs
+
+ - The arguments to resource properties.
-
+ opts
+
+ ResourceOption
+
+ - Bag of options to control resource's behavior.
+
+{{% /choosable %}}
+
+{{% choosable language csharp %}}
+
+-
+ name
+
+ string
+
+ - The unique name of the resource.
-
+ args
+
+ ModuleTestArgs
+
+ - The arguments to resource properties.
-
+ opts
+
+ CustomResourceOptions
+
+ - Bag of options to control resource's behavior.
+
+{{% /choosable %}}
+
+## ModuleTest Resource Properties {#properties}
+
+To learn more about resource properties and how to use them, see [Inputs and Outputs]({{< relref "/docs/intro/concepts/inputs-outputs" >}}) in the Architecture and Concepts docs.
+
+### Inputs
+
+The ModuleTest resource accepts the following [input]({{< relref "/docs/intro/concepts/inputs-outputs" >}}) properties:
+
+
+
+{{% choosable language csharp %}}
+-
+
+Mod1
+
+
+ Pulumi.Example.Mod1.Inputs.TypArgs
+
+ - {{% md %}}{{% /md %}}
-
+
+Val
+
+
+ TypArgs
+
+ - {{% md %}}{{% /md %}}
+{{% /choosable %}}
+
+{{% choosable language go %}}
+-
+
+Mod1
+
+
+ TypArgs
+
+ - {{% md %}}{{% /md %}}
-
+
+Val
+
+
+ TypArgs
+
+ - {{% md %}}{{% /md %}}
+{{% /choosable %}}
+
+{{% choosable language nodejs %}}
+-
+
+mod1
+
+
+ mod1TypArgs
+
+ - {{% md %}}{{% /md %}}
-
+
+val
+
+
+ TypArgs
+
+ - {{% md %}}{{% /md %}}
+{{% /choosable %}}
+
+{{% choosable language python %}}
+-
+
+mod1
+
+
+ TypArgs
+
+ - {{% md %}}{{% /md %}}
-
+
+val
+
+
+ TypArgs
+
+ - {{% md %}}{{% /md %}}
+{{% /choosable %}}
+
+
+### Outputs
+
+All [input](#inputs) properties are implicitly available as output properties. Additionally, the ModuleTest resource produces the following output properties:
+
+
+
+{{% choosable language csharp %}}
+-
+
+Id
+
+
+ string
+
+ - {{% md %}}The provider-assigned unique ID for this managed resource.{{% /md %}}
+{{% /choosable %}}
+
+{{% choosable language go %}}
+-
+
+Id
+
+
+ string
+
+ - {{% md %}}The provider-assigned unique ID for this managed resource.{{% /md %}}
+{{% /choosable %}}
+
+{{% choosable language nodejs %}}
+-
+
+id
+
+
+ string
+
+ - {{% md %}}The provider-assigned unique ID for this managed resource.{{% /md %}}
+{{% /choosable %}}
+
+{{% choosable language python %}}
+-
+
+id
+
+
+ str
+
+ - {{% md %}}The provider-assigned unique ID for this managed resource.{{% /md %}}
+{{% /choosable %}}
+
+
+
+
+
+
+
+## Supporting Types
+
+
+
+Typ
+
+{{% choosable language csharp %}}
+-
+
+Mod1
+
+
+ Pulumi.Example.Mod1.Inputs.Typ
+
+ - {{% md %}}{{% /md %}}
-
+
+Mod2
+
+
+ Pulumi.Example.Mod2.Inputs.Typ
+
+ - {{% md %}}{{% /md %}}
-
+
+Val
+
+
+ string
+
+ - {{% md %}}{{% /md %}}
+{{% /choosable %}}
+
+{{% choosable language go %}}
+-
+
+Mod1
+
+
+ Typ
+
+ - {{% md %}}{{% /md %}}
-
+
+Mod2
+
+
+ Typ
+
+ - {{% md %}}{{% /md %}}
-
+
+Val
+
+
+ string
+
+ - {{% md %}}{{% /md %}}
+{{% /choosable %}}
+
+{{% choosable language nodejs %}}
+-
+
+mod1
+
+
+ mod1Typ
+
+ - {{% md %}}{{% /md %}}
-
+
+mod2
+
+
+ mod2Typ
+
+ - {{% md %}}{{% /md %}}
-
+
+val
+
+
+ string
+
+ - {{% md %}}{{% /md %}}
+{{% /choosable %}}
+
+{{% choosable language python %}}
+-
+
+mod1
+
+
+ Typ
+
+ - {{% md %}}{{% /md %}}
-
+
+mod2
+
+
+ Typ
+
+ - {{% md %}}{{% /md %}}
-
+
+val
+
+
+ str
+
+ - {{% md %}}{{% /md %}}
+{{% /choosable %}}
+
+Typ
+
+{{% choosable language csharp %}}
+-
+
+Val
+
+
+ string
+
+ - {{% md %}}{{% /md %}}
+{{% /choosable %}}
+
+{{% choosable language go %}}
+-
+
+Val
+
+
+ string
+
+ - {{% md %}}{{% /md %}}
+{{% /choosable %}}
+
+{{% choosable language nodejs %}}
+-
+
+val
+
+
+ string
+
+ - {{% md %}}{{% /md %}}
+{{% /choosable %}}
+
+{{% choosable language python %}}
+-
+
+val
+
+
+ str
+
+ - {{% md %}}{{% /md %}}
+{{% /choosable %}}
+
+Typ
+
+{{% choosable language csharp %}}
+-
+
+Mod1
+
+
+ Pulumi.Example.Mod1.Inputs.Typ
+
+ - {{% md %}}{{% /md %}}
-
+
+Val
+
+
+ string
+
+ - {{% md %}}{{% /md %}}
+{{% /choosable %}}
+
+{{% choosable language go %}}
+-
+
+Mod1
+
+
+ Typ
+
+ - {{% md %}}{{% /md %}}
-
+
+Val
+
+
+ string
+
+ - {{% md %}}{{% /md %}}
+{{% /choosable %}}
+
+{{% choosable language nodejs %}}
+-
+
+mod1
+
+
+ mod1Typ
+
+ - {{% md %}}{{% /md %}}
-
+
+val
+
+
+ string
+
+ - {{% md %}}{{% /md %}}
+{{% /choosable %}}
+
+{{% choosable language python %}}
+-
+
+mod1
+
+
+ Typ
+
+ - {{% md %}}{{% /md %}}
-
+
+val
+
+
+ str
+
+ - {{% md %}}{{% /md %}}
+{{% /choosable %}}
+
+
+Package Details
+
+ - Repository
+
+ - License
+
+
+
diff --git a/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/docs/provider/_index.md b/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/docs/provider/_index.md
new file mode 100644
index 000000000..786b4e4d4
--- /dev/null
+++ b/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/docs/provider/_index.md
@@ -0,0 +1,394 @@
+
+---
+title: "Provider"
+title_tag: "example.Provider"
+meta_desc: "Documentation for the example.Provider resource with examples, input properties, output properties, lookup functions, and supporting types."
+layout: api
+no_edit_this_page: true
+---
+
+
+
+
+
+
+The provider type for the kubernetes package.
+
+
+
+
+## Create a Provider Resource {#create}
+{{< chooser language "typescript,python,go,csharp" / >}}
+
+
+{{% choosable language nodejs %}}
+
+{{% /choosable %}}
+
+{{% choosable language python %}}
+
+{{% /choosable %}}
+
+{{% choosable language go %}}
+
+{{% /choosable %}}
+
+{{% choosable language csharp %}}
+
+{{% /choosable %}}
+
+{{% choosable language nodejs %}}
+
+-
+ name
+
+ string
+
+ - The unique name of the resource.
-
+ args
+
+ ProviderArgs
+
+ - The arguments to resource properties.
-
+ opts
+
+ CustomResourceOptions
+
+ - Bag of options to control resource's behavior.
+
+{{% /choosable %}}
+
+{{% choosable language python %}}
+
+-
+ resource_name
+
+ str
+
+ - The unique name of the resource.
-
+ args
+
+ ProviderArgs
+
+ - The arguments to resource properties.
-
+ opts
+
+ ResourceOptions
+
+ - Bag of options to control resource's behavior.
+
+{{% /choosable %}}
+
+{{% choosable language go %}}
+
+-
+ ctx
+
+ Context
+
+ - Context object for the current deployment.
-
+ name
+
+ string
+
+ - The unique name of the resource.
-
+ args
+
+ ProviderArgs
+
+ - The arguments to resource properties.
-
+ opts
+
+ ResourceOption
+
+ - Bag of options to control resource's behavior.
+
+{{% /choosable %}}
+
+{{% choosable language csharp %}}
+
+-
+ name
+
+ string
+
+ - The unique name of the resource.
-
+ args
+
+ ProviderArgs
+
+ - The arguments to resource properties.
-
+ opts
+
+ CustomResourceOptions
+
+ - Bag of options to control resource's behavior.
+
+{{% /choosable %}}
+
+## Provider Resource Properties {#properties}
+
+To learn more about resource properties and how to use them, see [Inputs and Outputs]({{< relref "/docs/intro/concepts/inputs-outputs" >}}) in the Architecture and Concepts docs.
+
+### Inputs
+
+The Provider resource accepts the following [input]({{< relref "/docs/intro/concepts/inputs-outputs" >}}) properties:
+
+
+
+{{% choosable language csharp %}}
+-
+
+HelmReleaseSettings
+
+
+ HelmReleaseSettingsArgs
+
+ - {{% md %}}BETA FEATURE - Options to configure the Helm Release resource.{{% /md %}}
+{{% /choosable %}}
+
+{{% choosable language go %}}
+-
+
+HelmReleaseSettings
+
+
+ HelmReleaseSettingsArgs
+
+ - {{% md %}}BETA FEATURE - Options to configure the Helm Release resource.{{% /md %}}
+{{% /choosable %}}
+
+{{% choosable language nodejs %}}
+-
+
+helmReleaseSettings
+
+
+ HelmReleaseSettingsArgs
+
+ - {{% md %}}BETA FEATURE - Options to configure the Helm Release resource.{{% /md %}}
+{{% /choosable %}}
+
+{{% choosable language python %}}
+-
+
+helm_release_settings
+
+
+ HelmReleaseSettingsArgs
+
+ - {{% md %}}BETA FEATURE - Options to configure the Helm Release resource.{{% /md %}}
+{{% /choosable %}}
+
+
+### Outputs
+
+All [input](#inputs) properties are implicitly available as output properties. Additionally, the Provider resource produces the following output properties:
+
+
+
+{{% choosable language csharp %}}
+-
+
+Id
+
+
+ string
+
+ - {{% md %}}The provider-assigned unique ID for this managed resource.{{% /md %}}
+{{% /choosable %}}
+
+{{% choosable language go %}}
+-
+
+Id
+
+
+ string
+
+ - {{% md %}}The provider-assigned unique ID for this managed resource.{{% /md %}}
+{{% /choosable %}}
+
+{{% choosable language nodejs %}}
+-
+
+id
+
+
+ string
+
+ - {{% md %}}The provider-assigned unique ID for this managed resource.{{% /md %}}
+{{% /choosable %}}
+
+{{% choosable language python %}}
+-
+
+id
+
+
+ str
+
+ - {{% md %}}The provider-assigned unique ID for this managed resource.{{% /md %}}
+{{% /choosable %}}
+
+
+
+
+
+
+
+## Supporting Types
+
+
+
+HelmReleaseSettings
+
+{{% choosable language csharp %}}
+-
+
+RequiredArg
+
+
+ string
+
+ - {{% md %}}to test required args{{% /md %}}
-
+
+Driver
+
+
+ string
+
+ - {{% md %}}The backend storage driver for Helm. Values are: configmap, secret, memory, sql.{{% /md %}}
-
+
+PluginsPath
+
+
+ string
+
+ - {{% md %}}The path to the helm plugins directory.{{% /md %}}
+{{% /choosable %}}
+
+{{% choosable language go %}}
+-
+
+RequiredArg
+
+
+ string
+
+ - {{% md %}}to test required args{{% /md %}}
-
+
+Driver
+
+
+ string
+
+ - {{% md %}}The backend storage driver for Helm. Values are: configmap, secret, memory, sql.{{% /md %}}
-
+
+PluginsPath
+
+
+ string
+
+ - {{% md %}}The path to the helm plugins directory.{{% /md %}}
+{{% /choosable %}}
+
+{{% choosable language nodejs %}}
+-
+
+requiredArg
+
+
+ string
+
+ - {{% md %}}to test required args{{% /md %}}
-
+
+driver
+
+
+ string
+
+ - {{% md %}}The backend storage driver for Helm. Values are: configmap, secret, memory, sql.{{% /md %}}
-
+
+pluginsPath
+
+
+ string
+
+ - {{% md %}}The path to the helm plugins directory.{{% /md %}}
+{{% /choosable %}}
+
+{{% choosable language python %}}
+-
+
+required_arg
+
+
+ str
+
+ - {{% md %}}to test required args{{% /md %}}
-
+
+driver
+
+
+ str
+
+ - {{% md %}}The backend storage driver for Helm. Values are: configmap, secret, memory, sql.{{% /md %}}
-
+
+plugins_path
+
+
+ str
+
+ - {{% md %}}The path to the helm plugins directory.{{% /md %}}
+{{% /choosable %}}
+
+
+Package Details
+
+ - Repository
+
+ - License
+
+
+
diff --git a/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/dotnet/Foo.cs b/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/dotnet/Foo.cs
new file mode 100644
index 000000000..7e5d588a4
--- /dev/null
+++ b/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/dotnet/Foo.cs
@@ -0,0 +1,94 @@
+// *** 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
+{
+ ///
+ /// test new feature with resoruces
+ ///
+ [ExampleResourceType("example:index:Foo")]
+ public partial class Foo : Pulumi.CustomResource
+ {
+ ///
+ /// A test for plain types
+ ///
+ [Output("defaultKubeClientSettings")]
+ public Output DefaultKubeClientSettings { get; private set; } = null!;
+
+
+ ///
+ /// Create a Foo 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 Foo(string name, FooArgs args, CustomResourceOptions? options = null)
+ : base("example:index:Foo", name, args ?? new FooArgs(), MakeResourceOptions(options, ""))
+ {
+ }
+
+ private Foo(string name, Input id, CustomResourceOptions? options = null)
+ : base("example:index:Foo", 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 Foo 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 Foo Get(string name, Input id, CustomResourceOptions? options = null)
+ {
+ return new Foo(name, id, options);
+ }
+ }
+
+ public sealed class FooArgs : Pulumi.ResourceArgs
+ {
+ [Input("argument")]
+ public string? Argument { get; set; }
+
+ ///
+ /// Options for tuning the Kubernetes client used by a Provider.
+ ///
+ [Input("backupKubeClientSettings", required: true)]
+ public Input BackupKubeClientSettings { get; set; } = null!;
+
+ ///
+ /// Options for tuning the Kubernetes client used by a Provider.
+ ///
+ [Input("kubeClientSettings")]
+ public Input? KubeClientSettings { get; set; }
+
+ ///
+ /// describing things
+ ///
+ [Input("settings")]
+ public Input? Settings { get; set; }
+
+ public FooArgs()
+ {
+ }
+ }
+}
diff --git a/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/dotnet/FuncWithAllOptionalInputs.cs b/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/dotnet/FuncWithAllOptionalInputs.cs
new file mode 100644
index 000000000..43c18c45a
--- /dev/null
+++ b/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/dotnet/FuncWithAllOptionalInputs.cs
@@ -0,0 +1,81 @@
+// *** 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;
+using Pulumi.Utilities;
+
+namespace Pulumi.Mypkg
+{
+ public static class FuncWithAllOptionalInputs
+ {
+ ///
+ /// Check codegen of functions with all optional inputs.
+ ///
+ public static Task InvokeAsync(FuncWithAllOptionalInputsArgs? args = null, InvokeOptions? options = null)
+ => Pulumi.Deployment.Instance.InvokeAsync("mypkg::funcWithAllOptionalInputs", args ?? new FuncWithAllOptionalInputsArgs(), options.WithVersion());
+
+ ///
+ /// Check codegen of functions with all optional inputs.
+ ///
+ public static Output Invoke(FuncWithAllOptionalInputsInvokeArgs? args = null, InvokeOptions? options = null)
+ => Pulumi.Deployment.Instance.Invoke("mypkg::funcWithAllOptionalInputs", args ?? new FuncWithAllOptionalInputsInvokeArgs(), options.WithVersion());
+ }
+
+
+ public sealed class FuncWithAllOptionalInputsArgs : Pulumi.InvokeArgs
+ {
+ ///
+ /// Property A
+ ///
+ [Input("a")]
+ public Inputs.HelmReleaseSettings? A { get; set; }
+
+ ///
+ /// Property B
+ ///
+ [Input("b")]
+ public string? B { get; set; }
+
+ public FuncWithAllOptionalInputsArgs()
+ {
+ B = "defValue";
+ }
+ }
+
+ public sealed class FuncWithAllOptionalInputsInvokeArgs : Pulumi.InvokeArgs
+ {
+ ///
+ /// Property A
+ ///
+ [Input("a")]
+ public Input? A { get; set; }
+
+ ///
+ /// Property B
+ ///
+ [Input("b")]
+ public Input? B { get; set; }
+
+ public FuncWithAllOptionalInputsInvokeArgs()
+ {
+ B = "defValue";
+ }
+ }
+
+
+ [OutputType]
+ public sealed class FuncWithAllOptionalInputsResult
+ {
+ public readonly string R;
+
+ [OutputConstructor]
+ private FuncWithAllOptionalInputsResult(string r)
+ {
+ R = r;
+ }
+ }
+}
diff --git a/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/dotnet/Inputs/HelmReleaseSettings.cs b/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/dotnet/Inputs/HelmReleaseSettings.cs
new file mode 100644
index 000000000..04aa27280
--- /dev/null
+++ b/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/dotnet/Inputs/HelmReleaseSettings.cs
@@ -0,0 +1,42 @@
+// *** 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.Inputs
+{
+
+ ///
+ /// BETA FEATURE - Options to configure the Helm Release resource.
+ ///
+ public sealed class HelmReleaseSettings : Pulumi.InvokeArgs
+ {
+ ///
+ /// The backend storage driver for Helm. Values are: configmap, secret, memory, sql.
+ ///
+ [Input("driver")]
+ public string? Driver { get; set; }
+
+ ///
+ /// The path to the helm plugins directory.
+ ///
+ [Input("pluginsPath")]
+ public string? PluginsPath { get; set; }
+
+ ///
+ /// to test required args
+ ///
+ [Input("requiredArg", required: true)]
+ public string RequiredArg { get; set; } = null!;
+
+ public HelmReleaseSettings()
+ {
+ Driver = Utilities.GetEnv("PULUMI_K8S_HELM_DRIVER") ?? "secret";
+ PluginsPath = Utilities.GetEnv("PULUMI_K8S_HELM_PLUGINS_PATH");
+ }
+ }
+}
diff --git a/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/dotnet/Inputs/HelmReleaseSettingsArgs.cs b/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/dotnet/Inputs/HelmReleaseSettingsArgs.cs
new file mode 100644
index 000000000..212222ea7
--- /dev/null
+++ b/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/dotnet/Inputs/HelmReleaseSettingsArgs.cs
@@ -0,0 +1,42 @@
+// *** 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.Inputs
+{
+
+ ///
+ /// BETA FEATURE - Options to configure the Helm Release resource.
+ ///
+ public sealed class HelmReleaseSettingsArgs : Pulumi.ResourceArgs
+ {
+ ///
+ /// The backend storage driver for Helm. Values are: configmap, secret, memory, sql.
+ ///
+ [Input("driver")]
+ public Input? Driver { get; set; }
+
+ ///
+ /// The path to the helm plugins directory.
+ ///
+ [Input("pluginsPath")]
+ public Input? PluginsPath { get; set; }
+
+ ///
+ /// to test required args
+ ///
+ [Input("requiredArg", required: true)]
+ public Input RequiredArg { get; set; } = null!;
+
+ public HelmReleaseSettingsArgs()
+ {
+ Driver = Utilities.GetEnv("PULUMI_K8S_HELM_DRIVER") ?? "secret";
+ PluginsPath = Utilities.GetEnv("PULUMI_K8S_HELM_PLUGINS_PATH");
+ }
+ }
+}
diff --git a/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/dotnet/Inputs/KubeClientSettingsArgs.cs b/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/dotnet/Inputs/KubeClientSettingsArgs.cs
new file mode 100644
index 000000000..170d4e1fe
--- /dev/null
+++ b/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/dotnet/Inputs/KubeClientSettingsArgs.cs
@@ -0,0 +1,39 @@
+// *** 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.Inputs
+{
+
+ ///
+ /// Options for tuning the Kubernetes client used by a Provider.
+ ///
+ public sealed class KubeClientSettingsArgs : Pulumi.ResourceArgs
+ {
+ ///
+ /// Maximum burst for throttle. Default value is 10.
+ ///
+ [Input("burst")]
+ public Input? Burst { get; set; }
+
+ ///
+ /// Maximum queries per second (QPS) to the API server from this client. Default value is 5.
+ ///
+ [Input("qps")]
+ public Input? Qps { get; set; }
+
+ [Input("recTest")]
+ public Input? RecTest { get; set; }
+
+ public KubeClientSettingsArgs()
+ {
+ Burst = Utilities.GetEnvInt32("PULUMI_K8S_CLIENT_BURST");
+ Qps = Utilities.GetEnvDouble("PULUMI_K8S_CLIENT_QPS");
+ }
+ }
+}
diff --git a/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/dotnet/Inputs/LayeredTypeArgs.cs b/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/dotnet/Inputs/LayeredTypeArgs.cs
new file mode 100644
index 000000000..0e7825c19
--- /dev/null
+++ b/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/dotnet/Inputs/LayeredTypeArgs.cs
@@ -0,0 +1,55 @@
+// *** 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.Inputs
+{
+
+ ///
+ /// Make sure that defaults propagate through types
+ ///
+ public sealed class LayeredTypeArgs : Pulumi.ResourceArgs
+ {
+ ///
+ /// The answer to the question
+ ///
+ [Input("answer")]
+ public Input? Answer { get; set; }
+
+ [Input("other", required: true)]
+ public Input Other { get; set; } = null!;
+
+ ///
+ /// Test how plain types interact
+ ///
+ [Input("plainOther")]
+ public Inputs.HelmReleaseSettingsArgs? PlainOther { get; set; }
+
+ ///
+ /// The question already answered
+ ///
+ [Input("question")]
+ public Input? Question { get; set; }
+
+ [Input("recursive")]
+ public Input? Recursive { get; set; }
+
+ ///
+ /// To ask and answer
+ ///
+ [Input("thinker", required: true)]
+ public Input Thinker { get; set; } = null!;
+
+ public LayeredTypeArgs()
+ {
+ Answer = 42;
+ Question = Utilities.GetEnv("PULUMI_THE_QUESTION") ?? "";
+ Thinker = "not a good interaction";
+ }
+ }
+}
diff --git a/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/dotnet/Inputs/TypArgs.cs b/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/dotnet/Inputs/TypArgs.cs
new file mode 100644
index 000000000..663325d73
--- /dev/null
+++ b/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/dotnet/Inputs/TypArgs.cs
@@ -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! ***
+
+using System;
+using System.Collections.Generic;
+using System.Collections.Immutable;
+using System.Threading.Tasks;
+using Pulumi.Serialization;
+
+namespace Pulumi.Example.Inputs
+{
+
+ ///
+ /// A test for namespaces (mod main)
+ ///
+ public sealed class TypArgs : Pulumi.ResourceArgs
+ {
+ [Input("mod1")]
+ public Input? Mod1 { get; set; }
+
+ [Input("mod2")]
+ public Input? Mod2 { get; set; }
+
+ [Input("val")]
+ public Input? Val { get; set; }
+
+ public TypArgs()
+ {
+ Val = "mod main";
+ }
+ }
+}
diff --git a/pkg/codegen/internal/test/testdata/env-helper/dotnet/Mod1/Inputs/TypArgs.cs b/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/dotnet/Mod1/Inputs/TypArgs.cs
similarity index 100%
rename from pkg/codegen/internal/test/testdata/env-helper/dotnet/Mod1/Inputs/TypArgs.cs
rename to pkg/codegen/internal/test/testdata/plain-object-disable-defaults/dotnet/Mod1/Inputs/TypArgs.cs
diff --git a/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/dotnet/Mod1/README.md b/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/dotnet/Mod1/README.md
new file mode 100644
index 000000000..e69de29bb
diff --git a/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/dotnet/Mod2/Inputs/TypArgs.cs b/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/dotnet/Mod2/Inputs/TypArgs.cs
new file mode 100644
index 000000000..d8f075931
--- /dev/null
+++ b/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/dotnet/Mod2/Inputs/TypArgs.cs
@@ -0,0 +1,29 @@
+// *** 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.Mod2.Inputs
+{
+
+ ///
+ /// A test for namespaces (mod 2)
+ ///
+ public sealed class TypArgs : Pulumi.ResourceArgs
+ {
+ [Input("mod1")]
+ public Input? Mod1 { get; set; }
+
+ [Input("val")]
+ public Input? Val { get; set; }
+
+ public TypArgs()
+ {
+ Val = "mod2";
+ }
+ }
+}
diff --git a/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/dotnet/Mod2/README.md b/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/dotnet/Mod2/README.md
new file mode 100644
index 000000000..e69de29bb
diff --git a/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/dotnet/ModuleTest.cs b/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/dotnet/ModuleTest.cs
new file mode 100644
index 000000000..1cfff078c
--- /dev/null
+++ b/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/dotnet/ModuleTest.cs
@@ -0,0 +1,69 @@
+// *** 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:index:moduleTest")]
+ public partial class ModuleTest : Pulumi.CustomResource
+ {
+ ///
+ /// Create a ModuleTest 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 ModuleTest(string name, ModuleTestArgs? args = null, CustomResourceOptions? options = null)
+ : base("example:index:moduleTest", name, args ?? new ModuleTestArgs(), MakeResourceOptions(options, ""))
+ {
+ }
+
+ private ModuleTest(string name, Input id, CustomResourceOptions? options = null)
+ : base("example:index:moduleTest", 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 ModuleTest 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 ModuleTest Get(string name, Input id, CustomResourceOptions? options = null)
+ {
+ return new ModuleTest(name, id, options);
+ }
+ }
+
+ public sealed class ModuleTestArgs : Pulumi.ResourceArgs
+ {
+ [Input("mod1")]
+ public Input? Mod1 { get; set; }
+
+ [Input("val")]
+ public Input? Val { get; set; }
+
+ public ModuleTestArgs()
+ {
+ }
+ }
+}
diff --git a/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/dotnet/Outputs/KubeClientSettings.cs b/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/dotnet/Outputs/KubeClientSettings.cs
new file mode 100644
index 000000000..46437c486
--- /dev/null
+++ b/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/dotnet/Outputs/KubeClientSettings.cs
@@ -0,0 +1,42 @@
+// *** 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.Outputs
+{
+
+ ///
+ /// Options for tuning the Kubernetes client used by a Provider.
+ ///
+ [OutputType]
+ public sealed class KubeClientSettings
+ {
+ ///
+ /// Maximum burst for throttle. Default value is 10.
+ ///
+ public readonly int? Burst;
+ ///
+ /// Maximum queries per second (QPS) to the API server from this client. Default value is 5.
+ ///
+ public readonly double? Qps;
+ public readonly Outputs.KubeClientSettings? RecTest;
+
+ [OutputConstructor]
+ private KubeClientSettings(
+ int? burst,
+
+ double? qps,
+
+ Outputs.KubeClientSettings? recTest)
+ {
+ Burst = burst;
+ Qps = qps;
+ RecTest = recTest;
+ }
+ }
+}
diff --git a/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/dotnet/Provider.cs b/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/dotnet/Provider.cs
new file mode 100644
index 000000000..5748ab9f8
--- /dev/null
+++ b/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/dotnet/Provider.cs
@@ -0,0 +1,55 @@
+// *** 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
+{
+ ///
+ /// The provider type for the kubernetes package.
+ ///
+ [ExampleResourceType("pulumi:providers:example")]
+ public partial class Provider : Pulumi.ProviderResource
+ {
+ ///
+ /// Create a Provider 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 Provider(string name, ProviderArgs? args = null, CustomResourceOptions? options = null)
+ : base("example", name, args ?? new ProviderArgs(), MakeResourceOptions(options, ""))
+ {
+ }
+
+ 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;
+ }
+ }
+
+ public sealed class ProviderArgs : Pulumi.ResourceArgs
+ {
+ ///
+ /// BETA FEATURE - Options to configure the Helm Release resource.
+ ///
+ [Input("helmReleaseSettings", json: true)]
+ public Input? HelmReleaseSettings { get; set; }
+
+ public ProviderArgs()
+ {
+ }
+ }
+}
diff --git a/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/dotnet/Pulumi.Example.csproj b/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/dotnet/Pulumi.Example.csproj
new file mode 100644
index 000000000..e59637251
--- /dev/null
+++ b/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/dotnet/Pulumi.Example.csproj
@@ -0,0 +1,56 @@
+
+
+
+ true
+ Pulumi Corp.
+ Pulumi Corp.
+
+
+
+
+ logo.png
+
+ netcoreapp3.1
+ enable
+ false
+
+
+
+ true
+ 1701;1702;1591
+
+
+
+ $(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb
+ true
+ true
+
+
+
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ True
+
+
+
+
+
diff --git a/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/dotnet/README.md b/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/dotnet/README.md
new file mode 100644
index 000000000..e69de29bb
diff --git a/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/dotnet/Utilities.cs b/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/dotnet/Utilities.cs
new file mode 100644
index 000000000..e99f7fe43
--- /dev/null
+++ b/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/dotnet/Utilities.cs
@@ -0,0 +1,87 @@
+// *** 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.IO;
+using System.Reflection;
+using Pulumi;
+
+namespace Pulumi.Example
+{
+ static class Utilities
+ {
+ public static string? GetEnv(params string[] names)
+ {
+ foreach (var n in names)
+ {
+ var value = Environment.GetEnvironmentVariable(n);
+ if (value != null)
+ {
+ return value;
+ }
+ }
+ return null;
+ }
+
+ static string[] trueValues = { "1", "t", "T", "true", "TRUE", "True" };
+ static string[] falseValues = { "0", "f", "F", "false", "FALSE", "False" };
+ public static bool? GetEnvBoolean(params string[] names)
+ {
+ var s = GetEnv(names);
+ if (s != null)
+ {
+ if (Array.IndexOf(trueValues, s) != -1)
+ {
+ return true;
+ }
+ if (Array.IndexOf(falseValues, s) != -1)
+ {
+ return false;
+ }
+ }
+ return null;
+ }
+
+ public static int? GetEnvInt32(params string[] names) => int.TryParse(GetEnv(names), out int v) ? (int?)v : null;
+
+ public static double? GetEnvDouble(params string[] names) => double.TryParse(GetEnv(names), out double v) ? (double?)v : null;
+
+ public static InvokeOptions WithVersion(this InvokeOptions? options)
+ {
+ if (options?.Version != null)
+ {
+ return options;
+ }
+ return new InvokeOptions
+ {
+ Parent = options?.Parent,
+ Provider = options?.Provider,
+ Version = Version,
+ };
+ }
+
+ private readonly static string version;
+ public static string Version => version;
+
+ static Utilities()
+ {
+ var assembly = typeof(Utilities).GetTypeInfo().Assembly;
+ using var stream = assembly.GetManifestResourceStream("Pulumi.Example.version.txt");
+ using var reader = new StreamReader(stream ?? throw new NotSupportedException("Missing embedded version.txt file"));
+ version = reader.ReadToEnd().Trim();
+ var parts = version.Split("\n");
+ if (parts.Length == 2)
+ {
+ // The first part is the provider name.
+ version = parts[1].Trim();
+ }
+ }
+ }
+
+ internal sealed class ExampleResourceTypeAttribute : Pulumi.ResourceTypeAttribute
+ {
+ public ExampleResourceTypeAttribute(string type) : base(type, Utilities.Version)
+ {
+ }
+ }
+}
diff --git a/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/dotnet/codegen-manifest.json b/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/dotnet/codegen-manifest.json
new file mode 100644
index 000000000..889213733
--- /dev/null
+++ b/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/dotnet/codegen-manifest.json
@@ -0,0 +1,22 @@
+{
+ "emittedFiles": [
+ "Foo.cs",
+ "FuncWithAllOptionalInputs.cs",
+ "Inputs/HelmReleaseSettings.cs",
+ "Inputs/HelmReleaseSettingsArgs.cs",
+ "Inputs/KubeClientSettingsArgs.cs",
+ "Inputs/LayeredTypeArgs.cs",
+ "Inputs/TypArgs.cs",
+ "Mod1/Inputs/TypArgs.cs",
+ "Mod1/README.md",
+ "Mod2/Inputs/TypArgs.cs",
+ "Mod2/README.md",
+ "ModuleTest.cs",
+ "Outputs/KubeClientSettings.cs",
+ "Provider.cs",
+ "Pulumi.Example.csproj",
+ "README.md",
+ "Utilities.cs",
+ "logo.png"
+ ]
+}
diff --git a/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/dotnet/logo.png b/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/dotnet/logo.png
new file mode 100644
index 000000000..181f421e9
Binary files /dev/null and b/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/dotnet/logo.png differ
diff --git a/pkg/codegen/internal/test/testdata/env-helper/go/codegen-manifest.json b/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/go/codegen-manifest.json
similarity index 100%
rename from pkg/codegen/internal/test/testdata/env-helper/go/codegen-manifest.json
rename to pkg/codegen/internal/test/testdata/plain-object-disable-defaults/go/codegen-manifest.json
diff --git a/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/go/example/doc.go b/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/go/example/doc.go
new file mode 100644
index 000000000..24cd778aa
--- /dev/null
+++ b/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/go/example/doc.go
@@ -0,0 +1,3 @@
+// Package example exports types, functions, subpackages for provisioning example resources.
+//
+package example
diff --git a/pkg/codegen/internal/test/testdata/env-helper/go/example/foo.go b/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/go/example/foo.go
similarity index 100%
rename from pkg/codegen/internal/test/testdata/env-helper/go/example/foo.go
rename to pkg/codegen/internal/test/testdata/plain-object-disable-defaults/go/example/foo.go
diff --git a/pkg/codegen/internal/test/testdata/env-helper/go/example/funcWithAllOptionalInputs.go b/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/go/example/funcWithAllOptionalInputs.go
similarity index 100%
rename from pkg/codegen/internal/test/testdata/env-helper/go/example/funcWithAllOptionalInputs.go
rename to pkg/codegen/internal/test/testdata/plain-object-disable-defaults/go/example/funcWithAllOptionalInputs.go
diff --git a/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/go/example/init.go b/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/go/example/init.go
new file mode 100644
index 000000000..135eaf0b4
--- /dev/null
+++ b/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/go/example/init.go
@@ -0,0 +1,67 @@
+// *** WARNING: this file was generated by test. ***
+// *** Do not edit by hand unless you're certain you know what you are doing! ***
+
+package example
+
+import (
+ "fmt"
+
+ "github.com/blang/semver"
+ "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
+)
+
+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:index:Foo":
+ r = &Foo{}
+ case "example:index:moduleTest":
+ r = &ModuleTest{}
+ default:
+ return nil, fmt.Errorf("unknown resource type: %s", typ)
+ }
+
+ err = ctx.RegisterResource(typ, name, nil, r, pulumi.URN_(urn))
+ return
+}
+
+type pkg struct {
+ version semver.Version
+}
+
+func (p *pkg) Version() semver.Version {
+ return p.version
+}
+
+func (p *pkg) ConstructProvider(ctx *pulumi.Context, name, typ, urn string) (pulumi.ProviderResource, error) {
+ if typ != "pulumi:providers:example" {
+ return nil, fmt.Errorf("unknown provider type: %s", typ)
+ }
+
+ r := &Provider{}
+ err := ctx.RegisterResource(typ, name, nil, r, pulumi.URN_(urn))
+ return r, err
+}
+
+func init() {
+ version, err := PkgVersion()
+ if err != nil {
+ fmt.Printf("failed to determine package version. defaulting to v1: %v\n", err)
+ }
+ pulumi.RegisterResourceModule(
+ "example",
+ "index",
+ &module{version},
+ )
+ pulumi.RegisterResourcePackage(
+ "example",
+ &pkg{version},
+ )
+}
diff --git a/pkg/codegen/internal/test/testdata/env-helper/go/example/mod1/pulumiTypes.go b/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/go/example/mod1/pulumiTypes.go
similarity index 100%
rename from pkg/codegen/internal/test/testdata/env-helper/go/example/mod1/pulumiTypes.go
rename to pkg/codegen/internal/test/testdata/plain-object-disable-defaults/go/example/mod1/pulumiTypes.go
diff --git a/pkg/codegen/internal/test/testdata/env-helper/go/example/mod2/pulumiTypes.go b/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/go/example/mod2/pulumiTypes.go
similarity index 98%
rename from pkg/codegen/internal/test/testdata/env-helper/go/example/mod2/pulumiTypes.go
rename to pkg/codegen/internal/test/testdata/plain-object-disable-defaults/go/example/mod2/pulumiTypes.go
index e803f4256..49f0124fd 100644
--- a/pkg/codegen/internal/test/testdata/env-helper/go/example/mod2/pulumiTypes.go
+++ b/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/go/example/mod2/pulumiTypes.go
@@ -7,8 +7,8 @@ import (
"context"
"reflect"
- "env-helper/example/mod1"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
+ "plain-object-disable-defaults/example/mod1"
)
// A test for namespaces (mod 2)
diff --git a/pkg/codegen/internal/test/testdata/env-helper/go/example/moduleTest.go b/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/go/example/moduleTest.go
similarity index 98%
rename from pkg/codegen/internal/test/testdata/env-helper/go/example/moduleTest.go
rename to pkg/codegen/internal/test/testdata/plain-object-disable-defaults/go/example/moduleTest.go
index ea788d244..9769acc17 100644
--- a/pkg/codegen/internal/test/testdata/env-helper/go/example/moduleTest.go
+++ b/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/go/example/moduleTest.go
@@ -7,8 +7,8 @@ import (
"context"
"reflect"
- "env-helper/example/mod1"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
+ "plain-object-disable-defaults/example/mod1"
)
type ModuleTest struct {
diff --git a/pkg/codegen/internal/test/testdata/env-helper/go/example/provider.go b/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/go/example/provider.go
similarity index 100%
rename from pkg/codegen/internal/test/testdata/env-helper/go/example/provider.go
rename to pkg/codegen/internal/test/testdata/plain-object-disable-defaults/go/example/provider.go
diff --git a/pkg/codegen/internal/test/testdata/env-helper/go/example/pulumiTypes.go b/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/go/example/pulumiTypes.go
similarity index 99%
rename from pkg/codegen/internal/test/testdata/env-helper/go/example/pulumiTypes.go
rename to pkg/codegen/internal/test/testdata/plain-object-disable-defaults/go/example/pulumiTypes.go
index 3e5c6b754..a48754d3f 100644
--- a/pkg/codegen/internal/test/testdata/env-helper/go/example/pulumiTypes.go
+++ b/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/go/example/pulumiTypes.go
@@ -7,9 +7,9 @@ import (
"context"
"reflect"
- "env-helper/example/mod1"
- "env-helper/example/mod2"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
+ "plain-object-disable-defaults/example/mod1"
+ "plain-object-disable-defaults/example/mod2"
)
// BETA FEATURE - Options to configure the Helm Release resource.
diff --git a/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/go/example/pulumiUtilities.go b/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/go/example/pulumiUtilities.go
new file mode 100644
index 000000000..66ab34c97
--- /dev/null
+++ b/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/go/example/pulumiUtilities.go
@@ -0,0 +1,85 @@
+// *** WARNING: this file was generated by test. ***
+// *** Do not edit by hand unless you're certain you know what you are doing! ***
+
+package example
+
+import (
+ "fmt"
+ "os"
+ "reflect"
+ "regexp"
+ "strconv"
+ "strings"
+
+ "github.com/blang/semver"
+ "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
+)
+
+type envParser func(v string) interface{}
+
+func parseEnvBool(v string) interface{} {
+ b, err := strconv.ParseBool(v)
+ if err != nil {
+ return nil
+ }
+ return b
+}
+
+func parseEnvInt(v string) interface{} {
+ i, err := strconv.ParseInt(v, 0, 0)
+ if err != nil {
+ return nil
+ }
+ return int(i)
+}
+
+func parseEnvFloat(v string) interface{} {
+ f, err := strconv.ParseFloat(v, 64)
+ if err != nil {
+ return nil
+ }
+ return f
+}
+
+func parseEnvStringArray(v string) interface{} {
+ var result pulumi.StringArray
+ for _, item := range strings.Split(v, ";") {
+ result = append(result, pulumi.String(item))
+ }
+ return result
+}
+
+func getEnvOrDefault(def interface{}, parser envParser, vars ...string) interface{} {
+ for _, v := range vars {
+ if value := os.Getenv(v); value != "" {
+ if parser != nil {
+ return parser(value)
+ }
+ return value
+ }
+ }
+ return def
+}
+
+// PkgVersion uses reflection to determine the version of the current package.
+func PkgVersion() (semver.Version, error) {
+ type sentinal struct{}
+ pkgPath := reflect.TypeOf(sentinal{}).PkgPath()
+ re := regexp.MustCompile("^.*/pulumi-example/sdk(/v\\d+)?")
+ if match := re.FindStringSubmatch(pkgPath); match != nil {
+ vStr := match[1]
+ if len(vStr) == 0 { // If the version capture group was empty, default to v1.
+ return semver.Version{Major: 1}, nil
+ }
+ return semver.MustParse(fmt.Sprintf("%s.0.0", vStr[2:])), nil
+ }
+ return semver.Version{}, fmt.Errorf("failed to determine the package version from %s", pkgPath)
+}
+
+// isZero is a null safe check for if a value is it's types zero value.
+func isZero(v interface{}) bool {
+ if v == nil {
+ return true
+ }
+ return reflect.ValueOf(v).IsZero()
+}
diff --git a/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/nodejs/README.md b/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/nodejs/README.md
new file mode 100644
index 000000000..e69de29bb
diff --git a/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/nodejs/codegen-manifest.json b/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/nodejs/codegen-manifest.json
new file mode 100644
index 000000000..635ce30dc
--- /dev/null
+++ b/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/nodejs/codegen-manifest.json
@@ -0,0 +1,16 @@
+{
+ "emittedFiles": [
+ "README.md",
+ "foo.ts",
+ "funcWithAllOptionalInputs.ts",
+ "index.ts",
+ "moduleTest.ts",
+ "package.json",
+ "provider.ts",
+ "tsconfig.json",
+ "types/index.ts",
+ "types/input.ts",
+ "types/output.ts",
+ "utilities.ts"
+ ]
+}
diff --git a/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/nodejs/foo.ts b/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/nodejs/foo.ts
new file mode 100644
index 000000000..61a309b50
--- /dev/null
+++ b/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/nodejs/foo.ts
@@ -0,0 +1,89 @@
+// *** 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 { input as inputs, output as outputs } from "./types";
+import * as utilities from "./utilities";
+
+/**
+ * test new feature with resoruces
+ */
+export class Foo extends pulumi.CustomResource {
+ /**
+ * Get an existing Foo 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): Foo {
+ return new Foo(name, undefined as any, { ...opts, id: id });
+ }
+
+ /** @internal */
+ public static readonly __pulumiType = 'example:index:Foo';
+
+ /**
+ * Returns true if the given object is an instance of Foo. 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 Foo {
+ if (obj === undefined || obj === null) {
+ return false;
+ }
+ return obj['__pulumiType'] === Foo.__pulumiType;
+ }
+
+ /**
+ * A test for plain types
+ */
+ public /*out*/ readonly defaultKubeClientSettings!: pulumi.Output;
+
+ /**
+ * Create a Foo 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: FooArgs, opts?: pulumi.CustomResourceOptions) {
+ let resourceInputs: pulumi.Inputs = {};
+ opts = opts || {};
+ if (!opts.id) {
+ if ((!args || args.backupKubeClientSettings === undefined) && !opts.urn) {
+ throw new Error("Missing required property 'backupKubeClientSettings'");
+ }
+ resourceInputs["argument"] = args ? args.argument : undefined;
+ resourceInputs["backupKubeClientSettings"] = args ? (args.backupKubeClientSettings ? pulumi.output(args.backupKubeClientSettings).apply(inputs.kubeClientSettingsArgsProvideDefaults) : undefined) : undefined;
+ resourceInputs["kubeClientSettings"] = args ? (args.kubeClientSettings ? pulumi.output(args.kubeClientSettings).apply(inputs.kubeClientSettingsArgsProvideDefaults) : undefined) : undefined;
+ resourceInputs["settings"] = args ? (args.settings ? pulumi.output(args.settings).apply(inputs.layeredTypeArgsProvideDefaults) : undefined) : undefined;
+ resourceInputs["defaultKubeClientSettings"] = undefined /*out*/;
+ } else {
+ resourceInputs["defaultKubeClientSettings"] = undefined /*out*/;
+ }
+ if (!opts.version) {
+ opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()});
+ }
+ super(Foo.__pulumiType, name, resourceInputs, opts);
+ }
+}
+
+/**
+ * The set of arguments for constructing a Foo resource.
+ */
+export interface FooArgs {
+ argument?: string;
+ /**
+ * Options for tuning the Kubernetes client used by a Provider.
+ */
+ backupKubeClientSettings: pulumi.Input;
+ /**
+ * Options for tuning the Kubernetes client used by a Provider.
+ */
+ kubeClientSettings?: pulumi.Input;
+ /**
+ * describing things
+ */
+ settings?: pulumi.Input;
+}
diff --git a/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/nodejs/funcWithAllOptionalInputs.ts b/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/nodejs/funcWithAllOptionalInputs.ts
new file mode 100644
index 000000000..480f1db51
--- /dev/null
+++ b/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/nodejs/funcWithAllOptionalInputs.ts
@@ -0,0 +1,54 @@
+// *** 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 { input as inputs, output as outputs } from "./types";
+import * as utilities from "./utilities";
+
+/**
+ * Check codegen of functions with all optional inputs.
+ */
+export function funcWithAllOptionalInputs(args?: FuncWithAllOptionalInputsArgs, opts?: pulumi.InvokeOptions): Promise {
+ args = args || {};
+ if (!opts) {
+ opts = {}
+ }
+
+ if (!opts.version) {
+ opts.version = utilities.getVersion();
+ }
+ return pulumi.runtime.invoke("mypkg::funcWithAllOptionalInputs", {
+ "a": args.a ? inputs.helmReleaseSettingsProvideDefaults(args.a) : undefined,
+ "b": args.b,
+ }, opts);
+}
+
+export interface FuncWithAllOptionalInputsArgs {
+ /**
+ * Property A
+ */
+ a?: inputs.HelmReleaseSettings;
+ /**
+ * Property B
+ */
+ b?: string;
+}
+
+export interface FuncWithAllOptionalInputsResult {
+ readonly r: string;
+}
+
+export function funcWithAllOptionalInputsOutput(args?: FuncWithAllOptionalInputsOutputArgs, opts?: pulumi.InvokeOptions): pulumi.Output {
+ return pulumi.output(args).apply(a => funcWithAllOptionalInputs(a, opts))
+}
+
+export interface FuncWithAllOptionalInputsOutputArgs {
+ /**
+ * Property A
+ */
+ a?: pulumi.Input;
+ /**
+ * Property B
+ */
+ b?: pulumi.Input;
+}
diff --git a/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/nodejs/index.ts b/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/nodejs/index.ts
new file mode 100644
index 000000000..16e9f9075
--- /dev/null
+++ b/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/nodejs/index.ts
@@ -0,0 +1,49 @@
+// *** 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 * from "./foo";
+export * from "./funcWithAllOptionalInputs";
+export * from "./moduleTest";
+export * from "./provider";
+
+// Export sub-modules:
+import * as types from "./types";
+
+export {
+ types,
+};
+
+// Import resources to register:
+import { Foo } from "./foo";
+import { ModuleTest } from "./moduleTest";
+
+const _module = {
+ version: utilities.getVersion(),
+ construct: (name: string, type: string, urn: string): pulumi.Resource => {
+ switch (type) {
+ case "example:index:Foo":
+ return new Foo(name, undefined, { urn })
+ case "example:index:moduleTest":
+ return new ModuleTest(name, undefined, { urn })
+ default:
+ throw new Error(`unknown resource type ${type}`);
+ }
+ },
+};
+pulumi.runtime.registerResourceModule("example", "index", _module)
+
+import { Provider } from "./provider";
+
+pulumi.runtime.registerResourcePackage("example", {
+ version: utilities.getVersion(),
+ constructProvider: (name: string, type: string, urn: string): pulumi.ProviderResource => {
+ if (type !== "pulumi:providers:example") {
+ throw new Error(`unknown provider type ${type}`);
+ }
+ return new Provider(name, undefined, { urn });
+ },
+});
diff --git a/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/nodejs/moduleTest.ts b/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/nodejs/moduleTest.ts
new file mode 100644
index 000000000..ae75cac89
--- /dev/null
+++ b/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/nodejs/moduleTest.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 { input as inputs, output as outputs } from "./types";
+import * as utilities from "./utilities";
+
+export class ModuleTest extends pulumi.CustomResource {
+ /**
+ * Get an existing ModuleTest 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): ModuleTest {
+ return new ModuleTest(name, undefined as any, { ...opts, id: id });
+ }
+
+ /** @internal */
+ public static readonly __pulumiType = 'example:index:moduleTest';
+
+ /**
+ * Returns true if the given object is an instance of ModuleTest. 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 ModuleTest {
+ if (obj === undefined || obj === null) {
+ return false;
+ }
+ return obj['__pulumiType'] === ModuleTest.__pulumiType;
+ }
+
+
+ /**
+ * Create a ModuleTest 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?: ModuleTestArgs, opts?: pulumi.CustomResourceOptions) {
+ let resourceInputs: pulumi.Inputs = {};
+ opts = opts || {};
+ if (!opts.id) {
+ resourceInputs["mod1"] = args ? (args.mod1 ? pulumi.output(args.mod1).apply(inputs.mod1.typArgsProvideDefaults) : undefined) : undefined;
+ resourceInputs["val"] = args ? (args.val ? pulumi.output(args.val).apply(inputs.typArgsProvideDefaults) : undefined) : undefined;
+ } else {
+ }
+ if (!opts.version) {
+ opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()});
+ }
+ super(ModuleTest.__pulumiType, name, resourceInputs, opts);
+ }
+}
+
+/**
+ * The set of arguments for constructing a ModuleTest resource.
+ */
+export interface ModuleTestArgs {
+ mod1?: pulumi.Input;
+ val?: pulumi.Input;
+}
diff --git a/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/nodejs/package.json b/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/nodejs/package.json
new file mode 100644
index 000000000..63e5dd7b9
--- /dev/null
+++ b/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/nodejs/package.json
@@ -0,0 +1,16 @@
+{
+ "name": "@pulumi/example",
+ "version": "${VERSION}",
+ "scripts": {
+ "build": "tsc"
+ },
+ "dependencies": {
+ "@pulumi/pulumi": "^3.12"
+ },
+ "devDependencies": {
+ "typescript": "^3.7.0"
+ },
+ "pulumi": {
+ "resource": true
+ }
+}
diff --git a/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/nodejs/provider.ts b/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/nodejs/provider.ts
new file mode 100644
index 000000000..9f83355a1
--- /dev/null
+++ b/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/nodejs/provider.ts
@@ -0,0 +1,55 @@
+// *** 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 { input as inputs, output as outputs } from "./types";
+import * as utilities from "./utilities";
+
+/**
+ * The provider type for the kubernetes package.
+ */
+export class Provider extends pulumi.ProviderResource {
+ /** @internal */
+ public static readonly __pulumiType = 'example';
+
+ /**
+ * Returns true if the given object is an instance of Provider. 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 Provider {
+ if (obj === undefined || obj === null) {
+ return false;
+ }
+ return obj['__pulumiType'] === Provider.__pulumiType;
+ }
+
+
+ /**
+ * Create a Provider 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?: ProviderArgs, opts?: pulumi.ResourceOptions) {
+ let resourceInputs: pulumi.Inputs = {};
+ opts = opts || {};
+ {
+ resourceInputs["helmReleaseSettings"] = pulumi.output(args ? (args.helmReleaseSettings ? pulumi.output(args.helmReleaseSettings).apply(inputs.helmReleaseSettingsArgsProvideDefaults) : undefined) : undefined).apply(JSON.stringify);
+ }
+ if (!opts.version) {
+ opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()});
+ }
+ super(Provider.__pulumiType, name, resourceInputs, opts);
+ }
+}
+
+/**
+ * The set of arguments for constructing a Provider resource.
+ */
+export interface ProviderArgs {
+ /**
+ * BETA FEATURE - Options to configure the Helm Release resource.
+ */
+ helmReleaseSettings?: pulumi.Input;
+}
diff --git a/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/nodejs/tsconfig.json b/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/nodejs/tsconfig.json
new file mode 100644
index 000000000..9ed19d148
--- /dev/null
+++ b/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/nodejs/tsconfig.json
@@ -0,0 +1,26 @@
+{
+ "compilerOptions": {
+ "outDir": "bin",
+ "target": "es2016",
+ "module": "commonjs",
+ "moduleResolution": "node",
+ "declaration": true,
+ "sourceMap": true,
+ "stripInternal": true,
+ "experimentalDecorators": true,
+ "noFallthroughCasesInSwitch": true,
+ "forceConsistentCasingInFileNames": true,
+ "strict": true
+ },
+ "files": [
+ "foo.ts",
+ "funcWithAllOptionalInputs.ts",
+ "index.ts",
+ "moduleTest.ts",
+ "provider.ts",
+ "types/index.ts",
+ "types/input.ts",
+ "types/output.ts",
+ "utilities.ts"
+ ]
+}
diff --git a/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/nodejs/types/index.ts b/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/nodejs/types/index.ts
new file mode 100644
index 000000000..aec972eb2
--- /dev/null
+++ b/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/nodejs/types/index.ts
@@ -0,0 +1,11 @@
+// *** WARNING: this file was generated by test. ***
+// *** Do not edit by hand unless you're certain you know what you are doing! ***
+
+// Export sub-modules:
+import * as input from "./input";
+import * as output from "./output";
+
+export {
+ input,
+ output,
+};
diff --git a/pkg/codegen/internal/test/testdata/env-helper/nodejs/types/input.ts b/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/nodejs/types/input.ts
similarity index 100%
rename from pkg/codegen/internal/test/testdata/env-helper/nodejs/types/input.ts
rename to pkg/codegen/internal/test/testdata/plain-object-disable-defaults/nodejs/types/input.ts
diff --git a/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/nodejs/types/output.ts b/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/nodejs/types/output.ts
new file mode 100644
index 000000000..49ca43634
--- /dev/null
+++ b/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/nodejs/types/output.ts
@@ -0,0 +1,39 @@
+// *** 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 { input as inputs, output as outputs } from "../types";
+
+import * as utilities from "../utilities";
+
+/**
+ * Options for tuning the Kubernetes client used by a Provider.
+ */
+export interface KubeClientSettings {
+ /**
+ * Maximum burst for throttle. Default value is 10.
+ */
+ burst?: number;
+ /**
+ * Maximum queries per second (QPS) to the API server from this client. Default value is 5.
+ */
+ qps?: number;
+ recTest?: outputs.KubeClientSettings;
+}
+/**
+ * kubeClientSettingsProvideDefaults sets the appropriate defaults for KubeClientSettings
+ */
+export function kubeClientSettingsProvideDefaults(val: KubeClientSettings): KubeClientSettings {
+ return {
+ ...val,
+ burst: (val.burst) ?? utilities.getEnvNumber("PULUMI_K8S_CLIENT_BURST"),
+ qps: (val.qps) ?? utilities.getEnvNumber("PULUMI_K8S_CLIENT_QPS"),
+ recTest: (val.recTest ? outputs.kubeClientSettingsProvideDefaults(val.recTest) : undefined),
+ };
+}
+
+export namespace mod1 {
+}
+
+export namespace mod2 {
+}
diff --git a/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/nodejs/utilities.ts b/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/nodejs/utilities.ts
new file mode 100644
index 000000000..f26ed073c
--- /dev/null
+++ b/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/nodejs/utilities.ts
@@ -0,0 +1,49 @@
+// *** WARNING: this file was generated by test. ***
+// *** Do not edit by hand unless you're certain you know what you are doing! ***
+
+
+export function getEnv(...vars: string[]): string | undefined {
+ for (const v of vars) {
+ const value = process.env[v];
+ if (value) {
+ return value;
+ }
+ }
+ return undefined;
+}
+
+export function getEnvBoolean(...vars: string[]): boolean | undefined {
+ const s = getEnv(...vars);
+ if (s !== undefined) {
+ // NOTE: these values are taken from https://golang.org/src/strconv/atob.go?s=351:391#L1, which is what
+ // Terraform uses internally when parsing boolean values.
+ if (["1", "t", "T", "true", "TRUE", "True"].find(v => v === s) !== undefined) {
+ return true;
+ }
+ if (["0", "f", "F", "false", "FALSE", "False"].find(v => v === s) !== undefined) {
+ return false;
+ }
+ }
+ return undefined;
+}
+
+export function getEnvNumber(...vars: string[]): number | undefined {
+ const s = getEnv(...vars);
+ if (s !== undefined) {
+ const f = parseFloat(s);
+ if (!isNaN(f)) {
+ return f;
+ }
+ }
+ return undefined;
+}
+
+export function getVersion(): string {
+ let version = require('./package.json').version;
+ // Node allows for the version to be prefixed by a "v", while semver doesn't.
+ // If there is a v, strip it off.
+ if (version.indexOf('v') === 0) {
+ version = version.slice(1);
+ }
+ return version;
+}
diff --git a/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/python/codegen-manifest.json b/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/python/codegen-manifest.json
new file mode 100644
index 000000000..8e4d2595b
--- /dev/null
+++ b/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/python/codegen-manifest.json
@@ -0,0 +1,19 @@
+{
+ "emittedFiles": [
+ "pulumi_example/README.md",
+ "pulumi_example/__init__.py",
+ "pulumi_example/_inputs.py",
+ "pulumi_example/_utilities.py",
+ "pulumi_example/foo.py",
+ "pulumi_example/func_with_all_optional_inputs.py",
+ "pulumi_example/mod1/__init__.py",
+ "pulumi_example/mod1/_inputs.py",
+ "pulumi_example/mod2/__init__.py",
+ "pulumi_example/mod2/_inputs.py",
+ "pulumi_example/module_test.py",
+ "pulumi_example/outputs.py",
+ "pulumi_example/provider.py",
+ "pulumi_example/py.typed",
+ "setup.py"
+ ]
+}
diff --git a/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/python/pulumi_example/README.md b/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/python/pulumi_example/README.md
new file mode 100644
index 000000000..e69de29bb
diff --git a/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/python/pulumi_example/__init__.py b/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/python/pulumi_example/__init__.py
new file mode 100644
index 000000000..faa897cae
--- /dev/null
+++ b/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/python/pulumi_example/__init__.py
@@ -0,0 +1,49 @@
+# 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 .foo import *
+from .func_with_all_optional_inputs import *
+from .module_test import *
+from .provider import *
+from ._inputs import *
+from . import outputs
+
+# Make subpackages available:
+if typing.TYPE_CHECKING:
+ import pulumi_example.mod1 as __mod1
+ mod1 = __mod1
+ import pulumi_example.mod2 as __mod2
+ mod2 = __mod2
+else:
+ mod1 = _utilities.lazy_import('pulumi_example.mod1')
+ mod2 = _utilities.lazy_import('pulumi_example.mod2')
+
+_utilities.register(
+ resource_modules="""
+[
+ {
+ "pkg": "example",
+ "mod": "index",
+ "fqn": "pulumi_example",
+ "classes": {
+ "example:index:Foo": "Foo",
+ "example:index:moduleTest": "ModuleTest"
+ }
+ }
+]
+""",
+ resource_packages="""
+[
+ {
+ "pkg": "example",
+ "token": "pulumi:providers:example",
+ "fqn": "pulumi_example",
+ "class": "Provider"
+ }
+]
+"""
+)
diff --git a/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/python/pulumi_example/_inputs.py b/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/python/pulumi_example/_inputs.py
new file mode 100644
index 000000000..8257d5e0d
--- /dev/null
+++ b/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/python/pulumi_example/_inputs.py
@@ -0,0 +1,340 @@
+# 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 warnings
+import pulumi
+import pulumi.runtime
+from typing import Any, Mapping, Optional, Sequence, Union, overload
+from . import _utilities
+from . import mod1 as _mod1
+from . import mod2 as _mod2
+
+__all__ = [
+ 'HelmReleaseSettings',
+ 'HelmReleaseSettingsArgs',
+ 'KubeClientSettingsArgs',
+ 'LayeredTypeArgs',
+ 'TypArgs',
+]
+
+@pulumi.input_type
+class HelmReleaseSettings:
+ def __init__(__self__, *,
+ required_arg: str,
+ driver: Optional[str] = None,
+ plugins_path: Optional[str] = None):
+ """
+ BETA FEATURE - Options to configure the Helm Release resource.
+ :param str required_arg: to test required args
+ :param str driver: The backend storage driver for Helm. Values are: configmap, secret, memory, sql.
+ :param str plugins_path: The path to the helm plugins directory.
+ """
+ pulumi.set(__self__, "required_arg", required_arg)
+ if driver is None:
+ driver = (_utilities.get_env('PULUMI_K8S_HELM_DRIVER') or 'secret')
+ if driver is not None:
+ pulumi.set(__self__, "driver", driver)
+ if plugins_path is None:
+ plugins_path = _utilities.get_env('PULUMI_K8S_HELM_PLUGINS_PATH')
+ if plugins_path is not None:
+ pulumi.set(__self__, "plugins_path", plugins_path)
+
+ @property
+ @pulumi.getter(name="requiredArg")
+ def required_arg(self) -> str:
+ """
+ to test required args
+ """
+ return pulumi.get(self, "required_arg")
+
+ @required_arg.setter
+ def required_arg(self, value: str):
+ pulumi.set(self, "required_arg", value)
+
+ @property
+ @pulumi.getter
+ def driver(self) -> Optional[str]:
+ """
+ The backend storage driver for Helm. Values are: configmap, secret, memory, sql.
+ """
+ return pulumi.get(self, "driver")
+
+ @driver.setter
+ def driver(self, value: Optional[str]):
+ pulumi.set(self, "driver", value)
+
+ @property
+ @pulumi.getter(name="pluginsPath")
+ def plugins_path(self) -> Optional[str]:
+ """
+ The path to the helm plugins directory.
+ """
+ return pulumi.get(self, "plugins_path")
+
+ @plugins_path.setter
+ def plugins_path(self, value: Optional[str]):
+ pulumi.set(self, "plugins_path", value)
+
+
+@pulumi.input_type
+class HelmReleaseSettingsArgs:
+ def __init__(__self__, *,
+ required_arg: pulumi.Input[str],
+ driver: Optional[pulumi.Input[str]] = None,
+ plugins_path: Optional[pulumi.Input[str]] = None):
+ """
+ BETA FEATURE - Options to configure the Helm Release resource.
+ :param pulumi.Input[str] required_arg: to test required args
+ :param pulumi.Input[str] driver: The backend storage driver for Helm. Values are: configmap, secret, memory, sql.
+ :param pulumi.Input[str] plugins_path: The path to the helm plugins directory.
+ """
+ pulumi.set(__self__, "required_arg", required_arg)
+ if driver is None:
+ driver = (_utilities.get_env('PULUMI_K8S_HELM_DRIVER') or 'secret')
+ if driver is not None:
+ pulumi.set(__self__, "driver", driver)
+ if plugins_path is None:
+ plugins_path = _utilities.get_env('PULUMI_K8S_HELM_PLUGINS_PATH')
+ if plugins_path is not None:
+ pulumi.set(__self__, "plugins_path", plugins_path)
+
+ @property
+ @pulumi.getter(name="requiredArg")
+ def required_arg(self) -> pulumi.Input[str]:
+ """
+ to test required args
+ """
+ return pulumi.get(self, "required_arg")
+
+ @required_arg.setter
+ def required_arg(self, value: pulumi.Input[str]):
+ pulumi.set(self, "required_arg", value)
+
+ @property
+ @pulumi.getter
+ def driver(self) -> Optional[pulumi.Input[str]]:
+ """
+ The backend storage driver for Helm. Values are: configmap, secret, memory, sql.
+ """
+ return pulumi.get(self, "driver")
+
+ @driver.setter
+ def driver(self, value: Optional[pulumi.Input[str]]):
+ pulumi.set(self, "driver", value)
+
+ @property
+ @pulumi.getter(name="pluginsPath")
+ def plugins_path(self) -> Optional[pulumi.Input[str]]:
+ """
+ The path to the helm plugins directory.
+ """
+ return pulumi.get(self, "plugins_path")
+
+ @plugins_path.setter
+ def plugins_path(self, value: Optional[pulumi.Input[str]]):
+ pulumi.set(self, "plugins_path", value)
+
+
+@pulumi.input_type
+class KubeClientSettingsArgs:
+ def __init__(__self__, *,
+ burst: Optional[pulumi.Input[int]] = None,
+ qps: Optional[pulumi.Input[float]] = None,
+ rec_test: Optional[pulumi.Input['KubeClientSettingsArgs']] = None):
+ """
+ Options for tuning the Kubernetes client used by a Provider.
+ :param pulumi.Input[int] burst: Maximum burst for throttle. Default value is 10.
+ :param pulumi.Input[float] qps: Maximum queries per second (QPS) to the API server from this client. Default value is 5.
+ """
+ if burst is None:
+ burst = _utilities.get_env_int('PULUMI_K8S_CLIENT_BURST')
+ if burst is not None:
+ pulumi.set(__self__, "burst", burst)
+ if qps is None:
+ qps = _utilities.get_env_float('PULUMI_K8S_CLIENT_QPS')
+ if qps is not None:
+ pulumi.set(__self__, "qps", qps)
+ if rec_test is not None:
+ pulumi.set(__self__, "rec_test", rec_test)
+
+ @property
+ @pulumi.getter
+ def burst(self) -> Optional[pulumi.Input[int]]:
+ """
+ Maximum burst for throttle. Default value is 10.
+ """
+ return pulumi.get(self, "burst")
+
+ @burst.setter
+ def burst(self, value: Optional[pulumi.Input[int]]):
+ pulumi.set(self, "burst", value)
+
+ @property
+ @pulumi.getter
+ def qps(self) -> Optional[pulumi.Input[float]]:
+ """
+ Maximum queries per second (QPS) to the API server from this client. Default value is 5.
+ """
+ return pulumi.get(self, "qps")
+
+ @qps.setter
+ def qps(self, value: Optional[pulumi.Input[float]]):
+ pulumi.set(self, "qps", value)
+
+ @property
+ @pulumi.getter(name="recTest")
+ def rec_test(self) -> Optional[pulumi.Input['KubeClientSettingsArgs']]:
+ return pulumi.get(self, "rec_test")
+
+ @rec_test.setter
+ def rec_test(self, value: Optional[pulumi.Input['KubeClientSettingsArgs']]):
+ pulumi.set(self, "rec_test", value)
+
+
+@pulumi.input_type
+class LayeredTypeArgs:
+ def __init__(__self__, *,
+ other: pulumi.Input['HelmReleaseSettingsArgs'],
+ thinker: pulumi.Input[str],
+ answer: Optional[pulumi.Input[float]] = None,
+ plain_other: Optional['HelmReleaseSettingsArgs'] = None,
+ question: Optional[pulumi.Input[str]] = None,
+ recursive: Optional[pulumi.Input['LayeredTypeArgs']] = None):
+ """
+ Make sure that defaults propagate through types
+ :param pulumi.Input[str] thinker: To ask and answer
+ :param pulumi.Input[float] answer: The answer to the question
+ :param 'HelmReleaseSettingsArgs' plain_other: Test how plain types interact
+ :param pulumi.Input[str] question: The question already answered
+ """
+ pulumi.set(__self__, "other", other)
+ if thinker is None:
+ thinker = 'not a good interaction'
+ pulumi.set(__self__, "thinker", thinker)
+ if answer is None:
+ answer = 42
+ if answer is not None:
+ pulumi.set(__self__, "answer", answer)
+ if plain_other is not None:
+ pulumi.set(__self__, "plain_other", plain_other)
+ if question is None:
+ question = (_utilities.get_env('PULUMI_THE_QUESTION') or '')
+ if question is not None:
+ pulumi.set(__self__, "question", question)
+ if recursive is not None:
+ pulumi.set(__self__, "recursive", recursive)
+
+ @property
+ @pulumi.getter
+ def other(self) -> pulumi.Input['HelmReleaseSettingsArgs']:
+ return pulumi.get(self, "other")
+
+ @other.setter
+ def other(self, value: pulumi.Input['HelmReleaseSettingsArgs']):
+ pulumi.set(self, "other", value)
+
+ @property
+ @pulumi.getter
+ def thinker(self) -> pulumi.Input[str]:
+ """
+ To ask and answer
+ """
+ return pulumi.get(self, "thinker")
+
+ @thinker.setter
+ def thinker(self, value: pulumi.Input[str]):
+ pulumi.set(self, "thinker", value)
+
+ @property
+ @pulumi.getter
+ def answer(self) -> Optional[pulumi.Input[float]]:
+ """
+ The answer to the question
+ """
+ return pulumi.get(self, "answer")
+
+ @answer.setter
+ def answer(self, value: Optional[pulumi.Input[float]]):
+ pulumi.set(self, "answer", value)
+
+ @property
+ @pulumi.getter(name="plainOther")
+ def plain_other(self) -> Optional['HelmReleaseSettingsArgs']:
+ """
+ Test how plain types interact
+ """
+ return pulumi.get(self, "plain_other")
+
+ @plain_other.setter
+ def plain_other(self, value: Optional['HelmReleaseSettingsArgs']):
+ pulumi.set(self, "plain_other", value)
+
+ @property
+ @pulumi.getter
+ def question(self) -> Optional[pulumi.Input[str]]:
+ """
+ The question already answered
+ """
+ return pulumi.get(self, "question")
+
+ @question.setter
+ def question(self, value: Optional[pulumi.Input[str]]):
+ pulumi.set(self, "question", value)
+
+ @property
+ @pulumi.getter
+ def recursive(self) -> Optional[pulumi.Input['LayeredTypeArgs']]:
+ return pulumi.get(self, "recursive")
+
+ @recursive.setter
+ def recursive(self, value: Optional[pulumi.Input['LayeredTypeArgs']]):
+ pulumi.set(self, "recursive", value)
+
+
+@pulumi.input_type
+class TypArgs:
+ def __init__(__self__, *,
+ mod1: Optional[pulumi.Input['_mod1.TypArgs']] = None,
+ mod2: Optional[pulumi.Input['_mod2.TypArgs']] = None,
+ val: Optional[pulumi.Input[str]] = None):
+ """
+ A test for namespaces (mod main)
+ """
+ if mod1 is not None:
+ pulumi.set(__self__, "mod1", mod1)
+ if mod2 is not None:
+ pulumi.set(__self__, "mod2", mod2)
+ if val is None:
+ val = 'mod main'
+ if val is not None:
+ pulumi.set(__self__, "val", val)
+
+ @property
+ @pulumi.getter
+ def mod1(self) -> Optional[pulumi.Input['_mod1.TypArgs']]:
+ return pulumi.get(self, "mod1")
+
+ @mod1.setter
+ def mod1(self, value: Optional[pulumi.Input['_mod1.TypArgs']]):
+ pulumi.set(self, "mod1", value)
+
+ @property
+ @pulumi.getter
+ def mod2(self) -> Optional[pulumi.Input['_mod2.TypArgs']]:
+ return pulumi.get(self, "mod2")
+
+ @mod2.setter
+ def mod2(self, value: Optional[pulumi.Input['_mod2.TypArgs']]):
+ pulumi.set(self, "mod2", value)
+
+ @property
+ @pulumi.getter
+ def val(self) -> Optional[pulumi.Input[str]]:
+ return pulumi.get(self, "val")
+
+ @val.setter
+ def val(self, value: Optional[pulumi.Input[str]]):
+ pulumi.set(self, "val", value)
+
+
diff --git a/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/python/pulumi_example/_utilities.py b/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/python/pulumi_example/_utilities.py
new file mode 100644
index 000000000..01e27adcb
--- /dev/null
+++ b/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/python/pulumi_example/_utilities.py
@@ -0,0 +1,236 @@
+# 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 importlib.util
+import inspect
+import json
+import os
+import pkg_resources
+import sys
+import typing
+
+import pulumi
+import pulumi.runtime
+
+from semver import VersionInfo as SemverVersion
+from parver import Version as PEP440Version
+
+
+def get_env(*args):
+ for v in args:
+ value = os.getenv(v)
+ if value is not None:
+ return value
+ return None
+
+
+def get_env_bool(*args):
+ str = get_env(*args)
+ if str is not None:
+ # NOTE: these values are taken from https://golang.org/src/strconv/atob.go?s=351:391#L1, which is what
+ # Terraform uses internally when parsing boolean values.
+ if str in ["1", "t", "T", "true", "TRUE", "True"]:
+ return True
+ if str in ["0", "f", "F", "false", "FALSE", "False"]:
+ return False
+ return None
+
+
+def get_env_int(*args):
+ str = get_env(*args)
+ if str is not None:
+ try:
+ return int(str)
+ except:
+ return None
+ return None
+
+
+def get_env_float(*args):
+ str = get_env(*args)
+ if str is not None:
+ try:
+ return float(str)
+ except:
+ return None
+ return None
+
+
+def _get_semver_version():
+ # __name__ is set to the fully-qualified name of the current module, In our case, it will be
+ # ._utilities. is the module we want to query the version for.
+ root_package, *rest = __name__.split('.')
+
+ # pkg_resources uses setuptools to inspect the set of installed packages. We use it here to ask
+ # for the currently installed version of the root package (i.e. us) and get its version.
+
+ # Unfortunately, PEP440 and semver differ slightly in incompatible ways. The Pulumi engine expects
+ # to receive a valid semver string when receiving requests from the language host, so it's our
+ # responsibility as the library to convert our own PEP440 version into a valid semver string.
+
+ pep440_version_string = pkg_resources.require(root_package)[0].version
+ pep440_version = PEP440Version.parse(pep440_version_string)
+ (major, minor, patch) = pep440_version.release
+ prerelease = None
+ if pep440_version.pre_tag == 'a':
+ prerelease = f"alpha.{pep440_version.pre}"
+ elif pep440_version.pre_tag == 'b':
+ prerelease = f"beta.{pep440_version.pre}"
+ elif pep440_version.pre_tag == 'rc':
+ prerelease = f"rc.{pep440_version.pre}"
+ elif pep440_version.dev is not None:
+ prerelease = f"dev.{pep440_version.dev}"
+
+ # The only significant difference between PEP440 and semver as it pertains to us is that PEP440 has explicit support
+ # for dev builds, while semver encodes them as "prerelease" versions. In order to bridge between the two, we convert
+ # our dev build version into a prerelease tag. This matches what all of our other packages do when constructing
+ # their own semver string.
+ return SemverVersion(major=major, minor=minor, patch=patch, prerelease=prerelease)
+
+
+# Determine the version once and cache the value, which measurably improves program performance.
+_version = _get_semver_version()
+_version_str = str(_version)
+
+
+def get_version():
+ return _version_str
+
+
+def get_resource_args_opts(resource_args_type, resource_options_type, *args, **kwargs):
+ """
+ Return the resource args and options given the *args and **kwargs of a resource's
+ __init__ method.
+ """
+
+ resource_args, opts = None, None
+
+ # If the first item is the resource args type, save it and remove it from the args list.
+ if args and isinstance(args[0], resource_args_type):
+ resource_args, args = args[0], args[1:]
+
+ # Now look at the first item in the args list again.
+ # If the first item is the resource options class, save it.
+ if args and isinstance(args[0], resource_options_type):
+ opts = args[0]
+
+ # If resource_args is None, see if "args" is in kwargs, and, if so, if it's typed as the
+ # the resource args type.
+ if resource_args is None:
+ a = kwargs.get("args")
+ if isinstance(a, resource_args_type):
+ resource_args = a
+
+ # If opts is None, look it up in kwargs.
+ if opts is None:
+ opts = kwargs.get("opts")
+
+ return resource_args, opts
+
+
+# Temporary: just use pulumi._utils.lazy_import once everyone upgrades.
+def lazy_import(fullname):
+
+ import pulumi._utils as u
+ f = getattr(u, 'lazy_import', None)
+ if f is None:
+ f = _lazy_import_temp
+
+ return f(fullname)
+
+
+# Copied from pulumi._utils.lazy_import, see comments there.
+def _lazy_import_temp(fullname):
+ m = sys.modules.get(fullname, None)
+ if m is not None:
+ return m
+
+ spec = importlib.util.find_spec(fullname)
+
+ m = sys.modules.get(fullname, None)
+ if m is not None:
+ return m
+
+ loader = importlib.util.LazyLoader(spec.loader)
+ spec.loader = loader
+ module = importlib.util.module_from_spec(spec)
+
+ m = sys.modules.get(fullname, None)
+ if m is not None:
+ return m
+
+ sys.modules[fullname] = module
+ loader.exec_module(module)
+ return module
+
+
+class Package(pulumi.runtime.ResourcePackage):
+ def __init__(self, pkg_info):
+ super().__init__()
+ self.pkg_info = pkg_info
+
+ def version(self):
+ return _version
+
+ def construct_provider(self, name: str, typ: str, urn: str) -> pulumi.ProviderResource:
+ if typ != self.pkg_info['token']:
+ raise Exception(f"unknown provider type {typ}")
+ Provider = getattr(lazy_import(self.pkg_info['fqn']), self.pkg_info['class'])
+ return Provider(name, pulumi.ResourceOptions(urn=urn))
+
+
+class Module(pulumi.runtime.ResourceModule):
+ def __init__(self, mod_info):
+ super().__init__()
+ self.mod_info = mod_info
+
+ def version(self):
+ return _version
+
+ def construct(self, name: str, typ: str, urn: str) -> pulumi.Resource:
+ class_name = self.mod_info['classes'].get(typ, None)
+
+ if class_name is None:
+ raise Exception(f"unknown resource type {typ}")
+
+ TheClass = getattr(lazy_import(self.mod_info['fqn']), class_name)
+ return TheClass(name, pulumi.ResourceOptions(urn=urn))
+
+
+def register(resource_modules, resource_packages):
+ resource_modules = json.loads(resource_modules)
+ resource_packages = json.loads(resource_packages)
+
+ for pkg_info in resource_packages:
+ pulumi.runtime.register_resource_package(pkg_info['pkg'], Package(pkg_info))
+
+ for mod_info in resource_modules:
+ pulumi.runtime.register_resource_module(
+ mod_info['pkg'],
+ mod_info['mod'],
+ Module(mod_info))
+
+
+_F = typing.TypeVar('_F', bound=typing.Callable[..., typing.Any])
+
+
+def lift_output_func(func: typing.Any) -> typing.Callable[[_F], _F]:
+ """Decorator internally used on {fn}_output lifted function versions
+ to implement them automatically from the un-lifted function."""
+
+ func_sig = inspect.signature(func)
+
+ def lifted_func(*args, opts=None, **kwargs):
+ bound_args = func_sig.bind(*args, **kwargs)
+ # Convert tuple to list, see pulumi/pulumi#8172
+ args_list = list(bound_args.args)
+ return pulumi.Output.from_input({
+ 'args': args_list,
+ 'kwargs': bound_args.kwargs
+ }).apply(lambda resolved_args: func(*resolved_args['args'],
+ opts=opts,
+ **resolved_args['kwargs']))
+
+ return (lambda _: lifted_func)
diff --git a/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/python/pulumi_example/foo.py b/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/python/pulumi_example/foo.py
new file mode 100644
index 000000000..7879db199
--- /dev/null
+++ b/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/python/pulumi_example/foo.py
@@ -0,0 +1,180 @@
+# 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 warnings
+import pulumi
+import pulumi.runtime
+from typing import Any, Mapping, Optional, Sequence, Union, overload
+from . import _utilities
+from . import outputs
+from ._inputs import *
+
+__all__ = ['FooArgs', 'Foo']
+
+@pulumi.input_type
+class FooArgs:
+ def __init__(__self__, *,
+ backup_kube_client_settings: pulumi.Input['KubeClientSettingsArgs'],
+ argument: Optional[str] = None,
+ kube_client_settings: Optional[pulumi.Input['KubeClientSettingsArgs']] = None,
+ settings: Optional[pulumi.Input['LayeredTypeArgs']] = None):
+ """
+ The set of arguments for constructing a Foo resource.
+ :param pulumi.Input['KubeClientSettingsArgs'] backup_kube_client_settings: Options for tuning the Kubernetes client used by a Provider.
+ :param pulumi.Input['KubeClientSettingsArgs'] kube_client_settings: Options for tuning the Kubernetes client used by a Provider.
+ :param pulumi.Input['LayeredTypeArgs'] settings: describing things
+ """
+ pulumi.set(__self__, "backup_kube_client_settings", backup_kube_client_settings)
+ if argument is not None:
+ pulumi.set(__self__, "argument", argument)
+ if kube_client_settings is not None:
+ pulumi.set(__self__, "kube_client_settings", kube_client_settings)
+ if settings is not None:
+ pulumi.set(__self__, "settings", settings)
+
+ @property
+ @pulumi.getter(name="backupKubeClientSettings")
+ def backup_kube_client_settings(self) -> pulumi.Input['KubeClientSettingsArgs']:
+ """
+ Options for tuning the Kubernetes client used by a Provider.
+ """
+ return pulumi.get(self, "backup_kube_client_settings")
+
+ @backup_kube_client_settings.setter
+ def backup_kube_client_settings(self, value: pulumi.Input['KubeClientSettingsArgs']):
+ pulumi.set(self, "backup_kube_client_settings", value)
+
+ @property
+ @pulumi.getter
+ def argument(self) -> Optional[str]:
+ return pulumi.get(self, "argument")
+
+ @argument.setter
+ def argument(self, value: Optional[str]):
+ pulumi.set(self, "argument", value)
+
+ @property
+ @pulumi.getter(name="kubeClientSettings")
+ def kube_client_settings(self) -> Optional[pulumi.Input['KubeClientSettingsArgs']]:
+ """
+ Options for tuning the Kubernetes client used by a Provider.
+ """
+ return pulumi.get(self, "kube_client_settings")
+
+ @kube_client_settings.setter
+ def kube_client_settings(self, value: Optional[pulumi.Input['KubeClientSettingsArgs']]):
+ pulumi.set(self, "kube_client_settings", value)
+
+ @property
+ @pulumi.getter
+ def settings(self) -> Optional[pulumi.Input['LayeredTypeArgs']]:
+ """
+ describing things
+ """
+ return pulumi.get(self, "settings")
+
+ @settings.setter
+ def settings(self, value: Optional[pulumi.Input['LayeredTypeArgs']]):
+ pulumi.set(self, "settings", value)
+
+
+class Foo(pulumi.CustomResource):
+ @overload
+ def __init__(__self__,
+ resource_name: str,
+ opts: Optional[pulumi.ResourceOptions] = None,
+ argument: Optional[str] = None,
+ backup_kube_client_settings: Optional[pulumi.Input[pulumi.InputType['KubeClientSettingsArgs']]] = None,
+ kube_client_settings: Optional[pulumi.Input[pulumi.InputType['KubeClientSettingsArgs']]] = None,
+ settings: Optional[pulumi.Input[pulumi.InputType['LayeredTypeArgs']]] = None,
+ __props__=None):
+ """
+ test new feature with resoruces
+
+ :param str resource_name: The name of the resource.
+ :param pulumi.ResourceOptions opts: Options for the resource.
+ :param pulumi.Input[pulumi.InputType['KubeClientSettingsArgs']] backup_kube_client_settings: Options for tuning the Kubernetes client used by a Provider.
+ :param pulumi.Input[pulumi.InputType['KubeClientSettingsArgs']] kube_client_settings: Options for tuning the Kubernetes client used by a Provider.
+ :param pulumi.Input[pulumi.InputType['LayeredTypeArgs']] settings: describing things
+ """
+ ...
+ @overload
+ def __init__(__self__,
+ resource_name: str,
+ args: FooArgs,
+ opts: Optional[pulumi.ResourceOptions] = None):
+ """
+ test new feature with resoruces
+
+ :param str resource_name: The name of the resource.
+ :param FooArgs 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(FooArgs, 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,
+ argument: Optional[str] = None,
+ backup_kube_client_settings: Optional[pulumi.Input[pulumi.InputType['KubeClientSettingsArgs']]] = None,
+ kube_client_settings: Optional[pulumi.Input[pulumi.InputType['KubeClientSettingsArgs']]] = None,
+ settings: Optional[pulumi.Input[pulumi.InputType['LayeredTypeArgs']]] = None,
+ __props__=None):
+ if opts is None:
+ opts = pulumi.ResourceOptions()
+ if not isinstance(opts, pulumi.ResourceOptions):
+ raise TypeError('Expected resource options to be a ResourceOptions instance')
+ if opts.version is None:
+ opts.version = _utilities.get_version()
+ 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__ = FooArgs.__new__(FooArgs)
+
+ __props__.__dict__["argument"] = argument
+ if backup_kube_client_settings is None and not opts.urn:
+ raise TypeError("Missing required property 'backup_kube_client_settings'")
+ __props__.__dict__["backup_kube_client_settings"] = backup_kube_client_settings
+ __props__.__dict__["kube_client_settings"] = kube_client_settings
+ __props__.__dict__["settings"] = settings
+ __props__.__dict__["default_kube_client_settings"] = None
+ super(Foo, __self__).__init__(
+ 'example:index:Foo',
+ resource_name,
+ __props__,
+ opts)
+
+ @staticmethod
+ def get(resource_name: str,
+ id: pulumi.Input[str],
+ opts: Optional[pulumi.ResourceOptions] = None) -> 'Foo':
+ """
+ Get an existing Foo 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__ = FooArgs.__new__(FooArgs)
+
+ __props__.__dict__["default_kube_client_settings"] = None
+ return Foo(resource_name, opts=opts, __props__=__props__)
+
+ @property
+ @pulumi.getter(name="defaultKubeClientSettings")
+ def default_kube_client_settings(self) -> pulumi.Output[Optional['outputs.KubeClientSettings']]:
+ """
+ A test for plain types
+ """
+ return pulumi.get(self, "default_kube_client_settings")
+
diff --git a/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/python/pulumi_example/func_with_all_optional_inputs.py b/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/python/pulumi_example/func_with_all_optional_inputs.py
new file mode 100644
index 000000000..79d4298cd
--- /dev/null
+++ b/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/python/pulumi_example/func_with_all_optional_inputs.py
@@ -0,0 +1,75 @@
+# 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 warnings
+import pulumi
+import pulumi.runtime
+from typing import Any, Mapping, Optional, Sequence, Union, overload
+from . import _utilities
+from ._inputs import *
+
+__all__ = [
+ 'FuncWithAllOptionalInputsResult',
+ 'AwaitableFuncWithAllOptionalInputsResult',
+ 'func_with_all_optional_inputs',
+ 'func_with_all_optional_inputs_output',
+]
+
+@pulumi.output_type
+class FuncWithAllOptionalInputsResult:
+ def __init__(__self__, r=None):
+ if r and not isinstance(r, str):
+ raise TypeError("Expected argument 'r' to be a str")
+ pulumi.set(__self__, "r", r)
+
+ @property
+ @pulumi.getter
+ def r(self) -> str:
+ return pulumi.get(self, "r")
+
+
+class AwaitableFuncWithAllOptionalInputsResult(FuncWithAllOptionalInputsResult):
+ # pylint: disable=using-constant-test
+ def __await__(self):
+ if False:
+ yield self
+ return FuncWithAllOptionalInputsResult(
+ r=self.r)
+
+
+def func_with_all_optional_inputs(a: Optional[pulumi.InputType['HelmReleaseSettings']] = None,
+ b: Optional[str] = None,
+ opts: Optional[pulumi.InvokeOptions] = None) -> AwaitableFuncWithAllOptionalInputsResult:
+ """
+ Check codegen of functions with all optional inputs.
+
+
+ :param pulumi.InputType['HelmReleaseSettings'] a: Property A
+ :param str b: Property B
+ """
+ __args__ = dict()
+ __args__['a'] = a
+ __args__['b'] = b
+ if opts is None:
+ opts = pulumi.InvokeOptions()
+ if opts.version is None:
+ opts.version = _utilities.get_version()
+ __ret__ = pulumi.runtime.invoke('mypkg::funcWithAllOptionalInputs', __args__, opts=opts, typ=FuncWithAllOptionalInputsResult).value
+
+ return AwaitableFuncWithAllOptionalInputsResult(
+ r=__ret__.r)
+
+
+@_utilities.lift_output_func(func_with_all_optional_inputs)
+def func_with_all_optional_inputs_output(a: Optional[pulumi.Input[Optional[pulumi.InputType['HelmReleaseSettings']]]] = None,
+ b: Optional[pulumi.Input[Optional[str]]] = None,
+ opts: Optional[pulumi.InvokeOptions] = None) -> pulumi.Output[FuncWithAllOptionalInputsResult]:
+ """
+ Check codegen of functions with all optional inputs.
+
+
+ :param pulumi.InputType['HelmReleaseSettings'] a: Property A
+ :param str b: Property B
+ """
+ ...
diff --git a/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/python/pulumi_example/mod1/__init__.py b/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/python/pulumi_example/mod1/__init__.py
new file mode 100644
index 000000000..d90ad520e
--- /dev/null
+++ b/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/python/pulumi_example/mod1/__init__.py
@@ -0,0 +1,7 @@
+# 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
+from ._inputs import *
diff --git a/pkg/codegen/internal/test/testdata/env-helper/python/pulumi_example/mod1/_inputs.py b/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/python/pulumi_example/mod1/_inputs.py
similarity index 100%
rename from pkg/codegen/internal/test/testdata/env-helper/python/pulumi_example/mod1/_inputs.py
rename to pkg/codegen/internal/test/testdata/plain-object-disable-defaults/python/pulumi_example/mod1/_inputs.py
diff --git a/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/python/pulumi_example/mod2/__init__.py b/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/python/pulumi_example/mod2/__init__.py
new file mode 100644
index 000000000..d90ad520e
--- /dev/null
+++ b/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/python/pulumi_example/mod2/__init__.py
@@ -0,0 +1,7 @@
+# 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
+from ._inputs import *
diff --git a/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/python/pulumi_example/mod2/_inputs.py b/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/python/pulumi_example/mod2/_inputs.py
new file mode 100644
index 000000000..c21575d1c
--- /dev/null
+++ b/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/python/pulumi_example/mod2/_inputs.py
@@ -0,0 +1,49 @@
+# 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 warnings
+import pulumi
+import pulumi.runtime
+from typing import Any, Mapping, Optional, Sequence, Union, overload
+from .. import _utilities
+from .. import mod1 as _mod1
+
+__all__ = [
+ 'TypArgs',
+]
+
+@pulumi.input_type
+class TypArgs:
+ def __init__(__self__, *,
+ mod1: Optional[pulumi.Input['_mod1.TypArgs']] = None,
+ val: Optional[pulumi.Input[str]] = None):
+ """
+ A test for namespaces (mod 2)
+ """
+ if mod1 is not None:
+ pulumi.set(__self__, "mod1", mod1)
+ if val is None:
+ val = 'mod2'
+ if val is not None:
+ pulumi.set(__self__, "val", val)
+
+ @property
+ @pulumi.getter
+ def mod1(self) -> Optional[pulumi.Input['_mod1.TypArgs']]:
+ return pulumi.get(self, "mod1")
+
+ @mod1.setter
+ def mod1(self, value: Optional[pulumi.Input['_mod1.TypArgs']]):
+ pulumi.set(self, "mod1", value)
+
+ @property
+ @pulumi.getter
+ def val(self) -> Optional[pulumi.Input[str]]:
+ return pulumi.get(self, "val")
+
+ @val.setter
+ def val(self, value: Optional[pulumi.Input[str]]):
+ pulumi.set(self, "val", value)
+
+
diff --git a/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/python/pulumi_example/module_test.py b/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/python/pulumi_example/module_test.py
new file mode 100644
index 000000000..f8ae3cc2b
--- /dev/null
+++ b/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/python/pulumi_example/module_test.py
@@ -0,0 +1,123 @@
+# 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 warnings
+import pulumi
+import pulumi.runtime
+from typing import Any, Mapping, Optional, Sequence, Union, overload
+from . import _utilities
+from . import mod1 as _mod1
+from . import mod2 as _mod2
+from ._inputs import *
+
+__all__ = ['ModuleTestArgs', 'ModuleTest']
+
+@pulumi.input_type
+class ModuleTestArgs:
+ def __init__(__self__, *,
+ mod1: Optional[pulumi.Input['_mod1.TypArgs']] = None,
+ val: Optional[pulumi.Input['TypArgs']] = None):
+ """
+ The set of arguments for constructing a ModuleTest resource.
+ """
+ if mod1 is not None:
+ pulumi.set(__self__, "mod1", mod1)
+ if val is not None:
+ pulumi.set(__self__, "val", val)
+
+ @property
+ @pulumi.getter
+ def mod1(self) -> Optional[pulumi.Input['_mod1.TypArgs']]:
+ return pulumi.get(self, "mod1")
+
+ @mod1.setter
+ def mod1(self, value: Optional[pulumi.Input['_mod1.TypArgs']]):
+ pulumi.set(self, "mod1", value)
+
+ @property
+ @pulumi.getter
+ def val(self) -> Optional[pulumi.Input['TypArgs']]:
+ return pulumi.get(self, "val")
+
+ @val.setter
+ def val(self, value: Optional[pulumi.Input['TypArgs']]):
+ pulumi.set(self, "val", value)
+
+
+class ModuleTest(pulumi.CustomResource):
+ @overload
+ def __init__(__self__,
+ resource_name: str,
+ opts: Optional[pulumi.ResourceOptions] = None,
+ mod1: Optional[pulumi.Input[pulumi.InputType['_mod1.TypArgs']]] = None,
+ val: Optional[pulumi.Input[pulumi.InputType['TypArgs']]] = None,
+ __props__=None):
+ """
+ Create a ModuleTest 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[ModuleTestArgs] = None,
+ opts: Optional[pulumi.ResourceOptions] = None):
+ """
+ Create a ModuleTest resource with the given unique name, props, and options.
+ :param str resource_name: The name of the resource.
+ :param ModuleTestArgs 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(ModuleTestArgs, 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,
+ mod1: Optional[pulumi.Input[pulumi.InputType['_mod1.TypArgs']]] = None,
+ val: Optional[pulumi.Input[pulumi.InputType['TypArgs']]] = None,
+ __props__=None):
+ if opts is None:
+ opts = pulumi.ResourceOptions()
+ if not isinstance(opts, pulumi.ResourceOptions):
+ raise TypeError('Expected resource options to be a ResourceOptions instance')
+ if opts.version is None:
+ opts.version = _utilities.get_version()
+ 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__ = ModuleTestArgs.__new__(ModuleTestArgs)
+
+ __props__.__dict__["mod1"] = mod1
+ __props__.__dict__["val"] = val
+ super(ModuleTest, __self__).__init__(
+ 'example:index:moduleTest',
+ resource_name,
+ __props__,
+ opts)
+
+ @staticmethod
+ def get(resource_name: str,
+ id: pulumi.Input[str],
+ opts: Optional[pulumi.ResourceOptions] = None) -> 'ModuleTest':
+ """
+ Get an existing ModuleTest 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__ = ModuleTestArgs.__new__(ModuleTestArgs)
+
+ return ModuleTest(resource_name, opts=opts, __props__=__props__)
+
diff --git a/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/python/pulumi_example/outputs.py b/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/python/pulumi_example/outputs.py
new file mode 100644
index 000000000..869602068
--- /dev/null
+++ b/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/python/pulumi_example/outputs.py
@@ -0,0 +1,79 @@
+# 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 warnings
+import pulumi
+import pulumi.runtime
+from typing import Any, Mapping, Optional, Sequence, Union, overload
+from . import _utilities
+from . import outputs
+
+__all__ = [
+ 'KubeClientSettings',
+]
+
+@pulumi.output_type
+class KubeClientSettings(dict):
+ """
+ Options for tuning the Kubernetes client used by a Provider.
+ """
+ @staticmethod
+ def __key_warning(key: str):
+ suggest = None
+ if key == "recTest":
+ suggest = "rec_test"
+
+ if suggest:
+ pulumi.log.warn(f"Key '{key}' not found in KubeClientSettings. Access the value via the '{suggest}' property getter instead.")
+
+ def __getitem__(self, key: str) -> Any:
+ KubeClientSettings.__key_warning(key)
+ return super().__getitem__(key)
+
+ def get(self, key: str, default = None) -> Any:
+ KubeClientSettings.__key_warning(key)
+ return super().get(key, default)
+
+ def __init__(__self__, *,
+ burst: Optional[int] = None,
+ qps: Optional[float] = None,
+ rec_test: Optional['outputs.KubeClientSettings'] = None):
+ """
+ Options for tuning the Kubernetes client used by a Provider.
+ :param int burst: Maximum burst for throttle. Default value is 10.
+ :param float qps: Maximum queries per second (QPS) to the API server from this client. Default value is 5.
+ """
+ if burst is None:
+ burst = _utilities.get_env_int('PULUMI_K8S_CLIENT_BURST')
+ if burst is not None:
+ pulumi.set(__self__, "burst", burst)
+ if qps is None:
+ qps = _utilities.get_env_float('PULUMI_K8S_CLIENT_QPS')
+ if qps is not None:
+ pulumi.set(__self__, "qps", qps)
+ if rec_test is not None:
+ pulumi.set(__self__, "rec_test", rec_test)
+
+ @property
+ @pulumi.getter
+ def burst(self) -> Optional[int]:
+ """
+ Maximum burst for throttle. Default value is 10.
+ """
+ return pulumi.get(self, "burst")
+
+ @property
+ @pulumi.getter
+ def qps(self) -> Optional[float]:
+ """
+ Maximum queries per second (QPS) to the API server from this client. Default value is 5.
+ """
+ return pulumi.get(self, "qps")
+
+ @property
+ @pulumi.getter(name="recTest")
+ def rec_test(self) -> Optional['outputs.KubeClientSettings']:
+ return pulumi.get(self, "rec_test")
+
+
diff --git a/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/python/pulumi_example/provider.py b/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/python/pulumi_example/provider.py
new file mode 100644
index 000000000..4f41cfd19
--- /dev/null
+++ b/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/python/pulumi_example/provider.py
@@ -0,0 +1,95 @@
+# 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 warnings
+import pulumi
+import pulumi.runtime
+from typing import Any, Mapping, Optional, Sequence, Union, overload
+from . import _utilities
+from ._inputs import *
+
+__all__ = ['ProviderArgs', 'Provider']
+
+@pulumi.input_type
+class ProviderArgs:
+ def __init__(__self__, *,
+ helm_release_settings: Optional[pulumi.Input['HelmReleaseSettingsArgs']] = None):
+ """
+ The set of arguments for constructing a Provider resource.
+ :param pulumi.Input['HelmReleaseSettingsArgs'] helm_release_settings: BETA FEATURE - Options to configure the Helm Release resource.
+ """
+ if helm_release_settings is not None:
+ pulumi.set(__self__, "helm_release_settings", helm_release_settings)
+
+ @property
+ @pulumi.getter(name="helmReleaseSettings")
+ def helm_release_settings(self) -> Optional[pulumi.Input['HelmReleaseSettingsArgs']]:
+ """
+ BETA FEATURE - Options to configure the Helm Release resource.
+ """
+ return pulumi.get(self, "helm_release_settings")
+
+ @helm_release_settings.setter
+ def helm_release_settings(self, value: Optional[pulumi.Input['HelmReleaseSettingsArgs']]):
+ pulumi.set(self, "helm_release_settings", value)
+
+
+class Provider(pulumi.ProviderResource):
+ @overload
+ def __init__(__self__,
+ resource_name: str,
+ opts: Optional[pulumi.ResourceOptions] = None,
+ helm_release_settings: Optional[pulumi.Input[pulumi.InputType['HelmReleaseSettingsArgs']]] = None,
+ __props__=None):
+ """
+ The provider type for the kubernetes package.
+
+ :param str resource_name: The name of the resource.
+ :param pulumi.ResourceOptions opts: Options for the resource.
+ :param pulumi.Input[pulumi.InputType['HelmReleaseSettingsArgs']] helm_release_settings: BETA FEATURE - Options to configure the Helm Release resource.
+ """
+ ...
+ @overload
+ def __init__(__self__,
+ resource_name: str,
+ args: Optional[ProviderArgs] = None,
+ opts: Optional[pulumi.ResourceOptions] = None):
+ """
+ The provider type for the kubernetes package.
+
+ :param str resource_name: The name of the resource.
+ :param ProviderArgs 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(ProviderArgs, 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,
+ helm_release_settings: Optional[pulumi.Input[pulumi.InputType['HelmReleaseSettingsArgs']]] = None,
+ __props__=None):
+ if opts is None:
+ opts = pulumi.ResourceOptions()
+ if not isinstance(opts, pulumi.ResourceOptions):
+ raise TypeError('Expected resource options to be a ResourceOptions instance')
+ if opts.version is None:
+ opts.version = _utilities.get_version()
+ 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__ = ProviderArgs.__new__(ProviderArgs)
+
+ __props__.__dict__["helm_release_settings"] = pulumi.Output.from_input(helm_release_settings).apply(pulumi.runtime.to_json) if helm_release_settings is not None else None
+ super(Provider, __self__).__init__(
+ 'example',
+ resource_name,
+ __props__,
+ opts)
+
diff --git a/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/python/pulumi_example/py.typed b/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/python/pulumi_example/py.typed
new file mode 100644
index 000000000..e69de29bb
diff --git a/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/python/setup.py b/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/python/setup.py
new file mode 100644
index 000000000..4550e1ebd
--- /dev/null
+++ b/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/python/setup.py
@@ -0,0 +1,58 @@
+# 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 errno
+from setuptools import setup, find_packages
+from setuptools.command.install import install
+from subprocess import check_call
+
+
+VERSION = "0.0.0"
+PLUGIN_VERSION = "0.0.0"
+
+class InstallPluginCommand(install):
+ def run(self):
+ install.run(self)
+ try:
+ check_call(['pulumi', 'plugin', 'install', 'resource', 'example', PLUGIN_VERSION])
+ except OSError as error:
+ if error.errno == errno.ENOENT:
+ print(f"""
+ There was an error installing the example resource provider plugin.
+ It looks like `pulumi` is not installed on your system.
+ Please visit https://pulumi.com/ to install the Pulumi CLI.
+ You may try manually installing the plugin by running
+ `pulumi plugin install resource example {PLUGIN_VERSION}`
+ """)
+ else:
+ raise
+
+
+def readme():
+ try:
+ with open('README.md', encoding='utf-8') as f:
+ return f.read()
+ except FileNotFoundError:
+ return "example Pulumi Package - Development Version"
+
+
+setup(name='pulumi_example',
+ version=VERSION,
+ long_description=readme(),
+ long_description_content_type='text/markdown',
+ cmdclass={
+ 'install': InstallPluginCommand,
+ },
+ packages=find_packages(),
+ package_data={
+ 'pulumi_example': [
+ 'py.typed',
+ ]
+ },
+ install_requires=[
+ 'parver>=0.2.1',
+ 'pulumi',
+ 'semver>=2.8.1'
+ ],
+ zip_safe=False)
diff --git a/pkg/codegen/internal/test/testdata/env-helper/schema.json b/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/schema.json
similarity index 98%
rename from pkg/codegen/internal/test/testdata/env-helper/schema.json
rename to pkg/codegen/internal/test/testdata/plain-object-disable-defaults/schema.json
index 23f74ce08..801fe2e61 100644
--- a/pkg/codegen/internal/test/testdata/env-helper/schema.json
+++ b/pkg/codegen/internal/test/testdata/plain-object-disable-defaults/schema.json
@@ -219,7 +219,8 @@
}
},
"go": {
- "importBasePath": "env-helper/example"
+ "importBasePath": "plain-object-disable-defaults/example",
+ "disableObjectDefaults": true
},
"nodejs": {
"dependencies": {
diff --git a/pkg/codegen/internal/test/testdata/plain-schema-gh6957/go/xyz/pulumiUtilities.go b/pkg/codegen/internal/test/testdata/plain-schema-gh6957/go/xyz/pulumiUtilities.go
index dce47980e..d013d4c27 100644
--- a/pkg/codegen/internal/test/testdata/plain-schema-gh6957/go/xyz/pulumiUtilities.go
+++ b/pkg/codegen/internal/test/testdata/plain-schema-gh6957/go/xyz/pulumiUtilities.go
@@ -75,3 +75,11 @@ func PkgVersion() (semver.Version, error) {
}
return semver.Version{}, fmt.Errorf("failed to determine the package version from %s", pkgPath)
}
+
+// isZero is a null safe check for if a value is it's types zero value.
+func isZero(v interface{}) bool {
+ if v == nil {
+ return true
+ }
+ return reflect.ValueOf(v).IsZero()
+}
diff --git a/pkg/codegen/internal/test/testdata/provider-config-schema/go/configstation/config/pulumiUtilities.go b/pkg/codegen/internal/test/testdata/provider-config-schema/go/configstation/config/pulumiUtilities.go
index f38aa4b33..77634d1f3 100644
--- a/pkg/codegen/internal/test/testdata/provider-config-schema/go/configstation/config/pulumiUtilities.go
+++ b/pkg/codegen/internal/test/testdata/provider-config-schema/go/configstation/config/pulumiUtilities.go
@@ -75,3 +75,11 @@ func PkgVersion() (semver.Version, error) {
}
return semver.Version{}, fmt.Errorf("failed to determine the package version from %s", pkgPath)
}
+
+// isZero is a null safe check for if a value is it's types zero value.
+func isZero(v interface{}) bool {
+ if v == nil {
+ return true
+ }
+ return reflect.ValueOf(v).IsZero()
+}
diff --git a/pkg/codegen/internal/test/testdata/provider-config-schema/go/configstation/provider.go b/pkg/codegen/internal/test/testdata/provider-config-schema/go/configstation/provider.go
index 829991704..a72b404de 100644
--- a/pkg/codegen/internal/test/testdata/provider-config-schema/go/configstation/provider.go
+++ b/pkg/codegen/internal/test/testdata/provider-config-schema/go/configstation/provider.go
@@ -21,7 +21,7 @@ func NewProvider(ctx *pulumi.Context,
args = &ProviderArgs{}
}
- if args.FavoriteColor == nil {
+ if isZero(args.FavoriteColor) {
args.FavoriteColor = pulumi.StringPtr(getEnvOrDefault("", nil, "FAVE_COLOR").(string))
}
var resource Provider
diff --git a/pkg/codegen/internal/test/testdata/provider-config-schema/go/configstation/pulumiUtilities.go b/pkg/codegen/internal/test/testdata/provider-config-schema/go/configstation/pulumiUtilities.go
index cff02211c..72cea798a 100644
--- a/pkg/codegen/internal/test/testdata/provider-config-schema/go/configstation/pulumiUtilities.go
+++ b/pkg/codegen/internal/test/testdata/provider-config-schema/go/configstation/pulumiUtilities.go
@@ -75,3 +75,11 @@ func PkgVersion() (semver.Version, error) {
}
return semver.Version{}, fmt.Errorf("failed to determine the package version from %s", pkgPath)
}
+
+// isZero is a null safe check for if a value is it's types zero value.
+func isZero(v interface{}) bool {
+ if v == nil {
+ return true
+ }
+ return reflect.ValueOf(v).IsZero()
+}
diff --git a/pkg/codegen/internal/test/testdata/regress-node-8110/go/my8110/pulumiUtilities.go b/pkg/codegen/internal/test/testdata/regress-node-8110/go/my8110/pulumiUtilities.go
index 1842f5b59..e9a6b3b5a 100644
--- a/pkg/codegen/internal/test/testdata/regress-node-8110/go/my8110/pulumiUtilities.go
+++ b/pkg/codegen/internal/test/testdata/regress-node-8110/go/my8110/pulumiUtilities.go
@@ -75,3 +75,11 @@ func PkgVersion() (semver.Version, error) {
}
return semver.Version{}, fmt.Errorf("failed to determine the package version from %s", pkgPath)
}
+
+// isZero is a null safe check for if a value is it's types zero value.
+func isZero(v interface{}) bool {
+ if v == nil {
+ return true
+ }
+ return reflect.ValueOf(v).IsZero()
+}
diff --git a/pkg/codegen/internal/test/testdata/replace-on-change/go/example/pulumiUtilities.go b/pkg/codegen/internal/test/testdata/replace-on-change/go/example/pulumiUtilities.go
index 61e44b2aa..66ab34c97 100644
--- a/pkg/codegen/internal/test/testdata/replace-on-change/go/example/pulumiUtilities.go
+++ b/pkg/codegen/internal/test/testdata/replace-on-change/go/example/pulumiUtilities.go
@@ -75,3 +75,11 @@ func PkgVersion() (semver.Version, error) {
}
return semver.Version{}, fmt.Errorf("failed to determine the package version from %s", pkgPath)
}
+
+// isZero is a null safe check for if a value is it's types zero value.
+func isZero(v interface{}) bool {
+ if v == nil {
+ return true
+ }
+ return reflect.ValueOf(v).IsZero()
+}
diff --git a/pkg/codegen/internal/test/testdata/resource-args-python-case-insensitive/go/example/pulumiUtilities.go b/pkg/codegen/internal/test/testdata/resource-args-python-case-insensitive/go/example/pulumiUtilities.go
index 61e44b2aa..66ab34c97 100644
--- a/pkg/codegen/internal/test/testdata/resource-args-python-case-insensitive/go/example/pulumiUtilities.go
+++ b/pkg/codegen/internal/test/testdata/resource-args-python-case-insensitive/go/example/pulumiUtilities.go
@@ -75,3 +75,11 @@ func PkgVersion() (semver.Version, error) {
}
return semver.Version{}, fmt.Errorf("failed to determine the package version from %s", pkgPath)
}
+
+// isZero is a null safe check for if a value is it's types zero value.
+func isZero(v interface{}) bool {
+ if v == nil {
+ return true
+ }
+ return reflect.ValueOf(v).IsZero()
+}
diff --git a/pkg/codegen/internal/test/testdata/resource-args-python/go/example/pulumiUtilities.go b/pkg/codegen/internal/test/testdata/resource-args-python/go/example/pulumiUtilities.go
index 61e44b2aa..66ab34c97 100644
--- a/pkg/codegen/internal/test/testdata/resource-args-python/go/example/pulumiUtilities.go
+++ b/pkg/codegen/internal/test/testdata/resource-args-python/go/example/pulumiUtilities.go
@@ -75,3 +75,11 @@ func PkgVersion() (semver.Version, error) {
}
return semver.Version{}, fmt.Errorf("failed to determine the package version from %s", pkgPath)
}
+
+// isZero is a null safe check for if a value is it's types zero value.
+func isZero(v interface{}) bool {
+ if v == nil {
+ return true
+ }
+ return reflect.ValueOf(v).IsZero()
+}
diff --git a/pkg/codegen/internal/test/testdata/resource-property-overlap/go/example/pulumiUtilities.go b/pkg/codegen/internal/test/testdata/resource-property-overlap/go/example/pulumiUtilities.go
index 61e44b2aa..66ab34c97 100644
--- a/pkg/codegen/internal/test/testdata/resource-property-overlap/go/example/pulumiUtilities.go
+++ b/pkg/codegen/internal/test/testdata/resource-property-overlap/go/example/pulumiUtilities.go
@@ -75,3 +75,11 @@ func PkgVersion() (semver.Version, error) {
}
return semver.Version{}, fmt.Errorf("failed to determine the package version from %s", pkgPath)
}
+
+// isZero is a null safe check for if a value is it's types zero value.
+func isZero(v interface{}) bool {
+ if v == nil {
+ return true
+ }
+ return reflect.ValueOf(v).IsZero()
+}
diff --git a/pkg/codegen/internal/test/testdata/simple-enum-schema/go-extras/tests/go_test.go b/pkg/codegen/internal/test/testdata/simple-enum-schema/go-extras/tests/go_test.go
index 5e5473c7c..424ca05b1 100644
--- a/pkg/codegen/internal/test/testdata/simple-enum-schema/go-extras/tests/go_test.go
+++ b/pkg/codegen/internal/test/testdata/simple-enum-schema/go-extras/tests/go_test.go
@@ -47,7 +47,7 @@ func TestEnumUsage(t *testing.T) {
assert.Equal(t, *material, "ceramic", "unexpected material on resource: %v", urn)
assert.Equal(t, *color, "red", "unexpected color on resource: %v", urn)
assert.Equal(t, *size, plant.ContainerSizeFourInch, "unexpected size on resource: %v", urn)
- assert.Nil(t, brightness)
+ assert.Equal(t, *brightness, plant.ContainerBrightness(1.0))
assert.Equal(t, typ, tree.RubberTreeVarietyRuby, "unexpected type on resource: %v", urn)
wg.Done()
return nil
diff --git a/pkg/codegen/internal/test/testdata/simple-enum-schema/go/codegen-manifest.json b/pkg/codegen/internal/test/testdata/simple-enum-schema/go/codegen-manifest.json
index 8fd2cfe24..412ea9d4b 100644
--- a/pkg/codegen/internal/test/testdata/simple-enum-schema/go/codegen-manifest.json
+++ b/pkg/codegen/internal/test/testdata/simple-enum-schema/go/codegen-manifest.json
@@ -9,6 +9,7 @@
"plant/tree/v1/init.go",
"plant/tree/v1/nursery.go",
"plant/tree/v1/pulumiEnums.go",
+ "plant/tree/v1/pulumiUtilities.go",
"plant/tree/v1/rubberTree.go"
]
}
diff --git a/pkg/codegen/internal/test/testdata/simple-enum-schema/go/plant/pulumiTypes.go b/pkg/codegen/internal/test/testdata/simple-enum-schema/go/plant/pulumiTypes.go
index 6f868e8db..27695e441 100644
--- a/pkg/codegen/internal/test/testdata/simple-enum-schema/go/plant/pulumiTypes.go
+++ b/pkg/codegen/internal/test/testdata/simple-enum-schema/go/plant/pulumiTypes.go
@@ -17,6 +17,19 @@ type Container struct {
Size ContainerSize `pulumi:"size"`
}
+// Defaults sets the appropriate defaults for Container
+func (val *Container) Defaults() *Container {
+ if val == nil {
+ return nil
+ }
+ tmp := *val
+ if isZero(tmp.Brightness) {
+ brightness_ := ContainerBrightness(1.0)
+ tmp.Brightness = &brightness_
+ }
+ return &tmp
+}
+
// ContainerInput is an input type that accepts ContainerArgs and ContainerOutput values.
// You can construct a concrete instance of `ContainerInput` via:
//
diff --git a/pkg/codegen/internal/test/testdata/simple-enum-schema/go/plant/pulumiUtilities.go b/pkg/codegen/internal/test/testdata/simple-enum-schema/go/plant/pulumiUtilities.go
index ca0b56243..4fbfec44b 100644
--- a/pkg/codegen/internal/test/testdata/simple-enum-schema/go/plant/pulumiUtilities.go
+++ b/pkg/codegen/internal/test/testdata/simple-enum-schema/go/plant/pulumiUtilities.go
@@ -75,3 +75,11 @@ func PkgVersion() (semver.Version, error) {
}
return semver.Version{}, fmt.Errorf("failed to determine the package version from %s", pkgPath)
}
+
+// isZero is a null safe check for if a value is it's types zero value.
+func isZero(v interface{}) bool {
+ if v == nil {
+ return true
+ }
+ return reflect.ValueOf(v).IsZero()
+}
diff --git a/pkg/codegen/internal/test/testdata/simple-enum-schema/go/plant/tree/v1/pulumiUtilities.go b/pkg/codegen/internal/test/testdata/simple-enum-schema/go/plant/tree/v1/pulumiUtilities.go
new file mode 100644
index 000000000..4ed860515
--- /dev/null
+++ b/pkg/codegen/internal/test/testdata/simple-enum-schema/go/plant/tree/v1/pulumiUtilities.go
@@ -0,0 +1,85 @@
+// *** WARNING: this file was generated by test. ***
+// *** Do not edit by hand unless you're certain you know what you are doing! ***
+
+package v1
+
+import (
+ "fmt"
+ "os"
+ "reflect"
+ "regexp"
+ "strconv"
+ "strings"
+
+ "github.com/blang/semver"
+ "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
+)
+
+type envParser func(v string) interface{}
+
+func parseEnvBool(v string) interface{} {
+ b, err := strconv.ParseBool(v)
+ if err != nil {
+ return nil
+ }
+ return b
+}
+
+func parseEnvInt(v string) interface{} {
+ i, err := strconv.ParseInt(v, 0, 0)
+ if err != nil {
+ return nil
+ }
+ return int(i)
+}
+
+func parseEnvFloat(v string) interface{} {
+ f, err := strconv.ParseFloat(v, 64)
+ if err != nil {
+ return nil
+ }
+ return f
+}
+
+func parseEnvStringArray(v string) interface{} {
+ var result pulumi.StringArray
+ for _, item := range strings.Split(v, ";") {
+ result = append(result, pulumi.String(item))
+ }
+ return result
+}
+
+func getEnvOrDefault(def interface{}, parser envParser, vars ...string) interface{} {
+ for _, v := range vars {
+ if value := os.Getenv(v); value != "" {
+ if parser != nil {
+ return parser(value)
+ }
+ return value
+ }
+ }
+ return def
+}
+
+// PkgVersion uses reflection to determine the version of the current package.
+func PkgVersion() (semver.Version, error) {
+ type sentinal struct{}
+ pkgPath := reflect.TypeOf(sentinal{}).PkgPath()
+ re := regexp.MustCompile("^.*/pulumi-plant/sdk(/v\\d+)?")
+ if match := re.FindStringSubmatch(pkgPath); match != nil {
+ vStr := match[1]
+ if len(vStr) == 0 { // If the version capture group was empty, default to v1.
+ return semver.Version{Major: 1}, nil
+ }
+ return semver.MustParse(fmt.Sprintf("%s.0.0", vStr[2:])), nil
+ }
+ return semver.Version{}, fmt.Errorf("failed to determine the package version from %s", pkgPath)
+}
+
+// isZero is a null safe check for if a value is it's types zero value.
+func isZero(v interface{}) bool {
+ if v == nil {
+ return true
+ }
+ return reflect.ValueOf(v).IsZero()
+}
diff --git a/pkg/codegen/internal/test/testdata/simple-enum-schema/go/plant/tree/v1/rubberTree.go b/pkg/codegen/internal/test/testdata/simple-enum-schema/go/plant/tree/v1/rubberTree.go
index b516e488d..530a6e2e1 100644
--- a/pkg/codegen/internal/test/testdata/simple-enum-schema/go/plant/tree/v1/rubberTree.go
+++ b/pkg/codegen/internal/test/testdata/simple-enum-schema/go/plant/tree/v1/rubberTree.go
@@ -29,16 +29,20 @@ func NewRubberTree(ctx *pulumi.Context,
return nil, errors.New("missing one or more required arguments")
}
- if args.Diameter == nil {
+ containerApplier := func(v plant.Container) *plant.Container { return v.Defaults() }
+ if args.Container != nil {
+ args.Container = args.Container.ToContainerPtrOutput().Elem().ApplyT(containerApplier).(plant.ContainerPtrOutput)
+ }
+ if isZero(args.Diameter) {
args.Diameter = Diameter(6.0)
}
- if args.Farm == nil {
+ if isZero(args.Farm) {
args.Farm = pulumi.StringPtr("(unknown)")
}
- if args.Size == nil {
+ if isZero(args.Size) {
args.Size = TreeSize("medium")
}
- if args.Type == nil {
+ if isZero(args.Type) {
args.Type = RubberTreeVariety("Burgundy")
}
var resource RubberTree
diff --git a/pkg/codegen/internal/test/testdata/simple-methods-schema-single-value-returns/go/example/pulumiUtilities.go b/pkg/codegen/internal/test/testdata/simple-methods-schema-single-value-returns/go/example/pulumiUtilities.go
index 61e44b2aa..66ab34c97 100644
--- a/pkg/codegen/internal/test/testdata/simple-methods-schema-single-value-returns/go/example/pulumiUtilities.go
+++ b/pkg/codegen/internal/test/testdata/simple-methods-schema-single-value-returns/go/example/pulumiUtilities.go
@@ -75,3 +75,11 @@ func PkgVersion() (semver.Version, error) {
}
return semver.Version{}, fmt.Errorf("failed to determine the package version from %s", pkgPath)
}
+
+// isZero is a null safe check for if a value is it's types zero value.
+func isZero(v interface{}) bool {
+ if v == nil {
+ return true
+ }
+ return reflect.ValueOf(v).IsZero()
+}
diff --git a/pkg/codegen/internal/test/testdata/simple-methods-schema/go/example/pulumiUtilities.go b/pkg/codegen/internal/test/testdata/simple-methods-schema/go/example/pulumiUtilities.go
index 61e44b2aa..66ab34c97 100644
--- a/pkg/codegen/internal/test/testdata/simple-methods-schema/go/example/pulumiUtilities.go
+++ b/pkg/codegen/internal/test/testdata/simple-methods-schema/go/example/pulumiUtilities.go
@@ -75,3 +75,11 @@ func PkgVersion() (semver.Version, error) {
}
return semver.Version{}, fmt.Errorf("failed to determine the package version from %s", pkgPath)
}
+
+// isZero is a null safe check for if a value is it's types zero value.
+func isZero(v interface{}) bool {
+ if v == nil {
+ return true
+ }
+ return reflect.ValueOf(v).IsZero()
+}
diff --git a/pkg/codegen/internal/test/testdata/simple-plain-schema-with-root-package/go/pulumiUtilities.go b/pkg/codegen/internal/test/testdata/simple-plain-schema-with-root-package/go/pulumiUtilities.go
index e6b651200..6088b6ff6 100644
--- a/pkg/codegen/internal/test/testdata/simple-plain-schema-with-root-package/go/pulumiUtilities.go
+++ b/pkg/codegen/internal/test/testdata/simple-plain-schema-with-root-package/go/pulumiUtilities.go
@@ -75,3 +75,11 @@ func PkgVersion() (semver.Version, error) {
}
return semver.Version{}, fmt.Errorf("failed to determine the package version from %s", pkgPath)
}
+
+// isZero is a null safe check for if a value is it's types zero value.
+func isZero(v interface{}) bool {
+ if v == nil {
+ return true
+ }
+ return reflect.ValueOf(v).IsZero()
+}
diff --git a/pkg/codegen/internal/test/testdata/simple-plain-schema/go/example/pulumiUtilities.go b/pkg/codegen/internal/test/testdata/simple-plain-schema/go/example/pulumiUtilities.go
index 61e44b2aa..66ab34c97 100644
--- a/pkg/codegen/internal/test/testdata/simple-plain-schema/go/example/pulumiUtilities.go
+++ b/pkg/codegen/internal/test/testdata/simple-plain-schema/go/example/pulumiUtilities.go
@@ -75,3 +75,11 @@ func PkgVersion() (semver.Version, error) {
}
return semver.Version{}, fmt.Errorf("failed to determine the package version from %s", pkgPath)
}
+
+// isZero is a null safe check for if a value is it's types zero value.
+func isZero(v interface{}) bool {
+ if v == nil {
+ return true
+ }
+ return reflect.ValueOf(v).IsZero()
+}
diff --git a/pkg/codegen/internal/test/testdata/simple-resource-schema-custom-pypackage-name/go/example/pulumiUtilities.go b/pkg/codegen/internal/test/testdata/simple-resource-schema-custom-pypackage-name/go/example/pulumiUtilities.go
index 61e44b2aa..66ab34c97 100644
--- a/pkg/codegen/internal/test/testdata/simple-resource-schema-custom-pypackage-name/go/example/pulumiUtilities.go
+++ b/pkg/codegen/internal/test/testdata/simple-resource-schema-custom-pypackage-name/go/example/pulumiUtilities.go
@@ -75,3 +75,11 @@ func PkgVersion() (semver.Version, error) {
}
return semver.Version{}, fmt.Errorf("failed to determine the package version from %s", pkgPath)
}
+
+// isZero is a null safe check for if a value is it's types zero value.
+func isZero(v interface{}) bool {
+ if v == nil {
+ return true
+ }
+ return reflect.ValueOf(v).IsZero()
+}
diff --git a/pkg/codegen/internal/test/testdata/simple-resource-schema/go/example/pulumiUtilities.go b/pkg/codegen/internal/test/testdata/simple-resource-schema/go/example/pulumiUtilities.go
index 61e44b2aa..66ab34c97 100644
--- a/pkg/codegen/internal/test/testdata/simple-resource-schema/go/example/pulumiUtilities.go
+++ b/pkg/codegen/internal/test/testdata/simple-resource-schema/go/example/pulumiUtilities.go
@@ -75,3 +75,11 @@ func PkgVersion() (semver.Version, error) {
}
return semver.Version{}, fmt.Errorf("failed to determine the package version from %s", pkgPath)
}
+
+// isZero is a null safe check for if a value is it's types zero value.
+func isZero(v interface{}) bool {
+ if v == nil {
+ return true
+ }
+ return reflect.ValueOf(v).IsZero()
+}
diff --git a/pkg/codegen/internal/test/testdata/simple-yaml-schema/go/example/pulumiUtilities.go b/pkg/codegen/internal/test/testdata/simple-yaml-schema/go/example/pulumiUtilities.go
index 61e44b2aa..66ab34c97 100644
--- a/pkg/codegen/internal/test/testdata/simple-yaml-schema/go/example/pulumiUtilities.go
+++ b/pkg/codegen/internal/test/testdata/simple-yaml-schema/go/example/pulumiUtilities.go
@@ -75,3 +75,11 @@ func PkgVersion() (semver.Version, error) {
}
return semver.Version{}, fmt.Errorf("failed to determine the package version from %s", pkgPath)
}
+
+// isZero is a null safe check for if a value is it's types zero value.
+func isZero(v interface{}) bool {
+ if v == nil {
+ return true
+ }
+ return reflect.ValueOf(v).IsZero()
+}
diff --git a/pkg/codegen/nodejs/gen.go b/pkg/codegen/nodejs/gen.go
index 5613cf8b0..2e76147ef 100644
--- a/pkg/codegen/nodejs/gen.go
+++ b/pkg/codegen/nodejs/gen.go
@@ -427,7 +427,7 @@ func (mod *modContext) genPlainType(w io.Writer, name, comment string,
}
// Generate a provide defaults function for an associated plain object.
-func (mod *modContext) genPlainObjectDefaultFunc(w io.Writer, name, comment string,
+func (mod *modContext) genPlainObjectDefaultFunc(w io.Writer, name string,
properties []*schema.Property, input, readonly bool, level int) error {
indent := strings.Repeat(" ", level)
defaults := []string{}
@@ -499,7 +499,7 @@ func provideDefaultsFuncNameFromName(typeName string) string {
// `type` is the type which the function applies to.
// `input` indicates whither `type` is an input type.
func (mod *modContext) provideDefaultsFuncName(typ schema.Type, input bool) string {
- if !isProvideDefaultsFuncRequired(typ) {
+ if !codegen.IsProvideDefaultsFuncRequired(typ) {
return ""
}
requiredType := codegen.UnwrapType(typ)
@@ -507,30 +507,6 @@ func (mod *modContext) provideDefaultsFuncName(typ schema.Type, input bool) stri
return provideDefaultsFuncNameFromName(typeName)
}
-// If a helper function needs to be invoked to provide default values for a
-// plain type. The provided map cannot be reused.
-func isProvideDefaultsFuncRequired(t schema.Type) bool {
- return isProvideDefaultsFuncRequiredHelper(t, map[string]bool{})
-}
-
-func isProvideDefaultsFuncRequiredHelper(t schema.Type, seen map[string]bool) bool {
- if seen[t.String()] {
- return false
- }
- seen[t.String()] = true
- t = codegen.UnwrapType(t)
- object, ok := t.(*schema.ObjectType)
- if !ok {
- return false
- }
- for _, p := range object.Properties {
- if p.DefaultValue != nil || isProvideDefaultsFuncRequiredHelper(p.Type, seen) {
- return true
- }
- }
- return false
-}
-
func tsPrimitiveValue(value interface{}) (string, error) {
v := reflect.ValueOf(value)
if v.Kind() == reflect.Interface {
@@ -1258,7 +1234,7 @@ func (mod *modContext) genType(w io.Writer, obj *schema.ObjectType, input bool,
if err != nil {
return err
}
- return mod.genPlainObjectDefaultFunc(w, name, obj.Comment, properties, input, false, level)
+ return mod.genPlainObjectDefaultFunc(w, name, properties, input, false, level)
}
// getObjectName recovers the name of `obj` as a type.
@@ -1567,7 +1543,7 @@ func (mod *modContext) genTypes() (string, string, error) {
}
mod.getImports(t, externalImports, imports)
- if isProvideDefaultsFuncRequired(t) {
+ if codegen.IsProvideDefaultsFuncRequired(t) {
hasDefaultObjects = true
}
}
diff --git a/pkg/codegen/utilities_types.go b/pkg/codegen/utilities_types.go
index 407cc1e0c..7cc3aea47 100644
--- a/pkg/codegen/utilities_types.go
+++ b/pkg/codegen/utilities_types.go
@@ -161,3 +161,27 @@ func PlainType(t schema.Type) schema.Type {
func ResolvedType(t schema.Type) schema.Type {
return resolvedType(t, true)
}
+
+// If a helper function needs to be invoked to provide default values for a
+// plain type. The provided map cannot be reused.
+func IsProvideDefaultsFuncRequired(t schema.Type) bool {
+ return isProvideDefaultsFuncRequiredHelper(t, map[string]bool{})
+}
+
+func isProvideDefaultsFuncRequiredHelper(t schema.Type, seen map[string]bool) bool {
+ if seen[t.String()] {
+ return false
+ }
+ seen[t.String()] = true
+ t = UnwrapType(t)
+ object, ok := t.(*schema.ObjectType)
+ if !ok {
+ return false
+ }
+ for _, p := range object.Properties {
+ if p.DefaultValue != nil || isProvideDefaultsFuncRequiredHelper(p.Type, seen) {
+ return true
+ }
+ }
+ return false
+}