[codegen/go] allow plain default types (#8254)
* Respect `plain` when generating default values. * Add new test * Simplify test case * Add indirection to allow taking references * Reflect indirection problem in tests * Remove Plain fields. Base off of primitive type * Reenable docs * Update changelog * Implement always default solution * Fix test by pulling in master * Add enum test and cleanup * Fix const handling * Clarify the changelog
This commit is contained in:
parent
2f433d64b7
commit
530641576d
|
@ -13,5 +13,8 @@
|
|||
|
||||
### Bug Fixes
|
||||
|
||||
- [codegen/go] - Interaction between the `plain` and `default` tags of a type.
|
||||
[#8254](https://github.com/pulumi/pulumi/pull/8254)
|
||||
|
||||
- [sdk/dotnet] - Fix a race condition when detecting exceptions in stack creation
|
||||
[#8294](https://github.com/pulumi/pulumi/pull/8294)
|
||||
|
|
|
@ -297,6 +297,23 @@ func isNilType(t schema.Type) bool {
|
|||
return false
|
||||
}
|
||||
|
||||
// The default value for a Pulumi primitive type.
|
||||
func primitiveNilValue(t schema.Type) string {
|
||||
contract.Assert(schema.IsPrimitiveType(t))
|
||||
switch t {
|
||||
case schema.BoolType:
|
||||
return "false"
|
||||
case schema.IntType:
|
||||
return "0"
|
||||
case schema.NumberType:
|
||||
return "0.0"
|
||||
case schema.StringType:
|
||||
return "\"\""
|
||||
default:
|
||||
return "nil"
|
||||
}
|
||||
}
|
||||
|
||||
func (pkg *pkgContext) inputType(t schema.Type) (result string) {
|
||||
switch t := codegen.SimplifyInputUnion(t).(type) {
|
||||
case *schema.OptionalType:
|
||||
|
@ -1284,7 +1301,11 @@ func goPrimitiveValue(value interface{}) (string, error) {
|
|||
case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32:
|
||||
return strconv.FormatUint(v.Uint(), 10), nil
|
||||
case reflect.Float32, reflect.Float64:
|
||||
return strconv.FormatFloat(v.Float(), 'f', -1, 64), nil
|
||||
value := strconv.FormatFloat(v.Float(), 'f', -1, 64)
|
||||
if !strings.ContainsRune(value, '.') {
|
||||
value += ".0"
|
||||
}
|
||||
return value, nil
|
||||
case reflect.String:
|
||||
return fmt.Sprintf("%q", v.String()), nil
|
||||
default:
|
||||
|
@ -1404,42 +1425,48 @@ func (pkg *pkgContext) genResource(w io.Writer, r *schema.Resource, generateReso
|
|||
}
|
||||
}
|
||||
|
||||
assign := func(p *schema.Property, value string, indentation int) {
|
||||
ind := strings.Repeat("\t", indentation)
|
||||
t := strings.TrimSuffix(pkg.typeString(p.Type), "Input")
|
||||
switch codegen.UnwrapType(p.Type).(type) {
|
||||
case *schema.EnumType:
|
||||
t = strings.TrimSuffix(t, "Ptr")
|
||||
}
|
||||
if t == "pulumi." {
|
||||
t = "pulumi.Any"
|
||||
}
|
||||
|
||||
if codegen.IsNOptionalInput(p.Type) {
|
||||
fmt.Fprintf(w, "\targs.%s = %s(%s)\n", Title(p.Name), t, value)
|
||||
} else if isNilType(p.Type) {
|
||||
tmpName := camel(p.Name) + "_"
|
||||
fmt.Fprintf(w, "%s%s := %s\n", ind, tmpName, value)
|
||||
fmt.Fprintf(w, "%sargs.%s = &%s\n", ind, Title(p.Name), tmpName)
|
||||
} else {
|
||||
fmt.Fprintf(w, "%sargs.%s = %s\n", ind, Title(p.Name), value)
|
||||
}
|
||||
}
|
||||
|
||||
for _, p := range r.InputProperties {
|
||||
if p.ConstValue != nil {
|
||||
v, err := pkg.getConstValue(p.ConstValue)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
t := strings.TrimSuffix(pkg.inputType(p.Type), "Input")
|
||||
if t == "pulumi." {
|
||||
t = "pulumi.Any"
|
||||
}
|
||||
|
||||
fmt.Fprintf(w, "\targs.%s = %s(%s)\n", Title(p.Name), t, v)
|
||||
}
|
||||
if p.DefaultValue != nil {
|
||||
assign(p, v, 1)
|
||||
} else if p.DefaultValue != nil {
|
||||
v, err := pkg.getDefaultValue(p.DefaultValue, codegen.UnwrapType(p.Type))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
t := strings.TrimSuffix(pkg.inputType(p.Type), "Input")
|
||||
if t == "pulumi." {
|
||||
t = "pulumi.Any"
|
||||
defaultComp := "nil"
|
||||
if !codegen.IsNOptionalInput(p.Type) && !isNilType(p.Type) {
|
||||
defaultComp = primitiveNilValue(p.Type)
|
||||
}
|
||||
fmt.Fprintf(w, "\tif args.%s == %s {\n", Title(p.Name), defaultComp)
|
||||
assign(p, v, 2)
|
||||
fmt.Fprintf(w, "\t}\n")
|
||||
|
||||
switch codegen.UnwrapType(p.Type).(type) {
|
||||
case *schema.EnumType:
|
||||
fmt.Fprintf(w, "\tif args.%s == nil {\n", Title(p.Name))
|
||||
|
||||
fmt.Fprintf(w, "\t\targs.%s = %s(%s)\n", Title(p.Name), strings.TrimSuffix(t, "Ptr"), v)
|
||||
fmt.Fprintf(w, "\t}\n")
|
||||
default:
|
||||
fmt.Fprintf(w, "\tif args.%s == nil {\n", Title(p.Name))
|
||||
fmt.Fprintf(w, "\t\targs.%s = %s(%s)\n", Title(p.Name), t, v)
|
||||
fmt.Fprintf(w, "\t}\n")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -183,6 +183,12 @@ var sdkTests = []sdkTest{
|
|||
Description: "Ensure that we handle all valid go import paths",
|
||||
Skip: codegen.NewStringSet("nodejs/test", "go/test", "python/test", "dotnet/test"),
|
||||
},
|
||||
{
|
||||
Directory: "plain-and-default",
|
||||
Description: "Ensure that a resource with a plain default property works correctly",
|
||||
Skip: codegen.NewStringSet("python/test", "nodejs/test"),
|
||||
SkipCompileCheck: codegen.NewStringSet(nodejs),
|
||||
},
|
||||
}
|
||||
|
||||
var genSDKOnly bool
|
||||
|
|
|
@ -30,7 +30,7 @@ func NewRubberTree(ctx *pulumi.Context,
|
|||
}
|
||||
|
||||
if args.Diameter == nil {
|
||||
args.Diameter = Diameter(6)
|
||||
args.Diameter = Diameter(6.0)
|
||||
}
|
||||
if args.Farm == nil {
|
||||
args.Farm = pulumi.StringPtr("(unknown)")
|
||||
|
|
29
pkg/codegen/internal/test/testdata/plain-and-default/docs/_index.md
vendored
Normal file
29
pkg/codegen/internal/test/testdata/plain-and-default/docs/_index.md
vendored
Normal file
|
@ -0,0 +1,29 @@
|
|||
---
|
||||
title: "foobar"
|
||||
title_tag: "foobar.foobar"
|
||||
meta_desc: ""
|
||||
layout: api
|
||||
no_edit_this_page: true
|
||||
---
|
||||
|
||||
<!-- 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="moduleresource" title="ModuleResource"><span class="api-symbol api-symbol--resource"></span>ModuleResource</a></li>
|
||||
<li><a href="provider" title="Provider"><span class="api-symbol api-symbol--resource"></span>Provider</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/plain-and-default/docs/codegen-manifest.json
vendored
Normal file
7
pkg/codegen/internal/test/testdata/plain-and-default/docs/codegen-manifest.json
vendored
Normal file
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"emittedFiles": [
|
||||
"_index.md",
|
||||
"moduleresource/_index.md",
|
||||
"provider/_index.md"
|
||||
]
|
||||
}
|
737
pkg/codegen/internal/test/testdata/plain-and-default/docs/moduleresource/_index.md
vendored
Normal file
737
pkg/codegen/internal/test/testdata/plain-and-default/docs/moduleresource/_index.md
vendored
Normal file
|
@ -0,0 +1,737 @@
|
|||
|
||||
---
|
||||
title: "ModuleResource"
|
||||
title_tag: "foobar.ModuleResource"
|
||||
meta_desc: "Documentation for the foobar.ModuleResource resource with examples, input properties, output properties, lookup functions, and supporting types."
|
||||
layout: api
|
||||
no_edit_this_page: true
|
||||
---
|
||||
|
||||
|
||||
|
||||
<!-- WARNING: this file was generated by test. -->
|
||||
<!-- Do not edit by hand unless you're certain you know what you are doing! -->
|
||||
|
||||
|
||||
|
||||
|
||||
## Create a ModuleResource 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">ModuleResource</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">ModuleResourceArgs</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">ModuleResource</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="nx">optional_bool</span><span class="p">:</span> <span class="nx">Optional[bool]</span> = None<span class="p">,</span>
|
||||
<span class="nx">optional_enum</span><span class="p">:</span> <span class="nx">Optional[EnumThing]</span> = None<span class="p">,</span>
|
||||
<span class="nx">optional_number</span><span class="p">:</span> <span class="nx">Optional[float]</span> = None<span class="p">,</span>
|
||||
<span class="nx">optional_string</span><span class="p">:</span> <span class="nx">Optional[str]</span> = None<span class="p">,</span>
|
||||
<span class="nx">plain_optional_bool</span><span class="p">:</span> <span class="nx">Optional[bool]</span> = None<span class="p">,</span>
|
||||
<span class="nx">plain_optional_number</span><span class="p">:</span> <span class="nx">Optional[float]</span> = None<span class="p">,</span>
|
||||
<span class="nx">plain_optional_string</span><span class="p">:</span> <span class="nx">Optional[str]</span> = None<span class="p">,</span>
|
||||
<span class="nx">plain_required_bool</span><span class="p">:</span> <span class="nx">Optional[bool]</span> = None<span class="p">,</span>
|
||||
<span class="nx">plain_required_number</span><span class="p">:</span> <span class="nx">Optional[float]</span> = None<span class="p">,</span>
|
||||
<span class="nx">plain_required_string</span><span class="p">:</span> <span class="nx">Optional[str]</span> = None<span class="p">,</span>
|
||||
<span class="nx">required_bool</span><span class="p">:</span> <span class="nx">Optional[bool]</span> = None<span class="p">,</span>
|
||||
<span class="nx">required_enum</span><span class="p">:</span> <span class="nx">Optional[EnumThing]</span> = None<span class="p">,</span>
|
||||
<span class="nx">required_number</span><span class="p">:</span> <span class="nx">Optional[float]</span> = None<span class="p">,</span>
|
||||
<span class="nx">required_string</span><span class="p">:</span> <span class="nx">Optional[str]</span> = None<span class="p">)</span>
|
||||
<span class=nd>@overload</span>
|
||||
<span class="k">def </span><span class="nx">ModuleResource</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">ModuleResourceArgs</a></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></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">NewModuleResource</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">ModuleResourceArgs</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">ModuleResource</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">ModuleResource</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">ModuleResourceArgs</a></span><span class="p"> </span><span class="nx">args<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-required" title="Required">
|
||||
<span>args</span>
|
||||
<span class="property-indicator"></span>
|
||||
<span class="property-type"><a href="#inputs">ModuleResourceArgs</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-required" title="Required">
|
||||
<span>args</span>
|
||||
<span class="property-indicator"></span>
|
||||
<span class="property-type"><a href="#inputs">ModuleResourceArgs</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-required" title="Required">
|
||||
<span>args</span>
|
||||
<span class="property-indicator"></span>
|
||||
<span class="property-type"><a href="#inputs">ModuleResourceArgs</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-required" title="Required">
|
||||
<span>args</span>
|
||||
<span class="property-indicator"></span>
|
||||
<span class="property-type"><a href="#inputs">ModuleResourceArgs</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 %}}
|
||||
|
||||
## ModuleResource 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 ModuleResource resource accepts the following [input]({{< relref "/docs/intro/concepts/inputs-outputs" >}}) properties:
|
||||
|
||||
|
||||
|
||||
{{% choosable language csharp %}}
|
||||
<dl class="resources-properties"><dt class="property-required"
|
||||
title="Required">
|
||||
<span id="plain_required_bool_csharp">
|
||||
<a href="#plain_required_bool_csharp" style="color: inherit; text-decoration: inherit;">Plain_<wbr>required_<wbr>bool</a>
|
||||
</span>
|
||||
<span class="property-indicator"></span>
|
||||
<span class="property-type">bool</span>
|
||||
</dt>
|
||||
<dd>{{% md %}}{{% /md %}}</dd><dt class="property-required"
|
||||
title="Required">
|
||||
<span id="plain_required_number_csharp">
|
||||
<a href="#plain_required_number_csharp" style="color: inherit; text-decoration: inherit;">Plain_<wbr>required_<wbr>number</a>
|
||||
</span>
|
||||
<span class="property-indicator"></span>
|
||||
<span class="property-type">double</span>
|
||||
</dt>
|
||||
<dd>{{% md %}}{{% /md %}}</dd><dt class="property-required"
|
||||
title="Required">
|
||||
<span id="plain_required_string_csharp">
|
||||
<a href="#plain_required_string_csharp" style="color: inherit; text-decoration: inherit;">Plain_<wbr>required_<wbr>string</a>
|
||||
</span>
|
||||
<span class="property-indicator"></span>
|
||||
<span class="property-type">string</span>
|
||||
</dt>
|
||||
<dd>{{% md %}}{{% /md %}}</dd><dt class="property-required"
|
||||
title="Required">
|
||||
<span id="required_bool_csharp">
|
||||
<a href="#required_bool_csharp" style="color: inherit; text-decoration: inherit;">Required_<wbr>bool</a>
|
||||
</span>
|
||||
<span class="property-indicator"></span>
|
||||
<span class="property-type">bool</span>
|
||||
</dt>
|
||||
<dd>{{% md %}}{{% /md %}}</dd><dt class="property-required"
|
||||
title="Required">
|
||||
<span id="required_enum_csharp">
|
||||
<a href="#required_enum_csharp" style="color: inherit; text-decoration: inherit;">Required_<wbr>enum</a>
|
||||
</span>
|
||||
<span class="property-indicator"></span>
|
||||
<span class="property-type"><a href="#enumthing">Pulumi.<wbr>Foo<wbr>Bar.<wbr>Enum<wbr>Thing</a></span>
|
||||
</dt>
|
||||
<dd>{{% md %}}{{% /md %}}</dd><dt class="property-required"
|
||||
title="Required">
|
||||
<span id="required_number_csharp">
|
||||
<a href="#required_number_csharp" style="color: inherit; text-decoration: inherit;">Required_<wbr>number</a>
|
||||
</span>
|
||||
<span class="property-indicator"></span>
|
||||
<span class="property-type">double</span>
|
||||
</dt>
|
||||
<dd>{{% md %}}{{% /md %}}</dd><dt class="property-required"
|
||||
title="Required">
|
||||
<span id="required_string_csharp">
|
||||
<a href="#required_string_csharp" style="color: inherit; text-decoration: inherit;">Required_<wbr>string</a>
|
||||
</span>
|
||||
<span class="property-indicator"></span>
|
||||
<span class="property-type">string</span>
|
||||
</dt>
|
||||
<dd>{{% md %}}{{% /md %}}</dd><dt class="property-optional"
|
||||
title="Optional">
|
||||
<span id="optional_bool_csharp">
|
||||
<a href="#optional_bool_csharp" style="color: inherit; text-decoration: inherit;">Optional_<wbr>bool</a>
|
||||
</span>
|
||||
<span class="property-indicator"></span>
|
||||
<span class="property-type">bool</span>
|
||||
</dt>
|
||||
<dd>{{% md %}}{{% /md %}}</dd><dt class="property-optional"
|
||||
title="Optional">
|
||||
<span id="optional_enum_csharp">
|
||||
<a href="#optional_enum_csharp" style="color: inherit; text-decoration: inherit;">Optional_<wbr>enum</a>
|
||||
</span>
|
||||
<span class="property-indicator"></span>
|
||||
<span class="property-type"><a href="#enumthing">Pulumi.<wbr>Foo<wbr>Bar.<wbr>Enum<wbr>Thing</a></span>
|
||||
</dt>
|
||||
<dd>{{% md %}}{{% /md %}}</dd><dt class="property-optional"
|
||||
title="Optional">
|
||||
<span id="optional_number_csharp">
|
||||
<a href="#optional_number_csharp" style="color: inherit; text-decoration: inherit;">Optional_<wbr>number</a>
|
||||
</span>
|
||||
<span class="property-indicator"></span>
|
||||
<span class="property-type">double</span>
|
||||
</dt>
|
||||
<dd>{{% md %}}{{% /md %}}</dd><dt class="property-optional"
|
||||
title="Optional">
|
||||
<span id="optional_string_csharp">
|
||||
<a href="#optional_string_csharp" style="color: inherit; text-decoration: inherit;">Optional_<wbr>string</a>
|
||||
</span>
|
||||
<span class="property-indicator"></span>
|
||||
<span class="property-type">string</span>
|
||||
</dt>
|
||||
<dd>{{% md %}}{{% /md %}}</dd><dt class="property-optional"
|
||||
title="Optional">
|
||||
<span id="plain_optional_bool_csharp">
|
||||
<a href="#plain_optional_bool_csharp" style="color: inherit; text-decoration: inherit;">Plain_<wbr>optional_<wbr>bool</a>
|
||||
</span>
|
||||
<span class="property-indicator"></span>
|
||||
<span class="property-type">bool</span>
|
||||
</dt>
|
||||
<dd>{{% md %}}{{% /md %}}</dd><dt class="property-optional"
|
||||
title="Optional">
|
||||
<span id="plain_optional_number_csharp">
|
||||
<a href="#plain_optional_number_csharp" style="color: inherit; text-decoration: inherit;">Plain_<wbr>optional_<wbr>number</a>
|
||||
</span>
|
||||
<span class="property-indicator"></span>
|
||||
<span class="property-type">double</span>
|
||||
</dt>
|
||||
<dd>{{% md %}}{{% /md %}}</dd><dt class="property-optional"
|
||||
title="Optional">
|
||||
<span id="plain_optional_string_csharp">
|
||||
<a href="#plain_optional_string_csharp" style="color: inherit; text-decoration: inherit;">Plain_<wbr>optional_<wbr>string</a>
|
||||
</span>
|
||||
<span class="property-indicator"></span>
|
||||
<span class="property-type">string</span>
|
||||
</dt>
|
||||
<dd>{{% md %}}{{% /md %}}</dd></dl>
|
||||
{{% /choosable %}}
|
||||
|
||||
{{% choosable language go %}}
|
||||
<dl class="resources-properties"><dt class="property-required"
|
||||
title="Required">
|
||||
<span id="plain_required_bool_go">
|
||||
<a href="#plain_required_bool_go" style="color: inherit; text-decoration: inherit;">Plain_<wbr>required_<wbr>bool</a>
|
||||
</span>
|
||||
<span class="property-indicator"></span>
|
||||
<span class="property-type">bool</span>
|
||||
</dt>
|
||||
<dd>{{% md %}}{{% /md %}}</dd><dt class="property-required"
|
||||
title="Required">
|
||||
<span id="plain_required_number_go">
|
||||
<a href="#plain_required_number_go" style="color: inherit; text-decoration: inherit;">Plain_<wbr>required_<wbr>number</a>
|
||||
</span>
|
||||
<span class="property-indicator"></span>
|
||||
<span class="property-type">float64</span>
|
||||
</dt>
|
||||
<dd>{{% md %}}{{% /md %}}</dd><dt class="property-required"
|
||||
title="Required">
|
||||
<span id="plain_required_string_go">
|
||||
<a href="#plain_required_string_go" style="color: inherit; text-decoration: inherit;">Plain_<wbr>required_<wbr>string</a>
|
||||
</span>
|
||||
<span class="property-indicator"></span>
|
||||
<span class="property-type">string</span>
|
||||
</dt>
|
||||
<dd>{{% md %}}{{% /md %}}</dd><dt class="property-required"
|
||||
title="Required">
|
||||
<span id="required_bool_go">
|
||||
<a href="#required_bool_go" style="color: inherit; text-decoration: inherit;">Required_<wbr>bool</a>
|
||||
</span>
|
||||
<span class="property-indicator"></span>
|
||||
<span class="property-type">bool</span>
|
||||
</dt>
|
||||
<dd>{{% md %}}{{% /md %}}</dd><dt class="property-required"
|
||||
title="Required">
|
||||
<span id="required_enum_go">
|
||||
<a href="#required_enum_go" style="color: inherit; text-decoration: inherit;">Required_<wbr>enum</a>
|
||||
</span>
|
||||
<span class="property-indicator"></span>
|
||||
<span class="property-type"><a href="#enumthing">Enum<wbr>Thing</a></span>
|
||||
</dt>
|
||||
<dd>{{% md %}}{{% /md %}}</dd><dt class="property-required"
|
||||
title="Required">
|
||||
<span id="required_number_go">
|
||||
<a href="#required_number_go" style="color: inherit; text-decoration: inherit;">Required_<wbr>number</a>
|
||||
</span>
|
||||
<span class="property-indicator"></span>
|
||||
<span class="property-type">float64</span>
|
||||
</dt>
|
||||
<dd>{{% md %}}{{% /md %}}</dd><dt class="property-required"
|
||||
title="Required">
|
||||
<span id="required_string_go">
|
||||
<a href="#required_string_go" style="color: inherit; text-decoration: inherit;">Required_<wbr>string</a>
|
||||
</span>
|
||||
<span class="property-indicator"></span>
|
||||
<span class="property-type">string</span>
|
||||
</dt>
|
||||
<dd>{{% md %}}{{% /md %}}</dd><dt class="property-optional"
|
||||
title="Optional">
|
||||
<span id="optional_bool_go">
|
||||
<a href="#optional_bool_go" style="color: inherit; text-decoration: inherit;">Optional_<wbr>bool</a>
|
||||
</span>
|
||||
<span class="property-indicator"></span>
|
||||
<span class="property-type">bool</span>
|
||||
</dt>
|
||||
<dd>{{% md %}}{{% /md %}}</dd><dt class="property-optional"
|
||||
title="Optional">
|
||||
<span id="optional_enum_go">
|
||||
<a href="#optional_enum_go" style="color: inherit; text-decoration: inherit;">Optional_<wbr>enum</a>
|
||||
</span>
|
||||
<span class="property-indicator"></span>
|
||||
<span class="property-type"><a href="#enumthing">Enum<wbr>Thing</a></span>
|
||||
</dt>
|
||||
<dd>{{% md %}}{{% /md %}}</dd><dt class="property-optional"
|
||||
title="Optional">
|
||||
<span id="optional_number_go">
|
||||
<a href="#optional_number_go" style="color: inherit; text-decoration: inherit;">Optional_<wbr>number</a>
|
||||
</span>
|
||||
<span class="property-indicator"></span>
|
||||
<span class="property-type">float64</span>
|
||||
</dt>
|
||||
<dd>{{% md %}}{{% /md %}}</dd><dt class="property-optional"
|
||||
title="Optional">
|
||||
<span id="optional_string_go">
|
||||
<a href="#optional_string_go" style="color: inherit; text-decoration: inherit;">Optional_<wbr>string</a>
|
||||
</span>
|
||||
<span class="property-indicator"></span>
|
||||
<span class="property-type">string</span>
|
||||
</dt>
|
||||
<dd>{{% md %}}{{% /md %}}</dd><dt class="property-optional"
|
||||
title="Optional">
|
||||
<span id="plain_optional_bool_go">
|
||||
<a href="#plain_optional_bool_go" style="color: inherit; text-decoration: inherit;">Plain_<wbr>optional_<wbr>bool</a>
|
||||
</span>
|
||||
<span class="property-indicator"></span>
|
||||
<span class="property-type">bool</span>
|
||||
</dt>
|
||||
<dd>{{% md %}}{{% /md %}}</dd><dt class="property-optional"
|
||||
title="Optional">
|
||||
<span id="plain_optional_number_go">
|
||||
<a href="#plain_optional_number_go" style="color: inherit; text-decoration: inherit;">Plain_<wbr>optional_<wbr>number</a>
|
||||
</span>
|
||||
<span class="property-indicator"></span>
|
||||
<span class="property-type">float64</span>
|
||||
</dt>
|
||||
<dd>{{% md %}}{{% /md %}}</dd><dt class="property-optional"
|
||||
title="Optional">
|
||||
<span id="plain_optional_string_go">
|
||||
<a href="#plain_optional_string_go" style="color: inherit; text-decoration: inherit;">Plain_<wbr>optional_<wbr>string</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-required"
|
||||
title="Required">
|
||||
<span id="plain_required_bool_nodejs">
|
||||
<a href="#plain_required_bool_nodejs" style="color: inherit; text-decoration: inherit;">plain_<wbr>required_<wbr>bool</a>
|
||||
</span>
|
||||
<span class="property-indicator"></span>
|
||||
<span class="property-type">boolean</span>
|
||||
</dt>
|
||||
<dd>{{% md %}}{{% /md %}}</dd><dt class="property-required"
|
||||
title="Required">
|
||||
<span id="plain_required_number_nodejs">
|
||||
<a href="#plain_required_number_nodejs" style="color: inherit; text-decoration: inherit;">plain_<wbr>required_<wbr>number</a>
|
||||
</span>
|
||||
<span class="property-indicator"></span>
|
||||
<span class="property-type">number</span>
|
||||
</dt>
|
||||
<dd>{{% md %}}{{% /md %}}</dd><dt class="property-required"
|
||||
title="Required">
|
||||
<span id="plain_required_string_nodejs">
|
||||
<a href="#plain_required_string_nodejs" style="color: inherit; text-decoration: inherit;">plain_<wbr>required_<wbr>string</a>
|
||||
</span>
|
||||
<span class="property-indicator"></span>
|
||||
<span class="property-type">string</span>
|
||||
</dt>
|
||||
<dd>{{% md %}}{{% /md %}}</dd><dt class="property-required"
|
||||
title="Required">
|
||||
<span id="required_bool_nodejs">
|
||||
<a href="#required_bool_nodejs" style="color: inherit; text-decoration: inherit;">required_<wbr>bool</a>
|
||||
</span>
|
||||
<span class="property-indicator"></span>
|
||||
<span class="property-type">boolean</span>
|
||||
</dt>
|
||||
<dd>{{% md %}}{{% /md %}}</dd><dt class="property-required"
|
||||
title="Required">
|
||||
<span id="required_enum_nodejs">
|
||||
<a href="#required_enum_nodejs" style="color: inherit; text-decoration: inherit;">required_<wbr>enum</a>
|
||||
</span>
|
||||
<span class="property-indicator"></span>
|
||||
<span class="property-type"><a href="#enumthing">Enum<wbr>Thing</a></span>
|
||||
</dt>
|
||||
<dd>{{% md %}}{{% /md %}}</dd><dt class="property-required"
|
||||
title="Required">
|
||||
<span id="required_number_nodejs">
|
||||
<a href="#required_number_nodejs" style="color: inherit; text-decoration: inherit;">required_<wbr>number</a>
|
||||
</span>
|
||||
<span class="property-indicator"></span>
|
||||
<span class="property-type">number</span>
|
||||
</dt>
|
||||
<dd>{{% md %}}{{% /md %}}</dd><dt class="property-required"
|
||||
title="Required">
|
||||
<span id="required_string_nodejs">
|
||||
<a href="#required_string_nodejs" style="color: inherit; text-decoration: inherit;">required_<wbr>string</a>
|
||||
</span>
|
||||
<span class="property-indicator"></span>
|
||||
<span class="property-type">string</span>
|
||||
</dt>
|
||||
<dd>{{% md %}}{{% /md %}}</dd><dt class="property-optional"
|
||||
title="Optional">
|
||||
<span id="optional_bool_nodejs">
|
||||
<a href="#optional_bool_nodejs" style="color: inherit; text-decoration: inherit;">optional_<wbr>bool</a>
|
||||
</span>
|
||||
<span class="property-indicator"></span>
|
||||
<span class="property-type">boolean</span>
|
||||
</dt>
|
||||
<dd>{{% md %}}{{% /md %}}</dd><dt class="property-optional"
|
||||
title="Optional">
|
||||
<span id="optional_enum_nodejs">
|
||||
<a href="#optional_enum_nodejs" style="color: inherit; text-decoration: inherit;">optional_<wbr>enum</a>
|
||||
</span>
|
||||
<span class="property-indicator"></span>
|
||||
<span class="property-type"><a href="#enumthing">Enum<wbr>Thing</a></span>
|
||||
</dt>
|
||||
<dd>{{% md %}}{{% /md %}}</dd><dt class="property-optional"
|
||||
title="Optional">
|
||||
<span id="optional_number_nodejs">
|
||||
<a href="#optional_number_nodejs" style="color: inherit; text-decoration: inherit;">optional_<wbr>number</a>
|
||||
</span>
|
||||
<span class="property-indicator"></span>
|
||||
<span class="property-type">number</span>
|
||||
</dt>
|
||||
<dd>{{% md %}}{{% /md %}}</dd><dt class="property-optional"
|
||||
title="Optional">
|
||||
<span id="optional_string_nodejs">
|
||||
<a href="#optional_string_nodejs" style="color: inherit; text-decoration: inherit;">optional_<wbr>string</a>
|
||||
</span>
|
||||
<span class="property-indicator"></span>
|
||||
<span class="property-type">string</span>
|
||||
</dt>
|
||||
<dd>{{% md %}}{{% /md %}}</dd><dt class="property-optional"
|
||||
title="Optional">
|
||||
<span id="plain_optional_bool_nodejs">
|
||||
<a href="#plain_optional_bool_nodejs" style="color: inherit; text-decoration: inherit;">plain_<wbr>optional_<wbr>bool</a>
|
||||
</span>
|
||||
<span class="property-indicator"></span>
|
||||
<span class="property-type">boolean</span>
|
||||
</dt>
|
||||
<dd>{{% md %}}{{% /md %}}</dd><dt class="property-optional"
|
||||
title="Optional">
|
||||
<span id="plain_optional_number_nodejs">
|
||||
<a href="#plain_optional_number_nodejs" style="color: inherit; text-decoration: inherit;">plain_<wbr>optional_<wbr>number</a>
|
||||
</span>
|
||||
<span class="property-indicator"></span>
|
||||
<span class="property-type">number</span>
|
||||
</dt>
|
||||
<dd>{{% md %}}{{% /md %}}</dd><dt class="property-optional"
|
||||
title="Optional">
|
||||
<span id="plain_optional_string_nodejs">
|
||||
<a href="#plain_optional_string_nodejs" style="color: inherit; text-decoration: inherit;">plain_<wbr>optional_<wbr>string</a>
|
||||
</span>
|
||||
<span class="property-indicator"></span>
|
||||
<span class="property-type">string</span>
|
||||
</dt>
|
||||
<dd>{{% md %}}{{% /md %}}</dd></dl>
|
||||
{{% /choosable %}}
|
||||
|
||||
{{% choosable language python %}}
|
||||
<dl class="resources-properties"><dt class="property-required"
|
||||
title="Required">
|
||||
<span id="plain_required_bool_python">
|
||||
<a href="#plain_required_bool_python" style="color: inherit; text-decoration: inherit;">plain_<wbr>required_<wbr>bool</a>
|
||||
</span>
|
||||
<span class="property-indicator"></span>
|
||||
<span class="property-type">bool</span>
|
||||
</dt>
|
||||
<dd>{{% md %}}{{% /md %}}</dd><dt class="property-required"
|
||||
title="Required">
|
||||
<span id="plain_required_number_python">
|
||||
<a href="#plain_required_number_python" style="color: inherit; text-decoration: inherit;">plain_<wbr>required_<wbr>number</a>
|
||||
</span>
|
||||
<span class="property-indicator"></span>
|
||||
<span class="property-type">float</span>
|
||||
</dt>
|
||||
<dd>{{% md %}}{{% /md %}}</dd><dt class="property-required"
|
||||
title="Required">
|
||||
<span id="plain_required_string_python">
|
||||
<a href="#plain_required_string_python" style="color: inherit; text-decoration: inherit;">plain_<wbr>required_<wbr>string</a>
|
||||
</span>
|
||||
<span class="property-indicator"></span>
|
||||
<span class="property-type">str</span>
|
||||
</dt>
|
||||
<dd>{{% md %}}{{% /md %}}</dd><dt class="property-required"
|
||||
title="Required">
|
||||
<span id="required_bool_python">
|
||||
<a href="#required_bool_python" style="color: inherit; text-decoration: inherit;">required_<wbr>bool</a>
|
||||
</span>
|
||||
<span class="property-indicator"></span>
|
||||
<span class="property-type">bool</span>
|
||||
</dt>
|
||||
<dd>{{% md %}}{{% /md %}}</dd><dt class="property-required"
|
||||
title="Required">
|
||||
<span id="required_enum_python">
|
||||
<a href="#required_enum_python" style="color: inherit; text-decoration: inherit;">required_<wbr>enum</a>
|
||||
</span>
|
||||
<span class="property-indicator"></span>
|
||||
<span class="property-type"><a href="#enumthing">Enum<wbr>Thing</a></span>
|
||||
</dt>
|
||||
<dd>{{% md %}}{{% /md %}}</dd><dt class="property-required"
|
||||
title="Required">
|
||||
<span id="required_number_python">
|
||||
<a href="#required_number_python" style="color: inherit; text-decoration: inherit;">required_<wbr>number</a>
|
||||
</span>
|
||||
<span class="property-indicator"></span>
|
||||
<span class="property-type">float</span>
|
||||
</dt>
|
||||
<dd>{{% md %}}{{% /md %}}</dd><dt class="property-required"
|
||||
title="Required">
|
||||
<span id="required_string_python">
|
||||
<a href="#required_string_python" style="color: inherit; text-decoration: inherit;">required_<wbr>string</a>
|
||||
</span>
|
||||
<span class="property-indicator"></span>
|
||||
<span class="property-type">str</span>
|
||||
</dt>
|
||||
<dd>{{% md %}}{{% /md %}}</dd><dt class="property-optional"
|
||||
title="Optional">
|
||||
<span id="optional_bool_python">
|
||||
<a href="#optional_bool_python" style="color: inherit; text-decoration: inherit;">optional_<wbr>bool</a>
|
||||
</span>
|
||||
<span class="property-indicator"></span>
|
||||
<span class="property-type">bool</span>
|
||||
</dt>
|
||||
<dd>{{% md %}}{{% /md %}}</dd><dt class="property-optional"
|
||||
title="Optional">
|
||||
<span id="optional_enum_python">
|
||||
<a href="#optional_enum_python" style="color: inherit; text-decoration: inherit;">optional_<wbr>enum</a>
|
||||
</span>
|
||||
<span class="property-indicator"></span>
|
||||
<span class="property-type"><a href="#enumthing">Enum<wbr>Thing</a></span>
|
||||
</dt>
|
||||
<dd>{{% md %}}{{% /md %}}</dd><dt class="property-optional"
|
||||
title="Optional">
|
||||
<span id="optional_number_python">
|
||||
<a href="#optional_number_python" style="color: inherit; text-decoration: inherit;">optional_<wbr>number</a>
|
||||
</span>
|
||||
<span class="property-indicator"></span>
|
||||
<span class="property-type">float</span>
|
||||
</dt>
|
||||
<dd>{{% md %}}{{% /md %}}</dd><dt class="property-optional"
|
||||
title="Optional">
|
||||
<span id="optional_string_python">
|
||||
<a href="#optional_string_python" style="color: inherit; text-decoration: inherit;">optional_<wbr>string</a>
|
||||
</span>
|
||||
<span class="property-indicator"></span>
|
||||
<span class="property-type">str</span>
|
||||
</dt>
|
||||
<dd>{{% md %}}{{% /md %}}</dd><dt class="property-optional"
|
||||
title="Optional">
|
||||
<span id="plain_optional_bool_python">
|
||||
<a href="#plain_optional_bool_python" style="color: inherit; text-decoration: inherit;">plain_<wbr>optional_<wbr>bool</a>
|
||||
</span>
|
||||
<span class="property-indicator"></span>
|
||||
<span class="property-type">bool</span>
|
||||
</dt>
|
||||
<dd>{{% md %}}{{% /md %}}</dd><dt class="property-optional"
|
||||
title="Optional">
|
||||
<span id="plain_optional_number_python">
|
||||
<a href="#plain_optional_number_python" style="color: inherit; text-decoration: inherit;">plain_<wbr>optional_<wbr>number</a>
|
||||
</span>
|
||||
<span class="property-indicator"></span>
|
||||
<span class="property-type">float</span>
|
||||
</dt>
|
||||
<dd>{{% md %}}{{% /md %}}</dd><dt class="property-optional"
|
||||
title="Optional">
|
||||
<span id="plain_optional_string_python">
|
||||
<a href="#plain_optional_string_python" style="color: inherit; text-decoration: inherit;">plain_<wbr>optional_<wbr>string</a>
|
||||
</span>
|
||||
<span class="property-indicator"></span>
|
||||
<span class="property-type">str</span>
|
||||
</dt>
|
||||
<dd>{{% md %}}{{% /md %}}</dd></dl>
|
||||
{{% /choosable %}}
|
||||
|
||||
|
||||
### Outputs
|
||||
|
||||
All [input](#inputs) properties are implicitly available as output properties. Additionally, the ModuleResource 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 %}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## Supporting Types
|
||||
|
||||
|
||||
|
||||
<h4 id="enumthing">Enum<wbr>Thing</h4>
|
||||
|
||||
{{% choosable language csharp %}}
|
||||
<dl class="tabular"><dt>Four</dt>
|
||||
<dd>4</dd><dt>Six</dt>
|
||||
<dd>6</dd><dt>Eight</dt>
|
||||
<dd>8</dd></dl>
|
||||
{{% /choosable %}}
|
||||
|
||||
{{% choosable language go %}}
|
||||
<dl class="tabular"><dt>Enum<wbr>Thing<wbr>Four</dt>
|
||||
<dd>4</dd><dt>Enum<wbr>Thing<wbr>Six</dt>
|
||||
<dd>6</dd><dt>Enum<wbr>Thing<wbr>Eight</dt>
|
||||
<dd>8</dd></dl>
|
||||
{{% /choosable %}}
|
||||
|
||||
{{% choosable language nodejs %}}
|
||||
<dl class="tabular"><dt>Four</dt>
|
||||
<dd>4</dd><dt>Six</dt>
|
||||
<dd>6</dd><dt>Eight</dt>
|
||||
<dd>8</dd></dl>
|
||||
{{% /choosable %}}
|
||||
|
||||
{{% choosable language python %}}
|
||||
<dl class="tabular"><dt>FOUR</dt>
|
||||
<dd>4</dd><dt>SIX</dt>
|
||||
<dd>6</dd><dt>EIGHT</dt>
|
||||
<dd>8</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>
|
||||
|
241
pkg/codegen/internal/test/testdata/plain-and-default/docs/provider/_index.md
vendored
Normal file
241
pkg/codegen/internal/test/testdata/plain-and-default/docs/provider/_index.md
vendored
Normal file
|
@ -0,0 +1,241 @@
|
|||
|
||||
---
|
||||
title: "Provider"
|
||||
title_tag: "foobar.Provider"
|
||||
meta_desc: "Documentation for the foobar.Provider resource with examples, input properties, output properties, lookup functions, and supporting types."
|
||||
layout: api
|
||||
no_edit_this_page: true
|
||||
---
|
||||
|
||||
|
||||
|
||||
<!-- 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>
|
||||
|
16
pkg/codegen/internal/test/testdata/plain-and-default/dotnet/Enums.cs
vendored
Normal file
16
pkg/codegen/internal/test/testdata/plain-and-default/dotnet/Enums.cs
vendored
Normal file
|
@ -0,0 +1,16 @@
|
|||
// *** 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.FooBar
|
||||
{
|
||||
public enum EnumThing
|
||||
{
|
||||
Four = 4,
|
||||
Six = 6,
|
||||
Eight = 8,
|
||||
}
|
||||
}
|
140
pkg/codegen/internal/test/testdata/plain-and-default/dotnet/ModuleResource.cs
vendored
Normal file
140
pkg/codegen/internal/test/testdata/plain-and-default/dotnet/ModuleResource.cs
vendored
Normal file
|
@ -0,0 +1,140 @@
|
|||
// *** 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.FooBar
|
||||
{
|
||||
[FooBarResourceType("foobar::ModuleResource")]
|
||||
public partial class ModuleResource : Pulumi.CustomResource
|
||||
{
|
||||
/// <summary>
|
||||
/// Create a ModuleResource 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 ModuleResource(string name, ModuleResourceArgs args, CustomResourceOptions? options = null)
|
||||
: base("foobar::ModuleResource", name, MakeArgs(args), MakeResourceOptions(options, ""))
|
||||
{
|
||||
}
|
||||
|
||||
private ModuleResource(string name, Input<string> id, CustomResourceOptions? options = null)
|
||||
: base("foobar::ModuleResource", name, null, MakeResourceOptions(options, id))
|
||||
{
|
||||
}
|
||||
|
||||
private static ModuleResourceArgs MakeArgs(ModuleResourceArgs args)
|
||||
{
|
||||
args ??= new ModuleResourceArgs();
|
||||
args.Optional_const = "val";
|
||||
args.Plain_optional_const = "val";
|
||||
args.Plain_required_const = "val";
|
||||
return args;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
/// <summary>
|
||||
/// Get an existing ModuleResource resource's state with the given name, ID, and optional extra
|
||||
/// properties used to qualify the lookup.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="name">The unique name of the resulting resource.</param>
|
||||
/// <param name="id">The unique provider ID of the resource to lookup.</param>
|
||||
/// <param name="options">A bag of options that control this resource's behavior</param>
|
||||
public static ModuleResource Get(string name, Input<string> id, CustomResourceOptions? options = null)
|
||||
{
|
||||
return new ModuleResource(name, id, options);
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class ModuleResourceArgs : Pulumi.ResourceArgs
|
||||
{
|
||||
[Input("optional_bool")]
|
||||
public Input<bool>? Optional_bool { get; set; }
|
||||
|
||||
[Input("optional_const")]
|
||||
public Input<string>? Optional_const { get; set; }
|
||||
|
||||
[Input("optional_enum")]
|
||||
public Input<Pulumi.FooBar.EnumThing>? Optional_enum { get; set; }
|
||||
|
||||
[Input("optional_number")]
|
||||
public Input<double>? Optional_number { get; set; }
|
||||
|
||||
[Input("optional_string")]
|
||||
public Input<string>? Optional_string { get; set; }
|
||||
|
||||
[Input("plain_optional_bool")]
|
||||
public bool? Plain_optional_bool { get; set; }
|
||||
|
||||
[Input("plain_optional_const")]
|
||||
public string? Plain_optional_const { get; set; }
|
||||
|
||||
[Input("plain_optional_number")]
|
||||
public double? Plain_optional_number { get; set; }
|
||||
|
||||
[Input("plain_optional_string")]
|
||||
public string? Plain_optional_string { get; set; }
|
||||
|
||||
[Input("plain_required_bool", required: true)]
|
||||
public bool Plain_required_bool { get; set; }
|
||||
|
||||
[Input("plain_required_const", required: true)]
|
||||
public string Plain_required_const { get; set; } = null!;
|
||||
|
||||
[Input("plain_required_number", required: true)]
|
||||
public double Plain_required_number { get; set; }
|
||||
|
||||
[Input("plain_required_string", required: true)]
|
||||
public string Plain_required_string { get; set; } = null!;
|
||||
|
||||
[Input("required_bool", required: true)]
|
||||
public Input<bool> Required_bool { get; set; } = null!;
|
||||
|
||||
[Input("required_enum", required: true)]
|
||||
public Input<Pulumi.FooBar.EnumThing> Required_enum { get; set; } = null!;
|
||||
|
||||
[Input("required_number", required: true)]
|
||||
public Input<double> Required_number { get; set; } = null!;
|
||||
|
||||
[Input("required_string", required: true)]
|
||||
public Input<string> Required_string { get; set; } = null!;
|
||||
|
||||
public ModuleResourceArgs()
|
||||
{
|
||||
Optional_bool = true;
|
||||
Optional_const = "another";
|
||||
Optional_enum = Pulumi.FooBar.EnumThing.Eight;
|
||||
Optional_number = 42;
|
||||
Optional_string = "buzzer";
|
||||
Plain_optional_bool = true;
|
||||
Plain_optional_const = "another";
|
||||
Plain_optional_number = 42;
|
||||
Plain_optional_string = "buzzer";
|
||||
Plain_required_bool = true;
|
||||
Plain_required_const = "another";
|
||||
Plain_required_number = 42;
|
||||
Plain_required_string = "buzzer";
|
||||
Required_bool = true;
|
||||
Required_enum = Pulumi.FooBar.EnumThing.Four;
|
||||
Required_number = 42;
|
||||
Required_string = "buzzer";
|
||||
}
|
||||
}
|
||||
}
|
46
pkg/codegen/internal/test/testdata/plain-and-default/dotnet/Provider.cs
vendored
Normal file
46
pkg/codegen/internal/test/testdata/plain-and-default/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.FooBar
|
||||
{
|
||||
[FooBarResourceType("pulumi:providers:foobar")]
|
||||
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("foobar", 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()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
56
pkg/codegen/internal/test/testdata/plain-and-default/dotnet/Pulumi.FooBar.csproj
vendored
Normal file
56
pkg/codegen/internal/test/testdata/plain-and-default/dotnet/Pulumi.FooBar.csproj
vendored
Normal file
|
@ -0,0 +1,56 @@
|
|||
<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>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Include="logo.png">
|
||||
<Pack>True</Pack>
|
||||
<PackagePath></PackagePath>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
0
pkg/codegen/internal/test/testdata/plain-and-default/dotnet/README.md
vendored
Normal file
0
pkg/codegen/internal/test/testdata/plain-and-default/dotnet/README.md
vendored
Normal file
87
pkg/codegen/internal/test/testdata/plain-and-default/dotnet/Utilities.cs
vendored
Normal file
87
pkg/codegen/internal/test/testdata/plain-and-default/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.FooBar
|
||||
{
|
||||
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.FooBar.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 FooBarResourceTypeAttribute : Pulumi.ResourceTypeAttribute
|
||||
{
|
||||
public FooBarResourceTypeAttribute(string type) : base(type, Utilities.Version)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
11
pkg/codegen/internal/test/testdata/plain-and-default/dotnet/codegen-manifest.json
vendored
Normal file
11
pkg/codegen/internal/test/testdata/plain-and-default/dotnet/codegen-manifest.json
vendored
Normal file
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"emittedFiles": [
|
||||
"Enums.cs",
|
||||
"ModuleResource.cs",
|
||||
"Provider.cs",
|
||||
"Pulumi.FooBar.csproj",
|
||||
"README.md",
|
||||
"Utilities.cs",
|
||||
"logo.png"
|
||||
]
|
||||
}
|
BIN
pkg/codegen/internal/test/testdata/plain-and-default/dotnet/logo.png
vendored
Normal file
BIN
pkg/codegen/internal/test/testdata/plain-and-default/dotnet/logo.png
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 7.7 KiB |
10
pkg/codegen/internal/test/testdata/plain-and-default/go/codegen-manifest.json
vendored
Normal file
10
pkg/codegen/internal/test/testdata/plain-and-default/go/codegen-manifest.json
vendored
Normal file
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
"emittedFiles": [
|
||||
"foo/doc.go",
|
||||
"foo/init.go",
|
||||
"foo/moduleResource.go",
|
||||
"foo/provider.go",
|
||||
"foo/pulumiEnums.go",
|
||||
"foo/pulumiUtilities.go"
|
||||
]
|
||||
}
|
3
pkg/codegen/internal/test/testdata/plain-and-default/go/foo/doc.go
vendored
Normal file
3
pkg/codegen/internal/test/testdata/plain-and-default/go/foo/doc.go
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
// Package foobar exports types, functions, subpackages for provisioning foobar resources.
|
||||
//
|
||||
package foo
|
65
pkg/codegen/internal/test/testdata/plain-and-default/go/foo/init.go
vendored
Normal file
65
pkg/codegen/internal/test/testdata/plain-and-default/go/foo/init.go
vendored
Normal file
|
@ -0,0 +1,65 @@
|
|||
// *** WARNING: this file was generated by test. ***
|
||||
// *** Do not edit by hand unless you're certain you know what you are doing! ***
|
||||
|
||||
package foo
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/blang/semver"
|
||||
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
|
||||
)
|
||||
|
||||
type module struct {
|
||||
version semver.Version
|
||||
}
|
||||
|
||||
func (m *module) Version() semver.Version {
|
||||
return m.version
|
||||
}
|
||||
|
||||
func (m *module) Construct(ctx *pulumi.Context, name, typ, urn string) (r pulumi.Resource, err error) {
|
||||
switch typ {
|
||||
case "foobar::ModuleResource":
|
||||
r = &ModuleResource{}
|
||||
default:
|
||||
return nil, fmt.Errorf("unknown resource type: %s", typ)
|
||||
}
|
||||
|
||||
err = ctx.RegisterResource(typ, name, nil, r, pulumi.URN_(urn))
|
||||
return
|
||||
}
|
||||
|
||||
type pkg struct {
|
||||
version semver.Version
|
||||
}
|
||||
|
||||
func (p *pkg) Version() semver.Version {
|
||||
return p.version
|
||||
}
|
||||
|
||||
func (p *pkg) ConstructProvider(ctx *pulumi.Context, name, typ, urn string) (pulumi.ProviderResource, error) {
|
||||
if typ != "pulumi:providers:foobar" {
|
||||
return nil, fmt.Errorf("unknown provider type: %s", typ)
|
||||
}
|
||||
|
||||
r := &Provider{}
|
||||
err := ctx.RegisterResource(typ, name, nil, r, pulumi.URN_(urn))
|
||||
return r, err
|
||||
}
|
||||
|
||||
func init() {
|
||||
version, err := PkgVersion()
|
||||
if err != nil {
|
||||
fmt.Printf("failed to determine package version. defaulting to v1: %v\n", err)
|
||||
}
|
||||
pulumi.RegisterResourceModule(
|
||||
"foobar",
|
||||
"",
|
||||
&module{version},
|
||||
)
|
||||
pulumi.RegisterResourcePackage(
|
||||
"foobar",
|
||||
&pkg{version},
|
||||
)
|
||||
}
|
186
pkg/codegen/internal/test/testdata/plain-and-default/go/foo/moduleResource.go
vendored
Normal file
186
pkg/codegen/internal/test/testdata/plain-and-default/go/foo/moduleResource.go
vendored
Normal file
|
@ -0,0 +1,186 @@
|
|||
// *** WARNING: this file was generated by test. ***
|
||||
// *** Do not edit by hand unless you're certain you know what you are doing! ***
|
||||
|
||||
package foo
|
||||
|
||||
import (
|
||||
"context"
|
||||
"reflect"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
|
||||
)
|
||||
|
||||
type ModuleResource struct {
|
||||
pulumi.CustomResourceState
|
||||
}
|
||||
|
||||
// NewModuleResource registers a new resource with the given unique name, arguments, and options.
|
||||
func NewModuleResource(ctx *pulumi.Context,
|
||||
name string, args *ModuleResourceArgs, opts ...pulumi.ResourceOption) (*ModuleResource, error) {
|
||||
if args == nil {
|
||||
return nil, errors.New("missing one or more required arguments")
|
||||
}
|
||||
|
||||
if args.Optional_bool == nil {
|
||||
args.Optional_bool = pulumi.BoolPtr(true)
|
||||
}
|
||||
args.Optional_const = pulumi.StringPtr("val")
|
||||
if args.Optional_enum == nil {
|
||||
args.Optional_enum = EnumThing(8)
|
||||
}
|
||||
if args.Optional_number == nil {
|
||||
args.Optional_number = pulumi.Float64Ptr(42.0)
|
||||
}
|
||||
if args.Optional_string == nil {
|
||||
args.Optional_string = pulumi.StringPtr("buzzer")
|
||||
}
|
||||
if args.Plain_optional_bool == nil {
|
||||
plain_optional_bool_ := true
|
||||
args.Plain_optional_bool = &plain_optional_bool_
|
||||
}
|
||||
plain_optional_const_ := "val"
|
||||
args.Plain_optional_const = &plain_optional_const_
|
||||
if args.Plain_optional_number == nil {
|
||||
plain_optional_number_ := 42.0
|
||||
args.Plain_optional_number = &plain_optional_number_
|
||||
}
|
||||
if args.Plain_optional_string == nil {
|
||||
plain_optional_string_ := "buzzer"
|
||||
args.Plain_optional_string = &plain_optional_string_
|
||||
}
|
||||
if args.Plain_required_bool == false {
|
||||
args.Plain_required_bool = true
|
||||
}
|
||||
args.Plain_required_const = "val"
|
||||
if args.Plain_required_number == 0.0 {
|
||||
args.Plain_required_number = 42.0
|
||||
}
|
||||
if args.Plain_required_string == "" {
|
||||
args.Plain_required_string = "buzzer"
|
||||
}
|
||||
if args.Required_bool == nil {
|
||||
args.Required_bool = pulumi.Bool(true)
|
||||
}
|
||||
if args.Required_enum == nil {
|
||||
args.Required_enum = EnumThing(4)
|
||||
}
|
||||
if args.Required_number == nil {
|
||||
args.Required_number = pulumi.Float64(42.0)
|
||||
}
|
||||
if args.Required_string == nil {
|
||||
args.Required_string = pulumi.String("buzzer")
|
||||
}
|
||||
var resource ModuleResource
|
||||
err := ctx.RegisterResource("foobar::ModuleResource", name, args, &resource, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &resource, nil
|
||||
}
|
||||
|
||||
// GetModuleResource gets an existing ModuleResource resource's state with the given name, ID, and optional
|
||||
// state properties that are used to uniquely qualify the lookup (nil if not required).
|
||||
func GetModuleResource(ctx *pulumi.Context,
|
||||
name string, id pulumi.IDInput, state *ModuleResourceState, opts ...pulumi.ResourceOption) (*ModuleResource, error) {
|
||||
var resource ModuleResource
|
||||
err := ctx.ReadResource("foobar::ModuleResource", name, id, state, &resource, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &resource, nil
|
||||
}
|
||||
|
||||
// Input properties used for looking up and filtering ModuleResource resources.
|
||||
type moduleResourceState struct {
|
||||
}
|
||||
|
||||
type ModuleResourceState struct {
|
||||
}
|
||||
|
||||
func (ModuleResourceState) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((*moduleResourceState)(nil)).Elem()
|
||||
}
|
||||
|
||||
type moduleResourceArgs struct {
|
||||
Optional_bool *bool `pulumi:"optional_bool"`
|
||||
Optional_const *string `pulumi:"optional_const"`
|
||||
Optional_enum *EnumThing `pulumi:"optional_enum"`
|
||||
Optional_number *float64 `pulumi:"optional_number"`
|
||||
Optional_string *string `pulumi:"optional_string"`
|
||||
Plain_optional_bool *bool `pulumi:"plain_optional_bool"`
|
||||
Plain_optional_const *string `pulumi:"plain_optional_const"`
|
||||
Plain_optional_number *float64 `pulumi:"plain_optional_number"`
|
||||
Plain_optional_string *string `pulumi:"plain_optional_string"`
|
||||
Plain_required_bool bool `pulumi:"plain_required_bool"`
|
||||
Plain_required_const string `pulumi:"plain_required_const"`
|
||||
Plain_required_number float64 `pulumi:"plain_required_number"`
|
||||
Plain_required_string string `pulumi:"plain_required_string"`
|
||||
Required_bool bool `pulumi:"required_bool"`
|
||||
Required_enum EnumThing `pulumi:"required_enum"`
|
||||
Required_number float64 `pulumi:"required_number"`
|
||||
Required_string string `pulumi:"required_string"`
|
||||
}
|
||||
|
||||
// The set of arguments for constructing a ModuleResource resource.
|
||||
type ModuleResourceArgs struct {
|
||||
Optional_bool pulumi.BoolPtrInput
|
||||
Optional_const pulumi.StringPtrInput
|
||||
Optional_enum EnumThingPtrInput
|
||||
Optional_number pulumi.Float64PtrInput
|
||||
Optional_string pulumi.StringPtrInput
|
||||
Plain_optional_bool *bool
|
||||
Plain_optional_const *string
|
||||
Plain_optional_number *float64
|
||||
Plain_optional_string *string
|
||||
Plain_required_bool bool
|
||||
Plain_required_const string
|
||||
Plain_required_number float64
|
||||
Plain_required_string string
|
||||
Required_bool pulumi.BoolInput
|
||||
Required_enum EnumThingInput
|
||||
Required_number pulumi.Float64Input
|
||||
Required_string pulumi.StringInput
|
||||
}
|
||||
|
||||
func (ModuleResourceArgs) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((*moduleResourceArgs)(nil)).Elem()
|
||||
}
|
||||
|
||||
type ModuleResourceInput interface {
|
||||
pulumi.Input
|
||||
|
||||
ToModuleResourceOutput() ModuleResourceOutput
|
||||
ToModuleResourceOutputWithContext(ctx context.Context) ModuleResourceOutput
|
||||
}
|
||||
|
||||
func (*ModuleResource) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((*ModuleResource)(nil))
|
||||
}
|
||||
|
||||
func (i *ModuleResource) ToModuleResourceOutput() ModuleResourceOutput {
|
||||
return i.ToModuleResourceOutputWithContext(context.Background())
|
||||
}
|
||||
|
||||
func (i *ModuleResource) ToModuleResourceOutputWithContext(ctx context.Context) ModuleResourceOutput {
|
||||
return pulumi.ToOutputWithContext(ctx, i).(ModuleResourceOutput)
|
||||
}
|
||||
|
||||
type ModuleResourceOutput struct{ *pulumi.OutputState }
|
||||
|
||||
func (ModuleResourceOutput) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((*ModuleResource)(nil))
|
||||
}
|
||||
|
||||
func (o ModuleResourceOutput) ToModuleResourceOutput() ModuleResourceOutput {
|
||||
return o
|
||||
}
|
||||
|
||||
func (o ModuleResourceOutput) ToModuleResourceOutputWithContext(ctx context.Context) ModuleResourceOutput {
|
||||
return o
|
||||
}
|
||||
|
||||
func init() {
|
||||
pulumi.RegisterInputType(reflect.TypeOf((*ModuleResourceInput)(nil)).Elem(), &ModuleResource{})
|
||||
pulumi.RegisterOutputType(ModuleResourceOutput{})
|
||||
}
|
79
pkg/codegen/internal/test/testdata/plain-and-default/go/foo/provider.go
vendored
Normal file
79
pkg/codegen/internal/test/testdata/plain-and-default/go/foo/provider.go
vendored
Normal file
|
@ -0,0 +1,79 @@
|
|||
// *** WARNING: this file was generated by test. ***
|
||||
// *** Do not edit by hand unless you're certain you know what you are doing! ***
|
||||
|
||||
package foo
|
||||
|
||||
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:foobar", 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.RegisterInputType(reflect.TypeOf((*ProviderInput)(nil)).Elem(), &Provider{})
|
||||
pulumi.RegisterOutputType(ProviderOutput{})
|
||||
}
|
183
pkg/codegen/internal/test/testdata/plain-and-default/go/foo/pulumiEnums.go
vendored
Normal file
183
pkg/codegen/internal/test/testdata/plain-and-default/go/foo/pulumiEnums.go
vendored
Normal file
|
@ -0,0 +1,183 @@
|
|||
// *** WARNING: this file was generated by test. ***
|
||||
// *** Do not edit by hand unless you're certain you know what you are doing! ***
|
||||
|
||||
package foo
|
||||
|
||||
import (
|
||||
"context"
|
||||
"reflect"
|
||||
|
||||
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
|
||||
)
|
||||
|
||||
type EnumThing int
|
||||
|
||||
const (
|
||||
EnumThingFour = EnumThing(4)
|
||||
EnumThingSix = EnumThing(6)
|
||||
EnumThingEight = EnumThing(8)
|
||||
)
|
||||
|
||||
func (EnumThing) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((*EnumThing)(nil)).Elem()
|
||||
}
|
||||
|
||||
func (e EnumThing) ToEnumThingOutput() EnumThingOutput {
|
||||
return pulumi.ToOutput(e).(EnumThingOutput)
|
||||
}
|
||||
|
||||
func (e EnumThing) ToEnumThingOutputWithContext(ctx context.Context) EnumThingOutput {
|
||||
return pulumi.ToOutputWithContext(ctx, e).(EnumThingOutput)
|
||||
}
|
||||
|
||||
func (e EnumThing) ToEnumThingPtrOutput() EnumThingPtrOutput {
|
||||
return e.ToEnumThingPtrOutputWithContext(context.Background())
|
||||
}
|
||||
|
||||
func (e EnumThing) ToEnumThingPtrOutputWithContext(ctx context.Context) EnumThingPtrOutput {
|
||||
return EnumThing(e).ToEnumThingOutputWithContext(ctx).ToEnumThingPtrOutputWithContext(ctx)
|
||||
}
|
||||
|
||||
func (e EnumThing) ToIntOutput() pulumi.IntOutput {
|
||||
return pulumi.ToOutput(pulumi.Int(e)).(pulumi.IntOutput)
|
||||
}
|
||||
|
||||
func (e EnumThing) ToIntOutputWithContext(ctx context.Context) pulumi.IntOutput {
|
||||
return pulumi.ToOutputWithContext(ctx, pulumi.Int(e)).(pulumi.IntOutput)
|
||||
}
|
||||
|
||||
func (e EnumThing) ToIntPtrOutput() pulumi.IntPtrOutput {
|
||||
return pulumi.Int(e).ToIntPtrOutputWithContext(context.Background())
|
||||
}
|
||||
|
||||
func (e EnumThing) ToIntPtrOutputWithContext(ctx context.Context) pulumi.IntPtrOutput {
|
||||
return pulumi.Int(e).ToIntOutputWithContext(ctx).ToIntPtrOutputWithContext(ctx)
|
||||
}
|
||||
|
||||
type EnumThingOutput struct{ *pulumi.OutputState }
|
||||
|
||||
func (EnumThingOutput) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((*EnumThing)(nil)).Elem()
|
||||
}
|
||||
|
||||
func (o EnumThingOutput) ToEnumThingOutput() EnumThingOutput {
|
||||
return o
|
||||
}
|
||||
|
||||
func (o EnumThingOutput) ToEnumThingOutputWithContext(ctx context.Context) EnumThingOutput {
|
||||
return o
|
||||
}
|
||||
|
||||
func (o EnumThingOutput) ToEnumThingPtrOutput() EnumThingPtrOutput {
|
||||
return o.ToEnumThingPtrOutputWithContext(context.Background())
|
||||
}
|
||||
|
||||
func (o EnumThingOutput) ToEnumThingPtrOutputWithContext(ctx context.Context) EnumThingPtrOutput {
|
||||
return o.ApplyTWithContext(ctx, func(_ context.Context, v EnumThing) *EnumThing {
|
||||
return &v
|
||||
}).(EnumThingPtrOutput)
|
||||
}
|
||||
|
||||
func (o EnumThingOutput) ToIntOutput() pulumi.IntOutput {
|
||||
return o.ToIntOutputWithContext(context.Background())
|
||||
}
|
||||
|
||||
func (o EnumThingOutput) ToIntOutputWithContext(ctx context.Context) pulumi.IntOutput {
|
||||
return o.ApplyTWithContext(ctx, func(_ context.Context, e EnumThing) int {
|
||||
return int(e)
|
||||
}).(pulumi.IntOutput)
|
||||
}
|
||||
|
||||
func (o EnumThingOutput) ToIntPtrOutput() pulumi.IntPtrOutput {
|
||||
return o.ToIntPtrOutputWithContext(context.Background())
|
||||
}
|
||||
|
||||
func (o EnumThingOutput) ToIntPtrOutputWithContext(ctx context.Context) pulumi.IntPtrOutput {
|
||||
return o.ApplyTWithContext(ctx, func(_ context.Context, e EnumThing) *int {
|
||||
v := int(e)
|
||||
return &v
|
||||
}).(pulumi.IntPtrOutput)
|
||||
}
|
||||
|
||||
type EnumThingPtrOutput struct{ *pulumi.OutputState }
|
||||
|
||||
func (EnumThingPtrOutput) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((**EnumThing)(nil)).Elem()
|
||||
}
|
||||
|
||||
func (o EnumThingPtrOutput) ToEnumThingPtrOutput() EnumThingPtrOutput {
|
||||
return o
|
||||
}
|
||||
|
||||
func (o EnumThingPtrOutput) ToEnumThingPtrOutputWithContext(ctx context.Context) EnumThingPtrOutput {
|
||||
return o
|
||||
}
|
||||
|
||||
func (o EnumThingPtrOutput) Elem() EnumThingOutput {
|
||||
return o.ApplyT(func(v *EnumThing) EnumThing {
|
||||
if v != nil {
|
||||
return *v
|
||||
}
|
||||
var ret EnumThing
|
||||
return ret
|
||||
}).(EnumThingOutput)
|
||||
}
|
||||
|
||||
func (o EnumThingPtrOutput) ToIntPtrOutput() pulumi.IntPtrOutput {
|
||||
return o.ToIntPtrOutputWithContext(context.Background())
|
||||
}
|
||||
|
||||
func (o EnumThingPtrOutput) ToIntPtrOutputWithContext(ctx context.Context) pulumi.IntPtrOutput {
|
||||
return o.ApplyTWithContext(ctx, func(_ context.Context, e *EnumThing) *int {
|
||||
if e == nil {
|
||||
return nil
|
||||
}
|
||||
v := int(*e)
|
||||
return &v
|
||||
}).(pulumi.IntPtrOutput)
|
||||
}
|
||||
|
||||
// EnumThingInput is an input type that accepts EnumThingArgs and EnumThingOutput values.
|
||||
// You can construct a concrete instance of `EnumThingInput` via:
|
||||
//
|
||||
// EnumThingArgs{...}
|
||||
type EnumThingInput interface {
|
||||
pulumi.Input
|
||||
|
||||
ToEnumThingOutput() EnumThingOutput
|
||||
ToEnumThingOutputWithContext(context.Context) EnumThingOutput
|
||||
}
|
||||
|
||||
var enumThingPtrType = reflect.TypeOf((**EnumThing)(nil)).Elem()
|
||||
|
||||
type EnumThingPtrInput interface {
|
||||
pulumi.Input
|
||||
|
||||
ToEnumThingPtrOutput() EnumThingPtrOutput
|
||||
ToEnumThingPtrOutputWithContext(context.Context) EnumThingPtrOutput
|
||||
}
|
||||
|
||||
type enumThingPtr int
|
||||
|
||||
func EnumThingPtr(v int) EnumThingPtrInput {
|
||||
return (*enumThingPtr)(&v)
|
||||
}
|
||||
|
||||
func (*enumThingPtr) ElementType() reflect.Type {
|
||||
return enumThingPtrType
|
||||
}
|
||||
|
||||
func (in *enumThingPtr) ToEnumThingPtrOutput() EnumThingPtrOutput {
|
||||
return pulumi.ToOutput(in).(EnumThingPtrOutput)
|
||||
}
|
||||
|
||||
func (in *enumThingPtr) ToEnumThingPtrOutputWithContext(ctx context.Context) EnumThingPtrOutput {
|
||||
return pulumi.ToOutputWithContext(ctx, in).(EnumThingPtrOutput)
|
||||
}
|
||||
|
||||
func init() {
|
||||
pulumi.RegisterInputType(reflect.TypeOf((*EnumThingInput)(nil)).Elem(), EnumThing(4))
|
||||
pulumi.RegisterInputType(reflect.TypeOf((*EnumThingPtrInput)(nil)).Elem(), EnumThing(4))
|
||||
pulumi.RegisterOutputType(EnumThingOutput{})
|
||||
pulumi.RegisterOutputType(EnumThingPtrOutput{})
|
||||
}
|
77
pkg/codegen/internal/test/testdata/plain-and-default/go/foo/pulumiUtilities.go
vendored
Normal file
77
pkg/codegen/internal/test/testdata/plain-and-default/go/foo/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 foo
|
||||
|
||||
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-foobar/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)
|
||||
}
|
0
pkg/codegen/internal/test/testdata/plain-and-default/nodejs/README.md
vendored
Normal file
0
pkg/codegen/internal/test/testdata/plain-and-default/nodejs/README.md
vendored
Normal file
12
pkg/codegen/internal/test/testdata/plain-and-default/nodejs/codegen-manifest.json
vendored
Normal file
12
pkg/codegen/internal/test/testdata/plain-and-default/nodejs/codegen-manifest.json
vendored
Normal file
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"emittedFiles": [
|
||||
"README.md",
|
||||
"index.ts",
|
||||
"moduleResource.ts",
|
||||
"package.json",
|
||||
"provider.ts",
|
||||
"tsconfig.json",
|
||||
"types/enums/index.ts",
|
||||
"utilities.ts"
|
||||
]
|
||||
}
|
40
pkg/codegen/internal/test/testdata/plain-and-default/nodejs/index.ts
vendored
Normal file
40
pkg/codegen/internal/test/testdata/plain-and-default/nodejs/index.ts
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! ***
|
||||
|
||||
import * as pulumi from "@pulumi/pulumi";
|
||||
import * as utilities from "./utilities";
|
||||
|
||||
// Export members:
|
||||
export * from "./moduleResource";
|
||||
export * from "./provider";
|
||||
|
||||
// Export enums:
|
||||
export * from "./types/enums";
|
||||
|
||||
// Import resources to register:
|
||||
import { ModuleResource } from "./moduleResource";
|
||||
|
||||
const _module = {
|
||||
version: utilities.getVersion(),
|
||||
construct: (name: string, type: string, urn: string): pulumi.Resource => {
|
||||
switch (type) {
|
||||
case "foobar::ModuleResource":
|
||||
return new ModuleResource(name, <any>undefined, { urn })
|
||||
default:
|
||||
throw new Error(`unknown resource type ${type}`);
|
||||
}
|
||||
},
|
||||
};
|
||||
pulumi.runtime.registerResourceModule("foobar", "", _module)
|
||||
|
||||
import { Provider } from "./provider";
|
||||
|
||||
pulumi.runtime.registerResourcePackage("foobar", {
|
||||
version: utilities.getVersion(),
|
||||
constructProvider: (name: string, type: string, urn: string): pulumi.ProviderResource => {
|
||||
if (type !== "pulumi:providers:foobar") {
|
||||
throw new Error(`unknown provider type ${type}`);
|
||||
}
|
||||
return new Provider(name, <any>undefined, { urn });
|
||||
},
|
||||
});
|
118
pkg/codegen/internal/test/testdata/plain-and-default/nodejs/moduleResource.ts
vendored
Normal file
118
pkg/codegen/internal/test/testdata/plain-and-default/nodejs/moduleResource.ts
vendored
Normal file
|
@ -0,0 +1,118 @@
|
|||
// *** 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 class ModuleResource extends pulumi.CustomResource {
|
||||
/**
|
||||
* Get an existing ModuleResource resource's state with the given name, ID, and optional extra
|
||||
* properties used to qualify the lookup.
|
||||
*
|
||||
* @param name The _unique_ name of the resulting resource.
|
||||
* @param id The _unique_ provider ID of the resource to lookup.
|
||||
* @param opts Optional settings to control the behavior of the CustomResource.
|
||||
*/
|
||||
public static get(name: string, id: pulumi.Input<pulumi.ID>, opts?: pulumi.CustomResourceOptions): ModuleResource {
|
||||
return new ModuleResource(name, undefined as any, { ...opts, id: id });
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
public static readonly __pulumiType = 'foobar::ModuleResource';
|
||||
|
||||
/**
|
||||
* Returns true if the given object is an instance of ModuleResource. 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 ModuleResource {
|
||||
if (obj === undefined || obj === null) {
|
||||
return false;
|
||||
}
|
||||
return obj['__pulumiType'] === ModuleResource.__pulumiType;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create a ModuleResource 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: ModuleResourceArgs, opts?: pulumi.CustomResourceOptions) {
|
||||
let inputs: pulumi.Inputs = {};
|
||||
opts = opts || {};
|
||||
if (!opts.id) {
|
||||
if ((!args || args.plain_required_bool === undefined) && !opts.urn) {
|
||||
throw new Error("Missing required property 'plain_required_bool'");
|
||||
}
|
||||
if ((!args || args.plain_required_const === undefined) && !opts.urn) {
|
||||
throw new Error("Missing required property 'plain_required_const'");
|
||||
}
|
||||
if ((!args || args.plain_required_number === undefined) && !opts.urn) {
|
||||
throw new Error("Missing required property 'plain_required_number'");
|
||||
}
|
||||
if ((!args || args.plain_required_string === undefined) && !opts.urn) {
|
||||
throw new Error("Missing required property 'plain_required_string'");
|
||||
}
|
||||
if ((!args || args.required_bool === undefined) && !opts.urn) {
|
||||
throw new Error("Missing required property 'required_bool'");
|
||||
}
|
||||
if ((!args || args.required_enum === undefined) && !opts.urn) {
|
||||
throw new Error("Missing required property 'required_enum'");
|
||||
}
|
||||
if ((!args || args.required_number === undefined) && !opts.urn) {
|
||||
throw new Error("Missing required property 'required_number'");
|
||||
}
|
||||
if ((!args || args.required_string === undefined) && !opts.urn) {
|
||||
throw new Error("Missing required property 'required_string'");
|
||||
}
|
||||
inputs["optional_bool"] = (args ? args.optional_bool : undefined) ?? true;
|
||||
inputs["optional_const"] = "val";
|
||||
inputs["optional_enum"] = (args ? args.optional_enum : undefined) ?? 8;
|
||||
inputs["optional_number"] = (args ? args.optional_number : undefined) ?? 42;
|
||||
inputs["optional_string"] = (args ? args.optional_string : undefined) ?? "buzzer";
|
||||
inputs["plain_optional_bool"] = (args ? args.plain_optional_bool : undefined) ?? true;
|
||||
inputs["plain_optional_const"] = "val";
|
||||
inputs["plain_optional_number"] = (args ? args.plain_optional_number : undefined) ?? 42;
|
||||
inputs["plain_optional_string"] = (args ? args.plain_optional_string : undefined) ?? "buzzer";
|
||||
inputs["plain_required_bool"] = (args ? args.plain_required_bool : undefined) ?? true;
|
||||
inputs["plain_required_const"] = "val";
|
||||
inputs["plain_required_number"] = (args ? args.plain_required_number : undefined) ?? 42;
|
||||
inputs["plain_required_string"] = (args ? args.plain_required_string : undefined) ?? "buzzer";
|
||||
inputs["required_bool"] = (args ? args.required_bool : undefined) ?? true;
|
||||
inputs["required_enum"] = (args ? args.required_enum : undefined) ?? 4;
|
||||
inputs["required_number"] = (args ? args.required_number : undefined) ?? 42;
|
||||
inputs["required_string"] = (args ? args.required_string : undefined) ?? "buzzer";
|
||||
} else {
|
||||
}
|
||||
if (!opts.version) {
|
||||
opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()});
|
||||
}
|
||||
super(ModuleResource.__pulumiType, name, inputs, opts);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The set of arguments for constructing a ModuleResource resource.
|
||||
*/
|
||||
export interface ModuleResourceArgs {
|
||||
optional_bool?: pulumi.Input<boolean>;
|
||||
optional_const?: pulumi.Input<"val">;
|
||||
optional_enum?: pulumi.Input<enums.EnumThing>;
|
||||
optional_number?: pulumi.Input<number>;
|
||||
optional_string?: pulumi.Input<string>;
|
||||
plain_optional_bool?: boolean;
|
||||
plain_optional_const?: "val";
|
||||
plain_optional_number?: number;
|
||||
plain_optional_string?: string;
|
||||
plain_required_bool: boolean;
|
||||
plain_required_const: "val";
|
||||
plain_required_number: number;
|
||||
plain_required_string: string;
|
||||
required_bool: pulumi.Input<boolean>;
|
||||
required_enum: pulumi.Input<enums.EnumThing>;
|
||||
required_number: pulumi.Input<number>;
|
||||
required_string: pulumi.Input<string>;
|
||||
}
|
16
pkg/codegen/internal/test/testdata/plain-and-default/nodejs/package.json
vendored
Normal file
16
pkg/codegen/internal/test/testdata/plain-and-default/nodejs/package.json
vendored
Normal file
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
"name": "@pulumi/foobar",
|
||||
"version": "${VERSION}",
|
||||
"scripts": {
|
||||
"build": "tsc"
|
||||
},
|
||||
"dependencies": {
|
||||
"@pulumi/pulumi": "^3.12"
|
||||
},
|
||||
"devDependencies": {
|
||||
"typescript": "^3.7.0"
|
||||
},
|
||||
"pulumi": {
|
||||
"resource": true
|
||||
}
|
||||
}
|
46
pkg/codegen/internal/test/testdata/plain-and-default/nodejs/provider.ts
vendored
Normal file
46
pkg/codegen/internal/test/testdata/plain-and-default/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 = 'foobar';
|
||||
|
||||
/**
|
||||
* 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 {
|
||||
}
|
22
pkg/codegen/internal/test/testdata/plain-and-default/nodejs/tsconfig.json
vendored
Normal file
22
pkg/codegen/internal/test/testdata/plain-and-default/nodejs/tsconfig.json
vendored
Normal file
|
@ -0,0 +1,22 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"outDir": "bin",
|
||||
"target": "es2016",
|
||||
"module": "commonjs",
|
||||
"moduleResolution": "node",
|
||||
"declaration": true,
|
||||
"sourceMap": true,
|
||||
"stripInternal": true,
|
||||
"experimentalDecorators": true,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"strict": true
|
||||
},
|
||||
"files": [
|
||||
"index.ts",
|
||||
"moduleResource.ts",
|
||||
"provider.ts",
|
||||
"types/enums/index.ts",
|
||||
"utilities.ts"
|
||||
]
|
||||
}
|
11
pkg/codegen/internal/test/testdata/plain-and-default/nodejs/types/enums/index.ts
vendored
Normal file
11
pkg/codegen/internal/test/testdata/plain-and-default/nodejs/types/enums/index.ts
vendored
Normal file
|
@ -0,0 +1,11 @@
|
|||
// *** WARNING: this file was generated by test. ***
|
||||
// *** Do not edit by hand unless you're certain you know what you are doing! ***
|
||||
|
||||
|
||||
export const EnumThing = {
|
||||
Four: 4,
|
||||
Six: 6,
|
||||
Eight: 8,
|
||||
} as const;
|
||||
|
||||
export type EnumThing = (typeof EnumThing)[keyof typeof EnumThing];
|
49
pkg/codegen/internal/test/testdata/plain-and-default/nodejs/utilities.ts
vendored
Normal file
49
pkg/codegen/internal/test/testdata/plain-and-default/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/plain-and-default/python/codegen-manifest.json
vendored
Normal file
12
pkg/codegen/internal/test/testdata/plain-and-default/python/codegen-manifest.json
vendored
Normal file
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"emittedFiles": [
|
||||
"pulumi_foobar/README.md",
|
||||
"pulumi_foobar/__init__.py",
|
||||
"pulumi_foobar/_enums.py",
|
||||
"pulumi_foobar/_utilities.py",
|
||||
"pulumi_foobar/module_resource.py",
|
||||
"pulumi_foobar/provider.py",
|
||||
"pulumi_foobar/py.typed",
|
||||
"setup.py"
|
||||
]
|
||||
}
|
0
pkg/codegen/internal/test/testdata/plain-and-default/python/pulumi_foobar/README.md
vendored
Normal file
0
pkg/codegen/internal/test/testdata/plain-and-default/python/pulumi_foobar/README.md
vendored
Normal file
34
pkg/codegen/internal/test/testdata/plain-and-default/python/pulumi_foobar/__init__.py
vendored
Normal file
34
pkg/codegen/internal/test/testdata/plain-and-default/python/pulumi_foobar/__init__.py
vendored
Normal file
|
@ -0,0 +1,34 @@
|
|||
# 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 .module_resource import *
|
||||
from .provider import *
|
||||
_utilities.register(
|
||||
resource_modules="""
|
||||
[
|
||||
{
|
||||
"pkg": "foobar",
|
||||
"mod": "",
|
||||
"fqn": "pulumi_foobar",
|
||||
"classes": {
|
||||
"foobar::ModuleResource": "ModuleResource"
|
||||
}
|
||||
}
|
||||
]
|
||||
""",
|
||||
resource_packages="""
|
||||
[
|
||||
{
|
||||
"pkg": "foobar",
|
||||
"token": "pulumi:providers:foobar",
|
||||
"fqn": "pulumi_foobar",
|
||||
"class": "Provider"
|
||||
}
|
||||
]
|
||||
"""
|
||||
)
|
15
pkg/codegen/internal/test/testdata/plain-and-default/python/pulumi_foobar/_enums.py
vendored
Normal file
15
pkg/codegen/internal/test/testdata/plain-and-default/python/pulumi_foobar/_enums.py
vendored
Normal file
|
@ -0,0 +1,15 @@
|
|||
# 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__ = [
|
||||
'EnumThing',
|
||||
]
|
||||
|
||||
|
||||
class EnumThing(int, Enum):
|
||||
FOUR = 4
|
||||
SIX = 6
|
||||
EIGHT = 8
|
235
pkg/codegen/internal/test/testdata/plain-and-default/python/pulumi_foobar/_utilities.py
vendored
Normal file
235
pkg/codegen/internal/test/testdata/plain-and-default/python/pulumi_foobar/_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)
|
422
pkg/codegen/internal/test/testdata/plain-and-default/python/pulumi_foobar/module_resource.py
vendored
Normal file
422
pkg/codegen/internal/test/testdata/plain-and-default/python/pulumi_foobar/module_resource.py
vendored
Normal file
|
@ -0,0 +1,422 @@
|
|||
# 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__ = ['ModuleResourceArgs', 'ModuleResource']
|
||||
|
||||
@pulumi.input_type
|
||||
class ModuleResourceArgs:
|
||||
def __init__(__self__, *,
|
||||
plain_required_bool: bool,
|
||||
plain_required_const: str,
|
||||
plain_required_number: float,
|
||||
plain_required_string: str,
|
||||
required_bool: pulumi.Input[bool],
|
||||
required_enum: pulumi.Input['EnumThing'],
|
||||
required_number: pulumi.Input[float],
|
||||
required_string: pulumi.Input[str],
|
||||
optional_bool: Optional[pulumi.Input[bool]] = None,
|
||||
optional_const: Optional[pulumi.Input[str]] = None,
|
||||
optional_enum: Optional[pulumi.Input['EnumThing']] = None,
|
||||
optional_number: Optional[pulumi.Input[float]] = None,
|
||||
optional_string: Optional[pulumi.Input[str]] = None,
|
||||
plain_optional_bool: Optional[bool] = None,
|
||||
plain_optional_const: Optional[str] = None,
|
||||
plain_optional_number: Optional[float] = None,
|
||||
plain_optional_string: Optional[str] = None):
|
||||
"""
|
||||
The set of arguments for constructing a ModuleResource resource.
|
||||
"""
|
||||
if plain_required_bool is None:
|
||||
plain_required_bool = True
|
||||
pulumi.set(__self__, "plain_required_bool", plain_required_bool)
|
||||
if plain_required_const is None:
|
||||
plain_required_const = 'another'
|
||||
pulumi.set(__self__, "plain_required_const", 'val')
|
||||
if plain_required_number is None:
|
||||
plain_required_number = 42
|
||||
pulumi.set(__self__, "plain_required_number", plain_required_number)
|
||||
if plain_required_string is None:
|
||||
plain_required_string = 'buzzer'
|
||||
pulumi.set(__self__, "plain_required_string", plain_required_string)
|
||||
if required_bool is None:
|
||||
required_bool = True
|
||||
pulumi.set(__self__, "required_bool", required_bool)
|
||||
if required_enum is None:
|
||||
required_enum = 4
|
||||
pulumi.set(__self__, "required_enum", required_enum)
|
||||
if required_number is None:
|
||||
required_number = 42
|
||||
pulumi.set(__self__, "required_number", required_number)
|
||||
if required_string is None:
|
||||
required_string = 'buzzer'
|
||||
pulumi.set(__self__, "required_string", required_string)
|
||||
if optional_bool is None:
|
||||
optional_bool = True
|
||||
if optional_bool is not None:
|
||||
pulumi.set(__self__, "optional_bool", optional_bool)
|
||||
if optional_const is None:
|
||||
optional_const = 'another'
|
||||
if optional_const is not None:
|
||||
pulumi.set(__self__, "optional_const", 'val')
|
||||
if optional_enum is None:
|
||||
optional_enum = 8
|
||||
if optional_enum is not None:
|
||||
pulumi.set(__self__, "optional_enum", optional_enum)
|
||||
if optional_number is None:
|
||||
optional_number = 42
|
||||
if optional_number is not None:
|
||||
pulumi.set(__self__, "optional_number", optional_number)
|
||||
if optional_string is None:
|
||||
optional_string = 'buzzer'
|
||||
if optional_string is not None:
|
||||
pulumi.set(__self__, "optional_string", optional_string)
|
||||
if plain_optional_bool is None:
|
||||
plain_optional_bool = True
|
||||
if plain_optional_bool is not None:
|
||||
pulumi.set(__self__, "plain_optional_bool", plain_optional_bool)
|
||||
if plain_optional_const is None:
|
||||
plain_optional_const = 'another'
|
||||
if plain_optional_const is not None:
|
||||
pulumi.set(__self__, "plain_optional_const", 'val')
|
||||
if plain_optional_number is None:
|
||||
plain_optional_number = 42
|
||||
if plain_optional_number is not None:
|
||||
pulumi.set(__self__, "plain_optional_number", plain_optional_number)
|
||||
if plain_optional_string is None:
|
||||
plain_optional_string = 'buzzer'
|
||||
if plain_optional_string is not None:
|
||||
pulumi.set(__self__, "plain_optional_string", plain_optional_string)
|
||||
|
||||
@property
|
||||
@pulumi.getter
|
||||
def plain_required_bool(self) -> bool:
|
||||
return pulumi.get(self, "plain_required_bool")
|
||||
|
||||
@plain_required_bool.setter
|
||||
def plain_required_bool(self, value: bool):
|
||||
pulumi.set(self, "plain_required_bool", value)
|
||||
|
||||
@property
|
||||
@pulumi.getter
|
||||
def plain_required_const(self) -> str:
|
||||
return pulumi.get(self, "plain_required_const")
|
||||
|
||||
@plain_required_const.setter
|
||||
def plain_required_const(self, value: str):
|
||||
pulumi.set(self, "plain_required_const", value)
|
||||
|
||||
@property
|
||||
@pulumi.getter
|
||||
def plain_required_number(self) -> float:
|
||||
return pulumi.get(self, "plain_required_number")
|
||||
|
||||
@plain_required_number.setter
|
||||
def plain_required_number(self, value: float):
|
||||
pulumi.set(self, "plain_required_number", value)
|
||||
|
||||
@property
|
||||
@pulumi.getter
|
||||
def plain_required_string(self) -> str:
|
||||
return pulumi.get(self, "plain_required_string")
|
||||
|
||||
@plain_required_string.setter
|
||||
def plain_required_string(self, value: str):
|
||||
pulumi.set(self, "plain_required_string", value)
|
||||
|
||||
@property
|
||||
@pulumi.getter
|
||||
def required_bool(self) -> pulumi.Input[bool]:
|
||||
return pulumi.get(self, "required_bool")
|
||||
|
||||
@required_bool.setter
|
||||
def required_bool(self, value: pulumi.Input[bool]):
|
||||
pulumi.set(self, "required_bool", value)
|
||||
|
||||
@property
|
||||
@pulumi.getter
|
||||
def required_enum(self) -> pulumi.Input['EnumThing']:
|
||||
return pulumi.get(self, "required_enum")
|
||||
|
||||
@required_enum.setter
|
||||
def required_enum(self, value: pulumi.Input['EnumThing']):
|
||||
pulumi.set(self, "required_enum", value)
|
||||
|
||||
@property
|
||||
@pulumi.getter
|
||||
def required_number(self) -> pulumi.Input[float]:
|
||||
return pulumi.get(self, "required_number")
|
||||
|
||||
@required_number.setter
|
||||
def required_number(self, value: pulumi.Input[float]):
|
||||
pulumi.set(self, "required_number", value)
|
||||
|
||||
@property
|
||||
@pulumi.getter
|
||||
def required_string(self) -> pulumi.Input[str]:
|
||||
return pulumi.get(self, "required_string")
|
||||
|
||||
@required_string.setter
|
||||
def required_string(self, value: pulumi.Input[str]):
|
||||
pulumi.set(self, "required_string", value)
|
||||
|
||||
@property
|
||||
@pulumi.getter
|
||||
def optional_bool(self) -> Optional[pulumi.Input[bool]]:
|
||||
return pulumi.get(self, "optional_bool")
|
||||
|
||||
@optional_bool.setter
|
||||
def optional_bool(self, value: Optional[pulumi.Input[bool]]):
|
||||
pulumi.set(self, "optional_bool", value)
|
||||
|
||||
@property
|
||||
@pulumi.getter
|
||||
def optional_const(self) -> Optional[pulumi.Input[str]]:
|
||||
return pulumi.get(self, "optional_const")
|
||||
|
||||
@optional_const.setter
|
||||
def optional_const(self, value: Optional[pulumi.Input[str]]):
|
||||
pulumi.set(self, "optional_const", value)
|
||||
|
||||
@property
|
||||
@pulumi.getter
|
||||
def optional_enum(self) -> Optional[pulumi.Input['EnumThing']]:
|
||||
return pulumi.get(self, "optional_enum")
|
||||
|
||||
@optional_enum.setter
|
||||
def optional_enum(self, value: Optional[pulumi.Input['EnumThing']]):
|
||||
pulumi.set(self, "optional_enum", value)
|
||||
|
||||
@property
|
||||
@pulumi.getter
|
||||
def optional_number(self) -> Optional[pulumi.Input[float]]:
|
||||
return pulumi.get(self, "optional_number")
|
||||
|
||||
@optional_number.setter
|
||||
def optional_number(self, value: Optional[pulumi.Input[float]]):
|
||||
pulumi.set(self, "optional_number", value)
|
||||
|
||||
@property
|
||||
@pulumi.getter
|
||||
def optional_string(self) -> Optional[pulumi.Input[str]]:
|
||||
return pulumi.get(self, "optional_string")
|
||||
|
||||
@optional_string.setter
|
||||
def optional_string(self, value: Optional[pulumi.Input[str]]):
|
||||
pulumi.set(self, "optional_string", value)
|
||||
|
||||
@property
|
||||
@pulumi.getter
|
||||
def plain_optional_bool(self) -> Optional[bool]:
|
||||
return pulumi.get(self, "plain_optional_bool")
|
||||
|
||||
@plain_optional_bool.setter
|
||||
def plain_optional_bool(self, value: Optional[bool]):
|
||||
pulumi.set(self, "plain_optional_bool", value)
|
||||
|
||||
@property
|
||||
@pulumi.getter
|
||||
def plain_optional_const(self) -> Optional[str]:
|
||||
return pulumi.get(self, "plain_optional_const")
|
||||
|
||||
@plain_optional_const.setter
|
||||
def plain_optional_const(self, value: Optional[str]):
|
||||
pulumi.set(self, "plain_optional_const", value)
|
||||
|
||||
@property
|
||||
@pulumi.getter
|
||||
def plain_optional_number(self) -> Optional[float]:
|
||||
return pulumi.get(self, "plain_optional_number")
|
||||
|
||||
@plain_optional_number.setter
|
||||
def plain_optional_number(self, value: Optional[float]):
|
||||
pulumi.set(self, "plain_optional_number", value)
|
||||
|
||||
@property
|
||||
@pulumi.getter
|
||||
def plain_optional_string(self) -> Optional[str]:
|
||||
return pulumi.get(self, "plain_optional_string")
|
||||
|
||||
@plain_optional_string.setter
|
||||
def plain_optional_string(self, value: Optional[str]):
|
||||
pulumi.set(self, "plain_optional_string", value)
|
||||
|
||||
|
||||
class ModuleResource(pulumi.CustomResource):
|
||||
@overload
|
||||
def __init__(__self__,
|
||||
resource_name: str,
|
||||
opts: Optional[pulumi.ResourceOptions] = None,
|
||||
optional_bool: Optional[pulumi.Input[bool]] = None,
|
||||
optional_const: Optional[pulumi.Input[str]] = None,
|
||||
optional_enum: Optional[pulumi.Input['EnumThing']] = None,
|
||||
optional_number: Optional[pulumi.Input[float]] = None,
|
||||
optional_string: Optional[pulumi.Input[str]] = None,
|
||||
plain_optional_bool: Optional[bool] = None,
|
||||
plain_optional_const: Optional[str] = None,
|
||||
plain_optional_number: Optional[float] = None,
|
||||
plain_optional_string: Optional[str] = None,
|
||||
plain_required_bool: Optional[bool] = None,
|
||||
plain_required_const: Optional[str] = None,
|
||||
plain_required_number: Optional[float] = None,
|
||||
plain_required_string: Optional[str] = None,
|
||||
required_bool: Optional[pulumi.Input[bool]] = None,
|
||||
required_enum: Optional[pulumi.Input['EnumThing']] = None,
|
||||
required_number: Optional[pulumi.Input[float]] = None,
|
||||
required_string: Optional[pulumi.Input[str]] = None,
|
||||
__props__=None):
|
||||
"""
|
||||
Create a ModuleResource 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: ModuleResourceArgs,
|
||||
opts: Optional[pulumi.ResourceOptions] = None):
|
||||
"""
|
||||
Create a ModuleResource resource with the given unique name, props, and options.
|
||||
:param str resource_name: The name of the resource.
|
||||
:param ModuleResourceArgs 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(ModuleResourceArgs, 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,
|
||||
optional_bool: Optional[pulumi.Input[bool]] = None,
|
||||
optional_const: Optional[pulumi.Input[str]] = None,
|
||||
optional_enum: Optional[pulumi.Input['EnumThing']] = None,
|
||||
optional_number: Optional[pulumi.Input[float]] = None,
|
||||
optional_string: Optional[pulumi.Input[str]] = None,
|
||||
plain_optional_bool: Optional[bool] = None,
|
||||
plain_optional_const: Optional[str] = None,
|
||||
plain_optional_number: Optional[float] = None,
|
||||
plain_optional_string: Optional[str] = None,
|
||||
plain_required_bool: Optional[bool] = None,
|
||||
plain_required_const: Optional[str] = None,
|
||||
plain_required_number: Optional[float] = None,
|
||||
plain_required_string: Optional[str] = None,
|
||||
required_bool: Optional[pulumi.Input[bool]] = None,
|
||||
required_enum: Optional[pulumi.Input['EnumThing']] = None,
|
||||
required_number: Optional[pulumi.Input[float]] = None,
|
||||
required_string: Optional[pulumi.Input[str]] = 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__ = ModuleResourceArgs.__new__(ModuleResourceArgs)
|
||||
|
||||
if optional_bool is None:
|
||||
optional_bool = True
|
||||
__props__.__dict__["optional_bool"] = optional_bool
|
||||
if optional_const is None:
|
||||
optional_const = 'another'
|
||||
__props__.__dict__["optional_const"] = 'val'
|
||||
if optional_enum is None:
|
||||
optional_enum = 8
|
||||
__props__.__dict__["optional_enum"] = optional_enum
|
||||
if optional_number is None:
|
||||
optional_number = 42
|
||||
__props__.__dict__["optional_number"] = optional_number
|
||||
if optional_string is None:
|
||||
optional_string = 'buzzer'
|
||||
__props__.__dict__["optional_string"] = optional_string
|
||||
if plain_optional_bool is None:
|
||||
plain_optional_bool = True
|
||||
__props__.__dict__["plain_optional_bool"] = plain_optional_bool
|
||||
if plain_optional_const is None:
|
||||
plain_optional_const = 'another'
|
||||
__props__.__dict__["plain_optional_const"] = 'val'
|
||||
if plain_optional_number is None:
|
||||
plain_optional_number = 42
|
||||
__props__.__dict__["plain_optional_number"] = plain_optional_number
|
||||
if plain_optional_string is None:
|
||||
plain_optional_string = 'buzzer'
|
||||
__props__.__dict__["plain_optional_string"] = plain_optional_string
|
||||
if plain_required_bool is None:
|
||||
plain_required_bool = True
|
||||
if plain_required_bool is None and not opts.urn:
|
||||
raise TypeError("Missing required property 'plain_required_bool'")
|
||||
__props__.__dict__["plain_required_bool"] = plain_required_bool
|
||||
if plain_required_const is None:
|
||||
plain_required_const = 'another'
|
||||
if plain_required_const is None and not opts.urn:
|
||||
raise TypeError("Missing required property 'plain_required_const'")
|
||||
__props__.__dict__["plain_required_const"] = 'val'
|
||||
if plain_required_number is None:
|
||||
plain_required_number = 42
|
||||
if plain_required_number is None and not opts.urn:
|
||||
raise TypeError("Missing required property 'plain_required_number'")
|
||||
__props__.__dict__["plain_required_number"] = plain_required_number
|
||||
if plain_required_string is None:
|
||||
plain_required_string = 'buzzer'
|
||||
if plain_required_string is None and not opts.urn:
|
||||
raise TypeError("Missing required property 'plain_required_string'")
|
||||
__props__.__dict__["plain_required_string"] = plain_required_string
|
||||
if required_bool is None:
|
||||
required_bool = True
|
||||
if required_bool is None and not opts.urn:
|
||||
raise TypeError("Missing required property 'required_bool'")
|
||||
__props__.__dict__["required_bool"] = required_bool
|
||||
if required_enum is None:
|
||||
required_enum = 4
|
||||
if required_enum is None and not opts.urn:
|
||||
raise TypeError("Missing required property 'required_enum'")
|
||||
__props__.__dict__["required_enum"] = required_enum
|
||||
if required_number is None:
|
||||
required_number = 42
|
||||
if required_number is None and not opts.urn:
|
||||
raise TypeError("Missing required property 'required_number'")
|
||||
__props__.__dict__["required_number"] = required_number
|
||||
if required_string is None:
|
||||
required_string = 'buzzer'
|
||||
if required_string is None and not opts.urn:
|
||||
raise TypeError("Missing required property 'required_string'")
|
||||
__props__.__dict__["required_string"] = required_string
|
||||
super(ModuleResource, __self__).__init__(
|
||||
'foobar::ModuleResource',
|
||||
resource_name,
|
||||
__props__,
|
||||
opts)
|
||||
|
||||
@staticmethod
|
||||
def get(resource_name: str,
|
||||
id: pulumi.Input[str],
|
||||
opts: Optional[pulumi.ResourceOptions] = None) -> 'ModuleResource':
|
||||
"""
|
||||
Get an existing ModuleResource resource's state with the given name, id, and optional extra
|
||||
properties used to qualify the lookup.
|
||||
|
||||
:param str resource_name: The unique name of the resulting resource.
|
||||
:param pulumi.Input[str] id: The unique provider ID of the resource to lookup.
|
||||
:param pulumi.ResourceOptions opts: Options for the resource.
|
||||
"""
|
||||
opts = pulumi.ResourceOptions.merge(opts, pulumi.ResourceOptions(id=id))
|
||||
|
||||
__props__ = ModuleResourceArgs.__new__(ModuleResourceArgs)
|
||||
|
||||
return ModuleResource(resource_name, opts=opts, __props__=__props__)
|
||||
|
73
pkg/codegen/internal/test/testdata/plain-and-default/python/pulumi_foobar/provider.py
vendored
Normal file
73
pkg/codegen/internal/test/testdata/plain-and-default/python/pulumi_foobar/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 Foobar 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 Foobar 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__(
|
||||
'foobar',
|
||||
resource_name,
|
||||
__props__,
|
||||
opts)
|
||||
|
0
pkg/codegen/internal/test/testdata/plain-and-default/python/pulumi_foobar/py.typed
vendored
Normal file
0
pkg/codegen/internal/test/testdata/plain-and-default/python/pulumi_foobar/py.typed
vendored
Normal file
58
pkg/codegen/internal/test/testdata/plain-and-default/python/setup.py
vendored
Normal file
58
pkg/codegen/internal/test/testdata/plain-and-default/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', 'foobar', PLUGIN_VERSION])
|
||||
except OSError as error:
|
||||
if error.errno == errno.ENOENT:
|
||||
print(f"""
|
||||
There was an error installing the foobar 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 foobar {PLUGIN_VERSION}`
|
||||
""")
|
||||
else:
|
||||
raise
|
||||
|
||||
|
||||
def readme():
|
||||
try:
|
||||
with open('README.md', encoding='utf-8') as f:
|
||||
return f.read()
|
||||
except FileNotFoundError:
|
||||
return "foobar Pulumi Package - Development Version"
|
||||
|
||||
|
||||
setup(name='pulumi_foobar',
|
||||
version=VERSION,
|
||||
long_description=readme(),
|
||||
long_description_content_type='text/markdown',
|
||||
cmdclass={
|
||||
'install': InstallPluginCommand,
|
||||
},
|
||||
packages=find_packages(),
|
||||
package_data={
|
||||
'pulumi_foobar': [
|
||||
'py.typed',
|
||||
]
|
||||
},
|
||||
install_requires=[
|
||||
'parver>=0.2.1',
|
||||
'pulumi',
|
||||
'semver>=2.8.1'
|
||||
],
|
||||
zip_safe=False)
|
141
pkg/codegen/internal/test/testdata/plain-and-default/schema.json
vendored
Normal file
141
pkg/codegen/internal/test/testdata/plain-and-default/schema.json
vendored
Normal file
|
@ -0,0 +1,141 @@
|
|||
{
|
||||
"version": "0.0.1",
|
||||
"name": "foobar",
|
||||
"resources": {
|
||||
"foobar::ModuleResource": {
|
||||
"inputProperties": {
|
||||
"plain_optional_const": {
|
||||
"type": "string",
|
||||
"const": "val",
|
||||
"default": "another",
|
||||
"plain": true
|
||||
},
|
||||
"plain_optional_string": {
|
||||
"type": "string",
|
||||
"default": "buzzer",
|
||||
"plain": true
|
||||
},
|
||||
"plain_optional_bool": {
|
||||
"type": "boolean",
|
||||
"default": true,
|
||||
"plain": true
|
||||
},
|
||||
"plain_optional_number": {
|
||||
"type": "number",
|
||||
"default": 42,
|
||||
"plain": true
|
||||
},
|
||||
"plain_required_string": {
|
||||
"type": "string",
|
||||
"default": "buzzer",
|
||||
"plain": true
|
||||
},
|
||||
"plain_required_bool": {
|
||||
"type": "boolean",
|
||||
"default": true,
|
||||
"plain": true
|
||||
},
|
||||
"plain_required_number": {
|
||||
"type": "number",
|
||||
"default": 42,
|
||||
"plain": true
|
||||
},
|
||||
"optional_const": {
|
||||
"type": "string",
|
||||
"const": "val",
|
||||
"default": "another"
|
||||
},
|
||||
"optional_string": {
|
||||
"type": "string",
|
||||
"default": "buzzer"
|
||||
},
|
||||
"optional_bool": {
|
||||
"type": "boolean",
|
||||
"default": true
|
||||
},
|
||||
"optional_number": {
|
||||
"type": "number",
|
||||
"default": 42
|
||||
},
|
||||
"optional_enum": {
|
||||
"$ref": "#/types/foobar::EnumThing",
|
||||
"default": 8
|
||||
},
|
||||
"plain_required_const": {
|
||||
"type": "string",
|
||||
"const": "val",
|
||||
"default": "another",
|
||||
"plain": true
|
||||
},
|
||||
"required_string": {
|
||||
"type": "string",
|
||||
"default": "buzzer"
|
||||
},
|
||||
"required_bool": {
|
||||
"type": "boolean",
|
||||
"default": true
|
||||
},
|
||||
"required_number": {
|
||||
"type": "number",
|
||||
"default": 42
|
||||
},
|
||||
"required_enum": {
|
||||
"$ref": "#/types/foobar::EnumThing",
|
||||
"default": 4
|
||||
}
|
||||
},
|
||||
"requiredInputs": [
|
||||
"plain_required_string",
|
||||
"plain_required_bool",
|
||||
"plain_required_number",
|
||||
"plain_required_const",
|
||||
"required_string",
|
||||
"required_bool",
|
||||
"required_number",
|
||||
"required_enum"
|
||||
],
|
||||
"type": "object"
|
||||
}
|
||||
},
|
||||
"types": {
|
||||
"foobar::EnumThing": {
|
||||
"type": "integer",
|
||||
"enum": [
|
||||
{
|
||||
"value": 4,
|
||||
"name": "Four"
|
||||
},
|
||||
{
|
||||
"value": 6,
|
||||
"name": "Six"
|
||||
},
|
||||
{
|
||||
"value": 8,
|
||||
"name": "Eight"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"language": {
|
||||
"csharp": {
|
||||
"namespaces": {
|
||||
"foobar": "FooBar"
|
||||
},
|
||||
"packageReferences": {
|
||||
"Pulumi": "3.12"
|
||||
}
|
||||
},
|
||||
"go": {
|
||||
"importBasePath": "plain-and-default/foo"
|
||||
},
|
||||
"nodejs": {
|
||||
"dependencies": {
|
||||
"@pulumi/pulumi": "^3.12"
|
||||
},
|
||||
"devDependencies": {
|
||||
"typescript": "^3.7.0"
|
||||
}
|
||||
},
|
||||
"python": {}
|
||||
}
|
||||
}
|
|
@ -30,7 +30,7 @@ func NewRubberTree(ctx *pulumi.Context,
|
|||
}
|
||||
|
||||
if args.Diameter == nil {
|
||||
args.Diameter = Diameter(6)
|
||||
args.Diameter = Diameter(6.0)
|
||||
}
|
||||
if args.Farm == nil {
|
||||
args.Farm = pulumi.StringPtr("(unknown)")
|
||||
|
|
|
@ -89,6 +89,19 @@ func UnwrapType(t schema.Type) schema.Type {
|
|||
}
|
||||
}
|
||||
|
||||
func IsNOptionalInput(t schema.Type) bool {
|
||||
for {
|
||||
switch typ := t.(type) {
|
||||
case *schema.InputType:
|
||||
return true
|
||||
case *schema.OptionalType:
|
||||
t = typ.ElementType
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func resolvedType(t schema.Type, plainObjects bool) schema.Type {
|
||||
switch typ := t.(type) {
|
||||
case *schema.InputType:
|
||||
|
|
Loading…
Reference in a new issue