diff --git a/.github/workflows/run-docs-generation.yml b/.github/workflows/run-docs-generation.yml index 39f0d194b..21e86ff38 100644 --- a/.github/workflows/run-docs-generation.yml +++ b/.github/workflows/run-docs-generation.yml @@ -101,6 +101,13 @@ jobs: ./scripts/gen_resource_docs.sh aws true ./scripts/gen_resource_docs.sh kubernetes true + + # Undo the changes to the go.mod and go.sum files since we don't want the PR + # to contain local overrides or the PR build in docs repo would fail. + pushd tools/resourcedocsgen + git checkout . + popd + popd echo "::set-output name=branchName::${BRANCH_NAME}" diff --git a/CHANGELOG_PENDING.md b/CHANGELOG_PENDING.md index 05e6ced76..f32fa2edc 100644 --- a/CHANGELOG_PENDING.md +++ b/CHANGELOG_PENDING.md @@ -2,3 +2,5 @@ ### Bug Fixes +- [codegen/typescript] - Respect default values in Pulumi object types. + [#8400](https://github.com/pulumi/pulumi/pull/8400) diff --git a/pkg/codegen/docs/gen.go b/pkg/codegen/docs/gen.go index 47f4aa5fd..3eb743da8 100644 --- a/pkg/codegen/docs/gen.go +++ b/pkg/codegen/docs/gen.go @@ -1957,8 +1957,14 @@ func (dctx *docGenContext) generatePackage(tool string, pkg *schema.Package) (ma glog.V(3).Infoln("generating package docs now...") files := fs{} - for _, mod := range dctx.modules() { - if err := mod.gen(files); err != nil { + modules := []string{} + modMap := dctx.modules() + for k := range modMap { + modules = append(modules, k) + } + sort.Strings(modules) + for _, mod := range modules { + if err := modMap[mod].gen(files); err != nil { return nil, err } } diff --git a/pkg/codegen/internal/test/sdk_driver.go b/pkg/codegen/internal/test/sdk_driver.go index 22054dbf4..8a2a4376e 100644 --- a/pkg/codegen/internal/test/sdk_driver.go +++ b/pkg/codegen/internal/test/sdk_driver.go @@ -191,6 +191,12 @@ var sdkTests = []sdkTest{ Skip: codegen.NewStringSet("python/test", "nodejs/test"), SkipCompileCheck: codegen.NewStringSet(nodejs), }, + { + Directory: "env-helper", + Description: "Ensure that eviromental helpers are generated (repro #8132)", + Skip: codegen.NewStringSet("python/test", "nodejs/test"), + SkipCompileCheck: codegen.NewStringSet(dotnet), + }, } var genSDKOnly bool diff --git a/pkg/codegen/internal/test/testdata/cyclic-types/nodejs/provider.ts b/pkg/codegen/internal/test/testdata/cyclic-types/nodejs/provider.ts index 791f0a3cf..d2f15c3be 100644 --- a/pkg/codegen/internal/test/testdata/cyclic-types/nodejs/provider.ts +++ b/pkg/codegen/internal/test/testdata/cyclic-types/nodejs/provider.ts @@ -28,14 +28,14 @@ export class Provider extends pulumi.ProviderResource { * @param opts A bag of options that control this resource's behavior. */ constructor(name: string, args?: ProviderArgs, opts?: pulumi.ResourceOptions) { - let inputs: pulumi.Inputs = {}; + let resourceInputs: pulumi.Inputs = {}; opts = opts || {}; { } if (!opts.version) { opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()}); } - super(Provider.__pulumiType, name, inputs, opts); + super(Provider.__pulumiType, name, resourceInputs, opts); } } diff --git a/pkg/codegen/internal/test/testdata/dash-named-schema/nodejs/provider.ts b/pkg/codegen/internal/test/testdata/dash-named-schema/nodejs/provider.ts index a83f3c2fa..3e1e136d4 100644 --- a/pkg/codegen/internal/test/testdata/dash-named-schema/nodejs/provider.ts +++ b/pkg/codegen/internal/test/testdata/dash-named-schema/nodejs/provider.ts @@ -28,14 +28,14 @@ export class Provider extends pulumi.ProviderResource { * @param opts A bag of options that control this resource's behavior. */ constructor(name: string, args?: ProviderArgs, opts?: pulumi.ResourceOptions) { - let inputs: pulumi.Inputs = {}; + let resourceInputs: pulumi.Inputs = {}; opts = opts || {}; { } if (!opts.version) { opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()}); } - super(Provider.__pulumiType, name, inputs, opts); + super(Provider.__pulumiType, name, resourceInputs, opts); } } diff --git a/pkg/codegen/internal/test/testdata/dash-named-schema/nodejs/submodule1/moduleResource.ts b/pkg/codegen/internal/test/testdata/dash-named-schema/nodejs/submodule1/moduleResource.ts index 65b05b55d..14d0f7a9f 100644 --- a/pkg/codegen/internal/test/testdata/dash-named-schema/nodejs/submodule1/moduleResource.ts +++ b/pkg/codegen/internal/test/testdata/dash-named-schema/nodejs/submodule1/moduleResource.ts @@ -42,17 +42,17 @@ export class ModuleResource extends pulumi.CustomResource { * @param opts A bag of options that control this resource's behavior. */ constructor(name: string, args?: ModuleResourceArgs, opts?: pulumi.CustomResourceOptions) { - let inputs: pulumi.Inputs = {}; + let resourceInputs: pulumi.Inputs = {}; opts = opts || {}; if (!opts.id) { - inputs["thing"] = args ? args.thing : undefined; + resourceInputs["thing"] = args ? args.thing : undefined; } else { - inputs["thing"] = undefined /*out*/; + resourceInputs["thing"] = undefined /*out*/; } if (!opts.version) { opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()}); } - super(ModuleResource.__pulumiType, name, inputs, opts); + super(ModuleResource.__pulumiType, name, resourceInputs, opts); } } diff --git a/pkg/codegen/internal/test/testdata/dashed-import-schema/nodejs/provider.ts b/pkg/codegen/internal/test/testdata/dashed-import-schema/nodejs/provider.ts index 578b31bdc..d04b2779e 100644 --- a/pkg/codegen/internal/test/testdata/dashed-import-schema/nodejs/provider.ts +++ b/pkg/codegen/internal/test/testdata/dashed-import-schema/nodejs/provider.ts @@ -28,14 +28,14 @@ export class Provider extends pulumi.ProviderResource { * @param opts A bag of options that control this resource's behavior. */ constructor(name: string, args?: ProviderArgs, opts?: pulumi.ResourceOptions) { - let inputs: pulumi.Inputs = {}; + let resourceInputs: pulumi.Inputs = {}; opts = opts || {}; { } if (!opts.version) { opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()}); } - super(Provider.__pulumiType, name, inputs, opts); + super(Provider.__pulumiType, name, resourceInputs, opts); } } diff --git a/pkg/codegen/internal/test/testdata/dashed-import-schema/nodejs/tree/v1/nursery.ts b/pkg/codegen/internal/test/testdata/dashed-import-schema/nodejs/tree/v1/nursery.ts index d9d03bb54..1cefb9b25 100644 --- a/pkg/codegen/internal/test/testdata/dashed-import-schema/nodejs/tree/v1/nursery.ts +++ b/pkg/codegen/internal/test/testdata/dashed-import-schema/nodejs/tree/v1/nursery.ts @@ -41,20 +41,20 @@ export class Nursery extends pulumi.CustomResource { * @param opts A bag of options that control this resource's behavior. */ constructor(name: string, args: NurseryArgs, opts?: pulumi.CustomResourceOptions) { - let inputs: pulumi.Inputs = {}; + let resourceInputs: pulumi.Inputs = {}; opts = opts || {}; if (!opts.id) { if ((!args || args.varieties === undefined) && !opts.urn) { throw new Error("Missing required property 'varieties'"); } - inputs["sizes"] = args ? args.sizes : undefined; - inputs["varieties"] = args ? args.varieties : undefined; + resourceInputs["sizes"] = args ? args.sizes : undefined; + resourceInputs["varieties"] = args ? args.varieties : undefined; } else { } if (!opts.version) { opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()}); } - super(Nursery.__pulumiType, name, inputs, opts); + super(Nursery.__pulumiType, name, resourceInputs, opts); } } diff --git a/pkg/codegen/internal/test/testdata/dashed-import-schema/nodejs/tree/v1/rubberTree.ts b/pkg/codegen/internal/test/testdata/dashed-import-schema/nodejs/tree/v1/rubberTree.ts index bb0613bcd..a713617a2 100644 --- a/pkg/codegen/internal/test/testdata/dashed-import-schema/nodejs/tree/v1/rubberTree.ts +++ b/pkg/codegen/internal/test/testdata/dashed-import-schema/nodejs/tree/v1/rubberTree.ts @@ -48,11 +48,11 @@ export class RubberTree extends pulumi.CustomResource { */ constructor(name: string, args: RubberTreeArgs, opts?: pulumi.CustomResourceOptions) constructor(name: string, argsOrState?: RubberTreeArgs | RubberTreeState, opts?: pulumi.CustomResourceOptions) { - let inputs: pulumi.Inputs = {}; + let resourceInputs: pulumi.Inputs = {}; opts = opts || {}; if (opts.id) { const state = argsOrState as RubberTreeState | undefined; - inputs["farm"] = state ? state.farm : undefined; + resourceInputs["farm"] = state ? state.farm : undefined; } else { const args = argsOrState as RubberTreeArgs | undefined; if ((!args || args.diameter === undefined) && !opts.urn) { @@ -61,16 +61,16 @@ export class RubberTree extends pulumi.CustomResource { if ((!args || args.type === undefined) && !opts.urn) { throw new Error("Missing required property 'type'"); } - inputs["container"] = args ? args.container : undefined; - inputs["diameter"] = (args ? args.diameter : undefined) ?? 6; - inputs["farm"] = (args ? args.farm : undefined) ?? "(unknown)"; - inputs["size"] = (args ? args.size : undefined) ?? "medium"; - inputs["type"] = (args ? args.type : undefined) ?? "Burgundy"; + resourceInputs["container"] = args ? (args.container ? pulumi.output(args.container).apply(inputs.containerArgsProvideDefaults) : undefined) : undefined; + resourceInputs["diameter"] = (args ? args.diameter : undefined) ?? 6; + resourceInputs["farm"] = (args ? args.farm : undefined) ?? "(unknown)"; + resourceInputs["size"] = (args ? args.size : undefined) ?? "medium"; + resourceInputs["type"] = (args ? args.type : undefined) ?? "Burgundy"; } if (!opts.version) { opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()}); } - super(RubberTree.__pulumiType, name, inputs, opts); + super(RubberTree.__pulumiType, name, resourceInputs, opts); } } diff --git a/pkg/codegen/internal/test/testdata/dashed-import-schema/nodejs/types/input.ts b/pkg/codegen/internal/test/testdata/dashed-import-schema/nodejs/types/input.ts index 52f85fdca..5318cf864 100644 --- a/pkg/codegen/internal/test/testdata/dashed-import-schema/nodejs/types/input.ts +++ b/pkg/codegen/internal/test/testdata/dashed-import-schema/nodejs/types/input.ts @@ -4,9 +4,20 @@ import * as pulumi from "@pulumi/pulumi"; import { input as inputs, output as outputs, enums } from "../types"; +import * as utilities from "../utilities"; + export interface ContainerArgs { brightness?: pulumi.Input; color?: pulumi.Input; material?: pulumi.Input; size: pulumi.Input; } +/** + * containerArgsProvideDefaults sets the appropriate defaults for ContainerArgs + */ +export function containerArgsProvideDefaults(val: ContainerArgs): ContainerArgs { + return { + ...val, + brightness: (val.brightness) ?? 1, + }; +} diff --git a/pkg/codegen/internal/test/testdata/dashed-import-schema/nodejs/types/output.ts b/pkg/codegen/internal/test/testdata/dashed-import-schema/nodejs/types/output.ts index 7f015cf2b..c56d600e2 100644 --- a/pkg/codegen/internal/test/testdata/dashed-import-schema/nodejs/types/output.ts +++ b/pkg/codegen/internal/test/testdata/dashed-import-schema/nodejs/types/output.ts @@ -4,10 +4,21 @@ import * as pulumi from "@pulumi/pulumi"; import { input as inputs, output as outputs, enums } from "../types"; +import * as utilities from "../utilities"; + export interface Container { brightness?: enums.ContainerBrightness; color?: enums.ContainerColor | string; material?: string; size: enums.ContainerSize; } +/** + * containerProvideDefaults sets the appropriate defaults for Container + */ +export function containerProvideDefaults(val: Container): Container { + return { + ...val, + brightness: (val.brightness) ?? 1, + }; +} diff --git a/pkg/codegen/internal/test/testdata/env-helper/docs/_index.md b/pkg/codegen/internal/test/testdata/env-helper/docs/_index.md new file mode 100644 index 000000000..6d0011cb6 --- /dev/null +++ b/pkg/codegen/internal/test/testdata/env-helper/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/env-helper/docs/codegen-manifest.json b/pkg/codegen/internal/test/testdata/env-helper/docs/codegen-manifest.json new file mode 100644 index 000000000..ca9c36628 --- /dev/null +++ b/pkg/codegen/internal/test/testdata/env-helper/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/env-helper/docs/foo/_index.md b/pkg/codegen/internal/test/testdata/env-helper/docs/foo/_index.md new file mode 100644 index 000000000..bb03aef01 --- /dev/null +++ b/pkg/codegen/internal/test/testdata/env-helper/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 %}} +
new Foo(name: string, args: FooArgs, opts?: CustomResourceOptions);
+{{% /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 %}} +
func NewFoo(ctx *Context, name string, args FooArgs, opts ...ResourceOption) (*Foo, error)
+{{% /choosable %}} + +{{% choosable language csharp %}} +
public Foo(string name, FooArgs args, CustomResourceOptions? opts = null)
+{{% /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/env-helper/docs/funcwithalloptionalinputs/_index.md b/pkg/codegen/internal/test/testdata/env-helper/docs/funcwithalloptionalinputs/_index.md new file mode 100644 index 000000000..7eb89ca47 --- /dev/null +++ b/pkg/codegen/internal/test/testdata/env-helper/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 %}} +
function funcWithAllOptionalInputs(args: FuncWithAllOptionalInputsArgs, opts?: InvokeOptions): Promise<FuncWithAllOptionalInputsResult>
+function funcWithAllOptionalInputsOutput(args: FuncWithAllOptionalInputsOutputArgs, opts?: InvokeOptions): Output<FuncWithAllOptionalInputsResult>
+{{% /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 %}} +
func FuncWithAllOptionalInputs(ctx *Context, args *FuncWithAllOptionalInputsArgs, opts ...InvokeOption) (*FuncWithAllOptionalInputsResult, error)
+func FuncWithAllOptionalInputsOutput(ctx *Context, args *FuncWithAllOptionalInputsOutputArgs, opts ...InvokeOption) FuncWithAllOptionalInputsResultOutput
+ +> Note: This function is named `FuncWithAllOptionalInputs` in the Go SDK. + +{{% /choosable %}} + + +{{% choosable language csharp %}} +
public static class FuncWithAllOptionalInputs 
+{
+    public static Task<FuncWithAllOptionalInputsResult> InvokeAsync(FuncWithAllOptionalInputsArgs args, InvokeOptions? opts = null)
+    public static Output<FuncWithAllOptionalInputsResult> Invoke(FuncWithAllOptionalInputsInvokeArgs args, InvokeOptions? opts = null)
+}
+{{% /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/env-helper/docs/mod1/_index.md b/pkg/codegen/internal/test/testdata/env-helper/docs/mod1/_index.md new file mode 100644 index 000000000..6cce9b58f --- /dev/null +++ b/pkg/codegen/internal/test/testdata/env-helper/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/env-helper/docs/mod2/_index.md b/pkg/codegen/internal/test/testdata/env-helper/docs/mod2/_index.md new file mode 100644 index 000000000..0ac60b7cc --- /dev/null +++ b/pkg/codegen/internal/test/testdata/env-helper/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/env-helper/docs/moduletest/_index.md b/pkg/codegen/internal/test/testdata/env-helper/docs/moduletest/_index.md new file mode 100644 index 000000000..9bb509f64 --- /dev/null +++ b/pkg/codegen/internal/test/testdata/env-helper/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 %}} +
new ModuleTest(name: string, args?: ModuleTestArgs, opts?: CustomResourceOptions);
+{{% /choosable %}} + +{{% choosable language python %}} +
@overload
+def ModuleTest(resource_name: str,
+               opts: Optional[ResourceOptions] = None,
+               mod1: Optional[_mod1.TypArgs] = None,
+               val: Optional[TypArgs] = None)
+@overload
+def ModuleTest(resource_name: str,
+               args: Optional[ModuleTestArgs] = None,
+               opts: Optional[ResourceOptions] = None)
+{{% /choosable %}} + +{{% choosable language go %}} +
func NewModuleTest(ctx *Context, name string, args *ModuleTestArgs, opts ...ResourceOption) (*ModuleTest, error)
+{{% /choosable %}} + +{{% choosable language csharp %}} +
public ModuleTest(string name, ModuleTestArgs? args = null, CustomResourceOptions? opts = null)
+{{% /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 %}} +
+ +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 %}}
+ +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 %}} +
+ +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/env-helper/docs/provider/_index.md b/pkg/codegen/internal/test/testdata/env-helper/docs/provider/_index.md new file mode 100644 index 000000000..786b4e4d4 --- /dev/null +++ b/pkg/codegen/internal/test/testdata/env-helper/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 %}} +
new Provider(name: string, args?: ProviderArgs, opts?: CustomResourceOptions);
+{{% /choosable %}} + +{{% choosable language python %}} +
@overload
+def Provider(resource_name: str,
+             opts: Optional[ResourceOptions] = None,
+             helm_release_settings: Optional[HelmReleaseSettingsArgs] = None)
+@overload
+def Provider(resource_name: str,
+             args: Optional[ProviderArgs] = None,
+             opts: Optional[ResourceOptions] = None)
+{{% /choosable %}} + +{{% choosable language go %}} +
func NewProvider(ctx *Context, name string, args *ProviderArgs, opts ...ResourceOption) (*Provider, error)
+{{% /choosable %}} + +{{% choosable language csharp %}} +
public Provider(string name, ProviderArgs? args = null, CustomResourceOptions? opts = null)
+{{% /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/env-helper/dotnet/Foo.cs b/pkg/codegen/internal/test/testdata/env-helper/dotnet/Foo.cs new file mode 100644 index 000000000..7e5d588a4 --- /dev/null +++ b/pkg/codegen/internal/test/testdata/env-helper/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/env-helper/dotnet/FuncWithAllOptionalInputs.cs b/pkg/codegen/internal/test/testdata/env-helper/dotnet/FuncWithAllOptionalInputs.cs new file mode 100644 index 000000000..43c18c45a --- /dev/null +++ b/pkg/codegen/internal/test/testdata/env-helper/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/env-helper/dotnet/Inputs/HelmReleaseSettings.cs b/pkg/codegen/internal/test/testdata/env-helper/dotnet/Inputs/HelmReleaseSettings.cs new file mode 100644 index 000000000..04aa27280 --- /dev/null +++ b/pkg/codegen/internal/test/testdata/env-helper/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/env-helper/dotnet/Inputs/HelmReleaseSettingsArgs.cs b/pkg/codegen/internal/test/testdata/env-helper/dotnet/Inputs/HelmReleaseSettingsArgs.cs new file mode 100644 index 000000000..212222ea7 --- /dev/null +++ b/pkg/codegen/internal/test/testdata/env-helper/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/env-helper/dotnet/Inputs/KubeClientSettingsArgs.cs b/pkg/codegen/internal/test/testdata/env-helper/dotnet/Inputs/KubeClientSettingsArgs.cs new file mode 100644 index 000000000..170d4e1fe --- /dev/null +++ b/pkg/codegen/internal/test/testdata/env-helper/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/env-helper/dotnet/Inputs/LayeredTypeArgs.cs b/pkg/codegen/internal/test/testdata/env-helper/dotnet/Inputs/LayeredTypeArgs.cs new file mode 100644 index 000000000..0e7825c19 --- /dev/null +++ b/pkg/codegen/internal/test/testdata/env-helper/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/env-helper/dotnet/Inputs/TypArgs.cs b/pkg/codegen/internal/test/testdata/env-helper/dotnet/Inputs/TypArgs.cs new file mode 100644 index 000000000..663325d73 --- /dev/null +++ b/pkg/codegen/internal/test/testdata/env-helper/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/env-helper/dotnet/Mod1/Inputs/TypArgs.cs new file mode 100644 index 000000000..9318892a8 --- /dev/null +++ b/pkg/codegen/internal/test/testdata/env-helper/dotnet/Mod1/Inputs/TypArgs.cs @@ -0,0 +1,26 @@ +// *** 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.Mod1.Inputs +{ + + /// + /// A test for namespaces (mod 1) + /// + public sealed class TypArgs : Pulumi.ResourceArgs + { + [Input("val")] + public Input? Val { get; set; } + + public TypArgs() + { + Val = "mod1"; + } + } +} diff --git a/pkg/codegen/internal/test/testdata/env-helper/dotnet/Mod1/README.md b/pkg/codegen/internal/test/testdata/env-helper/dotnet/Mod1/README.md new file mode 100644 index 000000000..e69de29bb diff --git a/pkg/codegen/internal/test/testdata/env-helper/dotnet/Mod2/Inputs/TypArgs.cs b/pkg/codegen/internal/test/testdata/env-helper/dotnet/Mod2/Inputs/TypArgs.cs new file mode 100644 index 000000000..d8f075931 --- /dev/null +++ b/pkg/codegen/internal/test/testdata/env-helper/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/env-helper/dotnet/Mod2/README.md b/pkg/codegen/internal/test/testdata/env-helper/dotnet/Mod2/README.md new file mode 100644 index 000000000..e69de29bb diff --git a/pkg/codegen/internal/test/testdata/env-helper/dotnet/ModuleTest.cs b/pkg/codegen/internal/test/testdata/env-helper/dotnet/ModuleTest.cs new file mode 100644 index 000000000..1cfff078c --- /dev/null +++ b/pkg/codegen/internal/test/testdata/env-helper/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/env-helper/dotnet/Outputs/KubeClientSettings.cs b/pkg/codegen/internal/test/testdata/env-helper/dotnet/Outputs/KubeClientSettings.cs new file mode 100644 index 000000000..46437c486 --- /dev/null +++ b/pkg/codegen/internal/test/testdata/env-helper/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/env-helper/dotnet/Provider.cs b/pkg/codegen/internal/test/testdata/env-helper/dotnet/Provider.cs new file mode 100644 index 000000000..5748ab9f8 --- /dev/null +++ b/pkg/codegen/internal/test/testdata/env-helper/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/env-helper/dotnet/Pulumi.Example.csproj b/pkg/codegen/internal/test/testdata/env-helper/dotnet/Pulumi.Example.csproj new file mode 100644 index 000000000..e59637251 --- /dev/null +++ b/pkg/codegen/internal/test/testdata/env-helper/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/env-helper/dotnet/README.md b/pkg/codegen/internal/test/testdata/env-helper/dotnet/README.md new file mode 100644 index 000000000..e69de29bb diff --git a/pkg/codegen/internal/test/testdata/env-helper/dotnet/Utilities.cs b/pkg/codegen/internal/test/testdata/env-helper/dotnet/Utilities.cs new file mode 100644 index 000000000..e99f7fe43 --- /dev/null +++ b/pkg/codegen/internal/test/testdata/env-helper/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/env-helper/dotnet/codegen-manifest.json b/pkg/codegen/internal/test/testdata/env-helper/dotnet/codegen-manifest.json new file mode 100644 index 000000000..889213733 --- /dev/null +++ b/pkg/codegen/internal/test/testdata/env-helper/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/env-helper/dotnet/logo.png b/pkg/codegen/internal/test/testdata/env-helper/dotnet/logo.png new file mode 100644 index 000000000..181f421e9 Binary files /dev/null and b/pkg/codegen/internal/test/testdata/env-helper/dotnet/logo.png differ diff --git a/pkg/codegen/internal/test/testdata/env-helper/go/codegen-manifest.json b/pkg/codegen/internal/test/testdata/env-helper/go/codegen-manifest.json new file mode 100644 index 000000000..19448b971 --- /dev/null +++ b/pkg/codegen/internal/test/testdata/env-helper/go/codegen-manifest.json @@ -0,0 +1,14 @@ +{ + "emittedFiles": [ + "example/doc.go", + "example/foo.go", + "example/funcWithAllOptionalInputs.go", + "example/init.go", + "example/mod1/pulumiTypes.go", + "example/mod2/pulumiTypes.go", + "example/moduleTest.go", + "example/provider.go", + "example/pulumiTypes.go", + "example/pulumiUtilities.go" + ] +} diff --git a/pkg/codegen/internal/test/testdata/env-helper/go/example/doc.go b/pkg/codegen/internal/test/testdata/env-helper/go/example/doc.go new file mode 100644 index 000000000..24cd778aa --- /dev/null +++ b/pkg/codegen/internal/test/testdata/env-helper/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/env-helper/go/example/foo.go new file mode 100644 index 000000000..74ce67467 --- /dev/null +++ b/pkg/codegen/internal/test/testdata/env-helper/go/example/foo.go @@ -0,0 +1,124 @@ +// *** 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 ( + "context" + "reflect" + + "github.com/pkg/errors" + "github.com/pulumi/pulumi/sdk/v3/go/pulumi" +) + +// test new feature with resoruces +type Foo struct { + pulumi.CustomResourceState + + // A test for plain types + DefaultKubeClientSettings KubeClientSettingsPtrOutput `pulumi:"defaultKubeClientSettings"` +} + +// NewFoo registers a new resource with the given unique name, arguments, and options. +func NewFoo(ctx *pulumi.Context, + name string, args *FooArgs, opts ...pulumi.ResourceOption) (*Foo, error) { + if args == nil { + return nil, errors.New("missing one or more required arguments") + } + + if args.BackupKubeClientSettings == nil { + return nil, errors.New("invalid value for required argument 'BackupKubeClientSettings'") + } + var resource Foo + err := ctx.RegisterResource("example:index:Foo", name, args, &resource, opts...) + if err != nil { + return nil, err + } + return &resource, nil +} + +// GetFoo gets an existing Foo resource's state with the given name, ID, and optional +// state properties that are used to uniquely qualify the lookup (nil if not required). +func GetFoo(ctx *pulumi.Context, + name string, id pulumi.IDInput, state *FooState, opts ...pulumi.ResourceOption) (*Foo, error) { + var resource Foo + err := ctx.ReadResource("example:index:Foo", name, id, state, &resource, opts...) + if err != nil { + return nil, err + } + return &resource, nil +} + +// Input properties used for looking up and filtering Foo resources. +type fooState struct { +} + +type FooState struct { +} + +func (FooState) ElementType() reflect.Type { + return reflect.TypeOf((*fooState)(nil)).Elem() +} + +type fooArgs struct { + Argument *string `pulumi:"argument"` + // Options for tuning the Kubernetes client used by a Provider. + BackupKubeClientSettings KubeClientSettings `pulumi:"backupKubeClientSettings"` + // Options for tuning the Kubernetes client used by a Provider. + KubeClientSettings *KubeClientSettings `pulumi:"kubeClientSettings"` + // describing things + Settings *LayeredType `pulumi:"settings"` +} + +// The set of arguments for constructing a Foo resource. +type FooArgs struct { + Argument *string + // Options for tuning the Kubernetes client used by a Provider. + BackupKubeClientSettings KubeClientSettingsInput + // Options for tuning the Kubernetes client used by a Provider. + KubeClientSettings KubeClientSettingsPtrInput + // describing things + Settings LayeredTypePtrInput +} + +func (FooArgs) ElementType() reflect.Type { + return reflect.TypeOf((*fooArgs)(nil)).Elem() +} + +type FooInput interface { + pulumi.Input + + ToFooOutput() FooOutput + ToFooOutputWithContext(ctx context.Context) FooOutput +} + +func (*Foo) ElementType() reflect.Type { + return reflect.TypeOf((*Foo)(nil)) +} + +func (i *Foo) ToFooOutput() FooOutput { + return i.ToFooOutputWithContext(context.Background()) +} + +func (i *Foo) ToFooOutputWithContext(ctx context.Context) FooOutput { + return pulumi.ToOutputWithContext(ctx, i).(FooOutput) +} + +type FooOutput struct{ *pulumi.OutputState } + +func (FooOutput) ElementType() reflect.Type { + return reflect.TypeOf((*Foo)(nil)) +} + +func (o FooOutput) ToFooOutput() FooOutput { + return o +} + +func (o FooOutput) ToFooOutputWithContext(ctx context.Context) FooOutput { + return o +} + +func init() { + pulumi.RegisterInputType(reflect.TypeOf((*FooInput)(nil)).Elem(), &Foo{}) + pulumi.RegisterOutputType(FooOutput{}) +} diff --git a/pkg/codegen/internal/test/testdata/env-helper/go/example/funcWithAllOptionalInputs.go b/pkg/codegen/internal/test/testdata/env-helper/go/example/funcWithAllOptionalInputs.go new file mode 100644 index 000000000..1b3cabca6 --- /dev/null +++ b/pkg/codegen/internal/test/testdata/env-helper/go/example/funcWithAllOptionalInputs.go @@ -0,0 +1,74 @@ +// *** 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 ( + "context" + "reflect" + + "github.com/pulumi/pulumi/sdk/v3/go/pulumi" +) + +// Check codegen of functions with all optional inputs. +func FuncWithAllOptionalInputs(ctx *pulumi.Context, args *FuncWithAllOptionalInputsArgs, opts ...pulumi.InvokeOption) (*FuncWithAllOptionalInputsResult, error) { + var rv FuncWithAllOptionalInputsResult + err := ctx.Invoke("mypkg::funcWithAllOptionalInputs", args, &rv, opts...) + if err != nil { + return nil, err + } + return &rv, nil +} + +type FuncWithAllOptionalInputsArgs struct { + // Property A + A *HelmReleaseSettings `pulumi:"a"` + // Property B + B *string `pulumi:"b"` +} + +type FuncWithAllOptionalInputsResult struct { + R string `pulumi:"r"` +} + +func FuncWithAllOptionalInputsOutput(ctx *pulumi.Context, args FuncWithAllOptionalInputsOutputArgs, opts ...pulumi.InvokeOption) FuncWithAllOptionalInputsResultOutput { + return pulumi.ToOutputWithContext(context.Background(), args). + ApplyT(func(v interface{}) (FuncWithAllOptionalInputsResult, error) { + args := v.(FuncWithAllOptionalInputsArgs) + r, err := FuncWithAllOptionalInputs(ctx, &args, opts...) + return *r, err + }).(FuncWithAllOptionalInputsResultOutput) +} + +type FuncWithAllOptionalInputsOutputArgs struct { + // Property A + A HelmReleaseSettingsPtrInput `pulumi:"a"` + // Property B + B pulumi.StringPtrInput `pulumi:"b"` +} + +func (FuncWithAllOptionalInputsOutputArgs) ElementType() reflect.Type { + return reflect.TypeOf((*FuncWithAllOptionalInputsArgs)(nil)).Elem() +} + +type FuncWithAllOptionalInputsResultOutput struct{ *pulumi.OutputState } + +func (FuncWithAllOptionalInputsResultOutput) ElementType() reflect.Type { + return reflect.TypeOf((*FuncWithAllOptionalInputsResult)(nil)).Elem() +} + +func (o FuncWithAllOptionalInputsResultOutput) ToFuncWithAllOptionalInputsResultOutput() FuncWithAllOptionalInputsResultOutput { + return o +} + +func (o FuncWithAllOptionalInputsResultOutput) ToFuncWithAllOptionalInputsResultOutputWithContext(ctx context.Context) FuncWithAllOptionalInputsResultOutput { + return o +} + +func (o FuncWithAllOptionalInputsResultOutput) R() pulumi.StringOutput { + return o.ApplyT(func(v FuncWithAllOptionalInputsResult) string { return v.R }).(pulumi.StringOutput) +} + +func init() { + pulumi.RegisterOutputType(FuncWithAllOptionalInputsResultOutput{}) +} diff --git a/pkg/codegen/internal/test/testdata/env-helper/go/example/init.go b/pkg/codegen/internal/test/testdata/env-helper/go/example/init.go new file mode 100644 index 000000000..135eaf0b4 --- /dev/null +++ b/pkg/codegen/internal/test/testdata/env-helper/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/env-helper/go/example/mod1/pulumiTypes.go new file mode 100644 index 000000000..fe787ec3b --- /dev/null +++ b/pkg/codegen/internal/test/testdata/env-helper/go/example/mod1/pulumiTypes.go @@ -0,0 +1,154 @@ +// *** WARNING: this file was generated by test. *** +// *** Do not edit by hand unless you're certain you know what you are doing! *** + +package mod1 + +import ( + "context" + "reflect" + + "github.com/pulumi/pulumi/sdk/v3/go/pulumi" +) + +// A test for namespaces (mod 1) +type Typ struct { + Val *string `pulumi:"val"` +} + +// TypInput is an input type that accepts TypArgs and TypOutput values. +// You can construct a concrete instance of `TypInput` via: +// +// TypArgs{...} +type TypInput interface { + pulumi.Input + + ToTypOutput() TypOutput + ToTypOutputWithContext(context.Context) TypOutput +} + +// A test for namespaces (mod 1) +type TypArgs struct { + Val pulumi.StringPtrInput `pulumi:"val"` +} + +func (TypArgs) ElementType() reflect.Type { + return reflect.TypeOf((*Typ)(nil)).Elem() +} + +func (i TypArgs) ToTypOutput() TypOutput { + return i.ToTypOutputWithContext(context.Background()) +} + +func (i TypArgs) ToTypOutputWithContext(ctx context.Context) TypOutput { + return pulumi.ToOutputWithContext(ctx, i).(TypOutput) +} + +func (i TypArgs) ToTypPtrOutput() TypPtrOutput { + return i.ToTypPtrOutputWithContext(context.Background()) +} + +func (i TypArgs) ToTypPtrOutputWithContext(ctx context.Context) TypPtrOutput { + return pulumi.ToOutputWithContext(ctx, i).(TypOutput).ToTypPtrOutputWithContext(ctx) +} + +// TypPtrInput is an input type that accepts TypArgs, TypPtr and TypPtrOutput values. +// You can construct a concrete instance of `TypPtrInput` via: +// +// TypArgs{...} +// +// or: +// +// nil +type TypPtrInput interface { + pulumi.Input + + ToTypPtrOutput() TypPtrOutput + ToTypPtrOutputWithContext(context.Context) TypPtrOutput +} + +type typPtrType TypArgs + +func TypPtr(v *TypArgs) TypPtrInput { + return (*typPtrType)(v) +} + +func (*typPtrType) ElementType() reflect.Type { + return reflect.TypeOf((**Typ)(nil)).Elem() +} + +func (i *typPtrType) ToTypPtrOutput() TypPtrOutput { + return i.ToTypPtrOutputWithContext(context.Background()) +} + +func (i *typPtrType) ToTypPtrOutputWithContext(ctx context.Context) TypPtrOutput { + return pulumi.ToOutputWithContext(ctx, i).(TypPtrOutput) +} + +// A test for namespaces (mod 1) +type TypOutput struct{ *pulumi.OutputState } + +func (TypOutput) ElementType() reflect.Type { + return reflect.TypeOf((*Typ)(nil)).Elem() +} + +func (o TypOutput) ToTypOutput() TypOutput { + return o +} + +func (o TypOutput) ToTypOutputWithContext(ctx context.Context) TypOutput { + return o +} + +func (o TypOutput) ToTypPtrOutput() TypPtrOutput { + return o.ToTypPtrOutputWithContext(context.Background()) +} + +func (o TypOutput) ToTypPtrOutputWithContext(ctx context.Context) TypPtrOutput { + return o.ApplyTWithContext(ctx, func(_ context.Context, v Typ) *Typ { + return &v + }).(TypPtrOutput) +} + +func (o TypOutput) Val() pulumi.StringPtrOutput { + return o.ApplyT(func(v Typ) *string { return v.Val }).(pulumi.StringPtrOutput) +} + +type TypPtrOutput struct{ *pulumi.OutputState } + +func (TypPtrOutput) ElementType() reflect.Type { + return reflect.TypeOf((**Typ)(nil)).Elem() +} + +func (o TypPtrOutput) ToTypPtrOutput() TypPtrOutput { + return o +} + +func (o TypPtrOutput) ToTypPtrOutputWithContext(ctx context.Context) TypPtrOutput { + return o +} + +func (o TypPtrOutput) Elem() TypOutput { + return o.ApplyT(func(v *Typ) Typ { + if v != nil { + return *v + } + var ret Typ + return ret + }).(TypOutput) +} + +func (o TypPtrOutput) Val() pulumi.StringPtrOutput { + return o.ApplyT(func(v *Typ) *string { + if v == nil { + return nil + } + return v.Val + }).(pulumi.StringPtrOutput) +} + +func init() { + pulumi.RegisterInputType(reflect.TypeOf((*TypInput)(nil)).Elem(), TypArgs{}) + pulumi.RegisterInputType(reflect.TypeOf((*TypPtrInput)(nil)).Elem(), TypArgs{}) + pulumi.RegisterOutputType(TypOutput{}) + pulumi.RegisterOutputType(TypPtrOutput{}) +} diff --git a/pkg/codegen/internal/test/testdata/env-helper/go/example/mod2/pulumiTypes.go b/pkg/codegen/internal/test/testdata/env-helper/go/example/mod2/pulumiTypes.go new file mode 100644 index 000000000..e803f4256 --- /dev/null +++ b/pkg/codegen/internal/test/testdata/env-helper/go/example/mod2/pulumiTypes.go @@ -0,0 +1,170 @@ +// *** WARNING: this file was generated by test. *** +// *** Do not edit by hand unless you're certain you know what you are doing! *** + +package mod2 + +import ( + "context" + "reflect" + + "env-helper/example/mod1" + "github.com/pulumi/pulumi/sdk/v3/go/pulumi" +) + +// A test for namespaces (mod 2) +type Typ struct { + Mod1 *mod1.Typ `pulumi:"mod1"` + Val *string `pulumi:"val"` +} + +// TypInput is an input type that accepts TypArgs and TypOutput values. +// You can construct a concrete instance of `TypInput` via: +// +// TypArgs{...} +type TypInput interface { + pulumi.Input + + ToTypOutput() TypOutput + ToTypOutputWithContext(context.Context) TypOutput +} + +// A test for namespaces (mod 2) +type TypArgs struct { + Mod1 mod1.TypPtrInput `pulumi:"mod1"` + Val pulumi.StringPtrInput `pulumi:"val"` +} + +func (TypArgs) ElementType() reflect.Type { + return reflect.TypeOf((*Typ)(nil)).Elem() +} + +func (i TypArgs) ToTypOutput() TypOutput { + return i.ToTypOutputWithContext(context.Background()) +} + +func (i TypArgs) ToTypOutputWithContext(ctx context.Context) TypOutput { + return pulumi.ToOutputWithContext(ctx, i).(TypOutput) +} + +func (i TypArgs) ToTypPtrOutput() TypPtrOutput { + return i.ToTypPtrOutputWithContext(context.Background()) +} + +func (i TypArgs) ToTypPtrOutputWithContext(ctx context.Context) TypPtrOutput { + return pulumi.ToOutputWithContext(ctx, i).(TypOutput).ToTypPtrOutputWithContext(ctx) +} + +// TypPtrInput is an input type that accepts TypArgs, TypPtr and TypPtrOutput values. +// You can construct a concrete instance of `TypPtrInput` via: +// +// TypArgs{...} +// +// or: +// +// nil +type TypPtrInput interface { + pulumi.Input + + ToTypPtrOutput() TypPtrOutput + ToTypPtrOutputWithContext(context.Context) TypPtrOutput +} + +type typPtrType TypArgs + +func TypPtr(v *TypArgs) TypPtrInput { + return (*typPtrType)(v) +} + +func (*typPtrType) ElementType() reflect.Type { + return reflect.TypeOf((**Typ)(nil)).Elem() +} + +func (i *typPtrType) ToTypPtrOutput() TypPtrOutput { + return i.ToTypPtrOutputWithContext(context.Background()) +} + +func (i *typPtrType) ToTypPtrOutputWithContext(ctx context.Context) TypPtrOutput { + return pulumi.ToOutputWithContext(ctx, i).(TypPtrOutput) +} + +// A test for namespaces (mod 2) +type TypOutput struct{ *pulumi.OutputState } + +func (TypOutput) ElementType() reflect.Type { + return reflect.TypeOf((*Typ)(nil)).Elem() +} + +func (o TypOutput) ToTypOutput() TypOutput { + return o +} + +func (o TypOutput) ToTypOutputWithContext(ctx context.Context) TypOutput { + return o +} + +func (o TypOutput) ToTypPtrOutput() TypPtrOutput { + return o.ToTypPtrOutputWithContext(context.Background()) +} + +func (o TypOutput) ToTypPtrOutputWithContext(ctx context.Context) TypPtrOutput { + return o.ApplyTWithContext(ctx, func(_ context.Context, v Typ) *Typ { + return &v + }).(TypPtrOutput) +} + +func (o TypOutput) Mod1() mod1.TypPtrOutput { + return o.ApplyT(func(v Typ) *mod1.Typ { return v.Mod1 }).(mod1.TypPtrOutput) +} + +func (o TypOutput) Val() pulumi.StringPtrOutput { + return o.ApplyT(func(v Typ) *string { return v.Val }).(pulumi.StringPtrOutput) +} + +type TypPtrOutput struct{ *pulumi.OutputState } + +func (TypPtrOutput) ElementType() reflect.Type { + return reflect.TypeOf((**Typ)(nil)).Elem() +} + +func (o TypPtrOutput) ToTypPtrOutput() TypPtrOutput { + return o +} + +func (o TypPtrOutput) ToTypPtrOutputWithContext(ctx context.Context) TypPtrOutput { + return o +} + +func (o TypPtrOutput) Elem() TypOutput { + return o.ApplyT(func(v *Typ) Typ { + if v != nil { + return *v + } + var ret Typ + return ret + }).(TypOutput) +} + +func (o TypPtrOutput) Mod1() mod1.TypPtrOutput { + return o.ApplyT(func(v *Typ) *mod1.Typ { + if v == nil { + return nil + } + return v.Mod1 + }).(mod1.TypPtrOutput) +} + +func (o TypPtrOutput) Val() pulumi.StringPtrOutput { + return o.ApplyT(func(v *Typ) *string { + if v == nil { + return nil + } + return v.Val + }).(pulumi.StringPtrOutput) +} + +func init() { + pulumi.RegisterInputType(reflect.TypeOf((*TypInput)(nil)).Elem(), TypArgs{}) + pulumi.RegisterInputType(reflect.TypeOf((*TypPtrInput)(nil)).Elem(), TypArgs{}) + pulumi.RegisterOutputType(TypOutput{}) + pulumi.RegisterOutputType(TypPtrOutput{}) +} diff --git a/pkg/codegen/internal/test/testdata/env-helper/go/example/moduleTest.go b/pkg/codegen/internal/test/testdata/env-helper/go/example/moduleTest.go new file mode 100644 index 000000000..f8ab248b5 --- /dev/null +++ b/pkg/codegen/internal/test/testdata/env-helper/go/example/moduleTest.go @@ -0,0 +1,107 @@ +// *** 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 ( + "context" + "reflect" + + "env-helper/example/mod1" + "github.com/pulumi/pulumi/sdk/v3/go/pulumi" +) + +type ModuleTest struct { + pulumi.CustomResourceState +} + +// NewModuleTest registers a new resource with the given unique name, arguments, and options. +func NewModuleTest(ctx *pulumi.Context, + name string, args *ModuleTestArgs, opts ...pulumi.ResourceOption) (*ModuleTest, error) { + if args == nil { + args = &ModuleTestArgs{} + } + + var resource ModuleTest + err := ctx.RegisterResource("example:index:moduleTest", name, args, &resource, opts...) + if err != nil { + return nil, err + } + return &resource, nil +} + +// GetModuleTest gets an existing ModuleTest resource's state with the given name, ID, and optional +// state properties that are used to uniquely qualify the lookup (nil if not required). +func GetModuleTest(ctx *pulumi.Context, + name string, id pulumi.IDInput, state *ModuleTestState, opts ...pulumi.ResourceOption) (*ModuleTest, error) { + var resource ModuleTest + err := ctx.ReadResource("example:index:moduleTest", name, id, state, &resource, opts...) + if err != nil { + return nil, err + } + return &resource, nil +} + +// Input properties used for looking up and filtering ModuleTest resources. +type moduleTestState struct { +} + +type ModuleTestState struct { +} + +func (ModuleTestState) ElementType() reflect.Type { + return reflect.TypeOf((*moduleTestState)(nil)).Elem() +} + +type moduleTestArgs struct { + Mod1 *mod1.Typ `pulumi:"mod1"` + Val *Typ `pulumi:"val"` +} + +// The set of arguments for constructing a ModuleTest resource. +type ModuleTestArgs struct { + Mod1 mod1.TypPtrInput + Val TypPtrInput +} + +func (ModuleTestArgs) ElementType() reflect.Type { + return reflect.TypeOf((*moduleTestArgs)(nil)).Elem() +} + +type ModuleTestInput interface { + pulumi.Input + + ToModuleTestOutput() ModuleTestOutput + ToModuleTestOutputWithContext(ctx context.Context) ModuleTestOutput +} + +func (*ModuleTest) ElementType() reflect.Type { + return reflect.TypeOf((*ModuleTest)(nil)) +} + +func (i *ModuleTest) ToModuleTestOutput() ModuleTestOutput { + return i.ToModuleTestOutputWithContext(context.Background()) +} + +func (i *ModuleTest) ToModuleTestOutputWithContext(ctx context.Context) ModuleTestOutput { + return pulumi.ToOutputWithContext(ctx, i).(ModuleTestOutput) +} + +type ModuleTestOutput struct{ *pulumi.OutputState } + +func (ModuleTestOutput) ElementType() reflect.Type { + return reflect.TypeOf((*ModuleTest)(nil)) +} + +func (o ModuleTestOutput) ToModuleTestOutput() ModuleTestOutput { + return o +} + +func (o ModuleTestOutput) ToModuleTestOutputWithContext(ctx context.Context) ModuleTestOutput { + return o +} + +func init() { + pulumi.RegisterInputType(reflect.TypeOf((*ModuleTestInput)(nil)).Elem(), &ModuleTest{}) + pulumi.RegisterOutputType(ModuleTestOutput{}) +} diff --git a/pkg/codegen/internal/test/testdata/env-helper/go/example/provider.go b/pkg/codegen/internal/test/testdata/env-helper/go/example/provider.go new file mode 100644 index 000000000..b5dc7de27 --- /dev/null +++ b/pkg/codegen/internal/test/testdata/env-helper/go/example/provider.go @@ -0,0 +1,84 @@ +// *** 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 ( + "context" + "reflect" + + "github.com/pulumi/pulumi/sdk/v3/go/pulumi" +) + +// The provider type for the kubernetes package. +type Provider struct { + pulumi.ProviderResourceState +} + +// NewProvider registers a new resource with the given unique name, arguments, and options. +func NewProvider(ctx *pulumi.Context, + name string, args *ProviderArgs, opts ...pulumi.ResourceOption) (*Provider, error) { + if args == nil { + args = &ProviderArgs{} + } + + var resource Provider + err := ctx.RegisterResource("pulumi:providers:example", name, args, &resource, opts...) + if err != nil { + return nil, err + } + return &resource, nil +} + +type providerArgs struct { + // BETA FEATURE - Options to configure the Helm Release resource. + HelmReleaseSettings *HelmReleaseSettings `pulumi:"helmReleaseSettings"` +} + +// The set of arguments for constructing a Provider resource. +type ProviderArgs struct { + // BETA FEATURE - Options to configure the Helm Release resource. + HelmReleaseSettings HelmReleaseSettingsPtrInput +} + +func (ProviderArgs) ElementType() reflect.Type { + return reflect.TypeOf((*providerArgs)(nil)).Elem() +} + +type ProviderInput interface { + pulumi.Input + + ToProviderOutput() ProviderOutput + ToProviderOutputWithContext(ctx context.Context) ProviderOutput +} + +func (*Provider) ElementType() reflect.Type { + return reflect.TypeOf((*Provider)(nil)) +} + +func (i *Provider) ToProviderOutput() ProviderOutput { + return i.ToProviderOutputWithContext(context.Background()) +} + +func (i *Provider) ToProviderOutputWithContext(ctx context.Context) ProviderOutput { + return pulumi.ToOutputWithContext(ctx, i).(ProviderOutput) +} + +type ProviderOutput struct{ *pulumi.OutputState } + +func (ProviderOutput) ElementType() reflect.Type { + return reflect.TypeOf((*Provider)(nil)) +} + +func (o ProviderOutput) ToProviderOutput() ProviderOutput { + return o +} + +func (o ProviderOutput) ToProviderOutputWithContext(ctx context.Context) ProviderOutput { + return o +} + +func init() { + pulumi.RegisterInputType(reflect.TypeOf((*ProviderInput)(nil)).Elem(), &Provider{}) + pulumi.RegisterOutputType(ProviderOutput{}) +} diff --git a/pkg/codegen/internal/test/testdata/env-helper/go/example/pulumiTypes.go b/pkg/codegen/internal/test/testdata/env-helper/go/example/pulumiTypes.go new file mode 100644 index 000000000..3e5c6b754 --- /dev/null +++ b/pkg/codegen/internal/test/testdata/env-helper/go/example/pulumiTypes.go @@ -0,0 +1,777 @@ +// *** 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 ( + "context" + "reflect" + + "env-helper/example/mod1" + "env-helper/example/mod2" + "github.com/pulumi/pulumi/sdk/v3/go/pulumi" +) + +// BETA FEATURE - Options to configure the Helm Release resource. +type HelmReleaseSettings struct { + // The backend storage driver for Helm. Values are: configmap, secret, memory, sql. + Driver *string `pulumi:"driver"` + // The path to the helm plugins directory. + PluginsPath *string `pulumi:"pluginsPath"` + // to test required args + RequiredArg string `pulumi:"requiredArg"` +} + +// HelmReleaseSettingsInput is an input type that accepts HelmReleaseSettingsArgs and HelmReleaseSettingsOutput values. +// You can construct a concrete instance of `HelmReleaseSettingsInput` via: +// +// HelmReleaseSettingsArgs{...} +type HelmReleaseSettingsInput interface { + pulumi.Input + + ToHelmReleaseSettingsOutput() HelmReleaseSettingsOutput + ToHelmReleaseSettingsOutputWithContext(context.Context) HelmReleaseSettingsOutput +} + +// BETA FEATURE - Options to configure the Helm Release resource. +type HelmReleaseSettingsArgs struct { + // The backend storage driver for Helm. Values are: configmap, secret, memory, sql. + Driver pulumi.StringPtrInput `pulumi:"driver"` + // The path to the helm plugins directory. + PluginsPath pulumi.StringPtrInput `pulumi:"pluginsPath"` + // to test required args + RequiredArg pulumi.StringInput `pulumi:"requiredArg"` +} + +func (HelmReleaseSettingsArgs) ElementType() reflect.Type { + return reflect.TypeOf((*HelmReleaseSettings)(nil)).Elem() +} + +func (i HelmReleaseSettingsArgs) ToHelmReleaseSettingsOutput() HelmReleaseSettingsOutput { + return i.ToHelmReleaseSettingsOutputWithContext(context.Background()) +} + +func (i HelmReleaseSettingsArgs) ToHelmReleaseSettingsOutputWithContext(ctx context.Context) HelmReleaseSettingsOutput { + return pulumi.ToOutputWithContext(ctx, i).(HelmReleaseSettingsOutput) +} + +func (i HelmReleaseSettingsArgs) ToHelmReleaseSettingsPtrOutput() HelmReleaseSettingsPtrOutput { + return i.ToHelmReleaseSettingsPtrOutputWithContext(context.Background()) +} + +func (i HelmReleaseSettingsArgs) ToHelmReleaseSettingsPtrOutputWithContext(ctx context.Context) HelmReleaseSettingsPtrOutput { + return pulumi.ToOutputWithContext(ctx, i).(HelmReleaseSettingsOutput).ToHelmReleaseSettingsPtrOutputWithContext(ctx) +} + +// HelmReleaseSettingsPtrInput is an input type that accepts HelmReleaseSettingsArgs, HelmReleaseSettingsPtr and HelmReleaseSettingsPtrOutput values. +// You can construct a concrete instance of `HelmReleaseSettingsPtrInput` via: +// +// HelmReleaseSettingsArgs{...} +// +// or: +// +// nil +type HelmReleaseSettingsPtrInput interface { + pulumi.Input + + ToHelmReleaseSettingsPtrOutput() HelmReleaseSettingsPtrOutput + ToHelmReleaseSettingsPtrOutputWithContext(context.Context) HelmReleaseSettingsPtrOutput +} + +type helmReleaseSettingsPtrType HelmReleaseSettingsArgs + +func HelmReleaseSettingsPtr(v *HelmReleaseSettingsArgs) HelmReleaseSettingsPtrInput { + return (*helmReleaseSettingsPtrType)(v) +} + +func (*helmReleaseSettingsPtrType) ElementType() reflect.Type { + return reflect.TypeOf((**HelmReleaseSettings)(nil)).Elem() +} + +func (i *helmReleaseSettingsPtrType) ToHelmReleaseSettingsPtrOutput() HelmReleaseSettingsPtrOutput { + return i.ToHelmReleaseSettingsPtrOutputWithContext(context.Background()) +} + +func (i *helmReleaseSettingsPtrType) ToHelmReleaseSettingsPtrOutputWithContext(ctx context.Context) HelmReleaseSettingsPtrOutput { + return pulumi.ToOutputWithContext(ctx, i).(HelmReleaseSettingsPtrOutput) +} + +// BETA FEATURE - Options to configure the Helm Release resource. +type HelmReleaseSettingsOutput struct{ *pulumi.OutputState } + +func (HelmReleaseSettingsOutput) ElementType() reflect.Type { + return reflect.TypeOf((*HelmReleaseSettings)(nil)).Elem() +} + +func (o HelmReleaseSettingsOutput) ToHelmReleaseSettingsOutput() HelmReleaseSettingsOutput { + return o +} + +func (o HelmReleaseSettingsOutput) ToHelmReleaseSettingsOutputWithContext(ctx context.Context) HelmReleaseSettingsOutput { + return o +} + +func (o HelmReleaseSettingsOutput) ToHelmReleaseSettingsPtrOutput() HelmReleaseSettingsPtrOutput { + return o.ToHelmReleaseSettingsPtrOutputWithContext(context.Background()) +} + +func (o HelmReleaseSettingsOutput) ToHelmReleaseSettingsPtrOutputWithContext(ctx context.Context) HelmReleaseSettingsPtrOutput { + return o.ApplyTWithContext(ctx, func(_ context.Context, v HelmReleaseSettings) *HelmReleaseSettings { + return &v + }).(HelmReleaseSettingsPtrOutput) +} + +// The backend storage driver for Helm. Values are: configmap, secret, memory, sql. +func (o HelmReleaseSettingsOutput) Driver() pulumi.StringPtrOutput { + return o.ApplyT(func(v HelmReleaseSettings) *string { return v.Driver }).(pulumi.StringPtrOutput) +} + +// The path to the helm plugins directory. +func (o HelmReleaseSettingsOutput) PluginsPath() pulumi.StringPtrOutput { + return o.ApplyT(func(v HelmReleaseSettings) *string { return v.PluginsPath }).(pulumi.StringPtrOutput) +} + +// to test required args +func (o HelmReleaseSettingsOutput) RequiredArg() pulumi.StringOutput { + return o.ApplyT(func(v HelmReleaseSettings) string { return v.RequiredArg }).(pulumi.StringOutput) +} + +type HelmReleaseSettingsPtrOutput struct{ *pulumi.OutputState } + +func (HelmReleaseSettingsPtrOutput) ElementType() reflect.Type { + return reflect.TypeOf((**HelmReleaseSettings)(nil)).Elem() +} + +func (o HelmReleaseSettingsPtrOutput) ToHelmReleaseSettingsPtrOutput() HelmReleaseSettingsPtrOutput { + return o +} + +func (o HelmReleaseSettingsPtrOutput) ToHelmReleaseSettingsPtrOutputWithContext(ctx context.Context) HelmReleaseSettingsPtrOutput { + return o +} + +func (o HelmReleaseSettingsPtrOutput) Elem() HelmReleaseSettingsOutput { + return o.ApplyT(func(v *HelmReleaseSettings) HelmReleaseSettings { + if v != nil { + return *v + } + var ret HelmReleaseSettings + return ret + }).(HelmReleaseSettingsOutput) +} + +// The backend storage driver for Helm. Values are: configmap, secret, memory, sql. +func (o HelmReleaseSettingsPtrOutput) Driver() pulumi.StringPtrOutput { + return o.ApplyT(func(v *HelmReleaseSettings) *string { + if v == nil { + return nil + } + return v.Driver + }).(pulumi.StringPtrOutput) +} + +// The path to the helm plugins directory. +func (o HelmReleaseSettingsPtrOutput) PluginsPath() pulumi.StringPtrOutput { + return o.ApplyT(func(v *HelmReleaseSettings) *string { + if v == nil { + return nil + } + return v.PluginsPath + }).(pulumi.StringPtrOutput) +} + +// to test required args +func (o HelmReleaseSettingsPtrOutput) RequiredArg() pulumi.StringPtrOutput { + return o.ApplyT(func(v *HelmReleaseSettings) *string { + if v == nil { + return nil + } + return &v.RequiredArg + }).(pulumi.StringPtrOutput) +} + +// Options for tuning the Kubernetes client used by a Provider. +type KubeClientSettings struct { + // Maximum burst for throttle. Default value is 10. + Burst *int `pulumi:"burst"` + // Maximum queries per second (QPS) to the API server from this client. Default value is 5. + Qps *float64 `pulumi:"qps"` + RecTest *KubeClientSettings `pulumi:"recTest"` +} + +// KubeClientSettingsInput is an input type that accepts KubeClientSettingsArgs and KubeClientSettingsOutput values. +// You can construct a concrete instance of `KubeClientSettingsInput` via: +// +// KubeClientSettingsArgs{...} +type KubeClientSettingsInput interface { + pulumi.Input + + ToKubeClientSettingsOutput() KubeClientSettingsOutput + ToKubeClientSettingsOutputWithContext(context.Context) KubeClientSettingsOutput +} + +// Options for tuning the Kubernetes client used by a Provider. +type KubeClientSettingsArgs struct { + // Maximum burst for throttle. Default value is 10. + Burst pulumi.IntPtrInput `pulumi:"burst"` + // Maximum queries per second (QPS) to the API server from this client. Default value is 5. + Qps pulumi.Float64PtrInput `pulumi:"qps"` + RecTest KubeClientSettingsPtrInput `pulumi:"recTest"` +} + +func (KubeClientSettingsArgs) ElementType() reflect.Type { + return reflect.TypeOf((*KubeClientSettings)(nil)).Elem() +} + +func (i KubeClientSettingsArgs) ToKubeClientSettingsOutput() KubeClientSettingsOutput { + return i.ToKubeClientSettingsOutputWithContext(context.Background()) +} + +func (i KubeClientSettingsArgs) ToKubeClientSettingsOutputWithContext(ctx context.Context) KubeClientSettingsOutput { + return pulumi.ToOutputWithContext(ctx, i).(KubeClientSettingsOutput) +} + +func (i KubeClientSettingsArgs) ToKubeClientSettingsPtrOutput() KubeClientSettingsPtrOutput { + return i.ToKubeClientSettingsPtrOutputWithContext(context.Background()) +} + +func (i KubeClientSettingsArgs) ToKubeClientSettingsPtrOutputWithContext(ctx context.Context) KubeClientSettingsPtrOutput { + return pulumi.ToOutputWithContext(ctx, i).(KubeClientSettingsOutput).ToKubeClientSettingsPtrOutputWithContext(ctx) +} + +// KubeClientSettingsPtrInput is an input type that accepts KubeClientSettingsArgs, KubeClientSettingsPtr and KubeClientSettingsPtrOutput values. +// You can construct a concrete instance of `KubeClientSettingsPtrInput` via: +// +// KubeClientSettingsArgs{...} +// +// or: +// +// nil +type KubeClientSettingsPtrInput interface { + pulumi.Input + + ToKubeClientSettingsPtrOutput() KubeClientSettingsPtrOutput + ToKubeClientSettingsPtrOutputWithContext(context.Context) KubeClientSettingsPtrOutput +} + +type kubeClientSettingsPtrType KubeClientSettingsArgs + +func KubeClientSettingsPtr(v *KubeClientSettingsArgs) KubeClientSettingsPtrInput { + return (*kubeClientSettingsPtrType)(v) +} + +func (*kubeClientSettingsPtrType) ElementType() reflect.Type { + return reflect.TypeOf((**KubeClientSettings)(nil)).Elem() +} + +func (i *kubeClientSettingsPtrType) ToKubeClientSettingsPtrOutput() KubeClientSettingsPtrOutput { + return i.ToKubeClientSettingsPtrOutputWithContext(context.Background()) +} + +func (i *kubeClientSettingsPtrType) ToKubeClientSettingsPtrOutputWithContext(ctx context.Context) KubeClientSettingsPtrOutput { + return pulumi.ToOutputWithContext(ctx, i).(KubeClientSettingsPtrOutput) +} + +// Options for tuning the Kubernetes client used by a Provider. +type KubeClientSettingsOutput struct{ *pulumi.OutputState } + +func (KubeClientSettingsOutput) ElementType() reflect.Type { + return reflect.TypeOf((*KubeClientSettings)(nil)).Elem() +} + +func (o KubeClientSettingsOutput) ToKubeClientSettingsOutput() KubeClientSettingsOutput { + return o +} + +func (o KubeClientSettingsOutput) ToKubeClientSettingsOutputWithContext(ctx context.Context) KubeClientSettingsOutput { + return o +} + +func (o KubeClientSettingsOutput) ToKubeClientSettingsPtrOutput() KubeClientSettingsPtrOutput { + return o.ToKubeClientSettingsPtrOutputWithContext(context.Background()) +} + +func (o KubeClientSettingsOutput) ToKubeClientSettingsPtrOutputWithContext(ctx context.Context) KubeClientSettingsPtrOutput { + return o.ApplyTWithContext(ctx, func(_ context.Context, v KubeClientSettings) *KubeClientSettings { + return &v + }).(KubeClientSettingsPtrOutput) +} + +// Maximum burst for throttle. Default value is 10. +func (o KubeClientSettingsOutput) Burst() pulumi.IntPtrOutput { + return o.ApplyT(func(v KubeClientSettings) *int { return v.Burst }).(pulumi.IntPtrOutput) +} + +// Maximum queries per second (QPS) to the API server from this client. Default value is 5. +func (o KubeClientSettingsOutput) Qps() pulumi.Float64PtrOutput { + return o.ApplyT(func(v KubeClientSettings) *float64 { return v.Qps }).(pulumi.Float64PtrOutput) +} + +func (o KubeClientSettingsOutput) RecTest() KubeClientSettingsPtrOutput { + return o.ApplyT(func(v KubeClientSettings) *KubeClientSettings { return v.RecTest }).(KubeClientSettingsPtrOutput) +} + +type KubeClientSettingsPtrOutput struct{ *pulumi.OutputState } + +func (KubeClientSettingsPtrOutput) ElementType() reflect.Type { + return reflect.TypeOf((**KubeClientSettings)(nil)).Elem() +} + +func (o KubeClientSettingsPtrOutput) ToKubeClientSettingsPtrOutput() KubeClientSettingsPtrOutput { + return o +} + +func (o KubeClientSettingsPtrOutput) ToKubeClientSettingsPtrOutputWithContext(ctx context.Context) KubeClientSettingsPtrOutput { + return o +} + +func (o KubeClientSettingsPtrOutput) Elem() KubeClientSettingsOutput { + return o.ApplyT(func(v *KubeClientSettings) KubeClientSettings { + if v != nil { + return *v + } + var ret KubeClientSettings + return ret + }).(KubeClientSettingsOutput) +} + +// Maximum burst for throttle. Default value is 10. +func (o KubeClientSettingsPtrOutput) Burst() pulumi.IntPtrOutput { + return o.ApplyT(func(v *KubeClientSettings) *int { + if v == nil { + return nil + } + return v.Burst + }).(pulumi.IntPtrOutput) +} + +// Maximum queries per second (QPS) to the API server from this client. Default value is 5. +func (o KubeClientSettingsPtrOutput) Qps() pulumi.Float64PtrOutput { + return o.ApplyT(func(v *KubeClientSettings) *float64 { + if v == nil { + return nil + } + return v.Qps + }).(pulumi.Float64PtrOutput) +} + +func (o KubeClientSettingsPtrOutput) RecTest() KubeClientSettingsPtrOutput { + return o.ApplyT(func(v *KubeClientSettings) *KubeClientSettings { + if v == nil { + return nil + } + return v.RecTest + }).(KubeClientSettingsPtrOutput) +} + +// Make sure that defaults propagate through types +type LayeredType struct { + // The answer to the question + Answer *float64 `pulumi:"answer"` + Other HelmReleaseSettings `pulumi:"other"` + // Test how plain types interact + PlainOther *HelmReleaseSettings `pulumi:"plainOther"` + // The question already answered + Question *string `pulumi:"question"` + Recursive *LayeredType `pulumi:"recursive"` + // To ask and answer + Thinker string `pulumi:"thinker"` +} + +// LayeredTypeInput is an input type that accepts LayeredTypeArgs and LayeredTypeOutput values. +// You can construct a concrete instance of `LayeredTypeInput` via: +// +// LayeredTypeArgs{...} +type LayeredTypeInput interface { + pulumi.Input + + ToLayeredTypeOutput() LayeredTypeOutput + ToLayeredTypeOutputWithContext(context.Context) LayeredTypeOutput +} + +// Make sure that defaults propagate through types +type LayeredTypeArgs struct { + // The answer to the question + Answer pulumi.Float64PtrInput `pulumi:"answer"` + Other HelmReleaseSettingsInput `pulumi:"other"` + // Test how plain types interact + PlainOther *HelmReleaseSettingsArgs `pulumi:"plainOther"` + // The question already answered + Question pulumi.StringPtrInput `pulumi:"question"` + Recursive LayeredTypePtrInput `pulumi:"recursive"` + // To ask and answer + Thinker pulumi.StringInput `pulumi:"thinker"` +} + +func (LayeredTypeArgs) ElementType() reflect.Type { + return reflect.TypeOf((*LayeredType)(nil)).Elem() +} + +func (i LayeredTypeArgs) ToLayeredTypeOutput() LayeredTypeOutput { + return i.ToLayeredTypeOutputWithContext(context.Background()) +} + +func (i LayeredTypeArgs) ToLayeredTypeOutputWithContext(ctx context.Context) LayeredTypeOutput { + return pulumi.ToOutputWithContext(ctx, i).(LayeredTypeOutput) +} + +func (i LayeredTypeArgs) ToLayeredTypePtrOutput() LayeredTypePtrOutput { + return i.ToLayeredTypePtrOutputWithContext(context.Background()) +} + +func (i LayeredTypeArgs) ToLayeredTypePtrOutputWithContext(ctx context.Context) LayeredTypePtrOutput { + return pulumi.ToOutputWithContext(ctx, i).(LayeredTypeOutput).ToLayeredTypePtrOutputWithContext(ctx) +} + +// LayeredTypePtrInput is an input type that accepts LayeredTypeArgs, LayeredTypePtr and LayeredTypePtrOutput values. +// You can construct a concrete instance of `LayeredTypePtrInput` via: +// +// LayeredTypeArgs{...} +// +// or: +// +// nil +type LayeredTypePtrInput interface { + pulumi.Input + + ToLayeredTypePtrOutput() LayeredTypePtrOutput + ToLayeredTypePtrOutputWithContext(context.Context) LayeredTypePtrOutput +} + +type layeredTypePtrType LayeredTypeArgs + +func LayeredTypePtr(v *LayeredTypeArgs) LayeredTypePtrInput { + return (*layeredTypePtrType)(v) +} + +func (*layeredTypePtrType) ElementType() reflect.Type { + return reflect.TypeOf((**LayeredType)(nil)).Elem() +} + +func (i *layeredTypePtrType) ToLayeredTypePtrOutput() LayeredTypePtrOutput { + return i.ToLayeredTypePtrOutputWithContext(context.Background()) +} + +func (i *layeredTypePtrType) ToLayeredTypePtrOutputWithContext(ctx context.Context) LayeredTypePtrOutput { + return pulumi.ToOutputWithContext(ctx, i).(LayeredTypePtrOutput) +} + +// Make sure that defaults propagate through types +type LayeredTypeOutput struct{ *pulumi.OutputState } + +func (LayeredTypeOutput) ElementType() reflect.Type { + return reflect.TypeOf((*LayeredType)(nil)).Elem() +} + +func (o LayeredTypeOutput) ToLayeredTypeOutput() LayeredTypeOutput { + return o +} + +func (o LayeredTypeOutput) ToLayeredTypeOutputWithContext(ctx context.Context) LayeredTypeOutput { + return o +} + +func (o LayeredTypeOutput) ToLayeredTypePtrOutput() LayeredTypePtrOutput { + return o.ToLayeredTypePtrOutputWithContext(context.Background()) +} + +func (o LayeredTypeOutput) ToLayeredTypePtrOutputWithContext(ctx context.Context) LayeredTypePtrOutput { + return o.ApplyTWithContext(ctx, func(_ context.Context, v LayeredType) *LayeredType { + return &v + }).(LayeredTypePtrOutput) +} + +// The answer to the question +func (o LayeredTypeOutput) Answer() pulumi.Float64PtrOutput { + return o.ApplyT(func(v LayeredType) *float64 { return v.Answer }).(pulumi.Float64PtrOutput) +} + +func (o LayeredTypeOutput) Other() HelmReleaseSettingsOutput { + return o.ApplyT(func(v LayeredType) HelmReleaseSettings { return v.Other }).(HelmReleaseSettingsOutput) +} + +// Test how plain types interact +func (o LayeredTypeOutput) PlainOther() HelmReleaseSettingsPtrOutput { + return o.ApplyT(func(v LayeredType) *HelmReleaseSettings { return v.PlainOther }).(HelmReleaseSettingsPtrOutput) +} + +// The question already answered +func (o LayeredTypeOutput) Question() pulumi.StringPtrOutput { + return o.ApplyT(func(v LayeredType) *string { return v.Question }).(pulumi.StringPtrOutput) +} + +func (o LayeredTypeOutput) Recursive() LayeredTypePtrOutput { + return o.ApplyT(func(v LayeredType) *LayeredType { return v.Recursive }).(LayeredTypePtrOutput) +} + +// To ask and answer +func (o LayeredTypeOutput) Thinker() pulumi.StringOutput { + return o.ApplyT(func(v LayeredType) string { return v.Thinker }).(pulumi.StringOutput) +} + +type LayeredTypePtrOutput struct{ *pulumi.OutputState } + +func (LayeredTypePtrOutput) ElementType() reflect.Type { + return reflect.TypeOf((**LayeredType)(nil)).Elem() +} + +func (o LayeredTypePtrOutput) ToLayeredTypePtrOutput() LayeredTypePtrOutput { + return o +} + +func (o LayeredTypePtrOutput) ToLayeredTypePtrOutputWithContext(ctx context.Context) LayeredTypePtrOutput { + return o +} + +func (o LayeredTypePtrOutput) Elem() LayeredTypeOutput { + return o.ApplyT(func(v *LayeredType) LayeredType { + if v != nil { + return *v + } + var ret LayeredType + return ret + }).(LayeredTypeOutput) +} + +// The answer to the question +func (o LayeredTypePtrOutput) Answer() pulumi.Float64PtrOutput { + return o.ApplyT(func(v *LayeredType) *float64 { + if v == nil { + return nil + } + return v.Answer + }).(pulumi.Float64PtrOutput) +} + +func (o LayeredTypePtrOutput) Other() HelmReleaseSettingsPtrOutput { + return o.ApplyT(func(v *LayeredType) *HelmReleaseSettings { + if v == nil { + return nil + } + return &v.Other + }).(HelmReleaseSettingsPtrOutput) +} + +// Test how plain types interact +func (o LayeredTypePtrOutput) PlainOther() HelmReleaseSettingsPtrOutput { + return o.ApplyT(func(v *LayeredType) *HelmReleaseSettings { + if v == nil { + return nil + } + return v.PlainOther + }).(HelmReleaseSettingsPtrOutput) +} + +// The question already answered +func (o LayeredTypePtrOutput) Question() pulumi.StringPtrOutput { + return o.ApplyT(func(v *LayeredType) *string { + if v == nil { + return nil + } + return v.Question + }).(pulumi.StringPtrOutput) +} + +func (o LayeredTypePtrOutput) Recursive() LayeredTypePtrOutput { + return o.ApplyT(func(v *LayeredType) *LayeredType { + if v == nil { + return nil + } + return v.Recursive + }).(LayeredTypePtrOutput) +} + +// To ask and answer +func (o LayeredTypePtrOutput) Thinker() pulumi.StringPtrOutput { + return o.ApplyT(func(v *LayeredType) *string { + if v == nil { + return nil + } + return &v.Thinker + }).(pulumi.StringPtrOutput) +} + +// A test for namespaces (mod main) +type Typ struct { + Mod1 *mod1.Typ `pulumi:"mod1"` + Mod2 *mod2.Typ `pulumi:"mod2"` + Val *string `pulumi:"val"` +} + +// TypInput is an input type that accepts TypArgs and TypOutput values. +// You can construct a concrete instance of `TypInput` via: +// +// TypArgs{...} +type TypInput interface { + pulumi.Input + + ToTypOutput() TypOutput + ToTypOutputWithContext(context.Context) TypOutput +} + +// A test for namespaces (mod main) +type TypArgs struct { + Mod1 mod1.TypPtrInput `pulumi:"mod1"` + Mod2 mod2.TypPtrInput `pulumi:"mod2"` + Val pulumi.StringPtrInput `pulumi:"val"` +} + +func (TypArgs) ElementType() reflect.Type { + return reflect.TypeOf((*Typ)(nil)).Elem() +} + +func (i TypArgs) ToTypOutput() TypOutput { + return i.ToTypOutputWithContext(context.Background()) +} + +func (i TypArgs) ToTypOutputWithContext(ctx context.Context) TypOutput { + return pulumi.ToOutputWithContext(ctx, i).(TypOutput) +} + +func (i TypArgs) ToTypPtrOutput() TypPtrOutput { + return i.ToTypPtrOutputWithContext(context.Background()) +} + +func (i TypArgs) ToTypPtrOutputWithContext(ctx context.Context) TypPtrOutput { + return pulumi.ToOutputWithContext(ctx, i).(TypOutput).ToTypPtrOutputWithContext(ctx) +} + +// TypPtrInput is an input type that accepts TypArgs, TypPtr and TypPtrOutput values. +// You can construct a concrete instance of `TypPtrInput` via: +// +// TypArgs{...} +// +// or: +// +// nil +type TypPtrInput interface { + pulumi.Input + + ToTypPtrOutput() TypPtrOutput + ToTypPtrOutputWithContext(context.Context) TypPtrOutput +} + +type typPtrType TypArgs + +func TypPtr(v *TypArgs) TypPtrInput { + return (*typPtrType)(v) +} + +func (*typPtrType) ElementType() reflect.Type { + return reflect.TypeOf((**Typ)(nil)).Elem() +} + +func (i *typPtrType) ToTypPtrOutput() TypPtrOutput { + return i.ToTypPtrOutputWithContext(context.Background()) +} + +func (i *typPtrType) ToTypPtrOutputWithContext(ctx context.Context) TypPtrOutput { + return pulumi.ToOutputWithContext(ctx, i).(TypPtrOutput) +} + +// A test for namespaces (mod main) +type TypOutput struct{ *pulumi.OutputState } + +func (TypOutput) ElementType() reflect.Type { + return reflect.TypeOf((*Typ)(nil)).Elem() +} + +func (o TypOutput) ToTypOutput() TypOutput { + return o +} + +func (o TypOutput) ToTypOutputWithContext(ctx context.Context) TypOutput { + return o +} + +func (o TypOutput) ToTypPtrOutput() TypPtrOutput { + return o.ToTypPtrOutputWithContext(context.Background()) +} + +func (o TypOutput) ToTypPtrOutputWithContext(ctx context.Context) TypPtrOutput { + return o.ApplyTWithContext(ctx, func(_ context.Context, v Typ) *Typ { + return &v + }).(TypPtrOutput) +} + +func (o TypOutput) Mod1() mod1.TypPtrOutput { + return o.ApplyT(func(v Typ) *mod1.Typ { return v.Mod1 }).(mod1.TypPtrOutput) +} + +func (o TypOutput) Mod2() mod2.TypPtrOutput { + return o.ApplyT(func(v Typ) *mod2.Typ { return v.Mod2 }).(mod2.TypPtrOutput) +} + +func (o TypOutput) Val() pulumi.StringPtrOutput { + return o.ApplyT(func(v Typ) *string { return v.Val }).(pulumi.StringPtrOutput) +} + +type TypPtrOutput struct{ *pulumi.OutputState } + +func (TypPtrOutput) ElementType() reflect.Type { + return reflect.TypeOf((**Typ)(nil)).Elem() +} + +func (o TypPtrOutput) ToTypPtrOutput() TypPtrOutput { + return o +} + +func (o TypPtrOutput) ToTypPtrOutputWithContext(ctx context.Context) TypPtrOutput { + return o +} + +func (o TypPtrOutput) Elem() TypOutput { + return o.ApplyT(func(v *Typ) Typ { + if v != nil { + return *v + } + var ret Typ + return ret + }).(TypOutput) +} + +func (o TypPtrOutput) Mod1() mod1.TypPtrOutput { + return o.ApplyT(func(v *Typ) *mod1.Typ { + if v == nil { + return nil + } + return v.Mod1 + }).(mod1.TypPtrOutput) +} + +func (o TypPtrOutput) Mod2() mod2.TypPtrOutput { + return o.ApplyT(func(v *Typ) *mod2.Typ { + if v == nil { + return nil + } + return v.Mod2 + }).(mod2.TypPtrOutput) +} + +func (o TypPtrOutput) Val() pulumi.StringPtrOutput { + return o.ApplyT(func(v *Typ) *string { + if v == nil { + return nil + } + return v.Val + }).(pulumi.StringPtrOutput) +} + +func init() { + pulumi.RegisterInputType(reflect.TypeOf((*HelmReleaseSettingsInput)(nil)).Elem(), HelmReleaseSettingsArgs{}) + pulumi.RegisterInputType(reflect.TypeOf((*HelmReleaseSettingsPtrInput)(nil)).Elem(), HelmReleaseSettingsArgs{}) + pulumi.RegisterInputType(reflect.TypeOf((*KubeClientSettingsInput)(nil)).Elem(), KubeClientSettingsArgs{}) + pulumi.RegisterInputType(reflect.TypeOf((*KubeClientSettingsPtrInput)(nil)).Elem(), KubeClientSettingsArgs{}) + pulumi.RegisterInputType(reflect.TypeOf((*LayeredTypeInput)(nil)).Elem(), LayeredTypeArgs{}) + pulumi.RegisterInputType(reflect.TypeOf((*LayeredTypePtrInput)(nil)).Elem(), LayeredTypeArgs{}) + pulumi.RegisterInputType(reflect.TypeOf((*TypInput)(nil)).Elem(), TypArgs{}) + pulumi.RegisterInputType(reflect.TypeOf((*TypPtrInput)(nil)).Elem(), TypArgs{}) + pulumi.RegisterOutputType(HelmReleaseSettingsOutput{}) + pulumi.RegisterOutputType(HelmReleaseSettingsPtrOutput{}) + pulumi.RegisterOutputType(KubeClientSettingsOutput{}) + pulumi.RegisterOutputType(KubeClientSettingsPtrOutput{}) + pulumi.RegisterOutputType(LayeredTypeOutput{}) + pulumi.RegisterOutputType(LayeredTypePtrOutput{}) + pulumi.RegisterOutputType(TypOutput{}) + pulumi.RegisterOutputType(TypPtrOutput{}) +} diff --git a/pkg/codegen/internal/test/testdata/env-helper/go/example/pulumiUtilities.go b/pkg/codegen/internal/test/testdata/env-helper/go/example/pulumiUtilities.go new file mode 100644 index 000000000..61e44b2aa --- /dev/null +++ b/pkg/codegen/internal/test/testdata/env-helper/go/example/pulumiUtilities.go @@ -0,0 +1,77 @@ +// *** 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) +} diff --git a/pkg/codegen/internal/test/testdata/env-helper/nodejs/README.md b/pkg/codegen/internal/test/testdata/env-helper/nodejs/README.md new file mode 100644 index 000000000..e69de29bb diff --git a/pkg/codegen/internal/test/testdata/env-helper/nodejs/codegen-manifest.json b/pkg/codegen/internal/test/testdata/env-helper/nodejs/codegen-manifest.json new file mode 100644 index 000000000..635ce30dc --- /dev/null +++ b/pkg/codegen/internal/test/testdata/env-helper/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/env-helper/nodejs/foo.ts b/pkg/codegen/internal/test/testdata/env-helper/nodejs/foo.ts new file mode 100644 index 000000000..61a309b50 --- /dev/null +++ b/pkg/codegen/internal/test/testdata/env-helper/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/env-helper/nodejs/funcWithAllOptionalInputs.ts b/pkg/codegen/internal/test/testdata/env-helper/nodejs/funcWithAllOptionalInputs.ts new file mode 100644 index 000000000..480f1db51 --- /dev/null +++ b/pkg/codegen/internal/test/testdata/env-helper/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/env-helper/nodejs/index.ts b/pkg/codegen/internal/test/testdata/env-helper/nodejs/index.ts new file mode 100644 index 000000000..16e9f9075 --- /dev/null +++ b/pkg/codegen/internal/test/testdata/env-helper/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/env-helper/nodejs/moduleTest.ts b/pkg/codegen/internal/test/testdata/env-helper/nodejs/moduleTest.ts new file mode 100644 index 000000000..ae75cac89 --- /dev/null +++ b/pkg/codegen/internal/test/testdata/env-helper/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/env-helper/nodejs/package.json b/pkg/codegen/internal/test/testdata/env-helper/nodejs/package.json new file mode 100644 index 000000000..63e5dd7b9 --- /dev/null +++ b/pkg/codegen/internal/test/testdata/env-helper/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/env-helper/nodejs/provider.ts b/pkg/codegen/internal/test/testdata/env-helper/nodejs/provider.ts new file mode 100644 index 000000000..9f83355a1 --- /dev/null +++ b/pkg/codegen/internal/test/testdata/env-helper/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/env-helper/nodejs/tsconfig.json b/pkg/codegen/internal/test/testdata/env-helper/nodejs/tsconfig.json new file mode 100644 index 000000000..9ed19d148 --- /dev/null +++ b/pkg/codegen/internal/test/testdata/env-helper/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/env-helper/nodejs/types/index.ts b/pkg/codegen/internal/test/testdata/env-helper/nodejs/types/index.ts new file mode 100644 index 000000000..aec972eb2 --- /dev/null +++ b/pkg/codegen/internal/test/testdata/env-helper/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/env-helper/nodejs/types/input.ts new file mode 100644 index 000000000..59774868a --- /dev/null +++ b/pkg/codegen/internal/test/testdata/env-helper/nodejs/types/input.ts @@ -0,0 +1,184 @@ +// *** 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"; + +/** + * BETA FEATURE - Options to configure the Helm Release resource. + */ +export interface HelmReleaseSettings { + /** + * The backend storage driver for Helm. Values are: configmap, secret, memory, sql. + */ + driver?: string; + /** + * The path to the helm plugins directory. + */ + pluginsPath?: string; + /** + * to test required args + */ + requiredArg: string; +} +/** + * helmReleaseSettingsProvideDefaults sets the appropriate defaults for HelmReleaseSettings + */ +export function helmReleaseSettingsProvideDefaults(val: HelmReleaseSettings): HelmReleaseSettings { + return { + ...val, + driver: (val.driver) ?? (utilities.getEnv("PULUMI_K8S_HELM_DRIVER") || "secret"), + pluginsPath: (val.pluginsPath) ?? utilities.getEnv("PULUMI_K8S_HELM_PLUGINS_PATH"), + }; +} + +/** + * BETA FEATURE - Options to configure the Helm Release resource. + */ +export interface HelmReleaseSettingsArgs { + /** + * The backend storage driver for Helm. Values are: configmap, secret, memory, sql. + */ + driver?: pulumi.Input; + /** + * The path to the helm plugins directory. + */ + pluginsPath?: pulumi.Input; + /** + * to test required args + */ + requiredArg: pulumi.Input; +} +/** + * helmReleaseSettingsArgsProvideDefaults sets the appropriate defaults for HelmReleaseSettingsArgs + */ +export function helmReleaseSettingsArgsProvideDefaults(val: HelmReleaseSettingsArgs): HelmReleaseSettingsArgs { + return { + ...val, + driver: (val.driver) ?? (utilities.getEnv("PULUMI_K8S_HELM_DRIVER") || "secret"), + pluginsPath: (val.pluginsPath) ?? utilities.getEnv("PULUMI_K8S_HELM_PLUGINS_PATH"), + }; +} + +/** + * Options for tuning the Kubernetes client used by a Provider. + */ +export interface KubeClientSettingsArgs { + /** + * Maximum burst for throttle. Default value is 10. + */ + burst?: pulumi.Input; + /** + * Maximum queries per second (QPS) to the API server from this client. Default value is 5. + */ + qps?: pulumi.Input; + recTest?: pulumi.Input; +} +/** + * kubeClientSettingsArgsProvideDefaults sets the appropriate defaults for KubeClientSettingsArgs + */ +export function kubeClientSettingsArgsProvideDefaults(val: KubeClientSettingsArgs): KubeClientSettingsArgs { + return { + ...val, + burst: (val.burst) ?? utilities.getEnvNumber("PULUMI_K8S_CLIENT_BURST"), + qps: (val.qps) ?? utilities.getEnvNumber("PULUMI_K8S_CLIENT_QPS"), + recTest: (val.recTest ? pulumi.output(val.recTest).apply(inputs.kubeClientSettingsArgsProvideDefaults) : undefined), + }; +} + +/** + * Make sure that defaults propagate through types + */ +export interface LayeredTypeArgs { + /** + * The answer to the question + */ + answer?: pulumi.Input; + other: pulumi.Input; + /** + * Test how plain types interact + */ + plainOther?: inputs.HelmReleaseSettingsArgs; + /** + * The question already answered + */ + question?: pulumi.Input; + recursive?: pulumi.Input; + /** + * To ask and answer + */ + thinker: pulumi.Input; +} +/** + * layeredTypeArgsProvideDefaults sets the appropriate defaults for LayeredTypeArgs + */ +export function layeredTypeArgsProvideDefaults(val: LayeredTypeArgs): LayeredTypeArgs { + return { + ...val, + answer: (val.answer) ?? 42, + other: pulumi.output(val.other).apply(inputs.helmReleaseSettingsArgsProvideDefaults), + plainOther: (val.plainOther ? inputs.helmReleaseSettingsArgsProvideDefaults(val.plainOther) : undefined), + question: (val.question) ?? (utilities.getEnv("PULUMI_THE_QUESTION") || ""), + recursive: (val.recursive ? pulumi.output(val.recursive).apply(inputs.layeredTypeArgsProvideDefaults) : undefined), + thinker: (val.thinker) ?? "not a good interaction", + }; +} + +/** + * A test for namespaces (mod main) + */ +export interface TypArgs { + mod1?: pulumi.Input; + mod2?: pulumi.Input; + val?: pulumi.Input; +} +/** + * typArgsProvideDefaults sets the appropriate defaults for TypArgs + */ +export function typArgsProvideDefaults(val: TypArgs): TypArgs { + return { + ...val, + mod1: (val.mod1 ? pulumi.output(val.mod1).apply(inputs.mod1.typArgsProvideDefaults) : undefined), + mod2: (val.mod2 ? pulumi.output(val.mod2).apply(inputs.mod2.typArgsProvideDefaults) : undefined), + val: (val.val) ?? "mod main", + }; +} +export namespace mod1 { + /** + * A test for namespaces (mod 1) + */ + export interface TypArgs { + val?: pulumi.Input; + } + /** + * typArgsProvideDefaults sets the appropriate defaults for TypArgs + */ + export function typArgsProvideDefaults(val: TypArgs): TypArgs { + return { + ...val, + val: (val.val) ?? "mod1", + }; + } +} + +export namespace mod2 { + /** + * A test for namespaces (mod 2) + */ + export interface TypArgs { + mod1?: pulumi.Input; + val?: pulumi.Input; + } + /** + * typArgsProvideDefaults sets the appropriate defaults for TypArgs + */ + export function typArgsProvideDefaults(val: TypArgs): TypArgs { + return { + ...val, + mod1: (val.mod1 ? pulumi.output(val.mod1).apply(inputs.mod1.typArgsProvideDefaults) : undefined), + val: (val.val) ?? "mod2", + }; + } +} diff --git a/pkg/codegen/internal/test/testdata/env-helper/nodejs/types/output.ts b/pkg/codegen/internal/test/testdata/env-helper/nodejs/types/output.ts new file mode 100644 index 000000000..49ca43634 --- /dev/null +++ b/pkg/codegen/internal/test/testdata/env-helper/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/env-helper/nodejs/utilities.ts b/pkg/codegen/internal/test/testdata/env-helper/nodejs/utilities.ts new file mode 100644 index 000000000..f26ed073c --- /dev/null +++ b/pkg/codegen/internal/test/testdata/env-helper/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/env-helper/python/codegen-manifest.json b/pkg/codegen/internal/test/testdata/env-helper/python/codegen-manifest.json new file mode 100644 index 000000000..8e4d2595b --- /dev/null +++ b/pkg/codegen/internal/test/testdata/env-helper/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/env-helper/python/pulumi_example/README.md b/pkg/codegen/internal/test/testdata/env-helper/python/pulumi_example/README.md new file mode 100644 index 000000000..e69de29bb diff --git a/pkg/codegen/internal/test/testdata/env-helper/python/pulumi_example/__init__.py b/pkg/codegen/internal/test/testdata/env-helper/python/pulumi_example/__init__.py new file mode 100644 index 000000000..faa897cae --- /dev/null +++ b/pkg/codegen/internal/test/testdata/env-helper/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/env-helper/python/pulumi_example/_inputs.py b/pkg/codegen/internal/test/testdata/env-helper/python/pulumi_example/_inputs.py new file mode 100644 index 000000000..8257d5e0d --- /dev/null +++ b/pkg/codegen/internal/test/testdata/env-helper/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/env-helper/python/pulumi_example/_utilities.py b/pkg/codegen/internal/test/testdata/env-helper/python/pulumi_example/_utilities.py new file mode 100644 index 000000000..01e27adcb --- /dev/null +++ b/pkg/codegen/internal/test/testdata/env-helper/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/env-helper/python/pulumi_example/foo.py b/pkg/codegen/internal/test/testdata/env-helper/python/pulumi_example/foo.py new file mode 100644 index 000000000..7879db199 --- /dev/null +++ b/pkg/codegen/internal/test/testdata/env-helper/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/env-helper/python/pulumi_example/func_with_all_optional_inputs.py b/pkg/codegen/internal/test/testdata/env-helper/python/pulumi_example/func_with_all_optional_inputs.py new file mode 100644 index 000000000..79d4298cd --- /dev/null +++ b/pkg/codegen/internal/test/testdata/env-helper/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/env-helper/python/pulumi_example/mod1/__init__.py b/pkg/codegen/internal/test/testdata/env-helper/python/pulumi_example/mod1/__init__.py new file mode 100644 index 000000000..d90ad520e --- /dev/null +++ b/pkg/codegen/internal/test/testdata/env-helper/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/env-helper/python/pulumi_example/mod1/_inputs.py new file mode 100644 index 000000000..6bc5db8b2 --- /dev/null +++ b/pkg/codegen/internal/test/testdata/env-helper/python/pulumi_example/mod1/_inputs.py @@ -0,0 +1,36 @@ +# 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 + +__all__ = [ + 'TypArgs', +] + +@pulumi.input_type +class TypArgs: + def __init__(__self__, *, + val: Optional[pulumi.Input[str]] = None): + """ + A test for namespaces (mod 1) + """ + if val is None: + val = 'mod1' + if val is not None: + pulumi.set(__self__, "val", val) + + @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/env-helper/python/pulumi_example/mod2/__init__.py b/pkg/codegen/internal/test/testdata/env-helper/python/pulumi_example/mod2/__init__.py new file mode 100644 index 000000000..d90ad520e --- /dev/null +++ b/pkg/codegen/internal/test/testdata/env-helper/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/env-helper/python/pulumi_example/mod2/_inputs.py b/pkg/codegen/internal/test/testdata/env-helper/python/pulumi_example/mod2/_inputs.py new file mode 100644 index 000000000..c21575d1c --- /dev/null +++ b/pkg/codegen/internal/test/testdata/env-helper/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/env-helper/python/pulumi_example/module_test.py b/pkg/codegen/internal/test/testdata/env-helper/python/pulumi_example/module_test.py new file mode 100644 index 000000000..f8ae3cc2b --- /dev/null +++ b/pkg/codegen/internal/test/testdata/env-helper/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/env-helper/python/pulumi_example/outputs.py b/pkg/codegen/internal/test/testdata/env-helper/python/pulumi_example/outputs.py new file mode 100644 index 000000000..869602068 --- /dev/null +++ b/pkg/codegen/internal/test/testdata/env-helper/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/env-helper/python/pulumi_example/provider.py b/pkg/codegen/internal/test/testdata/env-helper/python/pulumi_example/provider.py new file mode 100644 index 000000000..4f41cfd19 --- /dev/null +++ b/pkg/codegen/internal/test/testdata/env-helper/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/env-helper/python/pulumi_example/py.typed b/pkg/codegen/internal/test/testdata/env-helper/python/pulumi_example/py.typed new file mode 100644 index 000000000..e69de29bb diff --git a/pkg/codegen/internal/test/testdata/env-helper/python/setup.py b/pkg/codegen/internal/test/testdata/env-helper/python/setup.py new file mode 100644 index 000000000..4550e1ebd --- /dev/null +++ b/pkg/codegen/internal/test/testdata/env-helper/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/env-helper/schema.json new file mode 100644 index 000000000..23f74ce08 --- /dev/null +++ b/pkg/codegen/internal/test/testdata/env-helper/schema.json @@ -0,0 +1,234 @@ +{ + "version": "0.0.1", + "name": "example", + + "provider": { + "description": "The provider type for the kubernetes package.", + "type": "object", + "inputProperties": { + "helmReleaseSettings": { + "$ref": "#/types/example:index:HelmReleaseSettings", + "description": "BETA FEATURE - Options to configure the Helm Release resource." + } + } + }, + + "resources": { + "example:index:Foo": { + "description": "test new feature with resoruces", + "inputProperties": { + "argument": { + "type": "string", + "plain": true + }, + "settings": { + "$ref": "#/types/example:index:LayeredType", + "description": "describing things" + }, + "kubeClientSettings": { + "$ref": "#/types/example:index:KubeClientSettings", + "description": "Options for tuning the Kubernetes client used by a Provider." + }, + "backupKubeClientSettings": { + "$ref": "#/types/example:index:KubeClientSettings", + "description": "Options for tuning the Kubernetes client used by a Provider." + } + }, + "properties": { + "defaultKubeClientSettings": { + "$ref": "#/types/example:index:KubeClientSettings", + "description": "A test for plain types", + "plain": true + } + }, + "requiredInputs": ["backupKubeClientSettings"] + }, + "example:index:moduleTest": { + "inputProperties": { + "val": { + "$ref": "#/types/example:index:typ" + }, + "mod1": { + "$ref": "#/types/example:mod1:typ" + } + } + } + }, + + "types": { + "example:mod1:typ": { + "description": "A test for namespaces (mod 1)", + "properties": { + "val": { + "type": "string", + "default": "mod1" + } + }, + "type": "object" + }, + "example:mod2:typ": { + "description": "A test for namespaces (mod 2)", + "properties": { + "val": { + "type": "string", + "default": "mod2" + }, + "mod1": { + "$ref": "#/types/example:mod1:typ" + } + }, + "type": "object" + }, + "example:index:typ": { + "description": "A test for namespaces (mod main)", + "properties": { + "val": { + "type": "string", + "default": "mod main" + }, + "mod1": { + "$ref": "#/types/example:mod1:typ" + }, + "mod2": { + "$ref": "#/types/example:mod2:typ" + } + }, + "type": "object" + }, + + "example:index:HelmReleaseSettings": { + "description": "BETA FEATURE - Options to configure the Helm Release resource.", + "properties": { + "driver": { + "type": "string", + "description": "The backend storage driver for Helm. Values are: configmap, secret, memory, sql.", + "default": "secret", + "defaultInfo": { + "environment": ["PULUMI_K8S_HELM_DRIVER"] + } + }, + "pluginsPath": { + "type": "string", + "description": "The path to the helm plugins directory.", + "defaultInfo": { + "environment": ["PULUMI_K8S_HELM_PLUGINS_PATH"] + } + }, + "requiredArg": { + "type": "string", + "description": "to test required args" + } + }, + "required": ["requiredArg"], + "type": "object" + }, + "example:index:LayeredType": { + "description": "Make sure that defaults propagate through types", + "type": "object", + "properties": { + "answer": { + "description": "The answer to the question", + "type": "number", + "default": 42 + }, + "question": { + "description": "The question already answered", + "type": "string", + "default": "", + "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": "env-helper/example" + }, + "nodejs": { + "dependencies": { + "@pulumi/pulumi": "^3.12" + }, + "devDependencies": { + "typescript": "^3.7.0" + } + }, + "python": {} + } +} diff --git a/pkg/codegen/internal/test/testdata/external-resource-schema/nodejs/cat.ts b/pkg/codegen/internal/test/testdata/external-resource-schema/nodejs/cat.ts index f4aaf5b26..4c02d29ba 100644 --- a/pkg/codegen/internal/test/testdata/external-resource-schema/nodejs/cat.ts +++ b/pkg/codegen/internal/test/testdata/external-resource-schema/nodejs/cat.ts @@ -44,19 +44,19 @@ export class Cat extends pulumi.CustomResource { * @param opts A bag of options that control this resource's behavior. */ constructor(name: string, args?: CatArgs, opts?: pulumi.CustomResourceOptions) { - let inputs: pulumi.Inputs = {}; + let resourceInputs: pulumi.Inputs = {}; opts = opts || {}; if (!opts.id) { - inputs["age"] = args ? args.age : undefined; - inputs["pet"] = args ? args.pet : undefined; - inputs["name"] = undefined /*out*/; + resourceInputs["age"] = args ? args.age : undefined; + resourceInputs["pet"] = args ? args.pet : undefined; + resourceInputs["name"] = undefined /*out*/; } else { - inputs["name"] = undefined /*out*/; + resourceInputs["name"] = undefined /*out*/; } if (!opts.version) { opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()}); } - super(Cat.__pulumiType, name, inputs, opts); + super(Cat.__pulumiType, name, resourceInputs, opts); } } diff --git a/pkg/codegen/internal/test/testdata/external-resource-schema/nodejs/component.ts b/pkg/codegen/internal/test/testdata/external-resource-schema/nodejs/component.ts index 0be0b56f4..45cd723d5 100644 --- a/pkg/codegen/internal/test/testdata/external-resource-schema/nodejs/component.ts +++ b/pkg/codegen/internal/test/testdata/external-resource-schema/nodejs/component.ts @@ -46,7 +46,7 @@ export class Component extends pulumi.CustomResource { * @param opts A bag of options that control this resource's behavior. */ constructor(name: string, args: ComponentArgs, opts?: pulumi.CustomResourceOptions) { - let inputs: pulumi.Inputs = {}; + let resourceInputs: pulumi.Inputs = {}; opts = opts || {}; if (!opts.id) { if ((!args || args.requiredMetadata === undefined) && !opts.urn) { @@ -58,24 +58,24 @@ export class Component extends pulumi.CustomResource { if ((!args || args.requiredMetadataMap === undefined) && !opts.urn) { throw new Error("Missing required property 'requiredMetadataMap'"); } - inputs["metadata"] = args ? args.metadata : undefined; - inputs["metadataArray"] = args ? args.metadataArray : undefined; - inputs["metadataMap"] = args ? args.metadataMap : undefined; - inputs["requiredMetadata"] = args ? args.requiredMetadata : undefined; - inputs["requiredMetadataArray"] = args ? args.requiredMetadataArray : undefined; - inputs["requiredMetadataMap"] = args ? args.requiredMetadataMap : undefined; - inputs["provider"] = undefined /*out*/; - inputs["securityGroup"] = undefined /*out*/; - inputs["storageClasses"] = undefined /*out*/; + resourceInputs["metadata"] = args ? args.metadata : undefined; + resourceInputs["metadataArray"] = args ? args.metadataArray : undefined; + resourceInputs["metadataMap"] = args ? args.metadataMap : undefined; + resourceInputs["requiredMetadata"] = args ? args.requiredMetadata : undefined; + resourceInputs["requiredMetadataArray"] = args ? args.requiredMetadataArray : undefined; + resourceInputs["requiredMetadataMap"] = args ? args.requiredMetadataMap : undefined; + resourceInputs["provider"] = undefined /*out*/; + resourceInputs["securityGroup"] = undefined /*out*/; + resourceInputs["storageClasses"] = undefined /*out*/; } else { - inputs["provider"] = undefined /*out*/; - inputs["securityGroup"] = undefined /*out*/; - inputs["storageClasses"] = undefined /*out*/; + resourceInputs["provider"] = undefined /*out*/; + resourceInputs["securityGroup"] = undefined /*out*/; + resourceInputs["storageClasses"] = undefined /*out*/; } if (!opts.version) { opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()}); } - super(Component.__pulumiType, name, inputs, opts); + super(Component.__pulumiType, name, resourceInputs, opts); } } diff --git a/pkg/codegen/internal/test/testdata/external-resource-schema/nodejs/provider.ts b/pkg/codegen/internal/test/testdata/external-resource-schema/nodejs/provider.ts index 791f0a3cf..d2f15c3be 100644 --- a/pkg/codegen/internal/test/testdata/external-resource-schema/nodejs/provider.ts +++ b/pkg/codegen/internal/test/testdata/external-resource-schema/nodejs/provider.ts @@ -28,14 +28,14 @@ export class Provider extends pulumi.ProviderResource { * @param opts A bag of options that control this resource's behavior. */ constructor(name: string, args?: ProviderArgs, opts?: pulumi.ResourceOptions) { - let inputs: pulumi.Inputs = {}; + let resourceInputs: pulumi.Inputs = {}; opts = opts || {}; { } if (!opts.version) { opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()}); } - super(Provider.__pulumiType, name, inputs, opts); + super(Provider.__pulumiType, name, resourceInputs, opts); } } diff --git a/pkg/codegen/internal/test/testdata/external-resource-schema/nodejs/workload.ts b/pkg/codegen/internal/test/testdata/external-resource-schema/nodejs/workload.ts index 9a96eb1f0..158207430 100644 --- a/pkg/codegen/internal/test/testdata/external-resource-schema/nodejs/workload.ts +++ b/pkg/codegen/internal/test/testdata/external-resource-schema/nodejs/workload.ts @@ -43,17 +43,17 @@ export class Workload extends pulumi.CustomResource { * @param opts A bag of options that control this resource's behavior. */ constructor(name: string, args?: WorkloadArgs, opts?: pulumi.CustomResourceOptions) { - let inputs: pulumi.Inputs = {}; + let resourceInputs: pulumi.Inputs = {}; opts = opts || {}; if (!opts.id) { - inputs["pod"] = undefined /*out*/; + resourceInputs["pod"] = undefined /*out*/; } else { - inputs["pod"] = undefined /*out*/; + resourceInputs["pod"] = undefined /*out*/; } if (!opts.version) { opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()}); } - super(Workload.__pulumiType, name, inputs, opts); + super(Workload.__pulumiType, name, resourceInputs, opts); } } diff --git a/pkg/codegen/internal/test/testdata/hyphen-url/nodejs/provider.ts b/pkg/codegen/internal/test/testdata/hyphen-url/nodejs/provider.ts index 6d8306747..92cd609f0 100644 --- a/pkg/codegen/internal/test/testdata/hyphen-url/nodejs/provider.ts +++ b/pkg/codegen/internal/test/testdata/hyphen-url/nodejs/provider.ts @@ -28,14 +28,14 @@ export class Provider extends pulumi.ProviderResource { * @param opts A bag of options that control this resource's behavior. */ constructor(name: string, args?: ProviderArgs, opts?: pulumi.ResourceOptions) { - let inputs: pulumi.Inputs = {}; + let resourceInputs: pulumi.Inputs = {}; opts = opts || {}; { } if (!opts.version) { opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()}); } - super(Provider.__pulumiType, name, inputs, opts); + super(Provider.__pulumiType, name, resourceInputs, opts); } } diff --git a/pkg/codegen/internal/test/testdata/hyphen-url/nodejs/registryGeoReplication.ts b/pkg/codegen/internal/test/testdata/hyphen-url/nodejs/registryGeoReplication.ts index 7d3a61eca..04af4ba58 100644 --- a/pkg/codegen/internal/test/testdata/hyphen-url/nodejs/registryGeoReplication.ts +++ b/pkg/codegen/internal/test/testdata/hyphen-url/nodejs/registryGeoReplication.ts @@ -42,25 +42,25 @@ export class RegistryGeoReplication extends pulumi.ComponentResource { * @param opts A bag of options that control this resource's behavior. */ constructor(name: string, args: RegistryGeoReplicationArgs, opts?: pulumi.ComponentResourceOptions) { - let inputs: pulumi.Inputs = {}; + let resourceInputs: pulumi.Inputs = {}; opts = opts || {}; if (!opts.id) { if ((!args || args.resourceGroup === undefined) && !opts.urn) { throw new Error("Missing required property 'resourceGroup'"); } - inputs["resourceGroup"] = args ? args.resourceGroup : undefined; - inputs["acrLoginServerOut"] = undefined /*out*/; - inputs["registry"] = undefined /*out*/; - inputs["replication"] = undefined /*out*/; + resourceInputs["resourceGroup"] = args ? args.resourceGroup : undefined; + resourceInputs["acrLoginServerOut"] = undefined /*out*/; + resourceInputs["registry"] = undefined /*out*/; + resourceInputs["replication"] = undefined /*out*/; } else { - inputs["acrLoginServerOut"] = undefined /*out*/; - inputs["registry"] = undefined /*out*/; - inputs["replication"] = undefined /*out*/; + resourceInputs["acrLoginServerOut"] = undefined /*out*/; + resourceInputs["registry"] = undefined /*out*/; + resourceInputs["replication"] = undefined /*out*/; } if (!opts.version) { opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()}); } - super(RegistryGeoReplication.__pulumiType, name, inputs, opts, true /*remote*/); + super(RegistryGeoReplication.__pulumiType, name, resourceInputs, opts, true /*remote*/); } } diff --git a/pkg/codegen/internal/test/testdata/naming-collisions/nodejs/provider.ts b/pkg/codegen/internal/test/testdata/naming-collisions/nodejs/provider.ts index 791f0a3cf..d2f15c3be 100644 --- a/pkg/codegen/internal/test/testdata/naming-collisions/nodejs/provider.ts +++ b/pkg/codegen/internal/test/testdata/naming-collisions/nodejs/provider.ts @@ -28,14 +28,14 @@ export class Provider extends pulumi.ProviderResource { * @param opts A bag of options that control this resource's behavior. */ constructor(name: string, args?: ProviderArgs, opts?: pulumi.ResourceOptions) { - let inputs: pulumi.Inputs = {}; + let resourceInputs: pulumi.Inputs = {}; opts = opts || {}; { } if (!opts.version) { opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()}); } - super(Provider.__pulumiType, name, inputs, opts); + super(Provider.__pulumiType, name, resourceInputs, opts); } } diff --git a/pkg/codegen/internal/test/testdata/naming-collisions/nodejs/resource.ts b/pkg/codegen/internal/test/testdata/naming-collisions/nodejs/resource.ts index 174293872..11f02a87e 100644 --- a/pkg/codegen/internal/test/testdata/naming-collisions/nodejs/resource.ts +++ b/pkg/codegen/internal/test/testdata/naming-collisions/nodejs/resource.ts @@ -41,17 +41,17 @@ export class Resource extends pulumi.CustomResource { * @param opts A bag of options that control this resource's behavior. */ constructor(name: string, args?: ResourceArgs, opts?: pulumi.CustomResourceOptions) { - let inputs: pulumi.Inputs = {}; + let resourceInputs: pulumi.Inputs = {}; opts = opts || {}; if (!opts.id) { - inputs["bar"] = undefined /*out*/; + resourceInputs["bar"] = undefined /*out*/; } else { - inputs["bar"] = undefined /*out*/; + resourceInputs["bar"] = undefined /*out*/; } if (!opts.version) { opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()}); } - super(Resource.__pulumiType, name, inputs, opts); + super(Resource.__pulumiType, name, resourceInputs, opts); } } diff --git a/pkg/codegen/internal/test/testdata/naming-collisions/nodejs/resourceInput.ts b/pkg/codegen/internal/test/testdata/naming-collisions/nodejs/resourceInput.ts index f7de3d0c5..202dd7b00 100644 --- a/pkg/codegen/internal/test/testdata/naming-collisions/nodejs/resourceInput.ts +++ b/pkg/codegen/internal/test/testdata/naming-collisions/nodejs/resourceInput.ts @@ -41,17 +41,17 @@ export class ResourceInput extends pulumi.CustomResource { * @param opts A bag of options that control this resource's behavior. */ constructor(name: string, args?: ResourceInputArgs, opts?: pulumi.CustomResourceOptions) { - let inputs: pulumi.Inputs = {}; + let resourceInputs: pulumi.Inputs = {}; opts = opts || {}; if (!opts.id) { - inputs["bar"] = undefined /*out*/; + resourceInputs["bar"] = undefined /*out*/; } else { - inputs["bar"] = undefined /*out*/; + resourceInputs["bar"] = undefined /*out*/; } if (!opts.version) { opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()}); } - super(ResourceInput.__pulumiType, name, inputs, opts); + super(ResourceInput.__pulumiType, name, resourceInputs, opts); } } diff --git a/pkg/codegen/internal/test/testdata/nested-module-thirdparty/nodejs/deeply/nested/module/resource.ts b/pkg/codegen/internal/test/testdata/nested-module-thirdparty/nodejs/deeply/nested/module/resource.ts index e15a4a59d..3327e6945 100644 --- a/pkg/codegen/internal/test/testdata/nested-module-thirdparty/nodejs/deeply/nested/module/resource.ts +++ b/pkg/codegen/internal/test/testdata/nested-module-thirdparty/nodejs/deeply/nested/module/resource.ts @@ -41,19 +41,19 @@ export class Resource extends pulumi.CustomResource { * @param opts A bag of options that control this resource's behavior. */ constructor(name: string, args?: ResourceArgs, opts?: pulumi.CustomResourceOptions) { - let inputs: pulumi.Inputs = {}; + let resourceInputs: pulumi.Inputs = {}; opts = opts || {}; if (!opts.id) { - inputs["baz"] = args?.baz ? pulumi.secret(args.baz) : undefined; + resourceInputs["baz"] = args?.baz ? pulumi.secret(args.baz) : undefined; } else { - inputs["baz"] = undefined /*out*/; + resourceInputs["baz"] = undefined /*out*/; } if (!opts.version) { opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()}); } const secretOpts = { additionalSecretOutputs: ["baz"] }; opts = pulumi.mergeOptions(opts, secretOpts); - super(Resource.__pulumiType, name, inputs, opts); + super(Resource.__pulumiType, name, resourceInputs, opts); } } diff --git a/pkg/codegen/internal/test/testdata/nested-module-thirdparty/nodejs/provider.ts b/pkg/codegen/internal/test/testdata/nested-module-thirdparty/nodejs/provider.ts index a83f3c2fa..3e1e136d4 100644 --- a/pkg/codegen/internal/test/testdata/nested-module-thirdparty/nodejs/provider.ts +++ b/pkg/codegen/internal/test/testdata/nested-module-thirdparty/nodejs/provider.ts @@ -28,14 +28,14 @@ export class Provider extends pulumi.ProviderResource { * @param opts A bag of options that control this resource's behavior. */ constructor(name: string, args?: ProviderArgs, opts?: pulumi.ResourceOptions) { - let inputs: pulumi.Inputs = {}; + let resourceInputs: pulumi.Inputs = {}; opts = opts || {}; { } if (!opts.version) { opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()}); } - super(Provider.__pulumiType, name, inputs, opts); + super(Provider.__pulumiType, name, resourceInputs, opts); } } diff --git a/pkg/codegen/internal/test/testdata/nested-module/nodejs/nested/module/resource.ts b/pkg/codegen/internal/test/testdata/nested-module/nodejs/nested/module/resource.ts index b1a9f8fc7..d7e5ec8a2 100644 --- a/pkg/codegen/internal/test/testdata/nested-module/nodejs/nested/module/resource.ts +++ b/pkg/codegen/internal/test/testdata/nested-module/nodejs/nested/module/resource.ts @@ -41,19 +41,19 @@ export class Resource extends pulumi.CustomResource { * @param opts A bag of options that control this resource's behavior. */ constructor(name: string, args?: ResourceArgs, opts?: pulumi.CustomResourceOptions) { - let inputs: pulumi.Inputs = {}; + let resourceInputs: pulumi.Inputs = {}; opts = opts || {}; if (!opts.id) { - inputs["bar"] = args?.bar ? pulumi.secret(args.bar) : undefined; + resourceInputs["bar"] = args?.bar ? pulumi.secret(args.bar) : undefined; } else { - inputs["bar"] = undefined /*out*/; + resourceInputs["bar"] = undefined /*out*/; } if (!opts.version) { opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()}); } const secretOpts = { additionalSecretOutputs: ["bar"] }; opts = pulumi.mergeOptions(opts, secretOpts); - super(Resource.__pulumiType, name, inputs, opts); + super(Resource.__pulumiType, name, resourceInputs, opts); } } diff --git a/pkg/codegen/internal/test/testdata/nested-module/nodejs/provider.ts b/pkg/codegen/internal/test/testdata/nested-module/nodejs/provider.ts index e6ab597ba..33c8958bf 100644 --- a/pkg/codegen/internal/test/testdata/nested-module/nodejs/provider.ts +++ b/pkg/codegen/internal/test/testdata/nested-module/nodejs/provider.ts @@ -28,14 +28,14 @@ export class Provider extends pulumi.ProviderResource { * @param opts A bag of options that control this resource's behavior. */ constructor(name: string, args?: ProviderArgs, opts?: pulumi.ResourceOptions) { - let inputs: pulumi.Inputs = {}; + let resourceInputs: pulumi.Inputs = {}; opts = opts || {}; { } if (!opts.version) { opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()}); } - super(Provider.__pulumiType, name, inputs, opts); + super(Provider.__pulumiType, name, resourceInputs, opts); } } diff --git a/pkg/codegen/internal/test/testdata/output-funcs-edgeorder/nodejs/provider.ts b/pkg/codegen/internal/test/testdata/output-funcs-edgeorder/nodejs/provider.ts index 5c6917b54..5840786c7 100644 --- a/pkg/codegen/internal/test/testdata/output-funcs-edgeorder/nodejs/provider.ts +++ b/pkg/codegen/internal/test/testdata/output-funcs-edgeorder/nodejs/provider.ts @@ -28,14 +28,14 @@ export class Provider extends pulumi.ProviderResource { * @param opts A bag of options that control this resource's behavior. */ constructor(name: string, args?: ProviderArgs, opts?: pulumi.ResourceOptions) { - let inputs: pulumi.Inputs = {}; + let resourceInputs: pulumi.Inputs = {}; opts = opts || {}; { } if (!opts.version) { opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()}); } - super(Provider.__pulumiType, name, inputs, opts); + super(Provider.__pulumiType, name, resourceInputs, opts); } } diff --git a/pkg/codegen/internal/test/testdata/output-funcs-tfbridge20/nodejs/provider.ts b/pkg/codegen/internal/test/testdata/output-funcs-tfbridge20/nodejs/provider.ts index f114e2667..1ee39fdd8 100644 --- a/pkg/codegen/internal/test/testdata/output-funcs-tfbridge20/nodejs/provider.ts +++ b/pkg/codegen/internal/test/testdata/output-funcs-tfbridge20/nodejs/provider.ts @@ -28,14 +28,14 @@ export class Provider extends pulumi.ProviderResource { * @param opts A bag of options that control this resource's behavior. */ constructor(name: string, args?: ProviderArgs, opts?: pulumi.ResourceOptions) { - let inputs: pulumi.Inputs = {}; + let resourceInputs: pulumi.Inputs = {}; opts = opts || {}; { } if (!opts.version) { opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()}); } - super(Provider.__pulumiType, name, inputs, opts); + super(Provider.__pulumiType, name, resourceInputs, opts); } } diff --git a/pkg/codegen/internal/test/testdata/output-funcs/nodejs/provider.ts b/pkg/codegen/internal/test/testdata/output-funcs/nodejs/provider.ts index f114e2667..1ee39fdd8 100644 --- a/pkg/codegen/internal/test/testdata/output-funcs/nodejs/provider.ts +++ b/pkg/codegen/internal/test/testdata/output-funcs/nodejs/provider.ts @@ -28,14 +28,14 @@ export class Provider extends pulumi.ProviderResource { * @param opts A bag of options that control this resource's behavior. */ constructor(name: string, args?: ProviderArgs, opts?: pulumi.ResourceOptions) { - let inputs: pulumi.Inputs = {}; + let resourceInputs: pulumi.Inputs = {}; opts = opts || {}; { } if (!opts.version) { opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()}); } - super(Provider.__pulumiType, name, inputs, opts); + super(Provider.__pulumiType, name, resourceInputs, opts); } } diff --git a/pkg/codegen/internal/test/testdata/plain-and-default/nodejs/moduleResource.ts b/pkg/codegen/internal/test/testdata/plain-and-default/nodejs/moduleResource.ts index 191b59df3..1b543735e 100644 --- a/pkg/codegen/internal/test/testdata/plain-and-default/nodejs/moduleResource.ts +++ b/pkg/codegen/internal/test/testdata/plain-and-default/nodejs/moduleResource.ts @@ -41,7 +41,7 @@ export class ModuleResource extends pulumi.CustomResource { * @param opts A bag of options that control this resource's behavior. */ constructor(name: string, args: ModuleResourceArgs, opts?: pulumi.CustomResourceOptions) { - let inputs: pulumi.Inputs = {}; + let resourceInputs: pulumi.Inputs = {}; opts = opts || {}; if (!opts.id) { if ((!args || args.plain_required_bool === undefined) && !opts.urn) { @@ -68,29 +68,29 @@ export class ModuleResource extends pulumi.CustomResource { if ((!args || args.required_string === undefined) && !opts.urn) { throw new Error("Missing required property 'required_string'"); } - inputs["optional_bool"] = (args ? args.optional_bool : undefined) ?? true; - inputs["optional_const"] = "val"; - inputs["optional_enum"] = (args ? args.optional_enum : undefined) ?? 8; - inputs["optional_number"] = (args ? args.optional_number : undefined) ?? 42; - inputs["optional_string"] = (args ? args.optional_string : undefined) ?? "buzzer"; - inputs["plain_optional_bool"] = (args ? args.plain_optional_bool : undefined) ?? true; - inputs["plain_optional_const"] = "val"; - inputs["plain_optional_number"] = (args ? args.plain_optional_number : undefined) ?? 42; - inputs["plain_optional_string"] = (args ? args.plain_optional_string : undefined) ?? "buzzer"; - inputs["plain_required_bool"] = (args ? args.plain_required_bool : undefined) ?? true; - inputs["plain_required_const"] = "val"; - inputs["plain_required_number"] = (args ? args.plain_required_number : undefined) ?? 42; - inputs["plain_required_string"] = (args ? args.plain_required_string : undefined) ?? "buzzer"; - inputs["required_bool"] = (args ? args.required_bool : undefined) ?? true; - inputs["required_enum"] = (args ? args.required_enum : undefined) ?? 4; - inputs["required_number"] = (args ? args.required_number : undefined) ?? 42; - inputs["required_string"] = (args ? args.required_string : undefined) ?? "buzzer"; + resourceInputs["optional_bool"] = (args ? args.optional_bool : undefined) ?? true; + resourceInputs["optional_const"] = "val"; + resourceInputs["optional_enum"] = (args ? args.optional_enum : undefined) ?? 8; + resourceInputs["optional_number"] = (args ? args.optional_number : undefined) ?? 42; + resourceInputs["optional_string"] = (args ? args.optional_string : undefined) ?? "buzzer"; + resourceInputs["plain_optional_bool"] = (args ? args.plain_optional_bool : undefined) ?? true; + resourceInputs["plain_optional_const"] = "val"; + resourceInputs["plain_optional_number"] = (args ? args.plain_optional_number : undefined) ?? 42; + resourceInputs["plain_optional_string"] = (args ? args.plain_optional_string : undefined) ?? "buzzer"; + resourceInputs["plain_required_bool"] = (args ? args.plain_required_bool : undefined) ?? true; + resourceInputs["plain_required_const"] = "val"; + resourceInputs["plain_required_number"] = (args ? args.plain_required_number : undefined) ?? 42; + resourceInputs["plain_required_string"] = (args ? args.plain_required_string : undefined) ?? "buzzer"; + resourceInputs["required_bool"] = (args ? args.required_bool : undefined) ?? true; + resourceInputs["required_enum"] = (args ? args.required_enum : undefined) ?? 4; + resourceInputs["required_number"] = (args ? args.required_number : undefined) ?? 42; + resourceInputs["required_string"] = (args ? args.required_string : undefined) ?? "buzzer"; } else { } if (!opts.version) { opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()}); } - super(ModuleResource.__pulumiType, name, inputs, opts); + super(ModuleResource.__pulumiType, name, resourceInputs, opts); } } diff --git a/pkg/codegen/internal/test/testdata/plain-and-default/nodejs/provider.ts b/pkg/codegen/internal/test/testdata/plain-and-default/nodejs/provider.ts index 3907c8f5e..92ea3d2b3 100644 --- a/pkg/codegen/internal/test/testdata/plain-and-default/nodejs/provider.ts +++ b/pkg/codegen/internal/test/testdata/plain-and-default/nodejs/provider.ts @@ -28,14 +28,14 @@ export class Provider extends pulumi.ProviderResource { * @param opts A bag of options that control this resource's behavior. */ constructor(name: string, args?: ProviderArgs, opts?: pulumi.ResourceOptions) { - let inputs: pulumi.Inputs = {}; + let resourceInputs: pulumi.Inputs = {}; opts = opts || {}; { } if (!opts.version) { opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()}); } - super(Provider.__pulumiType, name, inputs, opts); + super(Provider.__pulumiType, name, resourceInputs, opts); } } diff --git a/pkg/codegen/internal/test/testdata/plain-schema-gh6957/nodejs/provider.ts b/pkg/codegen/internal/test/testdata/plain-schema-gh6957/nodejs/provider.ts index a4698e2b3..649bbde05 100644 --- a/pkg/codegen/internal/test/testdata/plain-schema-gh6957/nodejs/provider.ts +++ b/pkg/codegen/internal/test/testdata/plain-schema-gh6957/nodejs/provider.ts @@ -28,14 +28,14 @@ export class Provider extends pulumi.ProviderResource { * @param opts A bag of options that control this resource's behavior. */ constructor(name: string, args?: ProviderArgs, opts?: pulumi.ResourceOptions) { - let inputs: pulumi.Inputs = {}; + let resourceInputs: pulumi.Inputs = {}; opts = opts || {}; { } if (!opts.version) { opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()}); } - super(Provider.__pulumiType, name, inputs, opts); + super(Provider.__pulumiType, name, resourceInputs, opts); } } diff --git a/pkg/codegen/internal/test/testdata/plain-schema-gh6957/nodejs/staticPage.ts b/pkg/codegen/internal/test/testdata/plain-schema-gh6957/nodejs/staticPage.ts index 476e7d2f2..5d67b8e69 100644 --- a/pkg/codegen/internal/test/testdata/plain-schema-gh6957/nodejs/staticPage.ts +++ b/pkg/codegen/internal/test/testdata/plain-schema-gh6957/nodejs/staticPage.ts @@ -39,24 +39,24 @@ export class StaticPage extends pulumi.ComponentResource { * @param opts A bag of options that control this resource's behavior. */ constructor(name: string, args: StaticPageArgs, opts?: pulumi.ComponentResourceOptions) { - let inputs: pulumi.Inputs = {}; + let resourceInputs: pulumi.Inputs = {}; opts = opts || {}; if (!opts.id) { if ((!args || args.indexContent === undefined) && !opts.urn) { throw new Error("Missing required property 'indexContent'"); } - inputs["foo"] = args ? args.foo : undefined; - inputs["indexContent"] = args ? args.indexContent : undefined; - inputs["bucket"] = undefined /*out*/; - inputs["websiteUrl"] = undefined /*out*/; + resourceInputs["foo"] = args ? args.foo : undefined; + resourceInputs["indexContent"] = args ? args.indexContent : undefined; + resourceInputs["bucket"] = undefined /*out*/; + resourceInputs["websiteUrl"] = undefined /*out*/; } else { - inputs["bucket"] = undefined /*out*/; - inputs["websiteUrl"] = undefined /*out*/; + resourceInputs["bucket"] = undefined /*out*/; + resourceInputs["websiteUrl"] = undefined /*out*/; } if (!opts.version) { opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()}); } - super(StaticPage.__pulumiType, name, inputs, opts, true /*remote*/); + super(StaticPage.__pulumiType, name, resourceInputs, opts, true /*remote*/); } } diff --git a/pkg/codegen/internal/test/testdata/provider-config-schema/nodejs/provider.ts b/pkg/codegen/internal/test/testdata/provider-config-schema/nodejs/provider.ts index 129cc12b8..de7c8db92 100644 --- a/pkg/codegen/internal/test/testdata/provider-config-schema/nodejs/provider.ts +++ b/pkg/codegen/internal/test/testdata/provider-config-schema/nodejs/provider.ts @@ -29,15 +29,15 @@ export class Provider extends pulumi.ProviderResource { * @param opts A bag of options that control this resource's behavior. */ constructor(name: string, args?: ProviderArgs, opts?: pulumi.ResourceOptions) { - let inputs: pulumi.Inputs = {}; + let resourceInputs: pulumi.Inputs = {}; opts = opts || {}; { - inputs["favoriteColor"] = (args ? args.favoriteColor : undefined) ?? utilities.getEnv("FAVE_COLOR"); + resourceInputs["favoriteColor"] = (args ? args.favoriteColor : undefined) ?? utilities.getEnv("FAVE_COLOR"); } if (!opts.version) { opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()}); } - super(Provider.__pulumiType, name, inputs, opts); + super(Provider.__pulumiType, name, resourceInputs, opts); } } diff --git a/pkg/codegen/internal/test/testdata/regress-node-8110/nodejs/provider.ts b/pkg/codegen/internal/test/testdata/regress-node-8110/nodejs/provider.ts index 47e024326..521293f3b 100644 --- a/pkg/codegen/internal/test/testdata/regress-node-8110/nodejs/provider.ts +++ b/pkg/codegen/internal/test/testdata/regress-node-8110/nodejs/provider.ts @@ -28,14 +28,14 @@ export class Provider extends pulumi.ProviderResource { * @param opts A bag of options that control this resource's behavior. */ constructor(name: string, args?: ProviderArgs, opts?: pulumi.ResourceOptions) { - let inputs: pulumi.Inputs = {}; + let resourceInputs: pulumi.Inputs = {}; opts = opts || {}; { } if (!opts.version) { opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()}); } - super(Provider.__pulumiType, name, inputs, opts); + super(Provider.__pulumiType, name, resourceInputs, opts); } } diff --git a/pkg/codegen/internal/test/testdata/replace-on-change/nodejs/cat.ts b/pkg/codegen/internal/test/testdata/replace-on-change/nodejs/cat.ts index 38fefb02a..06740734c 100644 --- a/pkg/codegen/internal/test/testdata/replace-on-change/nodejs/cat.ts +++ b/pkg/codegen/internal/test/testdata/replace-on-change/nodejs/cat.ts @@ -48,20 +48,20 @@ export class Cat extends pulumi.CustomResource { * @param opts A bag of options that control this resource's behavior. */ constructor(name: string, args?: CatArgs, opts?: pulumi.CustomResourceOptions) { - let inputs: pulumi.Inputs = {}; + let resourceInputs: pulumi.Inputs = {}; opts = opts || {}; if (!opts.id) { - inputs["foes"] = undefined /*out*/; - inputs["friends"] = undefined /*out*/; - inputs["name"] = undefined /*out*/; - inputs["other"] = undefined /*out*/; - inputs["toy"] = undefined /*out*/; + resourceInputs["foes"] = undefined /*out*/; + resourceInputs["friends"] = undefined /*out*/; + resourceInputs["name"] = undefined /*out*/; + resourceInputs["other"] = undefined /*out*/; + resourceInputs["toy"] = undefined /*out*/; } else { - inputs["foes"] = undefined /*out*/; - inputs["friends"] = undefined /*out*/; - inputs["name"] = undefined /*out*/; - inputs["other"] = undefined /*out*/; - inputs["toy"] = undefined /*out*/; + resourceInputs["foes"] = undefined /*out*/; + resourceInputs["friends"] = undefined /*out*/; + resourceInputs["name"] = undefined /*out*/; + resourceInputs["other"] = undefined /*out*/; + resourceInputs["toy"] = undefined /*out*/; } if (!opts.version) { opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()}); @@ -70,7 +70,7 @@ export class Cat extends pulumi.CustomResource { opts = pulumi.mergeOptions(opts, secretOpts); const replaceOnChanges = { replaceOnChanges: ["foes.*.associated.color", "foes.*.color", "friends[*].associated.color", "friends[*].color", "name", "toy.color"] }; opts = pulumi.mergeOptions(opts, replaceOnChanges); - super(Cat.__pulumiType, name, inputs, opts); + super(Cat.__pulumiType, name, resourceInputs, opts); } } diff --git a/pkg/codegen/internal/test/testdata/replace-on-change/nodejs/dog.ts b/pkg/codegen/internal/test/testdata/replace-on-change/nodejs/dog.ts index 25ceef83e..70e2fc340 100644 --- a/pkg/codegen/internal/test/testdata/replace-on-change/nodejs/dog.ts +++ b/pkg/codegen/internal/test/testdata/replace-on-change/nodejs/dog.ts @@ -41,19 +41,19 @@ export class Dog extends pulumi.CustomResource { * @param opts A bag of options that control this resource's behavior. */ constructor(name: string, args?: DogArgs, opts?: pulumi.CustomResourceOptions) { - let inputs: pulumi.Inputs = {}; + let resourceInputs: pulumi.Inputs = {}; opts = opts || {}; if (!opts.id) { - inputs["bone"] = undefined /*out*/; + resourceInputs["bone"] = undefined /*out*/; } else { - inputs["bone"] = undefined /*out*/; + resourceInputs["bone"] = undefined /*out*/; } if (!opts.version) { opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()}); } const replaceOnChanges = { replaceOnChanges: ["bone"] }; opts = pulumi.mergeOptions(opts, replaceOnChanges); - super(Dog.__pulumiType, name, inputs, opts); + super(Dog.__pulumiType, name, resourceInputs, opts); } } diff --git a/pkg/codegen/internal/test/testdata/replace-on-change/nodejs/god.ts b/pkg/codegen/internal/test/testdata/replace-on-change/nodejs/god.ts index 026a9d2dd..b1d26ff9c 100644 --- a/pkg/codegen/internal/test/testdata/replace-on-change/nodejs/god.ts +++ b/pkg/codegen/internal/test/testdata/replace-on-change/nodejs/god.ts @@ -43,17 +43,17 @@ export class God extends pulumi.CustomResource { * @param opts A bag of options that control this resource's behavior. */ constructor(name: string, args?: GodArgs, opts?: pulumi.CustomResourceOptions) { - let inputs: pulumi.Inputs = {}; + let resourceInputs: pulumi.Inputs = {}; opts = opts || {}; if (!opts.id) { - inputs["backwards"] = undefined /*out*/; + resourceInputs["backwards"] = undefined /*out*/; } else { - inputs["backwards"] = undefined /*out*/; + resourceInputs["backwards"] = undefined /*out*/; } if (!opts.version) { opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()}); } - super(God.__pulumiType, name, inputs, opts); + super(God.__pulumiType, name, resourceInputs, opts); } } diff --git a/pkg/codegen/internal/test/testdata/replace-on-change/nodejs/noRecursive.ts b/pkg/codegen/internal/test/testdata/replace-on-change/nodejs/noRecursive.ts index 0cf9b0acd..a0c4642fe 100644 --- a/pkg/codegen/internal/test/testdata/replace-on-change/nodejs/noRecursive.ts +++ b/pkg/codegen/internal/test/testdata/replace-on-change/nodejs/noRecursive.ts @@ -43,21 +43,21 @@ export class NoRecursive extends pulumi.CustomResource { * @param opts A bag of options that control this resource's behavior. */ constructor(name: string, args?: NoRecursiveArgs, opts?: pulumi.CustomResourceOptions) { - let inputs: pulumi.Inputs = {}; + let resourceInputs: pulumi.Inputs = {}; opts = opts || {}; if (!opts.id) { - inputs["rec"] = undefined /*out*/; - inputs["replace"] = undefined /*out*/; + resourceInputs["rec"] = undefined /*out*/; + resourceInputs["replace"] = undefined /*out*/; } else { - inputs["rec"] = undefined /*out*/; - inputs["replace"] = undefined /*out*/; + resourceInputs["rec"] = undefined /*out*/; + resourceInputs["replace"] = undefined /*out*/; } if (!opts.version) { opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()}); } const replaceOnChanges = { replaceOnChanges: ["replace"] }; opts = pulumi.mergeOptions(opts, replaceOnChanges); - super(NoRecursive.__pulumiType, name, inputs, opts); + super(NoRecursive.__pulumiType, name, resourceInputs, opts); } } diff --git a/pkg/codegen/internal/test/testdata/replace-on-change/nodejs/provider.ts b/pkg/codegen/internal/test/testdata/replace-on-change/nodejs/provider.ts index 791f0a3cf..d2f15c3be 100644 --- a/pkg/codegen/internal/test/testdata/replace-on-change/nodejs/provider.ts +++ b/pkg/codegen/internal/test/testdata/replace-on-change/nodejs/provider.ts @@ -28,14 +28,14 @@ export class Provider extends pulumi.ProviderResource { * @param opts A bag of options that control this resource's behavior. */ constructor(name: string, args?: ProviderArgs, opts?: pulumi.ResourceOptions) { - let inputs: pulumi.Inputs = {}; + let resourceInputs: pulumi.Inputs = {}; opts = opts || {}; { } if (!opts.version) { opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()}); } - super(Provider.__pulumiType, name, inputs, opts); + super(Provider.__pulumiType, name, resourceInputs, opts); } } diff --git a/pkg/codegen/internal/test/testdata/replace-on-change/nodejs/toyStore.ts b/pkg/codegen/internal/test/testdata/replace-on-change/nodejs/toyStore.ts index 29fa793ee..e532118c7 100644 --- a/pkg/codegen/internal/test/testdata/replace-on-change/nodejs/toyStore.ts +++ b/pkg/codegen/internal/test/testdata/replace-on-change/nodejs/toyStore.ts @@ -47,25 +47,25 @@ export class ToyStore extends pulumi.CustomResource { * @param opts A bag of options that control this resource's behavior. */ constructor(name: string, args?: ToyStoreArgs, opts?: pulumi.CustomResourceOptions) { - let inputs: pulumi.Inputs = {}; + let resourceInputs: pulumi.Inputs = {}; opts = opts || {}; if (!opts.id) { - inputs["chew"] = undefined /*out*/; - inputs["laser"] = undefined /*out*/; - inputs["stuff"] = undefined /*out*/; - inputs["wanted"] = undefined /*out*/; + resourceInputs["chew"] = undefined /*out*/; + resourceInputs["laser"] = undefined /*out*/; + resourceInputs["stuff"] = undefined /*out*/; + resourceInputs["wanted"] = undefined /*out*/; } else { - inputs["chew"] = undefined /*out*/; - inputs["laser"] = undefined /*out*/; - inputs["stuff"] = undefined /*out*/; - inputs["wanted"] = undefined /*out*/; + resourceInputs["chew"] = undefined /*out*/; + resourceInputs["laser"] = undefined /*out*/; + resourceInputs["stuff"] = undefined /*out*/; + resourceInputs["wanted"] = undefined /*out*/; } if (!opts.version) { opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()}); } const replaceOnChanges = { replaceOnChanges: ["chew.owner", "laser.batteries", "stuff[*].associated.color", "stuff[*].color", "wanted[*]"] }; opts = pulumi.mergeOptions(opts, replaceOnChanges); - super(ToyStore.__pulumiType, name, inputs, opts); + super(ToyStore.__pulumiType, name, resourceInputs, opts); } } diff --git a/pkg/codegen/internal/test/testdata/resource-args-python-case-insensitive/nodejs/person.ts b/pkg/codegen/internal/test/testdata/resource-args-python-case-insensitive/nodejs/person.ts index ae4dc79cb..40920bcd8 100644 --- a/pkg/codegen/internal/test/testdata/resource-args-python-case-insensitive/nodejs/person.ts +++ b/pkg/codegen/internal/test/testdata/resource-args-python-case-insensitive/nodejs/person.ts @@ -43,19 +43,19 @@ export class Person extends pulumi.CustomResource { * @param opts A bag of options that control this resource's behavior. */ constructor(name: string, args?: PersonArgs, opts?: pulumi.CustomResourceOptions) { - let inputs: pulumi.Inputs = {}; + let resourceInputs: pulumi.Inputs = {}; opts = opts || {}; if (!opts.id) { - inputs["name"] = args ? args.name : undefined; - inputs["pets"] = args ? args.pets : undefined; + resourceInputs["name"] = args ? args.name : undefined; + resourceInputs["pets"] = args ? args.pets : undefined; } else { - inputs["name"] = undefined /*out*/; - inputs["pets"] = undefined /*out*/; + resourceInputs["name"] = undefined /*out*/; + resourceInputs["pets"] = undefined /*out*/; } if (!opts.version) { opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()}); } - super(Person.__pulumiType, name, inputs, opts); + super(Person.__pulumiType, name, resourceInputs, opts); } } diff --git a/pkg/codegen/internal/test/testdata/resource-args-python-case-insensitive/nodejs/pet.ts b/pkg/codegen/internal/test/testdata/resource-args-python-case-insensitive/nodejs/pet.ts index 1dd08f636..38db07574 100644 --- a/pkg/codegen/internal/test/testdata/resource-args-python-case-insensitive/nodejs/pet.ts +++ b/pkg/codegen/internal/test/testdata/resource-args-python-case-insensitive/nodejs/pet.ts @@ -41,17 +41,17 @@ export class Pet extends pulumi.CustomResource { * @param opts A bag of options that control this resource's behavior. */ constructor(name: string, args?: PetArgs, opts?: pulumi.CustomResourceOptions) { - let inputs: pulumi.Inputs = {}; + let resourceInputs: pulumi.Inputs = {}; opts = opts || {}; if (!opts.id) { - inputs["name"] = args ? args.name : undefined; + resourceInputs["name"] = args ? args.name : undefined; } else { - inputs["name"] = undefined /*out*/; + resourceInputs["name"] = undefined /*out*/; } if (!opts.version) { opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()}); } - super(Pet.__pulumiType, name, inputs, opts); + super(Pet.__pulumiType, name, resourceInputs, opts); } } diff --git a/pkg/codegen/internal/test/testdata/resource-args-python-case-insensitive/nodejs/provider.ts b/pkg/codegen/internal/test/testdata/resource-args-python-case-insensitive/nodejs/provider.ts index 791f0a3cf..d2f15c3be 100644 --- a/pkg/codegen/internal/test/testdata/resource-args-python-case-insensitive/nodejs/provider.ts +++ b/pkg/codegen/internal/test/testdata/resource-args-python-case-insensitive/nodejs/provider.ts @@ -28,14 +28,14 @@ export class Provider extends pulumi.ProviderResource { * @param opts A bag of options that control this resource's behavior. */ constructor(name: string, args?: ProviderArgs, opts?: pulumi.ResourceOptions) { - let inputs: pulumi.Inputs = {}; + let resourceInputs: pulumi.Inputs = {}; opts = opts || {}; { } if (!opts.version) { opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()}); } - super(Provider.__pulumiType, name, inputs, opts); + super(Provider.__pulumiType, name, resourceInputs, opts); } } diff --git a/pkg/codegen/internal/test/testdata/resource-args-python/nodejs/person.ts b/pkg/codegen/internal/test/testdata/resource-args-python/nodejs/person.ts index ae4dc79cb..40920bcd8 100644 --- a/pkg/codegen/internal/test/testdata/resource-args-python/nodejs/person.ts +++ b/pkg/codegen/internal/test/testdata/resource-args-python/nodejs/person.ts @@ -43,19 +43,19 @@ export class Person extends pulumi.CustomResource { * @param opts A bag of options that control this resource's behavior. */ constructor(name: string, args?: PersonArgs, opts?: pulumi.CustomResourceOptions) { - let inputs: pulumi.Inputs = {}; + let resourceInputs: pulumi.Inputs = {}; opts = opts || {}; if (!opts.id) { - inputs["name"] = args ? args.name : undefined; - inputs["pets"] = args ? args.pets : undefined; + resourceInputs["name"] = args ? args.name : undefined; + resourceInputs["pets"] = args ? args.pets : undefined; } else { - inputs["name"] = undefined /*out*/; - inputs["pets"] = undefined /*out*/; + resourceInputs["name"] = undefined /*out*/; + resourceInputs["pets"] = undefined /*out*/; } if (!opts.version) { opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()}); } - super(Person.__pulumiType, name, inputs, opts); + super(Person.__pulumiType, name, resourceInputs, opts); } } diff --git a/pkg/codegen/internal/test/testdata/resource-args-python/nodejs/pet.ts b/pkg/codegen/internal/test/testdata/resource-args-python/nodejs/pet.ts index 1dd08f636..38db07574 100644 --- a/pkg/codegen/internal/test/testdata/resource-args-python/nodejs/pet.ts +++ b/pkg/codegen/internal/test/testdata/resource-args-python/nodejs/pet.ts @@ -41,17 +41,17 @@ export class Pet extends pulumi.CustomResource { * @param opts A bag of options that control this resource's behavior. */ constructor(name: string, args?: PetArgs, opts?: pulumi.CustomResourceOptions) { - let inputs: pulumi.Inputs = {}; + let resourceInputs: pulumi.Inputs = {}; opts = opts || {}; if (!opts.id) { - inputs["name"] = args ? args.name : undefined; + resourceInputs["name"] = args ? args.name : undefined; } else { - inputs["name"] = undefined /*out*/; + resourceInputs["name"] = undefined /*out*/; } if (!opts.version) { opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()}); } - super(Pet.__pulumiType, name, inputs, opts); + super(Pet.__pulumiType, name, resourceInputs, opts); } } diff --git a/pkg/codegen/internal/test/testdata/resource-args-python/nodejs/provider.ts b/pkg/codegen/internal/test/testdata/resource-args-python/nodejs/provider.ts index 791f0a3cf..d2f15c3be 100644 --- a/pkg/codegen/internal/test/testdata/resource-args-python/nodejs/provider.ts +++ b/pkg/codegen/internal/test/testdata/resource-args-python/nodejs/provider.ts @@ -28,14 +28,14 @@ export class Provider extends pulumi.ProviderResource { * @param opts A bag of options that control this resource's behavior. */ constructor(name: string, args?: ProviderArgs, opts?: pulumi.ResourceOptions) { - let inputs: pulumi.Inputs = {}; + let resourceInputs: pulumi.Inputs = {}; opts = opts || {}; { } if (!opts.version) { opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()}); } - super(Provider.__pulumiType, name, inputs, opts); + super(Provider.__pulumiType, name, resourceInputs, opts); } } diff --git a/pkg/codegen/internal/test/testdata/resource-property-overlap/nodejs/provider.ts b/pkg/codegen/internal/test/testdata/resource-property-overlap/nodejs/provider.ts index 791f0a3cf..d2f15c3be 100644 --- a/pkg/codegen/internal/test/testdata/resource-property-overlap/nodejs/provider.ts +++ b/pkg/codegen/internal/test/testdata/resource-property-overlap/nodejs/provider.ts @@ -28,14 +28,14 @@ export class Provider extends pulumi.ProviderResource { * @param opts A bag of options that control this resource's behavior. */ constructor(name: string, args?: ProviderArgs, opts?: pulumi.ResourceOptions) { - let inputs: pulumi.Inputs = {}; + let resourceInputs: pulumi.Inputs = {}; opts = opts || {}; { } if (!opts.version) { opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()}); } - super(Provider.__pulumiType, name, inputs, opts); + super(Provider.__pulumiType, name, resourceInputs, opts); } } diff --git a/pkg/codegen/internal/test/testdata/resource-property-overlap/nodejs/rec.ts b/pkg/codegen/internal/test/testdata/resource-property-overlap/nodejs/rec.ts index 6aa2030cd..ee3a6b7b7 100644 --- a/pkg/codegen/internal/test/testdata/resource-property-overlap/nodejs/rec.ts +++ b/pkg/codegen/internal/test/testdata/resource-property-overlap/nodejs/rec.ts @@ -43,17 +43,17 @@ export class Rec extends pulumi.CustomResource { * @param opts A bag of options that control this resource's behavior. */ constructor(name: string, args?: RecArgs, opts?: pulumi.CustomResourceOptions) { - let inputs: pulumi.Inputs = {}; + let resourceInputs: pulumi.Inputs = {}; opts = opts || {}; if (!opts.id) { - inputs["rec"] = undefined /*out*/; + resourceInputs["rec"] = undefined /*out*/; } else { - inputs["rec"] = undefined /*out*/; + resourceInputs["rec"] = undefined /*out*/; } if (!opts.version) { opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()}); } - super(Rec.__pulumiType, name, inputs, opts); + super(Rec.__pulumiType, name, resourceInputs, opts); } } diff --git a/pkg/codegen/internal/test/testdata/simple-enum-schema/nodejs/provider.ts b/pkg/codegen/internal/test/testdata/simple-enum-schema/nodejs/provider.ts index 578b31bdc..d04b2779e 100644 --- a/pkg/codegen/internal/test/testdata/simple-enum-schema/nodejs/provider.ts +++ b/pkg/codegen/internal/test/testdata/simple-enum-schema/nodejs/provider.ts @@ -28,14 +28,14 @@ export class Provider extends pulumi.ProviderResource { * @param opts A bag of options that control this resource's behavior. */ constructor(name: string, args?: ProviderArgs, opts?: pulumi.ResourceOptions) { - let inputs: pulumi.Inputs = {}; + let resourceInputs: pulumi.Inputs = {}; opts = opts || {}; { } if (!opts.version) { opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()}); } - super(Provider.__pulumiType, name, inputs, opts); + super(Provider.__pulumiType, name, resourceInputs, opts); } } diff --git a/pkg/codegen/internal/test/testdata/simple-enum-schema/nodejs/tree/v1/nursery.ts b/pkg/codegen/internal/test/testdata/simple-enum-schema/nodejs/tree/v1/nursery.ts index d9d03bb54..1cefb9b25 100644 --- a/pkg/codegen/internal/test/testdata/simple-enum-schema/nodejs/tree/v1/nursery.ts +++ b/pkg/codegen/internal/test/testdata/simple-enum-schema/nodejs/tree/v1/nursery.ts @@ -41,20 +41,20 @@ export class Nursery extends pulumi.CustomResource { * @param opts A bag of options that control this resource's behavior. */ constructor(name: string, args: NurseryArgs, opts?: pulumi.CustomResourceOptions) { - let inputs: pulumi.Inputs = {}; + let resourceInputs: pulumi.Inputs = {}; opts = opts || {}; if (!opts.id) { if ((!args || args.varieties === undefined) && !opts.urn) { throw new Error("Missing required property 'varieties'"); } - inputs["sizes"] = args ? args.sizes : undefined; - inputs["varieties"] = args ? args.varieties : undefined; + resourceInputs["sizes"] = args ? args.sizes : undefined; + resourceInputs["varieties"] = args ? args.varieties : undefined; } else { } if (!opts.version) { opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()}); } - super(Nursery.__pulumiType, name, inputs, opts); + super(Nursery.__pulumiType, name, resourceInputs, opts); } } diff --git a/pkg/codegen/internal/test/testdata/simple-enum-schema/nodejs/tree/v1/rubberTree.ts b/pkg/codegen/internal/test/testdata/simple-enum-schema/nodejs/tree/v1/rubberTree.ts index bb0613bcd..a713617a2 100644 --- a/pkg/codegen/internal/test/testdata/simple-enum-schema/nodejs/tree/v1/rubberTree.ts +++ b/pkg/codegen/internal/test/testdata/simple-enum-schema/nodejs/tree/v1/rubberTree.ts @@ -48,11 +48,11 @@ export class RubberTree extends pulumi.CustomResource { */ constructor(name: string, args: RubberTreeArgs, opts?: pulumi.CustomResourceOptions) constructor(name: string, argsOrState?: RubberTreeArgs | RubberTreeState, opts?: pulumi.CustomResourceOptions) { - let inputs: pulumi.Inputs = {}; + let resourceInputs: pulumi.Inputs = {}; opts = opts || {}; if (opts.id) { const state = argsOrState as RubberTreeState | undefined; - inputs["farm"] = state ? state.farm : undefined; + resourceInputs["farm"] = state ? state.farm : undefined; } else { const args = argsOrState as RubberTreeArgs | undefined; if ((!args || args.diameter === undefined) && !opts.urn) { @@ -61,16 +61,16 @@ export class RubberTree extends pulumi.CustomResource { if ((!args || args.type === undefined) && !opts.urn) { throw new Error("Missing required property 'type'"); } - inputs["container"] = args ? args.container : undefined; - inputs["diameter"] = (args ? args.diameter : undefined) ?? 6; - inputs["farm"] = (args ? args.farm : undefined) ?? "(unknown)"; - inputs["size"] = (args ? args.size : undefined) ?? "medium"; - inputs["type"] = (args ? args.type : undefined) ?? "Burgundy"; + resourceInputs["container"] = args ? (args.container ? pulumi.output(args.container).apply(inputs.containerArgsProvideDefaults) : undefined) : undefined; + resourceInputs["diameter"] = (args ? args.diameter : undefined) ?? 6; + resourceInputs["farm"] = (args ? args.farm : undefined) ?? "(unknown)"; + resourceInputs["size"] = (args ? args.size : undefined) ?? "medium"; + resourceInputs["type"] = (args ? args.type : undefined) ?? "Burgundy"; } if (!opts.version) { opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()}); } - super(RubberTree.__pulumiType, name, inputs, opts); + super(RubberTree.__pulumiType, name, resourceInputs, opts); } } diff --git a/pkg/codegen/internal/test/testdata/simple-enum-schema/nodejs/types/input.ts b/pkg/codegen/internal/test/testdata/simple-enum-schema/nodejs/types/input.ts index 52f85fdca..5318cf864 100644 --- a/pkg/codegen/internal/test/testdata/simple-enum-schema/nodejs/types/input.ts +++ b/pkg/codegen/internal/test/testdata/simple-enum-schema/nodejs/types/input.ts @@ -4,9 +4,20 @@ import * as pulumi from "@pulumi/pulumi"; import { input as inputs, output as outputs, enums } from "../types"; +import * as utilities from "../utilities"; + export interface ContainerArgs { brightness?: pulumi.Input; color?: pulumi.Input; material?: pulumi.Input; size: pulumi.Input; } +/** + * containerArgsProvideDefaults sets the appropriate defaults for ContainerArgs + */ +export function containerArgsProvideDefaults(val: ContainerArgs): ContainerArgs { + return { + ...val, + brightness: (val.brightness) ?? 1, + }; +} diff --git a/pkg/codegen/internal/test/testdata/simple-enum-schema/nodejs/types/output.ts b/pkg/codegen/internal/test/testdata/simple-enum-schema/nodejs/types/output.ts index 7f015cf2b..c56d600e2 100644 --- a/pkg/codegen/internal/test/testdata/simple-enum-schema/nodejs/types/output.ts +++ b/pkg/codegen/internal/test/testdata/simple-enum-schema/nodejs/types/output.ts @@ -4,10 +4,21 @@ import * as pulumi from "@pulumi/pulumi"; import { input as inputs, output as outputs, enums } from "../types"; +import * as utilities from "../utilities"; + export interface Container { brightness?: enums.ContainerBrightness; color?: enums.ContainerColor | string; material?: string; size: enums.ContainerSize; } +/** + * containerProvideDefaults sets the appropriate defaults for Container + */ +export function containerProvideDefaults(val: Container): Container { + return { + ...val, + brightness: (val.brightness) ?? 1, + }; +} diff --git a/pkg/codegen/internal/test/testdata/simple-methods-schema-single-value-returns/nodejs/foo.ts b/pkg/codegen/internal/test/testdata/simple-methods-schema-single-value-returns/nodejs/foo.ts index 02a470974..27ddea306 100644 --- a/pkg/codegen/internal/test/testdata/simple-methods-schema-single-value-returns/nodejs/foo.ts +++ b/pkg/codegen/internal/test/testdata/simple-methods-schema-single-value-returns/nodejs/foo.ts @@ -28,7 +28,7 @@ export class Foo extends pulumi.ComponentResource { * @param opts A bag of options that control this resource's behavior. */ constructor(name: string, args?: FooArgs, opts?: pulumi.ComponentResourceOptions) { - let inputs: pulumi.Inputs = {}; + let resourceInputs: pulumi.Inputs = {}; opts = opts || {}; if (!opts.id) { } else { @@ -36,7 +36,7 @@ export class Foo extends pulumi.ComponentResource { if (!opts.version) { opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()}); } - super(Foo.__pulumiType, name, inputs, opts, true /*remote*/); + super(Foo.__pulumiType, name, resourceInputs, opts, true /*remote*/); } getKubeconfig(args?: Foo.GetKubeconfigArgs): pulumi.Output { diff --git a/pkg/codegen/internal/test/testdata/simple-methods-schema-single-value-returns/nodejs/provider.ts b/pkg/codegen/internal/test/testdata/simple-methods-schema-single-value-returns/nodejs/provider.ts index 791f0a3cf..d2f15c3be 100644 --- a/pkg/codegen/internal/test/testdata/simple-methods-schema-single-value-returns/nodejs/provider.ts +++ b/pkg/codegen/internal/test/testdata/simple-methods-schema-single-value-returns/nodejs/provider.ts @@ -28,14 +28,14 @@ export class Provider extends pulumi.ProviderResource { * @param opts A bag of options that control this resource's behavior. */ constructor(name: string, args?: ProviderArgs, opts?: pulumi.ResourceOptions) { - let inputs: pulumi.Inputs = {}; + let resourceInputs: pulumi.Inputs = {}; opts = opts || {}; { } if (!opts.version) { opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()}); } - super(Provider.__pulumiType, name, inputs, opts); + super(Provider.__pulumiType, name, resourceInputs, opts); } } diff --git a/pkg/codegen/internal/test/testdata/simple-methods-schema/nodejs/foo.ts b/pkg/codegen/internal/test/testdata/simple-methods-schema/nodejs/foo.ts index 9176155c2..bfe170a0f 100644 --- a/pkg/codegen/internal/test/testdata/simple-methods-schema/nodejs/foo.ts +++ b/pkg/codegen/internal/test/testdata/simple-methods-schema/nodejs/foo.ts @@ -31,7 +31,7 @@ export class Foo extends pulumi.ComponentResource { * @param opts A bag of options that control this resource's behavior. */ constructor(name: string, args?: FooArgs, opts?: pulumi.ComponentResourceOptions) { - let inputs: pulumi.Inputs = {}; + let resourceInputs: pulumi.Inputs = {}; opts = opts || {}; if (!opts.id) { } else { @@ -39,7 +39,7 @@ export class Foo extends pulumi.ComponentResource { if (!opts.version) { opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()}); } - super(Foo.__pulumiType, name, inputs, opts, true /*remote*/); + super(Foo.__pulumiType, name, resourceInputs, opts, true /*remote*/); } /** diff --git a/pkg/codegen/internal/test/testdata/simple-methods-schema/nodejs/provider.ts b/pkg/codegen/internal/test/testdata/simple-methods-schema/nodejs/provider.ts index 791f0a3cf..d2f15c3be 100644 --- a/pkg/codegen/internal/test/testdata/simple-methods-schema/nodejs/provider.ts +++ b/pkg/codegen/internal/test/testdata/simple-methods-schema/nodejs/provider.ts @@ -28,14 +28,14 @@ export class Provider extends pulumi.ProviderResource { * @param opts A bag of options that control this resource's behavior. */ constructor(name: string, args?: ProviderArgs, opts?: pulumi.ResourceOptions) { - let inputs: pulumi.Inputs = {}; + let resourceInputs: pulumi.Inputs = {}; opts = opts || {}; { } if (!opts.version) { opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()}); } - super(Provider.__pulumiType, name, inputs, opts); + super(Provider.__pulumiType, name, resourceInputs, opts); } } diff --git a/pkg/codegen/internal/test/testdata/simple-plain-schema-with-root-package/nodejs/component.ts b/pkg/codegen/internal/test/testdata/simple-plain-schema-with-root-package/nodejs/component.ts index 727d54c2d..ae024c594 100644 --- a/pkg/codegen/internal/test/testdata/simple-plain-schema-with-root-package/nodejs/component.ts +++ b/pkg/codegen/internal/test/testdata/simple-plain-schema-with-root-package/nodejs/component.ts @@ -38,7 +38,7 @@ export class Component extends pulumi.ComponentResource { * @param opts A bag of options that control this resource's behavior. */ constructor(name: string, args: ComponentArgs, opts?: pulumi.ComponentResourceOptions) { - let inputs: pulumi.Inputs = {}; + let resourceInputs: pulumi.Inputs = {}; opts = opts || {}; if (!opts.id) { if ((!args || args.a === undefined) && !opts.urn) { @@ -50,30 +50,30 @@ export class Component extends pulumi.ComponentResource { if ((!args || args.e === undefined) && !opts.urn) { throw new Error("Missing required property 'e'"); } - inputs["a"] = args ? args.a : undefined; - inputs["b"] = args ? args.b : undefined; - inputs["bar"] = args ? args.bar : undefined; - inputs["baz"] = args ? args.baz : undefined; - inputs["c"] = args ? args.c : undefined; - inputs["d"] = args ? args.d : undefined; - inputs["e"] = args ? args.e : undefined; - inputs["f"] = args ? args.f : undefined; - inputs["foo"] = args ? args.foo : undefined; + resourceInputs["a"] = args ? args.a : undefined; + resourceInputs["b"] = args ? args.b : undefined; + resourceInputs["bar"] = args ? args.bar : undefined; + resourceInputs["baz"] = args ? args.baz : undefined; + resourceInputs["c"] = args ? args.c : undefined; + resourceInputs["d"] = args ? args.d : undefined; + resourceInputs["e"] = args ? args.e : undefined; + resourceInputs["f"] = args ? args.f : undefined; + resourceInputs["foo"] = args ? args.foo : undefined; } else { - inputs["a"] = undefined /*out*/; - inputs["b"] = undefined /*out*/; - inputs["bar"] = undefined /*out*/; - inputs["baz"] = undefined /*out*/; - inputs["c"] = undefined /*out*/; - inputs["d"] = undefined /*out*/; - inputs["e"] = undefined /*out*/; - inputs["f"] = undefined /*out*/; - inputs["foo"] = undefined /*out*/; + resourceInputs["a"] = undefined /*out*/; + resourceInputs["b"] = undefined /*out*/; + resourceInputs["bar"] = undefined /*out*/; + resourceInputs["baz"] = undefined /*out*/; + resourceInputs["c"] = undefined /*out*/; + resourceInputs["d"] = undefined /*out*/; + resourceInputs["e"] = undefined /*out*/; + resourceInputs["f"] = undefined /*out*/; + resourceInputs["foo"] = undefined /*out*/; } if (!opts.version) { opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()}); } - super(Component.__pulumiType, name, inputs, opts, true /*remote*/); + super(Component.__pulumiType, name, resourceInputs, opts, true /*remote*/); } } diff --git a/pkg/codegen/internal/test/testdata/simple-plain-schema-with-root-package/nodejs/provider.ts b/pkg/codegen/internal/test/testdata/simple-plain-schema-with-root-package/nodejs/provider.ts index 791f0a3cf..d2f15c3be 100644 --- a/pkg/codegen/internal/test/testdata/simple-plain-schema-with-root-package/nodejs/provider.ts +++ b/pkg/codegen/internal/test/testdata/simple-plain-schema-with-root-package/nodejs/provider.ts @@ -28,14 +28,14 @@ export class Provider extends pulumi.ProviderResource { * @param opts A bag of options that control this resource's behavior. */ constructor(name: string, args?: ProviderArgs, opts?: pulumi.ResourceOptions) { - let inputs: pulumi.Inputs = {}; + let resourceInputs: pulumi.Inputs = {}; opts = opts || {}; { } if (!opts.version) { opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()}); } - super(Provider.__pulumiType, name, inputs, opts); + super(Provider.__pulumiType, name, resourceInputs, opts); } } diff --git a/pkg/codegen/internal/test/testdata/simple-plain-schema/nodejs/component.ts b/pkg/codegen/internal/test/testdata/simple-plain-schema/nodejs/component.ts index 21e5e7957..a1637be0d 100644 --- a/pkg/codegen/internal/test/testdata/simple-plain-schema/nodejs/component.ts +++ b/pkg/codegen/internal/test/testdata/simple-plain-schema/nodejs/component.ts @@ -38,7 +38,7 @@ export class Component extends pulumi.ComponentResource { * @param opts A bag of options that control this resource's behavior. */ constructor(name: string, args: ComponentArgs, opts?: pulumi.ComponentResourceOptions) { - let inputs: pulumi.Inputs = {}; + let resourceInputs: pulumi.Inputs = {}; opts = opts || {}; if (!opts.id) { if ((!args || args.a === undefined) && !opts.urn) { @@ -50,31 +50,31 @@ export class Component extends pulumi.ComponentResource { if ((!args || args.e === undefined) && !opts.urn) { throw new Error("Missing required property 'e'"); } - inputs["a"] = args ? args.a : undefined; - inputs["b"] = args ? args.b : undefined; - inputs["bar"] = args ? args.bar : undefined; - inputs["baz"] = args ? args.baz : undefined; - inputs["bazMap"] = args ? args.bazMap : undefined; - inputs["c"] = args ? args.c : undefined; - inputs["d"] = args ? args.d : undefined; - inputs["e"] = args ? args.e : undefined; - inputs["f"] = args ? args.f : undefined; - inputs["foo"] = args ? args.foo : undefined; + resourceInputs["a"] = args ? args.a : undefined; + resourceInputs["b"] = args ? args.b : undefined; + resourceInputs["bar"] = args ? args.bar : undefined; + resourceInputs["baz"] = args ? args.baz : undefined; + resourceInputs["bazMap"] = args ? args.bazMap : undefined; + resourceInputs["c"] = args ? args.c : undefined; + resourceInputs["d"] = args ? args.d : undefined; + resourceInputs["e"] = args ? args.e : undefined; + resourceInputs["f"] = args ? args.f : undefined; + resourceInputs["foo"] = args ? args.foo : undefined; } else { - inputs["a"] = undefined /*out*/; - inputs["b"] = undefined /*out*/; - inputs["bar"] = undefined /*out*/; - inputs["baz"] = undefined /*out*/; - inputs["c"] = undefined /*out*/; - inputs["d"] = undefined /*out*/; - inputs["e"] = undefined /*out*/; - inputs["f"] = undefined /*out*/; - inputs["foo"] = undefined /*out*/; + resourceInputs["a"] = undefined /*out*/; + resourceInputs["b"] = undefined /*out*/; + resourceInputs["bar"] = undefined /*out*/; + resourceInputs["baz"] = undefined /*out*/; + resourceInputs["c"] = undefined /*out*/; + resourceInputs["d"] = undefined /*out*/; + resourceInputs["e"] = undefined /*out*/; + resourceInputs["f"] = undefined /*out*/; + resourceInputs["foo"] = undefined /*out*/; } if (!opts.version) { opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()}); } - super(Component.__pulumiType, name, inputs, opts, true /*remote*/); + super(Component.__pulumiType, name, resourceInputs, opts, true /*remote*/); } } diff --git a/pkg/codegen/internal/test/testdata/simple-plain-schema/nodejs/provider.ts b/pkg/codegen/internal/test/testdata/simple-plain-schema/nodejs/provider.ts index 791f0a3cf..d2f15c3be 100644 --- a/pkg/codegen/internal/test/testdata/simple-plain-schema/nodejs/provider.ts +++ b/pkg/codegen/internal/test/testdata/simple-plain-schema/nodejs/provider.ts @@ -28,14 +28,14 @@ export class Provider extends pulumi.ProviderResource { * @param opts A bag of options that control this resource's behavior. */ constructor(name: string, args?: ProviderArgs, opts?: pulumi.ResourceOptions) { - let inputs: pulumi.Inputs = {}; + let resourceInputs: pulumi.Inputs = {}; opts = opts || {}; { } if (!opts.version) { opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()}); } - super(Provider.__pulumiType, name, inputs, opts); + super(Provider.__pulumiType, name, resourceInputs, opts); } } diff --git a/pkg/codegen/internal/test/testdata/simple-resource-schema-custom-pypackage-name/nodejs/otherResource.ts b/pkg/codegen/internal/test/testdata/simple-resource-schema-custom-pypackage-name/nodejs/otherResource.ts index ad157d4a9..328690bcf 100644 --- a/pkg/codegen/internal/test/testdata/simple-resource-schema-custom-pypackage-name/nodejs/otherResource.ts +++ b/pkg/codegen/internal/test/testdata/simple-resource-schema-custom-pypackage-name/nodejs/otherResource.ts @@ -31,17 +31,17 @@ export class OtherResource extends pulumi.ComponentResource { * @param opts A bag of options that control this resource's behavior. */ constructor(name: string, args?: OtherResourceArgs, opts?: pulumi.ComponentResourceOptions) { - let inputs: pulumi.Inputs = {}; + let resourceInputs: pulumi.Inputs = {}; opts = opts || {}; if (!opts.id) { - inputs["foo"] = args ? args.foo : undefined; + resourceInputs["foo"] = args ? args.foo : undefined; } else { - inputs["foo"] = undefined /*out*/; + resourceInputs["foo"] = undefined /*out*/; } if (!opts.version) { opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()}); } - super(OtherResource.__pulumiType, name, inputs, opts, true /*remote*/); + super(OtherResource.__pulumiType, name, resourceInputs, opts, true /*remote*/); } } diff --git a/pkg/codegen/internal/test/testdata/simple-resource-schema-custom-pypackage-name/nodejs/provider.ts b/pkg/codegen/internal/test/testdata/simple-resource-schema-custom-pypackage-name/nodejs/provider.ts index 791f0a3cf..d2f15c3be 100644 --- a/pkg/codegen/internal/test/testdata/simple-resource-schema-custom-pypackage-name/nodejs/provider.ts +++ b/pkg/codegen/internal/test/testdata/simple-resource-schema-custom-pypackage-name/nodejs/provider.ts @@ -28,14 +28,14 @@ export class Provider extends pulumi.ProviderResource { * @param opts A bag of options that control this resource's behavior. */ constructor(name: string, args?: ProviderArgs, opts?: pulumi.ResourceOptions) { - let inputs: pulumi.Inputs = {}; + let resourceInputs: pulumi.Inputs = {}; opts = opts || {}; { } if (!opts.version) { opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()}); } - super(Provider.__pulumiType, name, inputs, opts); + super(Provider.__pulumiType, name, resourceInputs, opts); } } diff --git a/pkg/codegen/internal/test/testdata/simple-resource-schema-custom-pypackage-name/nodejs/resource.ts b/pkg/codegen/internal/test/testdata/simple-resource-schema-custom-pypackage-name/nodejs/resource.ts index e94097d4d..519c8395c 100644 --- a/pkg/codegen/internal/test/testdata/simple-resource-schema-custom-pypackage-name/nodejs/resource.ts +++ b/pkg/codegen/internal/test/testdata/simple-resource-schema-custom-pypackage-name/nodejs/resource.ts @@ -41,17 +41,17 @@ export class Resource extends pulumi.CustomResource { * @param opts A bag of options that control this resource's behavior. */ constructor(name: string, args?: ResourceArgs, opts?: pulumi.CustomResourceOptions) { - let inputs: pulumi.Inputs = {}; + let resourceInputs: pulumi.Inputs = {}; opts = opts || {}; if (!opts.id) { - inputs["bar"] = args ? args.bar : undefined; + resourceInputs["bar"] = args ? args.bar : undefined; } else { - inputs["bar"] = undefined /*out*/; + resourceInputs["bar"] = undefined /*out*/; } if (!opts.version) { opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()}); } - super(Resource.__pulumiType, name, inputs, opts); + super(Resource.__pulumiType, name, resourceInputs, opts); } } diff --git a/pkg/codegen/internal/test/testdata/simple-resource-schema/nodejs/otherResource.ts b/pkg/codegen/internal/test/testdata/simple-resource-schema/nodejs/otherResource.ts index ad157d4a9..328690bcf 100644 --- a/pkg/codegen/internal/test/testdata/simple-resource-schema/nodejs/otherResource.ts +++ b/pkg/codegen/internal/test/testdata/simple-resource-schema/nodejs/otherResource.ts @@ -31,17 +31,17 @@ export class OtherResource extends pulumi.ComponentResource { * @param opts A bag of options that control this resource's behavior. */ constructor(name: string, args?: OtherResourceArgs, opts?: pulumi.ComponentResourceOptions) { - let inputs: pulumi.Inputs = {}; + let resourceInputs: pulumi.Inputs = {}; opts = opts || {}; if (!opts.id) { - inputs["foo"] = args ? args.foo : undefined; + resourceInputs["foo"] = args ? args.foo : undefined; } else { - inputs["foo"] = undefined /*out*/; + resourceInputs["foo"] = undefined /*out*/; } if (!opts.version) { opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()}); } - super(OtherResource.__pulumiType, name, inputs, opts, true /*remote*/); + super(OtherResource.__pulumiType, name, resourceInputs, opts, true /*remote*/); } } diff --git a/pkg/codegen/internal/test/testdata/simple-resource-schema/nodejs/provider.ts b/pkg/codegen/internal/test/testdata/simple-resource-schema/nodejs/provider.ts index 791f0a3cf..d2f15c3be 100644 --- a/pkg/codegen/internal/test/testdata/simple-resource-schema/nodejs/provider.ts +++ b/pkg/codegen/internal/test/testdata/simple-resource-schema/nodejs/provider.ts @@ -28,14 +28,14 @@ export class Provider extends pulumi.ProviderResource { * @param opts A bag of options that control this resource's behavior. */ constructor(name: string, args?: ProviderArgs, opts?: pulumi.ResourceOptions) { - let inputs: pulumi.Inputs = {}; + let resourceInputs: pulumi.Inputs = {}; opts = opts || {}; { } if (!opts.version) { opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()}); } - super(Provider.__pulumiType, name, inputs, opts); + super(Provider.__pulumiType, name, resourceInputs, opts); } } diff --git a/pkg/codegen/internal/test/testdata/simple-resource-schema/nodejs/resource.ts b/pkg/codegen/internal/test/testdata/simple-resource-schema/nodejs/resource.ts index 8acb090c1..c5e639cb9 100644 --- a/pkg/codegen/internal/test/testdata/simple-resource-schema/nodejs/resource.ts +++ b/pkg/codegen/internal/test/testdata/simple-resource-schema/nodejs/resource.ts @@ -41,19 +41,19 @@ export class Resource extends pulumi.CustomResource { * @param opts A bag of options that control this resource's behavior. */ constructor(name: string, args?: ResourceArgs, opts?: pulumi.CustomResourceOptions) { - let inputs: pulumi.Inputs = {}; + let resourceInputs: pulumi.Inputs = {}; opts = opts || {}; if (!opts.id) { - inputs["bar"] = args?.bar ? pulumi.secret(args.bar) : undefined; + resourceInputs["bar"] = args?.bar ? pulumi.secret(args.bar) : undefined; } else { - inputs["bar"] = undefined /*out*/; + resourceInputs["bar"] = undefined /*out*/; } if (!opts.version) { opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()}); } const secretOpts = { additionalSecretOutputs: ["bar"] }; opts = pulumi.mergeOptions(opts, secretOpts); - super(Resource.__pulumiType, name, inputs, opts); + super(Resource.__pulumiType, name, resourceInputs, opts); } } diff --git a/pkg/codegen/internal/test/testdata/simple-resource-schema/nodejs/typeUses.ts b/pkg/codegen/internal/test/testdata/simple-resource-schema/nodejs/typeUses.ts index 9f76fd868..fa5ffaf8b 100644 --- a/pkg/codegen/internal/test/testdata/simple-resource-schema/nodejs/typeUses.ts +++ b/pkg/codegen/internal/test/testdata/simple-resource-schema/nodejs/typeUses.ts @@ -46,21 +46,21 @@ export class TypeUses extends pulumi.CustomResource { * @param opts A bag of options that control this resource's behavior. */ constructor(name: string, args?: TypeUsesArgs, opts?: pulumi.CustomResourceOptions) { - let inputs: pulumi.Inputs = {}; + let resourceInputs: pulumi.Inputs = {}; opts = opts || {}; if (!opts.id) { - inputs["bar"] = args ? args.bar : undefined; - inputs["baz"] = args ? args.baz : undefined; - inputs["foo"] = args ? args.foo : undefined; + resourceInputs["bar"] = args ? args.bar : undefined; + resourceInputs["baz"] = args ? args.baz : undefined; + resourceInputs["foo"] = args ? args.foo : undefined; } else { - inputs["bar"] = undefined /*out*/; - inputs["baz"] = undefined /*out*/; - inputs["foo"] = undefined /*out*/; + resourceInputs["bar"] = undefined /*out*/; + resourceInputs["baz"] = undefined /*out*/; + resourceInputs["foo"] = undefined /*out*/; } if (!opts.version) { opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()}); } - super(TypeUses.__pulumiType, name, inputs, opts); + super(TypeUses.__pulumiType, name, resourceInputs, opts); } } diff --git a/pkg/codegen/internal/test/testdata/simple-yaml-schema/nodejs/otherResource.ts b/pkg/codegen/internal/test/testdata/simple-yaml-schema/nodejs/otherResource.ts index 58de90c93..5f65e48c0 100644 --- a/pkg/codegen/internal/test/testdata/simple-yaml-schema/nodejs/otherResource.ts +++ b/pkg/codegen/internal/test/testdata/simple-yaml-schema/nodejs/otherResource.ts @@ -31,18 +31,18 @@ export class OtherResource extends pulumi.ComponentResource { * @param opts A bag of options that control this resource's behavior. */ constructor(name: string, args?: OtherResourceArgs, opts?: pulumi.ComponentResourceOptions) { - let inputs: pulumi.Inputs = {}; + let resourceInputs: pulumi.Inputs = {}; opts = opts || {}; if (!opts.id) { - inputs["bar"] = args ? args.bar : undefined; - inputs["foo"] = args ? args.foo : undefined; + resourceInputs["bar"] = args ? args.bar : undefined; + resourceInputs["foo"] = args ? args.foo : undefined; } else { - inputs["foo"] = undefined /*out*/; + resourceInputs["foo"] = undefined /*out*/; } if (!opts.version) { opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()}); } - super(OtherResource.__pulumiType, name, inputs, opts, true /*remote*/); + super(OtherResource.__pulumiType, name, resourceInputs, opts, true /*remote*/); } } diff --git a/pkg/codegen/internal/test/testdata/simple-yaml-schema/nodejs/provider.ts b/pkg/codegen/internal/test/testdata/simple-yaml-schema/nodejs/provider.ts index 791f0a3cf..d2f15c3be 100644 --- a/pkg/codegen/internal/test/testdata/simple-yaml-schema/nodejs/provider.ts +++ b/pkg/codegen/internal/test/testdata/simple-yaml-schema/nodejs/provider.ts @@ -28,14 +28,14 @@ export class Provider extends pulumi.ProviderResource { * @param opts A bag of options that control this resource's behavior. */ constructor(name: string, args?: ProviderArgs, opts?: pulumi.ResourceOptions) { - let inputs: pulumi.Inputs = {}; + let resourceInputs: pulumi.Inputs = {}; opts = opts || {}; { } if (!opts.version) { opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()}); } - super(Provider.__pulumiType, name, inputs, opts); + super(Provider.__pulumiType, name, resourceInputs, opts); } } diff --git a/pkg/codegen/internal/test/testdata/simple-yaml-schema/nodejs/resource.ts b/pkg/codegen/internal/test/testdata/simple-yaml-schema/nodejs/resource.ts index 8acb090c1..c5e639cb9 100644 --- a/pkg/codegen/internal/test/testdata/simple-yaml-schema/nodejs/resource.ts +++ b/pkg/codegen/internal/test/testdata/simple-yaml-schema/nodejs/resource.ts @@ -41,19 +41,19 @@ export class Resource extends pulumi.CustomResource { * @param opts A bag of options that control this resource's behavior. */ constructor(name: string, args?: ResourceArgs, opts?: pulumi.CustomResourceOptions) { - let inputs: pulumi.Inputs = {}; + let resourceInputs: pulumi.Inputs = {}; opts = opts || {}; if (!opts.id) { - inputs["bar"] = args?.bar ? pulumi.secret(args.bar) : undefined; + resourceInputs["bar"] = args?.bar ? pulumi.secret(args.bar) : undefined; } else { - inputs["bar"] = undefined /*out*/; + resourceInputs["bar"] = undefined /*out*/; } if (!opts.version) { opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()}); } const secretOpts = { additionalSecretOutputs: ["bar"] }; opts = pulumi.mergeOptions(opts, secretOpts); - super(Resource.__pulumiType, name, inputs, opts); + super(Resource.__pulumiType, name, resourceInputs, opts); } } diff --git a/pkg/codegen/internal/test/testdata/simple-yaml-schema/nodejs/typeUses.ts b/pkg/codegen/internal/test/testdata/simple-yaml-schema/nodejs/typeUses.ts index fea9057d7..901c1148f 100644 --- a/pkg/codegen/internal/test/testdata/simple-yaml-schema/nodejs/typeUses.ts +++ b/pkg/codegen/internal/test/testdata/simple-yaml-schema/nodejs/typeUses.ts @@ -47,23 +47,23 @@ export class TypeUses extends pulumi.CustomResource { * @param opts A bag of options that control this resource's behavior. */ constructor(name: string, args?: TypeUsesArgs, opts?: pulumi.CustomResourceOptions) { - let inputs: pulumi.Inputs = {}; + let resourceInputs: pulumi.Inputs = {}; opts = opts || {}; if (!opts.id) { - inputs["bar"] = args ? args.bar : undefined; - inputs["baz"] = args ? args.baz : undefined; - inputs["foo"] = args ? args.foo : undefined; - inputs["qux"] = args ? args.qux : undefined; + resourceInputs["bar"] = args ? args.bar : undefined; + resourceInputs["baz"] = args ? args.baz : undefined; + resourceInputs["foo"] = args ? args.foo : undefined; + resourceInputs["qux"] = args ? args.qux : undefined; } else { - inputs["bar"] = undefined /*out*/; - inputs["baz"] = undefined /*out*/; - inputs["foo"] = undefined /*out*/; - inputs["qux"] = undefined /*out*/; + resourceInputs["bar"] = undefined /*out*/; + resourceInputs["baz"] = undefined /*out*/; + resourceInputs["foo"] = undefined /*out*/; + resourceInputs["qux"] = undefined /*out*/; } if (!opts.version) { opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()}); } - super(TypeUses.__pulumiType, name, inputs, opts); + super(TypeUses.__pulumiType, name, resourceInputs, opts); } } diff --git a/pkg/codegen/nodejs/gen.go b/pkg/codegen/nodejs/gen.go index 045890b4d..5613cf8b0 100644 --- a/pkg/codegen/nodejs/gen.go +++ b/pkg/codegen/nodejs/gen.go @@ -396,7 +396,11 @@ func printComment(w io.Writer, comment, deprecationMessage, indent string) { fmt.Fprintf(w, "%s */\n", indent) } -func (mod *modContext) genPlainType(w io.Writer, name, comment string, properties []*schema.Property, input, readonly bool, level int) { +// Generates a plain interface type. +// +// We use this to represent both argument and plain object types. +func (mod *modContext) genPlainType(w io.Writer, name, comment string, + properties []*schema.Property, input, readonly bool, level int) error { indent := strings.Repeat(" ", level) printComment(w, comment, "", indent) @@ -419,6 +423,112 @@ func (mod *modContext) genPlainType(w io.Writer, name, comment string, propertie fmt.Fprintf(w, "%s %s%s%s: %s;\n", indent, prefix, p.Name, sigil, typ) } fmt.Fprintf(w, "%s}\n", indent) + return nil +} + +// Generate a provide defaults function for an associated plain object. +func (mod *modContext) genPlainObjectDefaultFunc(w io.Writer, name, comment string, + properties []*schema.Property, input, readonly bool, level int) error { + indent := strings.Repeat(" ", level) + defaults := []string{} + for _, p := range properties { + + if p.DefaultValue != nil { + dv, err := mod.getDefaultValue(p.DefaultValue, codegen.UnwrapType(p.Type)) + if err != nil { + return err + } + defaults = append(defaults, fmt.Sprintf("%s: (val.%s) ?? %s", p.Name, p.Name, dv)) + } else if funcName := mod.provideDefaultsFuncName(p.Type, input); funcName != "" { + // ProvideDefaults functions have the form `(Input | undefined) -> + // Output | undefined`. We need to disallow the undefined. This is safe + // because val.%arg existed in the input (type system enforced). + var compositeObject string + if codegen.IsNOptionalInput(p.Type) { + compositeObject = fmt.Sprintf("pulumi.output(val.%s).apply(%s)", p.Name, funcName) + } else { + compositeObject = fmt.Sprintf("%s(val.%s)", funcName, p.Name) + } + if !p.IsRequired() { + compositeObject = fmt.Sprintf("(val.%s ? %s : undefined)", p.Name, compositeObject) + } + defaults = append(defaults, fmt.Sprintf("%s: %s", p.Name, compositeObject)) + } + } + + // There are no defaults, so don't generate a default function. + if len(defaults) == 0 { + return nil + } + // Generates a function header that looks like this: + // export function %sProvideDefaults(val: pulumi.Input<%s> | undefined): pulumi.Output<%s> | undefined { + // const def = (val: LayeredTypeArgs) => ({ + // ...val, + defaultProvderName := provideDefaultsFuncNameFromName(name) + printComment(w, fmt.Sprintf("%s sets the appropriate defaults for %s", + defaultProvderName, name), "", indent) + fmt.Fprintf(w, "%sexport function %s(val: %s): "+ + "%s {\n", indent, defaultProvderName, name, name) + fmt.Fprintf(w, "%s return {\n", indent) + fmt.Fprintf(w, "%s ...val,\n", indent) + + // Fields look as follows + // %s: (val.%s) ?? devValue, + for _, val := range defaults { + fmt.Fprintf(w, "%s %s,\n", indent, val) + } + fmt.Fprintf(w, "%s };\n", indent) + fmt.Fprintf(w, "%s}\n", indent) + return nil +} + +// The name of the helper function used to provide default values to plain +// types, derived purely from the name of the enclosing type. Prefer to use +// provideDefaultsFuncName when full type information is available. +func provideDefaultsFuncNameFromName(typeName string) string { + var i int + if in := strings.LastIndex(typeName, "."); in != -1 { + i = in + } + // path + camel(name) + ProvideDefaults suffix + return typeName[:i] + camel(typeName[i:]) + "ProvideDefaults" +} + +// The name of the function used to set defaults on the plain type. +// +// `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) { + return "" + } + requiredType := codegen.UnwrapType(typ) + typeName := mod.typeString(requiredType, input, nil) + 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) { @@ -478,7 +588,7 @@ func (mod *modContext) getDefaultValue(dv *schema.DefaultValue, t schema.Type) ( } cast := "" - if t != schema.StringType { + if t != schema.StringType && getType == "" { cast = "" } @@ -661,10 +771,24 @@ func (mod *modContext) genResource(w io.Writer, r *schema.Resource) error { } for _, prop := range r.InputProperties { var arg string + applyDefaults := func(arg string) string { + if name := mod.provideDefaultsFuncName(prop.Type, true /*input*/); name != "" { + var body string + if codegen.IsNOptionalInput(prop.Type) { + body = fmt.Sprintf("pulumi.output(%[2]s).apply(%[1]s)", name, arg) + } else { + body = fmt.Sprintf("%s(%s)", name, arg) + } + return fmt.Sprintf("(%s ? %s : undefined)", arg, body) + } + return arg + } + + argValue := applyDefaults(fmt.Sprintf("args.%s", prop.Name)) if prop.Secret { - arg = fmt.Sprintf("args?.%[1]s ? pulumi.secret(args.%[1]s) : undefined", prop.Name) + arg = fmt.Sprintf("args?.%[1]s ? pulumi.secret(%[2]s) : undefined", prop.Name, argValue) } else { - arg = fmt.Sprintf("args ? args.%[1]s : undefined", prop.Name) + arg = fmt.Sprintf("args ? %[1]s : undefined", argValue) } prefix := " " @@ -689,13 +813,13 @@ func (mod *modContext) genResource(w io.Writer, r *schema.Resource) error { arg = fmt.Sprintf("pulumi.output(%s).apply(JSON.stringify)", arg) } } - fmt.Fprintf(w, "%sinputs[\"%s\"] = %s;\n", prefix, prop.Name, arg) + fmt.Fprintf(w, "%sresourceInputs[\"%s\"] = %s;\n", prefix, prop.Name, arg) } for _, prop := range r.Properties { prefix := " " if !ins.Has(prop.Name) { - fmt.Fprintf(w, "%sinputs[\"%s\"] = undefined /*out*/;\n", prefix, prop.Name) + fmt.Fprintf(w, "%sresourceInputs[\"%s\"] = undefined /*out*/;\n", prefix, prop.Name) } } @@ -717,7 +841,7 @@ func (mod *modContext) genResource(w io.Writer, r *schema.Resource) error { if r.DeprecationMessage != "" && mod.compatibility != kubernetes20 { fmt.Fprintf(w, " pulumi.log.warn(\"%s is deprecated: %s\")\n", name, r.DeprecationMessage) } - fmt.Fprintf(w, " let inputs: pulumi.Inputs = {};\n") + fmt.Fprintf(w, " let resourceInputs: pulumi.Inputs = {};\n") fmt.Fprintf(w, " opts = opts || {};\n") if r.StateInputs != nil { @@ -725,7 +849,7 @@ func (mod *modContext) genResource(w io.Writer, r *schema.Resource) error { fmt.Fprintf(w, " if (opts.id) {\n") fmt.Fprintf(w, " const state = argsOrState as %[1]s | undefined;\n", stateType) for _, prop := range r.StateInputs.Properties { - fmt.Fprintf(w, " inputs[\"%[1]s\"] = state ? state.%[1]s : undefined;\n", prop.Name) + fmt.Fprintf(w, " resourceInputs[\"%[1]s\"] = state ? state.%[1]s : undefined;\n", prop.Name) } // The creation case (with args): fmt.Fprintf(w, " } else {\n") @@ -744,11 +868,11 @@ func (mod *modContext) genResource(w io.Writer, r *schema.Resource) error { // The get case: fmt.Fprintf(w, " } else {\n") for _, prop := range r.Properties { - fmt.Fprintf(w, " inputs[\"%[1]s\"] = undefined /*out*/;\n", prop.Name) + fmt.Fprintf(w, " resourceInputs[\"%[1]s\"] = undefined /*out*/;\n", prop.Name) } } } else { - fmt.Fprintf(w, " let inputs: pulumi.Inputs = {};\n") + fmt.Fprintf(w, " let resourceInputs: pulumi.Inputs = {};\n") fmt.Fprintf(w, " opts = opts || {};\n") fmt.Fprintf(w, " {\n") err := genInputProps() @@ -800,9 +924,9 @@ func (mod *modContext) genResource(w io.Writer, r *schema.Resource) error { // If it's a ComponentResource, set the remote option. if r.IsComponent { - fmt.Fprintf(w, " super(%s.__pulumiType, name, inputs, opts, true /*remote*/);\n", name) + fmt.Fprintf(w, " super(%s.__pulumiType, name, resourceInputs, opts, true /*remote*/);\n", name) } else { - fmt.Fprintf(w, " super(%s.__pulumiType, name, inputs, opts);\n", name) + fmt.Fprintf(w, " super(%s.__pulumiType, name, resourceInputs, opts);\n", name) } fmt.Fprintf(w, " }\n") @@ -898,17 +1022,21 @@ func (mod *modContext) genResource(w io.Writer, r *schema.Resource) error { // Emit the state type for get methods. if r.StateInputs != nil { fmt.Fprintf(w, "\n") - mod.genPlainType(w, stateType, r.StateInputs.Comment, r.StateInputs.Properties, true, false, 0) + if err := mod.genPlainType(w, stateType, r.StateInputs.Comment, r.StateInputs.Properties, true, false, 0); err != nil { + return err + } } // Emit the argument type for construction. fmt.Fprintf(w, "\n") argsComment := fmt.Sprintf("The set of arguments for constructing a %s resource.", name) - mod.genPlainType(w, argsType, argsComment, r.InputProperties, true, false, 0) + if err := mod.genPlainType(w, argsType, argsComment, r.InputProperties, true, false, 0); err != nil { + return err + } // Emit any method types inside a namespace merged with the class, to represent types nested in the class. // https://www.typescriptlang.org/docs/handbook/declaration-merging.html#merging-namespaces-with-classes - genMethodTypes := func(w io.Writer, method *schema.Method) { + genMethodTypes := func(w io.Writer, method *schema.Method) error { fun := method.Function methodName := title(method.Name) if fun.Inputs != nil { @@ -924,7 +1052,9 @@ func (mod *modContext) genResource(w io.Writer, r *schema.Resource) error { if comment == "" { comment = fmt.Sprintf("The set of arguments for the %s.%s method.", name, method.Name) } - mod.genPlainType(w, methodName+"Args", comment, args, true, false, 1) + if err := mod.genPlainType(w, methodName+"Args", comment, args, true, false, 1); err != nil { + return err + } fmt.Fprintf(w, "\n") } } @@ -933,13 +1063,18 @@ func (mod *modContext) genResource(w io.Writer, r *schema.Resource) error { if comment == "" { comment = fmt.Sprintf("The results of the %s.%s method.", name, method.Name) } - mod.genPlainType(w, methodName+"Result", comment, fun.Outputs.Properties, false, true, 1) + if err := mod.genPlainType(w, methodName+"Result", comment, fun.Outputs.Properties, false, true, 1); err != nil { + return err + } fmt.Fprintf(w, "\n") } + return nil } types := &bytes.Buffer{} for _, method := range r.Methods { - genMethodTypes(types, method) + if err := genMethodTypes(types, method); err != nil { + return err + } } typesString := types.String() if typesString != "" { @@ -950,7 +1085,7 @@ func (mod *modContext) genResource(w io.Writer, r *schema.Resource) error { return nil } -func (mod *modContext) genFunction(w io.Writer, fun *schema.Function) { +func (mod *modContext) genFunction(w io.Writer, fun *schema.Function) error { name := tokenToFunctionName(fun.Token) // Write the TypeDoc/JSDoc for the data source function. @@ -995,7 +1130,16 @@ func (mod *modContext) genFunction(w io.Writer, fun *schema.Function) { if fun.Inputs != nil { for _, p := range fun.Inputs.Properties { // Pass the argument to the invocation. - fmt.Fprintf(w, " \"%[1]s\": args.%[1]s,\n", p.Name) + body := fmt.Sprintf("args.%s", p.Name) + if name := mod.provideDefaultsFuncName(p.Type, true /*input*/); name != "" { + if codegen.IsNOptionalInput(p.Type) { + body = fmt.Sprintf("pulumi.output(%s).apply(%s)", body, name) + } else { + body = fmt.Sprintf("%s(%s)", name, body) + } + body = fmt.Sprintf("args.%s ? %s : undefined", p.Name, body) + } + fmt.Fprintf(w, " \"%[1]s\": %[2]s,\n", p.Name, body) } } fmt.Fprintf(w, " }, opts);\n") @@ -1004,14 +1148,18 @@ func (mod *modContext) genFunction(w io.Writer, fun *schema.Function) { // If there are argument and/or return types, emit them. if fun.Inputs != nil { fmt.Fprintf(w, "\n") - mod.genPlainType(w, title(name)+"Args", fun.Inputs.Comment, fun.Inputs.Properties, true, false, 0) + if err := mod.genPlainType(w, title(name)+"Args", fun.Inputs.Comment, fun.Inputs.Properties, true, false, 0); err != nil { + return err + } } if fun.Outputs != nil { fmt.Fprintf(w, "\n") - mod.genPlainType(w, title(name)+"Result", fun.Outputs.Comment, fun.Outputs.Properties, false, true, 0) + if err := mod.genPlainType(w, title(name)+"Result", fun.Outputs.Comment, fun.Outputs.Properties, false, true, 0); err != nil { + return err + } } - mod.genFunctionOutputVersion(w, fun) + return mod.genFunctionOutputVersion(w, fun) } func functionArgsOptional(fun *schema.Function) bool { @@ -1034,9 +1182,9 @@ func functionReturnType(fun *schema.Function) string { // Generates `function ${fn}Output(..)` version lifted to work on // `Input`-warpped arguments and producing an `Output`-wrapped result. -func (mod *modContext) genFunctionOutputVersion(w io.Writer, fun *schema.Function) { +func (mod *modContext) genFunctionOutputVersion(w io.Writer, fun *schema.Function) error { if !fun.NeedsOutputVersion() { - return + return nil } originalName := tokenToFunctionName(fun.Token) @@ -1058,7 +1206,7 @@ export function %s(%sopts?: pulumi.InvokeOptions): pulumi.Output<%s> { `, fnOutput, argsig, functionReturnType(fun), originalName) fmt.Fprintf(w, "\n") - mod.genPlainType(w, + return mod.genPlainType(w, argTypeName, fun.Inputs.Comment, fun.Inputs.InputShape.Properties, @@ -1075,7 +1223,7 @@ func visitObjectTypes(properties []*schema.Property, visitor func(*schema.Object }) } -func (mod *modContext) genType(w io.Writer, obj *schema.ObjectType, input bool, level int) { +func (mod *modContext) genType(w io.Writer, obj *schema.ObjectType, input bool, level int) error { properties := obj.Properties info, hasInfo := obj.Language["nodejs"] if hasInfo { @@ -1105,6 +1253,16 @@ func (mod *modContext) genType(w io.Writer, obj *schema.ObjectType, input bool, } } + name := mod.getObjectName(obj, input) + err := mod.genPlainType(w, name, obj.Comment, properties, input, false, level) + if err != nil { + return err + } + return mod.genPlainObjectDefaultFunc(w, name, obj.Comment, properties, input, false, level) +} + +// getObjectName recovers the name of `obj` as a type. +func (mod *modContext) getObjectName(obj *schema.ObjectType, input bool) string { name := tokenToName(obj.Token) details := mod.details(obj) @@ -1114,8 +1272,7 @@ func (mod *modContext) genType(w io.Writer, obj *schema.ObjectType, input bool, } else if obj.IsInputShape() && mod.compatibility != tfbridge20 && mod.compatibility != kubernetes20 { name += "Args" } - - mod.genPlainType(w, name, obj.Comment, properties, input, false, level) + return name } func (mod *modContext) getTypeImports(t schema.Type, recurse bool, externalImports codegen.StringSet, imports map[string]codegen.StringSet, seen codegen.Set) bool { @@ -1400,8 +1557,9 @@ func (mod *modContext) sdkImports(nested, utilities bool) []string { return imports } -func (mod *modContext) genTypes() (string, string) { +func (mod *modContext) genTypes() (string, string, error) { externalImports, imports := codegen.NewStringSet(), map[string]codegen.StringSet{} + var hasDefaultObjects bool for _, t := range mod.types { if t.IsOverlay { // This type is generated by the provider, so no further action is required. @@ -1409,19 +1567,30 @@ func (mod *modContext) genTypes() (string, string) { } mod.getImports(t, externalImports, imports) + if isProvideDefaultsFuncRequired(t) { + hasDefaultObjects = true + } + } + // Instantiating the default might require an environmental variable. This + // uses utilities. + if hasDefaultObjects { + externalImports.Add(fmt.Sprintf("import * as utilities from \"%s/utilities\";", mod.getRelativePath())) } inputs, outputs := &bytes.Buffer{}, &bytes.Buffer{} - mod.genHeader(inputs, mod.sdkImports(true, false), externalImports, imports) mod.genHeader(outputs, mod.sdkImports(true, false), externalImports, imports) // Build a namespace tree out of the types, then emit them. namespaces := mod.getNamespaces() - mod.genNamespace(inputs, namespaces[""], true, 0) - mod.genNamespace(outputs, namespaces[""], false, 0) + if err := mod.genNamespace(inputs, namespaces[""], true, 0); err != nil { + return "", "", err + } + if err := mod.genNamespace(outputs, namespaces[""], false, 0); err != nil { + return "", "", err + } - return inputs.String(), outputs.String() + return inputs.String(), outputs.String(), nil } type namespace struct { @@ -1474,7 +1643,7 @@ func (mod *modContext) getNamespaces() map[string]*namespace { return namespaces } -func (mod *modContext) genNamespace(w io.Writer, ns *namespace, input bool, level int) { +func (mod *modContext) genNamespace(w io.Writer, ns *namespace, input bool, level int) error { indent := strings.Repeat(" ", level) sort.Slice(ns.types, func(i, j int) bool { @@ -1485,7 +1654,9 @@ func (mod *modContext) genNamespace(w io.Writer, ns *namespace, input bool, leve }) for i, t := range ns.types { if input && mod.details(t).inputType || !input && mod.details(t).outputType { - mod.genType(w, t, input, level) + if err := mod.genType(w, t, input, level); err != nil { + return err + } if i != len(ns.types)-1 { fmt.Fprintf(w, "\n") } @@ -1497,12 +1668,15 @@ func (mod *modContext) genNamespace(w io.Writer, ns *namespace, input bool, leve }) for i, child := range ns.children { fmt.Fprintf(w, "%sexport namespace %s {\n", indent, child.name) - mod.genNamespace(w, child, input, level+1) + if err := mod.genNamespace(w, child, input, level+1); err != nil { + return err + } fmt.Fprintf(w, "%s}\n", indent) if i != len(ns.children)-1 { fmt.Fprintf(w, "\n") } } + return nil } func (mod *modContext) genEnum(w io.Writer, enum *schema.EnumType) error { @@ -1640,7 +1814,9 @@ func (mod *modContext) gen(fs fs) error { buffer := &bytes.Buffer{} mod.genHeader(buffer, mod.sdkImports(referencesNestedTypes, true), externalImports, imports) - mod.genFunction(buffer, f) + if err := mod.genFunction(buffer, f); err != nil { + return err + } fileName := camel(tokenToName(f.Token)) + ".ts" if mod.isReservedSourceFileName(fileName) { @@ -1670,7 +1846,10 @@ func (mod *modContext) gen(fs fs) error { // Nested types if len(mod.types) > 0 { - input, output := mod.genTypes() + input, output, err := mod.genTypes() + if err != nil { + return err + } fs.add(path.Join(modDir, "input.ts"), []byte(input)) fs.add(path.Join(modDir, "output.ts"), []byte(output)) }