Fix 8110 (#8116)
* Add a test demonstrating the problem * Fix the bug * Accept changes over the example set * Accept go changes * Accept python codegen; avoid nil lang info panic * Accept .NET changes, compile * Accept docs changes * Add changelog notes * Fix lint * Add parens sparingly * Flatten unions * PR feedback
This commit is contained in:
parent
25f396bf49
commit
1ee85d8d2f
|
@ -12,5 +12,16 @@
|
|||
- [codegen/go] - Fix generation of cyclic struct types.
|
||||
[#8049](https://github.com/pulumi/pulumi/pull/8049)
|
||||
|
||||
- [codegen/nodejs] - Fix type literal generation by adding
|
||||
disambiguating parens; previously nested types such as arrays of
|
||||
unions and optionals generated type literals that were incorrectly
|
||||
parsed by TypeScript precedence rules.
|
||||
|
||||
NOTE for providers: using updated codegen may result in API changes
|
||||
that break existing working programs built against the older
|
||||
(incorrect) API declarations.
|
||||
|
||||
[#8116](https://github.com/pulumi/pulumi/pull/8116)
|
||||
|
||||
- [sdk/go] - Fix --target / --replace args
|
||||
[#8109](https://github.com/pulumi/pulumi/pull/8109)
|
||||
[#8109](https://github.com/pulumi/pulumi/pull/8109)
|
||||
|
|
|
@ -159,6 +159,11 @@ var sdkTests = []sdkTest{
|
|||
Description: "Cyclic object types",
|
||||
Skip: codegen.NewStringSet("python/test"),
|
||||
},
|
||||
{
|
||||
Directory: "regress-node-8110",
|
||||
Description: "Test the fix for pulumi/pulumi#8110 nodejs compilation error",
|
||||
Skip: codegen.NewStringSet("nodejs/test", "go/test", "python/test", "dotnet/test"),
|
||||
},
|
||||
}
|
||||
|
||||
var genSDKOnly bool
|
||||
|
|
|
@ -262,7 +262,7 @@ The following output properties are available:
|
|||
<a href="#value_nodejs" style="color: inherit; text-decoration: inherit;">value</a>
|
||||
</span>
|
||||
<span class="property-indicator"></span>
|
||||
<span class="property-type">Ssis<wbr>Environment<wbr>Response | Ssis<wbr>Folder<wbr>Response | Ssis<wbr>Package<wbr>Response | Ssis<wbr>Project<wbr>Response[]</span>
|
||||
<span class="property-type">(Ssis<wbr>Environment<wbr>Response | Ssis<wbr>Folder<wbr>Response | Ssis<wbr>Package<wbr>Response | Ssis<wbr>Project<wbr>Response)[]</span>
|
||||
</dt>
|
||||
<dd>{{% md %}}List of SSIS object metadata.{{% /md %}}</dd></dl>
|
||||
{{% /choosable %}}
|
||||
|
|
|
@ -55,5 +55,5 @@ export interface GetIntegrationRuntimeObjectMetadatumResult {
|
|||
/**
|
||||
* List of SSIS object metadata.
|
||||
*/
|
||||
readonly value?: outputs.SsisEnvironmentResponse | outputs.SsisFolderResponse | outputs.SsisPackageResponse | outputs.SsisProjectResponse[];
|
||||
readonly value?: (outputs.SsisEnvironmentResponse | outputs.SsisFolderResponse | outputs.SsisPackageResponse | outputs.SsisProjectResponse)[];
|
||||
}
|
||||
|
|
|
@ -578,10 +578,7 @@
|
|||
"@types/node": "latest",
|
||||
"mocha": "latest",
|
||||
"ts-node": "latest"
|
||||
},
|
||||
"extraTypeScriptFiles": [
|
||||
"tests/codegen.spec.ts"
|
||||
]
|
||||
}
|
||||
},
|
||||
"python": {
|
||||
}
|
||||
|
|
1
pkg/codegen/internal/test/testdata/regress-node-8110/.gitignore
vendored
Normal file
1
pkg/codegen/internal/test/testdata/regress-node-8110/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
nodejs/compileCheck.ts
|
34
pkg/codegen/internal/test/testdata/regress-node-8110/docs/_index.md
vendored
Normal file
34
pkg/codegen/internal/test/testdata/regress-node-8110/docs/_index.md
vendored
Normal file
|
@ -0,0 +1,34 @@
|
|||
---
|
||||
title: "my8110"
|
||||
title_tag: "my8110.my8110"
|
||||
meta_desc: ""
|
||||
menu:
|
||||
reference:
|
||||
parent: API Reference
|
||||
---
|
||||
|
||||
<!-- WARNING: this file was generated by test. -->
|
||||
<!-- Do not edit by hand unless you're certain you know what you are doing! -->
|
||||
|
||||
|
||||
|
||||
<h2 id="resources">Resources</h2>
|
||||
<ul class="api">
|
||||
<li><a href="provider" title="Provider"><span class="symbol resource"></span>Provider</a></li>
|
||||
</ul>
|
||||
|
||||
<h2 id="functions">Functions</h2>
|
||||
<ul class="api">
|
||||
<li><a href="examplefunc" title="ExampleFunc"><span class="symbol function"></span>ExampleFunc</a></li>
|
||||
</ul>
|
||||
|
||||
<h2 id="package-details">Package Details</h2>
|
||||
<dl class="package-details">
|
||||
<dt>Repository</dt>
|
||||
<dd><a href=""></a></dd>
|
||||
<dt>License</dt>
|
||||
<dd></dd>
|
||||
<dt>Version</dt>
|
||||
<dd>0.0.1</dd>
|
||||
</dl>
|
||||
|
7
pkg/codegen/internal/test/testdata/regress-node-8110/docs/codegen-manifest.json
vendored
Normal file
7
pkg/codegen/internal/test/testdata/regress-node-8110/docs/codegen-manifest.json
vendored
Normal file
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"emittedFiles": [
|
||||
"_index.md",
|
||||
"examplefunc/_index.md",
|
||||
"provider/_index.md"
|
||||
]
|
||||
}
|
129
pkg/codegen/internal/test/testdata/regress-node-8110/docs/examplefunc/_index.md
vendored
Normal file
129
pkg/codegen/internal/test/testdata/regress-node-8110/docs/examplefunc/_index.md
vendored
Normal file
|
@ -0,0 +1,129 @@
|
|||
|
||||
---
|
||||
title: "exampleFunc"
|
||||
title_tag: "my8110.exampleFunc"
|
||||
meta_desc: "Documentation for the my8110.exampleFunc function with examples, input properties, output properties, and supporting types."
|
||||
---
|
||||
|
||||
|
||||
|
||||
<!-- WARNING: this file was generated by test. -->
|
||||
<!-- Do not edit by hand unless you're certain you know what you are doing! -->
|
||||
|
||||
|
||||
|
||||
|
||||
## Using exampleFunc {#using}
|
||||
|
||||
{{< chooser language "typescript,python,go,csharp" / >}}
|
||||
|
||||
|
||||
{{% choosable language nodejs %}}
|
||||
<div class="highlight"><pre class="chroma"><code class="language-typescript" data-lang="typescript"><span class="k">function </span>exampleFunc<span class="p">(</span><span class="nx">args</span><span class="p">:</span> <span class="nx">ExampleFuncArgs</span><span class="p">,</span> <span class="nx">opts</span><span class="p">?:</span> <span class="nx"><a href="/docs/reference/pkg/nodejs/pulumi/pulumi/#InvokeOptions">InvokeOptions</a></span><span class="p">): Promise<<span class="nx"><a href="#result">ExampleFuncResult</a></span>></span></code></pre></div>
|
||||
{{% /choosable %}}
|
||||
|
||||
|
||||
{{% choosable language python %}}
|
||||
<div class="highlight"><pre class="chroma"><code class="language-python" data-lang="python"><span class="k">def </span>example_func(</span><span class="nx">enums</span><span class="p">:</span> <span class="nx">Optional[Sequence[Union[str, MyEnum]]]</span> = None<span class="p">,</span>
|
||||
<span class="nx">opts</span><span class="p">:</span> <span class="nx"><a href="/docs/reference/pkg/python/pulumi/#pulumi.InvokeOptions">Optional[InvokeOptions]</a></span> = None<span class="p">) -></span> ExampleFuncResult</code></pre></div>
|
||||
{{% /choosable %}}
|
||||
|
||||
|
||||
{{% choosable language go %}}
|
||||
<div class="highlight"><pre class="chroma"><code class="language-go" data-lang="go"><span class="k">func </span>ExampleFunc<span class="p">(</span><span class="nx">ctx</span><span class="p"> *</span><span class="nx"><a href="https://pkg.go.dev/github.com/pulumi/pulumi/sdk/v3/go/pulumi?tab=doc#Context">Context</a></span><span class="p">,</span> <span class="nx">args</span><span class="p"> *</span><span class="nx">ExampleFuncArgs</span><span class="p">,</span> <span class="nx">opts</span><span class="p"> ...</span><span class="nx"><a href="https://pkg.go.dev/github.com/pulumi/pulumi/sdk/v3/go/pulumi?tab=doc#InvokeOption">InvokeOption</a></span><span class="p">) (*<span class="nx"><a href="#result">ExampleFuncResult</a></span>, error)</span></code></pre></div>
|
||||
|
||||
> Note: This function is named `ExampleFunc` in the Go SDK.
|
||||
|
||||
{{% /choosable %}}
|
||||
|
||||
|
||||
{{% choosable language csharp %}}
|
||||
<div class="highlight"><pre class="chroma"><code class="language-csharp" data-lang="csharp"><span class="k">public static class </span><span class="nx">ExampleFunc </span><span class="p">{</span><span class="k">
|
||||
public static </span>Task<<span class="nx"><a href="#result">ExampleFuncResult</a></span>> <span class="p">InvokeAsync(</span><span class="nx">ExampleFuncArgs</span><span class="p"> </span><span class="nx">args<span class="p">,</span> <span class="nx"><a href="/docs/reference/pkg/dotnet/Pulumi/Pulumi.InvokeOptions.html">InvokeOptions</a></span><span class="p">? </span><span class="nx">opts = null<span class="p">)</span><span class="p">
|
||||
}</span></code></pre></div>
|
||||
{{% /choosable %}}
|
||||
|
||||
|
||||
|
||||
The following arguments are supported:
|
||||
|
||||
|
||||
{{% choosable language csharp %}}
|
||||
<dl class="resources-properties"><dt class="property-optional"
|
||||
title="Optional">
|
||||
<span id="enums_csharp">
|
||||
<a href="#enums_csharp" style="color: inherit; text-decoration: inherit;">Enums</a>
|
||||
</span>
|
||||
<span class="property-indicator"></span>
|
||||
<span class="property-type">List<Union<string, Pulumi.<wbr>My8110.<wbr>My<wbr>Enum>></span>
|
||||
</dt>
|
||||
<dd>{{% md %}}{{% /md %}}</dd></dl>
|
||||
{{% /choosable %}}
|
||||
|
||||
{{% choosable language go %}}
|
||||
<dl class="resources-properties"><dt class="property-optional"
|
||||
title="Optional">
|
||||
<span id="enums_go">
|
||||
<a href="#enums_go" style="color: inherit; text-decoration: inherit;">Enums</a>
|
||||
</span>
|
||||
<span class="property-indicator"></span>
|
||||
<span class="property-type">[]string</span>
|
||||
</dt>
|
||||
<dd>{{% md %}}{{% /md %}}</dd></dl>
|
||||
{{% /choosable %}}
|
||||
|
||||
{{% choosable language nodejs %}}
|
||||
<dl class="resources-properties"><dt class="property-optional"
|
||||
title="Optional">
|
||||
<span id="enums_nodejs">
|
||||
<a href="#enums_nodejs" style="color: inherit; text-decoration: inherit;">enums</a>
|
||||
</span>
|
||||
<span class="property-indicator"></span>
|
||||
<span class="property-type">(string | My<wbr>Enum)[]</span>
|
||||
</dt>
|
||||
<dd>{{% md %}}{{% /md %}}</dd></dl>
|
||||
{{% /choosable %}}
|
||||
|
||||
{{% choosable language python %}}
|
||||
<dl class="resources-properties"><dt class="property-optional"
|
||||
title="Optional">
|
||||
<span id="enums_python">
|
||||
<a href="#enums_python" style="color: inherit; text-decoration: inherit;">enums</a>
|
||||
</span>
|
||||
<span class="property-indicator"></span>
|
||||
<span class="property-type">Sequence[Union[str, My<wbr>Enum]]</span>
|
||||
</dt>
|
||||
<dd>{{% md %}}{{% /md %}}</dd></dl>
|
||||
{{% /choosable %}}
|
||||
|
||||
|
||||
|
||||
|
||||
## exampleFunc Result {#result}
|
||||
|
||||
The following output properties are available:
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## Supporting Types
|
||||
|
||||
|
||||
<h4 id="myenum">My<wbr>Enum</h4>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h2 id="package-details">Package Details</h2>
|
||||
<dl class="package-details">
|
||||
<dt>Repository</dt>
|
||||
<dd><a href=""></a></dd>
|
||||
<dt>License</dt>
|
||||
<dd></dd>
|
||||
</dl>
|
||||
|
239
pkg/codegen/internal/test/testdata/regress-node-8110/docs/provider/_index.md
vendored
Normal file
239
pkg/codegen/internal/test/testdata/regress-node-8110/docs/provider/_index.md
vendored
Normal file
|
@ -0,0 +1,239 @@
|
|||
|
||||
---
|
||||
title: "Provider"
|
||||
title_tag: "my8110.Provider"
|
||||
meta_desc: "Documentation for the my8110.Provider resource with examples, input properties, output properties, lookup functions, and supporting types."
|
||||
---
|
||||
|
||||
|
||||
|
||||
<!-- WARNING: this file was generated by test. -->
|
||||
<!-- Do not edit by hand unless you're certain you know what you are doing! -->
|
||||
|
||||
|
||||
|
||||
|
||||
## Create a Provider Resource {#create}
|
||||
{{< chooser language "typescript,python,go,csharp" / >}}
|
||||
|
||||
|
||||
{{% choosable language nodejs %}}
|
||||
<div class="highlight"><pre class="chroma"><code class="language-typescript" data-lang="typescript"><span class="k">new </span><span class="nx">Provider</span><span class="p">(</span><span class="nx">name</span><span class="p">:</span> <span class="nx">string</span><span class="p">,</span> <span class="nx">args</span><span class="p">?:</span> <span class="nx"><a href="#inputs">ProviderArgs</a></span><span class="p">,</span> <span class="nx">opts</span><span class="p">?:</span> <span class="nx"><a href="/docs/reference/pkg/nodejs/pulumi/pulumi/#CustomResourceOptions">CustomResourceOptions</a></span><span class="p">);</span></code></pre></div>
|
||||
{{% /choosable %}}
|
||||
|
||||
{{% choosable language python %}}
|
||||
<div class="highlight"><pre class="chroma"><code class="language-python" data-lang="python"><span class=nd>@overload</span>
|
||||
<span class="k">def </span><span class="nx">Provider</span><span class="p">(</span><span class="nx">resource_name</span><span class="p">:</span> <span class="nx">str</span><span class="p">,</span>
|
||||
<span class="nx">opts</span><span class="p">:</span> <span class="nx"><a href="/docs/reference/pkg/python/pulumi/#pulumi.ResourceOptions">Optional[ResourceOptions]</a></span> = None<span class="p">)</span>
|
||||
<span class=nd>@overload</span>
|
||||
<span class="k">def </span><span class="nx">Provider</span><span class="p">(</span><span class="nx">resource_name</span><span class="p">:</span> <span class="nx">str</span><span class="p">,</span>
|
||||
<span class="nx">args</span><span class="p">:</span> <span class="nx"><a href="#inputs">Optional[ProviderArgs]</a></span> = None<span class="p">,</span>
|
||||
<span class="nx">opts</span><span class="p">:</span> <span class="nx"><a href="/docs/reference/pkg/python/pulumi/#pulumi.ResourceOptions">Optional[ResourceOptions]</a></span> = None<span class="p">)</span></code></pre></div>
|
||||
{{% /choosable %}}
|
||||
|
||||
{{% choosable language go %}}
|
||||
<div class="highlight"><pre class="chroma"><code class="language-go" data-lang="go"><span class="k">func </span><span class="nx">NewProvider</span><span class="p">(</span><span class="nx">ctx</span><span class="p"> *</span><span class="nx"><a href="https://pkg.go.dev/github.com/pulumi/pulumi/sdk/v3/go/pulumi?tab=doc#Context">Context</a></span><span class="p">,</span> <span class="nx">name</span><span class="p"> </span><span class="nx">string</span><span class="p">,</span> <span class="nx">args</span><span class="p"> *</span><span class="nx"><a href="#inputs">ProviderArgs</a></span><span class="p">,</span> <span class="nx">opts</span><span class="p"> ...</span><span class="nx"><a href="https://pkg.go.dev/github.com/pulumi/pulumi/sdk/v3/go/pulumi?tab=doc#ResourceOption">ResourceOption</a></span><span class="p">) (*<span class="nx">Provider</span>, error)</span></code></pre></div>
|
||||
{{% /choosable %}}
|
||||
|
||||
{{% choosable language csharp %}}
|
||||
<div class="highlight"><pre class="chroma"><code class="language-csharp" data-lang="csharp"><span class="k">public </span><span class="nx">Provider</span><span class="p">(</span><span class="nx">string</span><span class="p"> </span><span class="nx">name<span class="p">,</span> <span class="nx"><a href="#inputs">ProviderArgs</a></span><span class="p">? </span><span class="nx">args = null<span class="p">,</span> <span class="nx"><a href="/docs/reference/pkg/dotnet/Pulumi/Pulumi.CustomResourceOptions.html">CustomResourceOptions</a></span><span class="p">? </span><span class="nx">opts = null<span class="p">)</span></code></pre></div>
|
||||
{{% /choosable %}}
|
||||
|
||||
{{% choosable language nodejs %}}
|
||||
|
||||
<dl class="resources-properties"><dt
|
||||
class="property-required" title="Required">
|
||||
<span>name</span>
|
||||
<span class="property-indicator"></span>
|
||||
<span class="property-type">string</span>
|
||||
</dt>
|
||||
<dd>The unique name of the resource.</dd><dt
|
||||
class="property-optional" title="Optional">
|
||||
<span>args</span>
|
||||
<span class="property-indicator"></span>
|
||||
<span class="property-type"><a href="#inputs">ProviderArgs</a></span>
|
||||
</dt>
|
||||
<dd>The arguments to resource properties.</dd><dt
|
||||
class="property-optional" title="Optional">
|
||||
<span>opts</span>
|
||||
<span class="property-indicator"></span>
|
||||
<span class="property-type"><a href="/docs/reference/pkg/nodejs/pulumi/pulumi/#CustomResourceOptions">CustomResourceOptions</a></span>
|
||||
</dt>
|
||||
<dd>Bag of options to control resource's behavior.</dd></dl>
|
||||
|
||||
{{% /choosable %}}
|
||||
|
||||
{{% choosable language python %}}
|
||||
|
||||
<dl class="resources-properties"><dt
|
||||
class="property-required" title="Required">
|
||||
<span>resource_name</span>
|
||||
<span class="property-indicator"></span>
|
||||
<span class="property-type">str</span>
|
||||
</dt>
|
||||
<dd>The unique name of the resource.</dd><dt
|
||||
class="property-optional" title="Optional">
|
||||
<span>args</span>
|
||||
<span class="property-indicator"></span>
|
||||
<span class="property-type"><a href="#inputs">ProviderArgs</a></span>
|
||||
</dt>
|
||||
<dd>The arguments to resource properties.</dd><dt
|
||||
class="property-optional" title="Optional">
|
||||
<span>opts</span>
|
||||
<span class="property-indicator"></span>
|
||||
<span class="property-type"><a href="/docs/reference/pkg/python/pulumi/#pulumi.ResourceOptions">ResourceOptions</a></span>
|
||||
</dt>
|
||||
<dd>Bag of options to control resource's behavior.</dd></dl>
|
||||
|
||||
{{% /choosable %}}
|
||||
|
||||
{{% choosable language go %}}
|
||||
|
||||
<dl class="resources-properties"><dt
|
||||
class="property-optional" title="Optional">
|
||||
<span>ctx</span>
|
||||
<span class="property-indicator"></span>
|
||||
<span class="property-type"><a href="https://pkg.go.dev/github.com/pulumi/pulumi/sdk/v3/go/pulumi?tab=doc#Context">Context</a></span>
|
||||
</dt>
|
||||
<dd>Context object for the current deployment.</dd><dt
|
||||
class="property-required" title="Required">
|
||||
<span>name</span>
|
||||
<span class="property-indicator"></span>
|
||||
<span class="property-type">string</span>
|
||||
</dt>
|
||||
<dd>The unique name of the resource.</dd><dt
|
||||
class="property-optional" title="Optional">
|
||||
<span>args</span>
|
||||
<span class="property-indicator"></span>
|
||||
<span class="property-type"><a href="#inputs">ProviderArgs</a></span>
|
||||
</dt>
|
||||
<dd>The arguments to resource properties.</dd><dt
|
||||
class="property-optional" title="Optional">
|
||||
<span>opts</span>
|
||||
<span class="property-indicator"></span>
|
||||
<span class="property-type"><a href="https://pkg.go.dev/github.com/pulumi/pulumi/sdk/v3/go/pulumi?tab=doc#ResourceOption">ResourceOption</a></span>
|
||||
</dt>
|
||||
<dd>Bag of options to control resource's behavior.</dd></dl>
|
||||
|
||||
{{% /choosable %}}
|
||||
|
||||
{{% choosable language csharp %}}
|
||||
|
||||
<dl class="resources-properties"><dt
|
||||
class="property-required" title="Required">
|
||||
<span>name</span>
|
||||
<span class="property-indicator"></span>
|
||||
<span class="property-type">string</span>
|
||||
</dt>
|
||||
<dd>The unique name of the resource.</dd><dt
|
||||
class="property-optional" title="Optional">
|
||||
<span>args</span>
|
||||
<span class="property-indicator"></span>
|
||||
<span class="property-type"><a href="#inputs">ProviderArgs</a></span>
|
||||
</dt>
|
||||
<dd>The arguments to resource properties.</dd><dt
|
||||
class="property-optional" title="Optional">
|
||||
<span>opts</span>
|
||||
<span class="property-indicator"></span>
|
||||
<span class="property-type"><a href="/docs/reference/pkg/dotnet/Pulumi/Pulumi.CustomResourceOptions.html">CustomResourceOptions</a></span>
|
||||
</dt>
|
||||
<dd>Bag of options to control resource's behavior.</dd></dl>
|
||||
|
||||
{{% /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 %}}
|
||||
<dl class="resources-properties"></dl>
|
||||
{{% /choosable %}}
|
||||
|
||||
{{% choosable language go %}}
|
||||
<dl class="resources-properties"></dl>
|
||||
{{% /choosable %}}
|
||||
|
||||
{{% choosable language nodejs %}}
|
||||
<dl class="resources-properties"></dl>
|
||||
{{% /choosable %}}
|
||||
|
||||
{{% choosable language python %}}
|
||||
<dl class="resources-properties"></dl>
|
||||
{{% /choosable %}}
|
||||
|
||||
|
||||
### Outputs
|
||||
|
||||
All [input](#inputs) properties are implicitly available as output properties. Additionally, the Provider resource produces the following output properties:
|
||||
|
||||
|
||||
|
||||
{{% choosable language csharp %}}
|
||||
<dl class="resources-properties"><dt class="property-"
|
||||
title="">
|
||||
<span id="id_csharp">
|
||||
<a href="#id_csharp" style="color: inherit; text-decoration: inherit;">Id</a>
|
||||
</span>
|
||||
<span class="property-indicator"></span>
|
||||
<span class="property-type">string</span>
|
||||
</dt>
|
||||
<dd>{{% md %}}The provider-assigned unique ID for this managed resource.{{% /md %}}</dd></dl>
|
||||
{{% /choosable %}}
|
||||
|
||||
{{% choosable language go %}}
|
||||
<dl class="resources-properties"><dt class="property-"
|
||||
title="">
|
||||
<span id="id_go">
|
||||
<a href="#id_go" style="color: inherit; text-decoration: inherit;">Id</a>
|
||||
</span>
|
||||
<span class="property-indicator"></span>
|
||||
<span class="property-type">string</span>
|
||||
</dt>
|
||||
<dd>{{% md %}}The provider-assigned unique ID for this managed resource.{{% /md %}}</dd></dl>
|
||||
{{% /choosable %}}
|
||||
|
||||
{{% choosable language nodejs %}}
|
||||
<dl class="resources-properties"><dt class="property-"
|
||||
title="">
|
||||
<span id="id_nodejs">
|
||||
<a href="#id_nodejs" style="color: inherit; text-decoration: inherit;">id</a>
|
||||
</span>
|
||||
<span class="property-indicator"></span>
|
||||
<span class="property-type">string</span>
|
||||
</dt>
|
||||
<dd>{{% md %}}The provider-assigned unique ID for this managed resource.{{% /md %}}</dd></dl>
|
||||
{{% /choosable %}}
|
||||
|
||||
{{% choosable language python %}}
|
||||
<dl class="resources-properties"><dt class="property-"
|
||||
title="">
|
||||
<span id="id_python">
|
||||
<a href="#id_python" style="color: inherit; text-decoration: inherit;">id</a>
|
||||
</span>
|
||||
<span class="property-indicator"></span>
|
||||
<span class="property-type">str</span>
|
||||
</dt>
|
||||
<dd>{{% md %}}The provider-assigned unique ID for this managed resource.{{% /md %}}</dd></dl>
|
||||
{{% /choosable %}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h2 id="package-details">Package Details</h2>
|
||||
<dl class="package-details">
|
||||
<dt>Repository</dt>
|
||||
<dd><a href=""></a></dd>
|
||||
<dt>License</dt>
|
||||
<dd></dd>
|
||||
</dl>
|
||||
|
37
pkg/codegen/internal/test/testdata/regress-node-8110/dotnet/Enums.cs
vendored
Normal file
37
pkg/codegen/internal/test/testdata/regress-node-8110/dotnet/Enums.cs
vendored
Normal file
|
@ -0,0 +1,37 @@
|
|||
// *** 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.ComponentModel;
|
||||
using Pulumi;
|
||||
|
||||
namespace Pulumi.My8110
|
||||
{
|
||||
[EnumType]
|
||||
public readonly struct MyEnum : IEquatable<MyEnum>
|
||||
{
|
||||
private readonly string _value;
|
||||
|
||||
private MyEnum(string value)
|
||||
{
|
||||
_value = value ?? throw new ArgumentNullException(nameof(value));
|
||||
}
|
||||
|
||||
public static MyEnum One { get; } = new MyEnum("one");
|
||||
public static MyEnum Two { get; } = new MyEnum("two");
|
||||
|
||||
public static bool operator ==(MyEnum left, MyEnum right) => left.Equals(right);
|
||||
public static bool operator !=(MyEnum left, MyEnum right) => !left.Equals(right);
|
||||
|
||||
public static explicit operator string(MyEnum value) => value._value;
|
||||
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public override bool Equals(object? obj) => obj is MyEnum other && Equals(other);
|
||||
public bool Equals(MyEnum other) => string.Equals(_value, other._value, StringComparison.Ordinal);
|
||||
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public override int GetHashCode() => _value?.GetHashCode() ?? 0;
|
||||
|
||||
public override string ToString() => _value;
|
||||
}
|
||||
}
|
33
pkg/codegen/internal/test/testdata/regress-node-8110/dotnet/ExampleFunc.cs
vendored
Normal file
33
pkg/codegen/internal/test/testdata/regress-node-8110/dotnet/ExampleFunc.cs
vendored
Normal file
|
@ -0,0 +1,33 @@
|
|||
// *** 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.My8110
|
||||
{
|
||||
public static class ExampleFunc
|
||||
{
|
||||
public static Task InvokeAsync(ExampleFuncArgs? args = null, InvokeOptions? options = null)
|
||||
=> Pulumi.Deployment.Instance.InvokeAsync("my8110::exampleFunc", args ?? new ExampleFuncArgs(), options.WithVersion());
|
||||
}
|
||||
|
||||
|
||||
public sealed class ExampleFuncArgs : Pulumi.InvokeArgs
|
||||
{
|
||||
[Input("enums")]
|
||||
private List<Union<string, Pulumi.My8110.MyEnum>>? _enums;
|
||||
public List<Union<string, Pulumi.My8110.MyEnum>> Enums
|
||||
{
|
||||
get => _enums ?? (_enums = new List<Union<string, Pulumi.My8110.MyEnum>>());
|
||||
set => _enums = value;
|
||||
}
|
||||
|
||||
public ExampleFuncArgs()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
46
pkg/codegen/internal/test/testdata/regress-node-8110/dotnet/Provider.cs
vendored
Normal file
46
pkg/codegen/internal/test/testdata/regress-node-8110/dotnet/Provider.cs
vendored
Normal file
|
@ -0,0 +1,46 @@
|
|||
// *** 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.My8110
|
||||
{
|
||||
[My8110ResourceType("pulumi:providers:my8110")]
|
||||
public partial class Provider : Pulumi.ProviderResource
|
||||
{
|
||||
/// <summary>
|
||||
/// Create a Provider resource with the given unique name, arguments, and options.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="name">The unique name of the resource</param>
|
||||
/// <param name="args">The arguments used to populate this resource's properties</param>
|
||||
/// <param name="options">A bag of options that control this resource's behavior</param>
|
||||
public Provider(string name, ProviderArgs? args = null, CustomResourceOptions? options = null)
|
||||
: base("my8110", name, args ?? new ProviderArgs(), MakeResourceOptions(options, ""))
|
||||
{
|
||||
}
|
||||
|
||||
private static CustomResourceOptions MakeResourceOptions(CustomResourceOptions? options, Input<string>? 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
|
||||
{
|
||||
public ProviderArgs()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
53
pkg/codegen/internal/test/testdata/regress-node-8110/dotnet/Pulumi.My8110.csproj
vendored
Normal file
53
pkg/codegen/internal/test/testdata/regress-node-8110/dotnet/Pulumi.My8110.csproj
vendored
Normal file
|
@ -0,0 +1,53 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||
<Authors>Pulumi Corp.</Authors>
|
||||
<Company>Pulumi Corp.</Company>
|
||||
<Description></Description>
|
||||
<PackageLicenseExpression></PackageLicenseExpression>
|
||||
<PackageProjectUrl></PackageProjectUrl>
|
||||
<RepositoryUrl></RepositoryUrl>
|
||||
<PackageIcon>logo.png</PackageIcon>
|
||||
|
||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<UseSharedCompilation>false</UseSharedCompilation>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||
<NoWarn>1701;1702;1591</NoWarn>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
|
||||
<EmbedUntrackedSources>true</EmbedUntrackedSources>
|
||||
<PublishRepositoryUrl>true</PublishRepositoryUrl>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(GITHUB_ACTIONS)' == 'true'">
|
||||
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="version.txt" />
|
||||
<None Include="version.txt" Pack="True" PackagePath="content" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Pulumi" Version="3.12" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Include="logo.png">
|
||||
<Pack>True</Pack>
|
||||
<PackagePath></PackagePath>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
0
pkg/codegen/internal/test/testdata/regress-node-8110/dotnet/README.md
vendored
Normal file
0
pkg/codegen/internal/test/testdata/regress-node-8110/dotnet/README.md
vendored
Normal file
87
pkg/codegen/internal/test/testdata/regress-node-8110/dotnet/Utilities.cs
vendored
Normal file
87
pkg/codegen/internal/test/testdata/regress-node-8110/dotnet/Utilities.cs
vendored
Normal file
|
@ -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.My8110
|
||||
{
|
||||
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.My8110.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 My8110ResourceTypeAttribute : Pulumi.ResourceTypeAttribute
|
||||
{
|
||||
public My8110ResourceTypeAttribute(string type) : base(type, Utilities.Version)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
11
pkg/codegen/internal/test/testdata/regress-node-8110/dotnet/codegen-manifest.json
vendored
Normal file
11
pkg/codegen/internal/test/testdata/regress-node-8110/dotnet/codegen-manifest.json
vendored
Normal file
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"emittedFiles": [
|
||||
"Enums.cs",
|
||||
"ExampleFunc.cs",
|
||||
"Provider.cs",
|
||||
"Pulumi.My8110.csproj",
|
||||
"README.md",
|
||||
"Utilities.cs",
|
||||
"logo.png"
|
||||
]
|
||||
}
|
BIN
pkg/codegen/internal/test/testdata/regress-node-8110/dotnet/logo.png
vendored
Normal file
BIN
pkg/codegen/internal/test/testdata/regress-node-8110/dotnet/logo.png
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 7.7 KiB |
11
pkg/codegen/internal/test/testdata/regress-node-8110/go/codegen-manifest.json
vendored
Normal file
11
pkg/codegen/internal/test/testdata/regress-node-8110/go/codegen-manifest.json
vendored
Normal file
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"emittedFiles": [
|
||||
"my8110/doc.go",
|
||||
"my8110/exampleFunc.go",
|
||||
"my8110/init.go",
|
||||
"my8110/provider.go",
|
||||
"my8110/pulumiEnums.go",
|
||||
"my8110/pulumiTypes.go",
|
||||
"my8110/pulumiUtilities.go"
|
||||
]
|
||||
}
|
3
pkg/codegen/internal/test/testdata/regress-node-8110/go/my8110/doc.go
vendored
Normal file
3
pkg/codegen/internal/test/testdata/regress-node-8110/go/my8110/doc.go
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
// Package my8110 exports types, functions, subpackages for provisioning my8110 resources.
|
||||
//
|
||||
package my8110
|
18
pkg/codegen/internal/test/testdata/regress-node-8110/go/my8110/exampleFunc.go
vendored
Normal file
18
pkg/codegen/internal/test/testdata/regress-node-8110/go/my8110/exampleFunc.go
vendored
Normal file
|
@ -0,0 +1,18 @@
|
|||
// *** WARNING: this file was generated by test. ***
|
||||
// *** Do not edit by hand unless you're certain you know what you are doing! ***
|
||||
|
||||
package my8110
|
||||
|
||||
import (
|
||||
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
|
||||
)
|
||||
|
||||
func ExampleFunc(ctx *pulumi.Context, args *ExampleFuncArgs, opts ...pulumi.InvokeOption) error {
|
||||
var rv struct{}
|
||||
err := ctx.Invoke("my8110::exampleFunc", args, &rv, opts...)
|
||||
return err
|
||||
}
|
||||
|
||||
type ExampleFuncArgs struct {
|
||||
Enums []string `pulumi:"enums"`
|
||||
}
|
40
pkg/codegen/internal/test/testdata/regress-node-8110/go/my8110/init.go
vendored
Normal file
40
pkg/codegen/internal/test/testdata/regress-node-8110/go/my8110/init.go
vendored
Normal file
|
@ -0,0 +1,40 @@
|
|||
// *** WARNING: this file was generated by test. ***
|
||||
// *** Do not edit by hand unless you're certain you know what you are doing! ***
|
||||
|
||||
package my8110
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/blang/semver"
|
||||
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
|
||||
)
|
||||
|
||||
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:my8110" {
|
||||
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.RegisterResourcePackage(
|
||||
"my8110",
|
||||
&pkg{version},
|
||||
)
|
||||
}
|
78
pkg/codegen/internal/test/testdata/regress-node-8110/go/my8110/provider.go
vendored
Normal file
78
pkg/codegen/internal/test/testdata/regress-node-8110/go/my8110/provider.go
vendored
Normal file
|
@ -0,0 +1,78 @@
|
|||
// *** WARNING: this file was generated by test. ***
|
||||
// *** Do not edit by hand unless you're certain you know what you are doing! ***
|
||||
|
||||
package my8110
|
||||
|
||||
import (
|
||||
"context"
|
||||
"reflect"
|
||||
|
||||
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
|
||||
)
|
||||
|
||||
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:my8110", name, args, &resource, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &resource, nil
|
||||
}
|
||||
|
||||
type providerArgs struct {
|
||||
}
|
||||
|
||||
// The set of arguments for constructing a Provider resource.
|
||||
type ProviderArgs struct {
|
||||
}
|
||||
|
||||
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.RegisterOutputType(ProviderOutput{})
|
||||
}
|
180
pkg/codegen/internal/test/testdata/regress-node-8110/go/my8110/pulumiEnums.go
vendored
Normal file
180
pkg/codegen/internal/test/testdata/regress-node-8110/go/my8110/pulumiEnums.go
vendored
Normal file
|
@ -0,0 +1,180 @@
|
|||
// *** WARNING: this file was generated by test. ***
|
||||
// *** Do not edit by hand unless you're certain you know what you are doing! ***
|
||||
|
||||
package my8110
|
||||
|
||||
import (
|
||||
"context"
|
||||
"reflect"
|
||||
|
||||
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
|
||||
)
|
||||
|
||||
type MyEnum string
|
||||
|
||||
const (
|
||||
MyEnumOne = MyEnum("one")
|
||||
MyEnumTwo = MyEnum("two")
|
||||
)
|
||||
|
||||
func (MyEnum) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((*MyEnum)(nil)).Elem()
|
||||
}
|
||||
|
||||
func (e MyEnum) ToMyEnumOutput() MyEnumOutput {
|
||||
return pulumi.ToOutput(e).(MyEnumOutput)
|
||||
}
|
||||
|
||||
func (e MyEnum) ToMyEnumOutputWithContext(ctx context.Context) MyEnumOutput {
|
||||
return pulumi.ToOutputWithContext(ctx, e).(MyEnumOutput)
|
||||
}
|
||||
|
||||
func (e MyEnum) ToMyEnumPtrOutput() MyEnumPtrOutput {
|
||||
return e.ToMyEnumPtrOutputWithContext(context.Background())
|
||||
}
|
||||
|
||||
func (e MyEnum) ToMyEnumPtrOutputWithContext(ctx context.Context) MyEnumPtrOutput {
|
||||
return MyEnum(e).ToMyEnumOutputWithContext(ctx).ToMyEnumPtrOutputWithContext(ctx)
|
||||
}
|
||||
|
||||
func (e MyEnum) ToStringOutput() pulumi.StringOutput {
|
||||
return pulumi.ToOutput(pulumi.String(e)).(pulumi.StringOutput)
|
||||
}
|
||||
|
||||
func (e MyEnum) ToStringOutputWithContext(ctx context.Context) pulumi.StringOutput {
|
||||
return pulumi.ToOutputWithContext(ctx, pulumi.String(e)).(pulumi.StringOutput)
|
||||
}
|
||||
|
||||
func (e MyEnum) ToStringPtrOutput() pulumi.StringPtrOutput {
|
||||
return pulumi.String(e).ToStringPtrOutputWithContext(context.Background())
|
||||
}
|
||||
|
||||
func (e MyEnum) ToStringPtrOutputWithContext(ctx context.Context) pulumi.StringPtrOutput {
|
||||
return pulumi.String(e).ToStringOutputWithContext(ctx).ToStringPtrOutputWithContext(ctx)
|
||||
}
|
||||
|
||||
type MyEnumOutput struct{ *pulumi.OutputState }
|
||||
|
||||
func (MyEnumOutput) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((*MyEnum)(nil)).Elem()
|
||||
}
|
||||
|
||||
func (o MyEnumOutput) ToMyEnumOutput() MyEnumOutput {
|
||||
return o
|
||||
}
|
||||
|
||||
func (o MyEnumOutput) ToMyEnumOutputWithContext(ctx context.Context) MyEnumOutput {
|
||||
return o
|
||||
}
|
||||
|
||||
func (o MyEnumOutput) ToMyEnumPtrOutput() MyEnumPtrOutput {
|
||||
return o.ToMyEnumPtrOutputWithContext(context.Background())
|
||||
}
|
||||
|
||||
func (o MyEnumOutput) ToMyEnumPtrOutputWithContext(ctx context.Context) MyEnumPtrOutput {
|
||||
return o.ApplyTWithContext(ctx, func(_ context.Context, v MyEnum) *MyEnum {
|
||||
return &v
|
||||
}).(MyEnumPtrOutput)
|
||||
}
|
||||
|
||||
func (o MyEnumOutput) ToStringOutput() pulumi.StringOutput {
|
||||
return o.ToStringOutputWithContext(context.Background())
|
||||
}
|
||||
|
||||
func (o MyEnumOutput) ToStringOutputWithContext(ctx context.Context) pulumi.StringOutput {
|
||||
return o.ApplyTWithContext(ctx, func(_ context.Context, e MyEnum) string {
|
||||
return string(e)
|
||||
}).(pulumi.StringOutput)
|
||||
}
|
||||
|
||||
func (o MyEnumOutput) ToStringPtrOutput() pulumi.StringPtrOutput {
|
||||
return o.ToStringPtrOutputWithContext(context.Background())
|
||||
}
|
||||
|
||||
func (o MyEnumOutput) ToStringPtrOutputWithContext(ctx context.Context) pulumi.StringPtrOutput {
|
||||
return o.ApplyTWithContext(ctx, func(_ context.Context, e MyEnum) *string {
|
||||
v := string(e)
|
||||
return &v
|
||||
}).(pulumi.StringPtrOutput)
|
||||
}
|
||||
|
||||
type MyEnumPtrOutput struct{ *pulumi.OutputState }
|
||||
|
||||
func (MyEnumPtrOutput) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((**MyEnum)(nil)).Elem()
|
||||
}
|
||||
|
||||
func (o MyEnumPtrOutput) ToMyEnumPtrOutput() MyEnumPtrOutput {
|
||||
return o
|
||||
}
|
||||
|
||||
func (o MyEnumPtrOutput) ToMyEnumPtrOutputWithContext(ctx context.Context) MyEnumPtrOutput {
|
||||
return o
|
||||
}
|
||||
|
||||
func (o MyEnumPtrOutput) Elem() MyEnumOutput {
|
||||
return o.ApplyT(func(v *MyEnum) MyEnum {
|
||||
if v != nil {
|
||||
return *v
|
||||
}
|
||||
var ret MyEnum
|
||||
return ret
|
||||
}).(MyEnumOutput)
|
||||
}
|
||||
|
||||
func (o MyEnumPtrOutput) ToStringPtrOutput() pulumi.StringPtrOutput {
|
||||
return o.ToStringPtrOutputWithContext(context.Background())
|
||||
}
|
||||
|
||||
func (o MyEnumPtrOutput) ToStringPtrOutputWithContext(ctx context.Context) pulumi.StringPtrOutput {
|
||||
return o.ApplyTWithContext(ctx, func(_ context.Context, e *MyEnum) *string {
|
||||
if e == nil {
|
||||
return nil
|
||||
}
|
||||
v := string(*e)
|
||||
return &v
|
||||
}).(pulumi.StringPtrOutput)
|
||||
}
|
||||
|
||||
// MyEnumInput is an input type that accepts MyEnumArgs and MyEnumOutput values.
|
||||
// You can construct a concrete instance of `MyEnumInput` via:
|
||||
//
|
||||
// MyEnumArgs{...}
|
||||
type MyEnumInput interface {
|
||||
pulumi.Input
|
||||
|
||||
ToMyEnumOutput() MyEnumOutput
|
||||
ToMyEnumOutputWithContext(context.Context) MyEnumOutput
|
||||
}
|
||||
|
||||
var myEnumPtrType = reflect.TypeOf((**MyEnum)(nil)).Elem()
|
||||
|
||||
type MyEnumPtrInput interface {
|
||||
pulumi.Input
|
||||
|
||||
ToMyEnumPtrOutput() MyEnumPtrOutput
|
||||
ToMyEnumPtrOutputWithContext(context.Context) MyEnumPtrOutput
|
||||
}
|
||||
|
||||
type myEnumPtr string
|
||||
|
||||
func MyEnumPtr(v string) MyEnumPtrInput {
|
||||
return (*myEnumPtr)(&v)
|
||||
}
|
||||
|
||||
func (*myEnumPtr) ElementType() reflect.Type {
|
||||
return myEnumPtrType
|
||||
}
|
||||
|
||||
func (in *myEnumPtr) ToMyEnumPtrOutput() MyEnumPtrOutput {
|
||||
return pulumi.ToOutput(in).(MyEnumPtrOutput)
|
||||
}
|
||||
|
||||
func (in *myEnumPtr) ToMyEnumPtrOutputWithContext(ctx context.Context) MyEnumPtrOutput {
|
||||
return pulumi.ToOutputWithContext(ctx, in).(MyEnumPtrOutput)
|
||||
}
|
||||
|
||||
func init() {
|
||||
pulumi.RegisterOutputType(MyEnumOutput{})
|
||||
pulumi.RegisterOutputType(MyEnumPtrOutput{})
|
||||
}
|
64
pkg/codegen/internal/test/testdata/regress-node-8110/go/my8110/pulumiTypes.go
vendored
Normal file
64
pkg/codegen/internal/test/testdata/regress-node-8110/go/my8110/pulumiTypes.go
vendored
Normal file
|
@ -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! ***
|
||||
|
||||
package my8110
|
||||
|
||||
import (
|
||||
"context"
|
||||
"reflect"
|
||||
|
||||
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
|
||||
)
|
||||
|
||||
type MyObj struct {
|
||||
A *string `pulumi:"a"`
|
||||
}
|
||||
|
||||
// MyObjInput is an input type that accepts MyObjArgs and MyObjOutput values.
|
||||
// You can construct a concrete instance of `MyObjInput` via:
|
||||
//
|
||||
// MyObjArgs{...}
|
||||
type MyObjInput interface {
|
||||
pulumi.Input
|
||||
|
||||
ToMyObjOutput() MyObjOutput
|
||||
ToMyObjOutputWithContext(context.Context) MyObjOutput
|
||||
}
|
||||
|
||||
type MyObjArgs struct {
|
||||
A pulumi.StringPtrInput `pulumi:"a"`
|
||||
}
|
||||
|
||||
func (MyObjArgs) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((*MyObj)(nil)).Elem()
|
||||
}
|
||||
|
||||
func (i MyObjArgs) ToMyObjOutput() MyObjOutput {
|
||||
return i.ToMyObjOutputWithContext(context.Background())
|
||||
}
|
||||
|
||||
func (i MyObjArgs) ToMyObjOutputWithContext(ctx context.Context) MyObjOutput {
|
||||
return pulumi.ToOutputWithContext(ctx, i).(MyObjOutput)
|
||||
}
|
||||
|
||||
type MyObjOutput struct{ *pulumi.OutputState }
|
||||
|
||||
func (MyObjOutput) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((*MyObj)(nil)).Elem()
|
||||
}
|
||||
|
||||
func (o MyObjOutput) ToMyObjOutput() MyObjOutput {
|
||||
return o
|
||||
}
|
||||
|
||||
func (o MyObjOutput) ToMyObjOutputWithContext(ctx context.Context) MyObjOutput {
|
||||
return o
|
||||
}
|
||||
|
||||
func (o MyObjOutput) A() pulumi.StringPtrOutput {
|
||||
return o.ApplyT(func(v MyObj) *string { return v.A }).(pulumi.StringPtrOutput)
|
||||
}
|
||||
|
||||
func init() {
|
||||
pulumi.RegisterOutputType(MyObjOutput{})
|
||||
}
|
77
pkg/codegen/internal/test/testdata/regress-node-8110/go/my8110/pulumiUtilities.go
vendored
Normal file
77
pkg/codegen/internal/test/testdata/regress-node-8110/go/my8110/pulumiUtilities.go
vendored
Normal file
|
@ -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 my8110
|
||||
|
||||
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-my8110/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)
|
||||
}
|
15
pkg/codegen/internal/test/testdata/regress-node-8110/nodejs-extras/compileCheck.ts
vendored
Normal file
15
pkg/codegen/internal/test/testdata/regress-node-8110/nodejs-extras/compileCheck.ts
vendored
Normal file
|
@ -0,0 +1,15 @@
|
|||
import * as e from "./exampleFunc";
|
||||
import { MyEnum } from "./types/enums";
|
||||
|
||||
// Check that common scenarios type-check.
|
||||
export function checkCall() {
|
||||
e.exampleFunc({
|
||||
"enums": ["a", "b", "c"],
|
||||
});
|
||||
e.exampleFunc({
|
||||
"enums": [MyEnum.One, MyEnum.Two],
|
||||
});
|
||||
e.exampleFunc({
|
||||
"enums": ["a", "b", "c", MyEnum.One, MyEnum.Two],
|
||||
});
|
||||
}
|
0
pkg/codegen/internal/test/testdata/regress-node-8110/nodejs/README.md
vendored
Normal file
0
pkg/codegen/internal/test/testdata/regress-node-8110/nodejs/README.md
vendored
Normal file
15
pkg/codegen/internal/test/testdata/regress-node-8110/nodejs/codegen-manifest.json
vendored
Normal file
15
pkg/codegen/internal/test/testdata/regress-node-8110/nodejs/codegen-manifest.json
vendored
Normal file
|
@ -0,0 +1,15 @@
|
|||
{
|
||||
"emittedFiles": [
|
||||
"README.md",
|
||||
"exampleFunc.ts",
|
||||
"index.ts",
|
||||
"package.json",
|
||||
"provider.ts",
|
||||
"tsconfig.json",
|
||||
"types/enums/index.ts",
|
||||
"types/index.ts",
|
||||
"types/input.ts",
|
||||
"types/output.ts",
|
||||
"utilities.ts"
|
||||
]
|
||||
}
|
24
pkg/codegen/internal/test/testdata/regress-node-8110/nodejs/exampleFunc.ts
vendored
Normal file
24
pkg/codegen/internal/test/testdata/regress-node-8110/nodejs/exampleFunc.ts
vendored
Normal file
|
@ -0,0 +1,24 @@
|
|||
// *** 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, enums } from "./types";
|
||||
import * as utilities from "./utilities";
|
||||
|
||||
export function exampleFunc(args?: ExampleFuncArgs, opts?: pulumi.InvokeOptions): Promise<void> {
|
||||
args = args || {};
|
||||
if (!opts) {
|
||||
opts = {}
|
||||
}
|
||||
|
||||
if (!opts.version) {
|
||||
opts.version = utilities.getVersion();
|
||||
}
|
||||
return pulumi.runtime.invoke("my8110::exampleFunc", {
|
||||
"enums": args.enums,
|
||||
}, opts);
|
||||
}
|
||||
|
||||
export interface ExampleFuncArgs {
|
||||
enums?: (string | enums.MyEnum)[];
|
||||
}
|
31
pkg/codegen/internal/test/testdata/regress-node-8110/nodejs/index.ts
vendored
Normal file
31
pkg/codegen/internal/test/testdata/regress-node-8110/nodejs/index.ts
vendored
Normal file
|
@ -0,0 +1,31 @@
|
|||
// *** 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 "./exampleFunc";
|
||||
export * from "./provider";
|
||||
|
||||
// Export enums:
|
||||
export * from "./types/enums";
|
||||
|
||||
// Export sub-modules:
|
||||
import * as types from "./types";
|
||||
|
||||
export {
|
||||
types,
|
||||
};
|
||||
|
||||
import { Provider } from "./provider";
|
||||
|
||||
pulumi.runtime.registerResourcePackage("my8110", {
|
||||
version: utilities.getVersion(),
|
||||
constructProvider: (name: string, type: string, urn: string): pulumi.ProviderResource => {
|
||||
if (type !== "pulumi:providers:my8110") {
|
||||
throw new Error(`unknown provider type ${type}`);
|
||||
}
|
||||
return new Provider(name, <any>undefined, { urn });
|
||||
},
|
||||
});
|
18
pkg/codegen/internal/test/testdata/regress-node-8110/nodejs/package.json
vendored
Normal file
18
pkg/codegen/internal/test/testdata/regress-node-8110/nodejs/package.json
vendored
Normal file
|
@ -0,0 +1,18 @@
|
|||
{
|
||||
"name": "@pulumi/my8110",
|
||||
"version": "${VERSION}",
|
||||
"scripts": {
|
||||
"build": "tsc"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "latest",
|
||||
"ts-node": "latest",
|
||||
"typescript": "^4.3.5"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@pulumi/pulumi": "latest"
|
||||
},
|
||||
"pulumi": {
|
||||
"resource": true
|
||||
}
|
||||
}
|
46
pkg/codegen/internal/test/testdata/regress-node-8110/nodejs/provider.ts
vendored
Normal file
46
pkg/codegen/internal/test/testdata/regress-node-8110/nodejs/provider.ts
vendored
Normal file
|
@ -0,0 +1,46 @@
|
|||
// *** WARNING: this file was generated by test. ***
|
||||
// *** Do not edit by hand unless you're certain you know what you are doing! ***
|
||||
|
||||
import * as pulumi from "@pulumi/pulumi";
|
||||
import * as utilities from "./utilities";
|
||||
|
||||
export class Provider extends pulumi.ProviderResource {
|
||||
/** @internal */
|
||||
public static readonly __pulumiType = 'my8110';
|
||||
|
||||
/**
|
||||
* 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 inputs: pulumi.Inputs = {};
|
||||
opts = opts || {};
|
||||
{
|
||||
}
|
||||
if (!opts.version) {
|
||||
opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()});
|
||||
}
|
||||
super(Provider.__pulumiType, name, inputs, opts);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The set of arguments for constructing a Provider resource.
|
||||
*/
|
||||
export interface ProviderArgs {
|
||||
}
|
26
pkg/codegen/internal/test/testdata/regress-node-8110/nodejs/tsconfig.json
vendored
Normal file
26
pkg/codegen/internal/test/testdata/regress-node-8110/nodejs/tsconfig.json
vendored
Normal file
|
@ -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": [
|
||||
"compileCheck.ts",
|
||||
"exampleFunc.ts",
|
||||
"index.ts",
|
||||
"provider.ts",
|
||||
"types/enums/index.ts",
|
||||
"types/index.ts",
|
||||
"types/input.ts",
|
||||
"types/output.ts",
|
||||
"utilities.ts"
|
||||
]
|
||||
}
|
10
pkg/codegen/internal/test/testdata/regress-node-8110/nodejs/types/enums/index.ts
vendored
Normal file
10
pkg/codegen/internal/test/testdata/regress-node-8110/nodejs/types/enums/index.ts
vendored
Normal file
|
@ -0,0 +1,10 @@
|
|||
// *** WARNING: this file was generated by test. ***
|
||||
// *** Do not edit by hand unless you're certain you know what you are doing! ***
|
||||
|
||||
|
||||
export const MyEnum = {
|
||||
One: "one",
|
||||
Two: "two",
|
||||
} as const;
|
||||
|
||||
export type MyEnum = (typeof MyEnum)[keyof typeof MyEnum];
|
13
pkg/codegen/internal/test/testdata/regress-node-8110/nodejs/types/index.ts
vendored
Normal file
13
pkg/codegen/internal/test/testdata/regress-node-8110/nodejs/types/index.ts
vendored
Normal file
|
@ -0,0 +1,13 @@
|
|||
// *** 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 enums from "./enums";
|
||||
import * as input from "./input";
|
||||
import * as output from "./output";
|
||||
|
||||
export {
|
||||
enums,
|
||||
input,
|
||||
output,
|
||||
};
|
6
pkg/codegen/internal/test/testdata/regress-node-8110/nodejs/types/input.ts
vendored
Normal file
6
pkg/codegen/internal/test/testdata/regress-node-8110/nodejs/types/input.ts
vendored
Normal file
|
@ -0,0 +1,6 @@
|
|||
// *** 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, enums } from "../types";
|
||||
|
6
pkg/codegen/internal/test/testdata/regress-node-8110/nodejs/types/output.ts
vendored
Normal file
6
pkg/codegen/internal/test/testdata/regress-node-8110/nodejs/types/output.ts
vendored
Normal file
|
@ -0,0 +1,6 @@
|
|||
// *** 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, enums } from "../types";
|
||||
|
49
pkg/codegen/internal/test/testdata/regress-node-8110/nodejs/utilities.ts
vendored
Normal file
49
pkg/codegen/internal/test/testdata/regress-node-8110/nodejs/utilities.ts
vendored
Normal file
|
@ -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;
|
||||
}
|
12
pkg/codegen/internal/test/testdata/regress-node-8110/python/codegen-manifest.json
vendored
Normal file
12
pkg/codegen/internal/test/testdata/regress-node-8110/python/codegen-manifest.json
vendored
Normal file
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"emittedFiles": [
|
||||
"pulumi_my8110/README.md",
|
||||
"pulumi_my8110/__init__.py",
|
||||
"pulumi_my8110/_enums.py",
|
||||
"pulumi_my8110/_utilities.py",
|
||||
"pulumi_my8110/example_func.py",
|
||||
"pulumi_my8110/provider.py",
|
||||
"pulumi_my8110/py.typed",
|
||||
"setup.py"
|
||||
]
|
||||
}
|
0
pkg/codegen/internal/test/testdata/regress-node-8110/python/pulumi_my8110/README.md
vendored
Normal file
0
pkg/codegen/internal/test/testdata/regress-node-8110/python/pulumi_my8110/README.md
vendored
Normal file
25
pkg/codegen/internal/test/testdata/regress-node-8110/python/pulumi_my8110/__init__.py
vendored
Normal file
25
pkg/codegen/internal/test/testdata/regress-node-8110/python/pulumi_my8110/__init__.py
vendored
Normal file
|
@ -0,0 +1,25 @@
|
|||
# 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 ._enums import *
|
||||
from .example_func import *
|
||||
from .provider import *
|
||||
_utilities.register(
|
||||
resource_modules="""
|
||||
[]
|
||||
""",
|
||||
resource_packages="""
|
||||
[
|
||||
{
|
||||
"pkg": "my8110",
|
||||
"token": "pulumi:providers:my8110",
|
||||
"fqn": "pulumi_my8110",
|
||||
"class": "Provider"
|
||||
}
|
||||
]
|
||||
"""
|
||||
)
|
14
pkg/codegen/internal/test/testdata/regress-node-8110/python/pulumi_my8110/_enums.py
vendored
Normal file
14
pkg/codegen/internal/test/testdata/regress-node-8110/python/pulumi_my8110/_enums.py
vendored
Normal file
|
@ -0,0 +1,14 @@
|
|||
# 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 enum import Enum
|
||||
|
||||
__all__ = [
|
||||
'MyEnum',
|
||||
]
|
||||
|
||||
|
||||
class MyEnum(str, Enum):
|
||||
ONE = "one"
|
||||
TWO = "two"
|
235
pkg/codegen/internal/test/testdata/regress-node-8110/python/pulumi_my8110/_utilities.py
vendored
Normal file
235
pkg/codegen/internal/test/testdata/regress-node-8110/python/pulumi_my8110/_utilities.py
vendored
Normal file
|
@ -0,0 +1,235 @@
|
|||
# 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
|
||||
# <some module>._utilities. <some module> 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)
|
||||
|
||||
return pulumi.Output.from_input({
|
||||
'args': bound_args.args,
|
||||
'kwargs': bound_args.kwargs
|
||||
}).apply(lambda resolved_args: func(*resolved_args['args'],
|
||||
opts=opts,
|
||||
**resolved_args['kwargs']))
|
||||
|
||||
return (lambda _: lifted_func)
|
28
pkg/codegen/internal/test/testdata/regress-node-8110/python/pulumi_my8110/example_func.py
vendored
Normal file
28
pkg/codegen/internal/test/testdata/regress-node-8110/python/pulumi_my8110/example_func.py
vendored
Normal file
|
@ -0,0 +1,28 @@
|
|||
# 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 ._enums import *
|
||||
|
||||
__all__ = [
|
||||
'example_func',
|
||||
]
|
||||
|
||||
def example_func(enums: Optional[Sequence[Union[str, 'MyEnum']]] = None,
|
||||
opts: Optional[pulumi.InvokeOptions] = None):
|
||||
"""
|
||||
Use this data source to access information about an existing resource.
|
||||
"""
|
||||
__args__ = dict()
|
||||
__args__['enums'] = enums
|
||||
if opts is None:
|
||||
opts = pulumi.InvokeOptions()
|
||||
if opts.version is None:
|
||||
opts.version = _utilities.get_version()
|
||||
__ret__ = pulumi.runtime.invoke('my8110::exampleFunc', __args__, opts=opts).value
|
||||
|
73
pkg/codegen/internal/test/testdata/regress-node-8110/python/pulumi_my8110/provider.py
vendored
Normal file
73
pkg/codegen/internal/test/testdata/regress-node-8110/python/pulumi_my8110/provider.py
vendored
Normal file
|
@ -0,0 +1,73 @@
|
|||
# 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__ = ['ProviderArgs', 'Provider']
|
||||
|
||||
@pulumi.input_type
|
||||
class ProviderArgs:
|
||||
def __init__(__self__):
|
||||
"""
|
||||
The set of arguments for constructing a Provider resource.
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
class Provider(pulumi.ProviderResource):
|
||||
@overload
|
||||
def __init__(__self__,
|
||||
resource_name: str,
|
||||
opts: Optional[pulumi.ResourceOptions] = None,
|
||||
__props__=None):
|
||||
"""
|
||||
Create a My8110 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[ProviderArgs] = None,
|
||||
opts: Optional[pulumi.ResourceOptions] = None):
|
||||
"""
|
||||
Create a My8110 resource with the given unique name, props, and options.
|
||||
: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,
|
||||
__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)
|
||||
|
||||
super(Provider, __self__).__init__(
|
||||
'my8110',
|
||||
resource_name,
|
||||
__props__,
|
||||
opts)
|
||||
|
0
pkg/codegen/internal/test/testdata/regress-node-8110/python/pulumi_my8110/py.typed
vendored
Normal file
0
pkg/codegen/internal/test/testdata/regress-node-8110/python/pulumi_my8110/py.typed
vendored
Normal file
58
pkg/codegen/internal/test/testdata/regress-node-8110/python/setup.py
vendored
Normal file
58
pkg/codegen/internal/test/testdata/regress-node-8110/python/setup.py
vendored
Normal file
|
@ -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', 'my8110', PLUGIN_VERSION])
|
||||
except OSError as error:
|
||||
if error.errno == errno.ENOENT:
|
||||
print(f"""
|
||||
There was an error installing the my8110 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 my8110 {PLUGIN_VERSION}`
|
||||
""")
|
||||
else:
|
||||
raise
|
||||
|
||||
|
||||
def readme():
|
||||
try:
|
||||
with open('README.md', encoding='utf-8') as f:
|
||||
return f.read()
|
||||
except FileNotFoundError:
|
||||
return "my8110 Pulumi Package - Development Version"
|
||||
|
||||
|
||||
setup(name='pulumi_my8110',
|
||||
version=VERSION,
|
||||
long_description=readme(),
|
||||
long_description_content_type='text/markdown',
|
||||
cmdclass={
|
||||
'install': InstallPluginCommand,
|
||||
},
|
||||
packages=find_packages(),
|
||||
package_data={
|
||||
'pulumi_my8110': [
|
||||
'py.typed',
|
||||
]
|
||||
},
|
||||
install_requires=[
|
||||
'parver>=0.2.1',
|
||||
'pulumi',
|
||||
'semver>=2.8.1'
|
||||
],
|
||||
zip_safe=False)
|
63
pkg/codegen/internal/test/testdata/regress-node-8110/schema.json
vendored
Normal file
63
pkg/codegen/internal/test/testdata/regress-node-8110/schema.json
vendored
Normal file
|
@ -0,0 +1,63 @@
|
|||
{
|
||||
"name": "my8110",
|
||||
"version": "0.0.1",
|
||||
"functions": {
|
||||
"my8110::exampleFunc": {
|
||||
"inputs": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"enums": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"oneOf": [
|
||||
{
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"$ref": "#/types/my8110::MyEnum"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"types": {
|
||||
"my8110::MyEnum": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
{
|
||||
"value": "one"
|
||||
},
|
||||
{
|
||||
"value": "two"
|
||||
}
|
||||
]
|
||||
},
|
||||
"my8110::MyObj": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"a": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"language": {
|
||||
"csharp": {
|
||||
"packageReferences": {
|
||||
"Pulumi": "3.12"
|
||||
}
|
||||
},
|
||||
"nodejs": {
|
||||
"devDependencies": {
|
||||
"@types/node": "latest",
|
||||
"ts-node": "latest"
|
||||
},
|
||||
"extraTypeScriptFiles": [
|
||||
"compileCheck.ts"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
222
pkg/codegen/internal/tstypes/tstypes.go
Normal file
222
pkg/codegen/internal/tstypes/tstypes.go
Normal file
|
@ -0,0 +1,222 @@
|
|||
// Copyright 2016-2021, Pulumi Corporation.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
// Helper code to assist emitting correctly minimally parenthesized
|
||||
// TypeScript type literals.
|
||||
package tstypes
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
)
|
||||
|
||||
// Supported types include type identifiers, arrays `T[]`, unions
|
||||
// `A|B`, and maps with string keys.
|
||||
type TypeAst interface {
|
||||
depth() int
|
||||
}
|
||||
|
||||
// Produces a TypeScript type literal for the type, with minimally
|
||||
// inserted parentheses.
|
||||
func TypeLiteral(ast TypeAst) string {
|
||||
tokens := (&typeScriptTypeUnparser{}).unparse(ast)
|
||||
return toLiteral(tokens)
|
||||
}
|
||||
|
||||
// Builds a type identifier (possibly qualified such as
|
||||
// "my.module.MyType") or a primitive such as "boolean".
|
||||
func Identifier(id string) TypeAst {
|
||||
return &idType{id}
|
||||
}
|
||||
|
||||
// Builds a `T[]` type from a `T` type.
|
||||
func Array(t TypeAst) TypeAst {
|
||||
return &arrayType{t}
|
||||
}
|
||||
|
||||
// Builds a `{[key: string]: T}` type from a `T` type.
|
||||
func StringMap(t TypeAst) TypeAst {
|
||||
return &mapType{t}
|
||||
}
|
||||
|
||||
// Builds a union `A | B | C` type.
|
||||
func Union(t ...TypeAst) TypeAst {
|
||||
if len(t) == 0 {
|
||||
panic("At least one type is needed to form a Union, none are given")
|
||||
}
|
||||
if len(t) == 1 {
|
||||
return t[0]
|
||||
}
|
||||
return &unionType{t[0], t[1], t[2:]}
|
||||
}
|
||||
|
||||
// Normalizes by unnesting unions `A | (B | C) => A | B | C`.
|
||||
func Normalize(ast TypeAst) TypeAst {
|
||||
return transform(ast, func(t TypeAst) TypeAst {
|
||||
switch v := t.(type) {
|
||||
case *unionType:
|
||||
var all []TypeAst
|
||||
for _, e := range v.all() {
|
||||
switch ev := e.(type) {
|
||||
case *unionType:
|
||||
all = append(all, ev.all()...)
|
||||
default:
|
||||
all = append(all, ev)
|
||||
}
|
||||
}
|
||||
return Union(all...)
|
||||
default:
|
||||
return t
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func transform(t TypeAst, f func(x TypeAst) TypeAst) TypeAst {
|
||||
switch v := t.(type) {
|
||||
case *unionType:
|
||||
var ts []TypeAst
|
||||
for _, x := range v.all() {
|
||||
ts = append(ts, transform(x, f))
|
||||
}
|
||||
return f(Union(ts...))
|
||||
case *arrayType:
|
||||
return f(&arrayType{transform(v.arrayElement, f)})
|
||||
case *mapType:
|
||||
return f(&mapType{transform(v.mapElement, f)})
|
||||
default:
|
||||
return f(t)
|
||||
}
|
||||
}
|
||||
|
||||
type idType struct {
|
||||
id string
|
||||
}
|
||||
|
||||
func (*idType) depth() int {
|
||||
return 1
|
||||
}
|
||||
|
||||
var _ TypeAst = &idType{}
|
||||
|
||||
type mapType struct {
|
||||
mapElement TypeAst
|
||||
}
|
||||
|
||||
func (t *mapType) depth() int {
|
||||
return t.mapElement.depth() + 1
|
||||
}
|
||||
|
||||
var _ TypeAst = &mapType{}
|
||||
|
||||
type arrayType struct {
|
||||
arrayElement TypeAst
|
||||
}
|
||||
|
||||
func (t *arrayType) depth() int {
|
||||
return t.arrayElement.depth() + 1
|
||||
}
|
||||
|
||||
var _ TypeAst = &arrayType{}
|
||||
|
||||
type unionType struct {
|
||||
t1 TypeAst
|
||||
t2 TypeAst
|
||||
tRest []TypeAst
|
||||
}
|
||||
|
||||
func (t *unionType) all() []TypeAst {
|
||||
return append([]TypeAst{t.t1, t.t2}, t.tRest...)
|
||||
}
|
||||
|
||||
func (t *unionType) depth() int {
|
||||
var maxDepth = 0
|
||||
for _, t := range t.all() {
|
||||
d := t.depth()
|
||||
if d > maxDepth {
|
||||
maxDepth = d
|
||||
}
|
||||
}
|
||||
return maxDepth
|
||||
}
|
||||
|
||||
var _ TypeAst = &unionType{}
|
||||
|
||||
type typeTokenKind string
|
||||
|
||||
const (
|
||||
openParen typeTokenKind = "("
|
||||
closeParen = ")"
|
||||
openMap = "{[key: string]: "
|
||||
closeMap = "}"
|
||||
identifier = "x"
|
||||
array = "[]"
|
||||
union = " | "
|
||||
)
|
||||
|
||||
type typeToken struct {
|
||||
kind typeTokenKind
|
||||
value string
|
||||
}
|
||||
|
||||
type typeScriptTypeUnparser struct{}
|
||||
|
||||
func (u typeScriptTypeUnparser) unparse(ast TypeAst) []typeToken {
|
||||
switch v := ast.(type) {
|
||||
case *idType:
|
||||
return []typeToken{{identifier, v.id}}
|
||||
case *arrayType:
|
||||
return append(u.unparseWithUnionParens(v.arrayElement), typeToken{array, ""})
|
||||
case *mapType:
|
||||
return append([]typeToken{{openMap, ""}}, append(u.unparse(v.mapElement), typeToken{closeMap, ""})...)
|
||||
case *unionType:
|
||||
var tokens []typeToken
|
||||
for i, t := range v.all() {
|
||||
if i > 0 {
|
||||
tokens = append(tokens, typeToken{union, ""})
|
||||
}
|
||||
tokens = append(tokens, u.unparseWithUnionParens(t)...)
|
||||
}
|
||||
return tokens
|
||||
default:
|
||||
panic("Unknown object of type typeAst")
|
||||
}
|
||||
}
|
||||
|
||||
func (u typeScriptTypeUnparser) unparseWithUnionParens(ast TypeAst) []typeToken {
|
||||
var parens bool
|
||||
switch ast.(type) {
|
||||
case *unionType:
|
||||
parens = true
|
||||
}
|
||||
tokens := u.unparse(ast)
|
||||
if parens {
|
||||
return u.parenthesize(tokens)
|
||||
}
|
||||
return tokens
|
||||
}
|
||||
|
||||
func (u typeScriptTypeUnparser) parenthesize(tokens []typeToken) []typeToken {
|
||||
return append([]typeToken{{openParen, ""}}, append(tokens, typeToken{closeParen, ""})...)
|
||||
}
|
||||
|
||||
func toLiteral(tokens []typeToken) string {
|
||||
var buffer bytes.Buffer
|
||||
for _, t := range tokens {
|
||||
if t.value != "" {
|
||||
buffer.WriteString(t.value)
|
||||
} else {
|
||||
buffer.WriteString(string(t.kind))
|
||||
}
|
||||
}
|
||||
return buffer.String()
|
||||
}
|
181
pkg/codegen/internal/tstypes/tstypes_test.go
Normal file
181
pkg/codegen/internal/tstypes/tstypes_test.go
Normal file
|
@ -0,0 +1,181 @@
|
|||
// Copyright 2016-2021, Pulumi Corporation.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package tstypes
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/davecgh/go-spew/spew"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"pgregory.net/rapid"
|
||||
)
|
||||
|
||||
func TestParenInsert(t *testing.T) {
|
||||
ast := astGenerator()
|
||||
rapid.Check(t, func(t *rapid.T) {
|
||||
example := ast.Draw(t, "ast").(TypeAst)
|
||||
|
||||
t.Logf("example: %s", spew.Sdump(example))
|
||||
t.Logf("example type: %s", TypeLiteral(example))
|
||||
|
||||
tokens := (&typeScriptTypeUnparser{}).unparse(example)
|
||||
|
||||
parsed, err := (&typeScriptTypeParser{}).parse(tokens)
|
||||
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
return
|
||||
}
|
||||
t.Logf("parsed: %s", spew.Sdump(parsed))
|
||||
assert.Equal(t, example, parsed)
|
||||
})
|
||||
}
|
||||
|
||||
func astGenerator() *rapid.Generator {
|
||||
names := rapid.OneOf(rapid.Just("x"), rapid.Just("y"))
|
||||
|
||||
var ast func(depth int) *rapid.Generator
|
||||
ast = func(depth int) *rapid.Generator {
|
||||
if depth <= 1 {
|
||||
return rapid.Custom(func(t *rapid.T) TypeAst {
|
||||
n := names.Draw(t, "name").(string)
|
||||
return &idType{n}
|
||||
})
|
||||
}
|
||||
|
||||
sub := ast(depth - 1)
|
||||
subs := rapid.SliceOfN(sub, 2, 4)
|
||||
|
||||
mapGen := rapid.Custom(func(t *rapid.T) TypeAst {
|
||||
element := sub.Draw(t, "ast").(TypeAst)
|
||||
return &mapType{element}
|
||||
})
|
||||
|
||||
arrGen := rapid.Custom(func(t *rapid.T) TypeAst {
|
||||
element := sub.Draw(t, "ast").(TypeAst)
|
||||
return &arrayType{element}
|
||||
})
|
||||
|
||||
unionGen := rapid.Custom(func(t *rapid.T) TypeAst {
|
||||
ts := subs.Draw(t, "asts").([]TypeAst)
|
||||
return &unionType{ts[0], ts[1], ts[2:]}
|
||||
})
|
||||
|
||||
return rapid.OneOf(mapGen, arrGen, unionGen)
|
||||
}
|
||||
|
||||
n := rapid.IntRange(1, 3)
|
||||
return rapid.Custom(func(t *rapid.T) TypeAst {
|
||||
sz := n.Draw(t, "n").(int)
|
||||
return ast(sz).Draw(t, "ast").(TypeAst)
|
||||
})
|
||||
}
|
||||
|
||||
type typeScriptTypeParser struct{}
|
||||
|
||||
func (p *typeScriptTypeParser) parse(tokens []typeToken) (TypeAst, error) {
|
||||
e, rest, err := p.parseType(tokens)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(rest) > 0 {
|
||||
return nil, fmt.Errorf("Unexpected trailing tokens")
|
||||
}
|
||||
return e, nil
|
||||
}
|
||||
|
||||
func (p *typeScriptTypeParser) parseType(tokens []typeToken) (TypeAst, []typeToken, error) {
|
||||
return p.parseType3(tokens)
|
||||
}
|
||||
|
||||
func (p *typeScriptTypeParser) parseType1(tokens []typeToken) (TypeAst, []typeToken, error) {
|
||||
if len(tokens) == 0 {
|
||||
return nil, nil, fmt.Errorf("Expect more tokens")
|
||||
}
|
||||
|
||||
switch tokens[0].kind {
|
||||
case openParen:
|
||||
t, rest, err := p.parseType(tokens[1:])
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
if len(rest) == 0 || rest[0].kind != closeParen {
|
||||
return nil, nil, fmt.Errorf("Expect `)`")
|
||||
}
|
||||
return t, rest[1:], nil
|
||||
case openMap:
|
||||
t, rest, err := p.parseType(tokens[1:])
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
if len(rest) == 0 {
|
||||
return nil, nil, fmt.Errorf("Expect `}`, but got nothing")
|
||||
}
|
||||
if rest[0].kind != closeMap {
|
||||
return nil, nil, fmt.Errorf("Expect `}`, but got %s", toLiteral(rest))
|
||||
}
|
||||
return &mapType{t}, rest[1:], nil
|
||||
case identifier:
|
||||
return &idType{tokens[0].value}, tokens[1:], nil
|
||||
default:
|
||||
return nil, nil, fmt.Errorf("Unexpected token kind: %v", tokens[0].kind)
|
||||
}
|
||||
}
|
||||
|
||||
func (p *typeScriptTypeParser) parseType2(tokens []typeToken) (TypeAst, []typeToken, error) {
|
||||
t, tokens2, err := p.parseType1(tokens)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
t2, tokens3 := p.parseArraySuffix(t, tokens2)
|
||||
return t2, tokens3, nil
|
||||
}
|
||||
|
||||
func (p *typeScriptTypeParser) parseType3(tokens []typeToken) (TypeAst, []typeToken, error) {
|
||||
t, tokens2, err := p.parseType2(tokens)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
return p.parseUnionSuffix(t, tokens2)
|
||||
}
|
||||
|
||||
func (p *typeScriptTypeParser) parseArraySuffix(expr TypeAst, tokens []typeToken) (TypeAst, []typeToken) {
|
||||
for len(tokens) > 0 && tokens[0].kind == array {
|
||||
expr = &arrayType{expr}
|
||||
tokens = tokens[1:]
|
||||
}
|
||||
return expr, tokens
|
||||
}
|
||||
|
||||
func (p typeScriptTypeParser) parseUnionSuffix(expr TypeAst, tokens []typeToken) (TypeAst, []typeToken, error) {
|
||||
exprs := []TypeAst{}
|
||||
|
||||
for len(tokens) > 0 && tokens[0].kind == union {
|
||||
extraExpr, rest, err := p.parseType2(tokens[1:])
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
exprs = append(exprs, extraExpr)
|
||||
tokens = rest
|
||||
}
|
||||
|
||||
if len(exprs) == 0 {
|
||||
return expr, tokens, nil
|
||||
}
|
||||
|
||||
return &unionType{expr, exprs[0], exprs[1:]}, tokens, nil
|
||||
}
|
|
@ -34,7 +34,9 @@ import (
|
|||
"github.com/pkg/errors"
|
||||
|
||||
"github.com/pulumi/pulumi/pkg/v3/codegen"
|
||||
"github.com/pulumi/pulumi/pkg/v3/codegen/internal/tstypes"
|
||||
"github.com/pulumi/pulumi/pkg/v3/codegen/schema"
|
||||
|
||||
"github.com/pulumi/pulumi/sdk/v3/go/common/diag"
|
||||
"github.com/pulumi/pulumi/sdk/v3/go/common/util/cmdutil"
|
||||
"github.com/pulumi/pulumi/sdk/v3/go/common/util/contract"
|
||||
|
@ -267,66 +269,75 @@ func tokenToFunctionName(tok string) string {
|
|||
return camel(tokenToName(tok))
|
||||
}
|
||||
|
||||
func (mod *modContext) typeString(t schema.Type, input bool, constValue interface{}) string {
|
||||
func (mod *modContext) typeAst(t schema.Type, input bool, constValue interface{}) tstypes.TypeAst {
|
||||
switch t := t.(type) {
|
||||
case *schema.OptionalType:
|
||||
return mod.typeString(t.ElementType, input, constValue) + " | undefined"
|
||||
return tstypes.Union(
|
||||
mod.typeAst(t.ElementType, input, constValue),
|
||||
tstypes.Identifier("undefined"),
|
||||
)
|
||||
case *schema.InputType:
|
||||
typ := mod.typeString(codegen.SimplifyInputUnion(t.ElementType), input, constValue)
|
||||
if typ == "any" {
|
||||
return typ
|
||||
return tstypes.Identifier("any")
|
||||
}
|
||||
return fmt.Sprintf("pulumi.Input<%s>", typ)
|
||||
return tstypes.Identifier(fmt.Sprintf("pulumi.Input<%s>", typ))
|
||||
case *schema.EnumType:
|
||||
return mod.objectType(nil, t.Token, input, false, true)
|
||||
return tstypes.Identifier(mod.objectType(nil, t.Token, input, false, true))
|
||||
case *schema.ArrayType:
|
||||
return mod.typeString(t.ElementType, input, constValue) + "[]"
|
||||
return tstypes.Array(mod.typeAst(t.ElementType, input, constValue))
|
||||
case *schema.MapType:
|
||||
return fmt.Sprintf("{[key: string]: %v}", mod.typeString(t.ElementType, input, constValue))
|
||||
return tstypes.StringMap(mod.typeAst(t.ElementType, input, constValue))
|
||||
case *schema.ObjectType:
|
||||
return mod.objectType(t.Package, t.Token, input, t.IsInputShape(), false)
|
||||
return tstypes.Identifier(mod.objectType(t.Package, t.Token, input, t.IsInputShape(), false))
|
||||
case *schema.ResourceType:
|
||||
return mod.resourceType(t)
|
||||
return tstypes.Identifier(mod.resourceType(t))
|
||||
case *schema.TokenType:
|
||||
return tokenToName(t.Token)
|
||||
return tstypes.Identifier(tokenToName(t.Token))
|
||||
case *schema.UnionType:
|
||||
if !input && mod.disableUnionOutputTypes {
|
||||
if t.DefaultType != nil {
|
||||
return mod.typeString(t.DefaultType, input, constValue)
|
||||
return mod.typeAst(t.DefaultType, input, constValue)
|
||||
}
|
||||
return "any"
|
||||
return tstypes.Identifier("any")
|
||||
}
|
||||
|
||||
elements := make([]string, len(t.ElementTypes))
|
||||
elements := make([]tstypes.TypeAst, len(t.ElementTypes))
|
||||
for i, e := range t.ElementTypes {
|
||||
elements[i] = mod.typeString(e, input, constValue)
|
||||
elements[i] = mod.typeAst(e, input, constValue)
|
||||
}
|
||||
return strings.Join(elements, " | ")
|
||||
return tstypes.Union(elements...)
|
||||
default:
|
||||
switch t {
|
||||
case schema.BoolType:
|
||||
return "boolean"
|
||||
return tstypes.Identifier("boolean")
|
||||
case schema.IntType, schema.NumberType:
|
||||
return "number"
|
||||
return tstypes.Identifier("number")
|
||||
case schema.StringType:
|
||||
if constValue != nil {
|
||||
return fmt.Sprintf("%q", constValue.(string))
|
||||
return tstypes.Identifier(fmt.Sprintf("%q", constValue.(string)))
|
||||
}
|
||||
return "string"
|
||||
return tstypes.Identifier("string")
|
||||
case schema.ArchiveType:
|
||||
return "pulumi.asset.Archive"
|
||||
return tstypes.Identifier("pulumi.asset.Archive")
|
||||
case schema.AssetType:
|
||||
return "pulumi.asset.Asset | pulumi.asset.Archive"
|
||||
return tstypes.Union(
|
||||
tstypes.Identifier("pulumi.asset.Asset"),
|
||||
tstypes.Identifier("pulumi.asset.Archive"),
|
||||
)
|
||||
case schema.JSONType:
|
||||
fallthrough
|
||||
case schema.AnyType:
|
||||
return "any"
|
||||
return tstypes.Identifier("any")
|
||||
}
|
||||
}
|
||||
|
||||
panic(fmt.Errorf("unexpected type %T", t))
|
||||
}
|
||||
|
||||
func (mod *modContext) typeString(t schema.Type, input bool, constValue interface{}) string {
|
||||
return tstypes.TypeLiteral(tstypes.Normalize(mod.typeAst(t, input, constValue)))
|
||||
}
|
||||
|
||||
func isStringType(t schema.Type) bool {
|
||||
t = codegen.UnwrapType(t)
|
||||
|
||||
|
@ -1964,6 +1975,8 @@ func genTypeScriptProjectFile(info NodePackageInfo, files fs) string {
|
|||
tsFiles = append(tsFiles, f)
|
||||
}
|
||||
}
|
||||
|
||||
tsFiles = append(tsFiles, info.ExtraTypeScriptFiles...)
|
||||
sort.Strings(tsFiles)
|
||||
|
||||
for i, file := range tsFiles {
|
||||
|
|
|
@ -58,6 +58,12 @@ type NodePackageInfo struct {
|
|||
PluginName string `json:"pluginName,omitempty"`
|
||||
// The version of the plugin, which might be different from the version of the package..
|
||||
PluginVersion string `json:"pluginVersion,omitempty"`
|
||||
// Additional files to include in TypeScript compilation.
|
||||
// These paths are added to the `files` section of the
|
||||
// generated `tsconfig.json`. A typical use case for this is
|
||||
// compiling hand-authored unit test files that check the
|
||||
// generated code.
|
||||
ExtraTypeScriptFiles []string `json:"extraTypeScriptFiles,omitempty"`
|
||||
// Determines whether to make single-return-value methods return an output object or the single value.
|
||||
LiftSingleValueMethodReturns bool `json:"liftSingleValueMethodReturns,omitempty"`
|
||||
}
|
||||
|
|
|
@ -430,7 +430,14 @@ func (mod *modContext) gen(fs fs) error {
|
|||
fs.add(filepath.Join(dir, "py.typed"), []byte{})
|
||||
|
||||
// Ensure that the top-level (provider) module directory contains a README.md file.
|
||||
readme := mod.pkg.Language["python"].(PackageInfo).Readme
|
||||
|
||||
var readme string
|
||||
if pythonInfo, ok := mod.pkg.Language["python"]; ok {
|
||||
if typedInfo, ok := pythonInfo.(PackageInfo); ok {
|
||||
readme = typedInfo.Readme
|
||||
}
|
||||
}
|
||||
|
||||
if readme == "" {
|
||||
readme = mod.pkg.Description
|
||||
if readme != "" && readme[len(readme)-1] != '\n' {
|
||||
|
|
|
@ -13,6 +13,7 @@ require (
|
|||
github.com/StackExchange/wmi v1.2.1 // indirect
|
||||
github.com/aws/aws-sdk-go v1.38.35
|
||||
github.com/blang/semver v3.5.1+incompatible
|
||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||
github.com/djherbis/times v1.2.0
|
||||
github.com/docker/docker v1.4.2-0.20200319182547-c7ad2b866182
|
||||
github.com/dustin/go-humanize v1.0.0
|
||||
|
|
Loading…
Reference in a new issue