[schema] Add IsOverlay option to disable codegen for particular types (#8338)
Add a new `IsOverlay` option to schema types and functions that allows providers to document overlays in the schema. This makes it easier to generate API docs consistently, even for code that is generated outside of the typical codegen process.
This commit is contained in:
parent
fbeac6fc10
commit
0d4fb3e340
|
@ -1,3 +1,6 @@
|
|||
### Improvements
|
||||
|
||||
- [schema] Add IsOverlay option to disable codegen for particular types
|
||||
[#8338](https://github.com/pulumi/pulumi/pull/8338)
|
||||
|
||||
### Bug Fixes
|
||||
|
|
|
@ -297,7 +297,7 @@ Enum: `"boolean"` | `"integer"` | `"number"` | `"string"`
|
|||
|
||||
#### `deprecationMessage`
|
||||
|
||||
Indicates whether or not the value is deprecated.
|
||||
Indicates whether the value is deprecated.
|
||||
|
||||
`string`
|
||||
|
||||
|
@ -339,7 +339,7 @@ Describes a function.
|
|||
|
||||
#### `deprecationMessage`
|
||||
|
||||
Indicates whether or not the function is deprecated
|
||||
Indicates whether the function is deprecated
|
||||
|
||||
`string`
|
||||
|
||||
|
@ -564,7 +564,7 @@ Additional language-specific data about the default value.
|
|||
|
||||
#### `deprecationMessage`
|
||||
|
||||
Indicates whether or not the property is deprecated
|
||||
Indicates whether the property is deprecated
|
||||
|
||||
`string`
|
||||
|
||||
|
@ -627,7 +627,7 @@ Items: [Alias Definition](#alias-definition)
|
|||
|
||||
#### `deprecationMessage`
|
||||
|
||||
Indicates whether or not the resource is deprecated
|
||||
Indicates whether the resource is deprecated
|
||||
|
||||
`string`
|
||||
|
||||
|
@ -653,7 +653,15 @@ Additional properties: [Property Definition](#property-definition)
|
|||
|
||||
#### `isComponent`
|
||||
|
||||
Indicates whether or not the resource is a component.
|
||||
Indicates whether the resource is a component.
|
||||
|
||||
`boolean`
|
||||
|
||||
---
|
||||
|
||||
#### `isOverlay`
|
||||
|
||||
Indicates whether the resource is an overlay (code is generated by the package rather than by the core Pulumi codegen).
|
||||
|
||||
`boolean`
|
||||
|
||||
|
|
|
@ -1995,6 +1995,11 @@ func (mod *modContext) gen(fs fs) error {
|
|||
|
||||
// Resources
|
||||
for _, r := range mod.resources {
|
||||
if r.IsOverlay {
|
||||
// This resource code is generated by the provider, so no further action is required.
|
||||
continue
|
||||
}
|
||||
|
||||
imports := map[string]codegen.StringSet{}
|
||||
mod.getImportsForResource(r, imports, r)
|
||||
|
||||
|
@ -2017,6 +2022,11 @@ func (mod *modContext) gen(fs fs) error {
|
|||
|
||||
// Functions
|
||||
for _, f := range mod.functions {
|
||||
if f.IsOverlay {
|
||||
// This function code is generated by the provider, so no further action is required.
|
||||
continue
|
||||
}
|
||||
|
||||
code, err := mod.genFunctionFileCode(f)
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -2026,6 +2036,11 @@ func (mod *modContext) gen(fs fs) error {
|
|||
|
||||
// Nested types
|
||||
for _, t := range mod.types {
|
||||
if t.IsOverlay {
|
||||
// This type is generated by the provider, so no further action is required.
|
||||
continue
|
||||
}
|
||||
|
||||
if mod.details(t).inputType {
|
||||
buffer := &bytes.Buffer{}
|
||||
mod.genHeader(buffer, pulumiImports)
|
||||
|
@ -2186,6 +2201,11 @@ func generateModuleContextMap(tool string, pkg *schema.Package) (map[string]*mod
|
|||
computePropertyNames(pkg.Config, propertyNames)
|
||||
computePropertyNames(pkg.Provider.InputProperties, propertyNames)
|
||||
for _, r := range pkg.Resources {
|
||||
if r.IsOverlay {
|
||||
// This resource code is generated by the provider, so no further action is required.
|
||||
continue
|
||||
}
|
||||
|
||||
computePropertyNames(r.Properties, propertyNames)
|
||||
computePropertyNames(r.InputProperties, propertyNames)
|
||||
if r.StateInputs != nil {
|
||||
|
@ -2193,6 +2213,11 @@ func generateModuleContextMap(tool string, pkg *schema.Package) (map[string]*mod
|
|||
}
|
||||
}
|
||||
for _, f := range pkg.Functions {
|
||||
if f.IsOverlay {
|
||||
// This function code is generated by the provider, so no further action is required.
|
||||
continue
|
||||
}
|
||||
|
||||
if f.Inputs != nil {
|
||||
computePropertyNames(f.Inputs.Properties, propertyNames)
|
||||
}
|
||||
|
@ -2289,6 +2314,11 @@ func generateModuleContextMap(tool string, pkg *schema.Package) (map[string]*mod
|
|||
|
||||
// Find input and output types referenced by functions.
|
||||
for _, f := range pkg.Functions {
|
||||
if f.IsOverlay {
|
||||
// This function code is generated by the provider, so no further action is required.
|
||||
continue
|
||||
}
|
||||
|
||||
mod := getModFromToken(f.Token, pkg)
|
||||
if !f.IsMethod {
|
||||
mod.functions = append(mod.functions, f)
|
||||
|
@ -2347,6 +2377,11 @@ func LanguageResources(tool string, pkg *schema.Package) (map[string]LanguageRes
|
|||
continue
|
||||
}
|
||||
for _, r := range mod.resources {
|
||||
if r.IsOverlay {
|
||||
// This resource code is generated by the provider, so no further action is required.
|
||||
continue
|
||||
}
|
||||
|
||||
lr := LanguageResource{
|
||||
Resource: r,
|
||||
Package: namespaceName(info.Namespaces, modName),
|
||||
|
|
|
@ -2019,6 +2019,10 @@ func rewriteCyclicObjectFields(pkg *schema.Package) {
|
|||
|
||||
func (pkg *pkgContext) genType(w io.Writer, obj *schema.ObjectType) {
|
||||
contract.Assert(!obj.IsInputShape())
|
||||
if obj.IsOverlay {
|
||||
// This type is generated by the provider, so no further action is required.
|
||||
return
|
||||
}
|
||||
|
||||
pkg.genPlainType(w, pkg.tokenToType(obj.Token), obj.Comment, "", obj.Properties)
|
||||
pkg.genInputTypes(w, obj.InputShape, pkg.detailsForType(obj))
|
||||
|
@ -2130,6 +2134,10 @@ func (pkg *pkgContext) genTypeRegistrations(w io.Writer, objTypes []*schema.Obje
|
|||
// Input types.
|
||||
if !pkg.disableInputTypeRegistrations {
|
||||
for _, obj := range objTypes {
|
||||
if obj.IsOverlay {
|
||||
// This type is generated by the provider, so no further action is required.
|
||||
continue
|
||||
}
|
||||
name, details := pkg.tokenToType(obj.Token), pkg.detailsForType(obj)
|
||||
fmt.Fprintf(w, "\tpulumi.RegisterInputType(reflect.TypeOf((*%[1]sInput)(nil)).Elem(), %[1]sArgs{})\n", name)
|
||||
if details.ptrElement {
|
||||
|
@ -2152,6 +2160,10 @@ func (pkg *pkgContext) genTypeRegistrations(w io.Writer, objTypes []*schema.Obje
|
|||
|
||||
// Output types.
|
||||
for _, obj := range objTypes {
|
||||
if obj.IsOverlay {
|
||||
// This type is generated by the provider, so no further action is required.
|
||||
continue
|
||||
}
|
||||
name, details := pkg.tokenToType(obj.Token), pkg.detailsForType(obj)
|
||||
fmt.Fprintf(w, "\tpulumi.RegisterOutputType(%sOutput{})\n", name)
|
||||
if details.ptrElement {
|
||||
|
@ -2510,6 +2522,17 @@ func (pkg *pkgContext) genConfig(w io.Writer, variables []*schema.Property) erro
|
|||
// definition and its registration to support rehydrating providers.
|
||||
func (pkg *pkgContext) genResourceModule(w io.Writer) {
|
||||
contract.Assert(len(pkg.resources) != 0)
|
||||
allResourcesAreOverlays := true
|
||||
for _, r := range pkg.resources {
|
||||
if !r.IsOverlay {
|
||||
allResourcesAreOverlays = false
|
||||
break
|
||||
}
|
||||
}
|
||||
if allResourcesAreOverlays {
|
||||
// If all resources in this module are overlays, skip further code generation.
|
||||
return
|
||||
}
|
||||
|
||||
basePath := pkg.importBasePath
|
||||
|
||||
|
@ -2545,6 +2568,10 @@ func (pkg *pkgContext) genResourceModule(w io.Writer) {
|
|||
fmt.Fprintf(w, "func (m *module) Construct(ctx *pulumi.Context, name, typ, urn string) (r pulumi.Resource, err error) {\n")
|
||||
fmt.Fprintf(w, "\tswitch typ {\n")
|
||||
for _, r := range pkg.resources {
|
||||
if r.IsOverlay {
|
||||
// This resource code is generated by the provider, so no further action is required.
|
||||
continue
|
||||
}
|
||||
if r.IsProvider {
|
||||
contract.Assert(provider == nil)
|
||||
provider = r
|
||||
|
@ -3029,6 +3056,11 @@ func LanguageResources(tool string, pkg *schema.Package) (map[string]LanguageRes
|
|||
pkg := packages[mod]
|
||||
|
||||
for _, r := range pkg.resources {
|
||||
if r.IsOverlay {
|
||||
// This resource code is generated by the provider, so no further action is required.
|
||||
continue
|
||||
}
|
||||
|
||||
packagePath := path.Join(goPkgInfo.ImportBasePath, pkg.mod)
|
||||
resources[r.Token] = LanguageResource{
|
||||
Resource: r,
|
||||
|
@ -3142,6 +3174,11 @@ func GeneratePackage(tool string, pkg *schema.Package) (map[string][]byte, error
|
|||
|
||||
// Resources
|
||||
for _, r := range pkg.resources {
|
||||
if r.IsOverlay {
|
||||
// This resource code is generated by the provider, so no further action is required.
|
||||
continue
|
||||
}
|
||||
|
||||
importsAndAliases := map[string]string{}
|
||||
pkg.getImports(r, importsAndAliases)
|
||||
|
||||
|
@ -3157,6 +3194,11 @@ func GeneratePackage(tool string, pkg *schema.Package) (map[string][]byte, error
|
|||
|
||||
// Functions
|
||||
for _, f := range pkg.functions {
|
||||
if f.IsOverlay {
|
||||
// This function code is generated by the provider, so no further action is required.
|
||||
continue
|
||||
}
|
||||
|
||||
fileName := path.Join(mod, camel(tokenToName(f.Token))+".go")
|
||||
code := pkg.genFunctionCodeFile(f)
|
||||
setFile(fileName, code)
|
||||
|
@ -3248,7 +3290,7 @@ func GeneratePackage(tool string, pkg *schema.Package) (map[string][]byte, error
|
|||
}
|
||||
|
||||
// If there are resources in this module, register the module with the runtime.
|
||||
if len(pkg.resources) != 0 {
|
||||
if len(pkg.resources) != 0 && !allResourcesAreOverlays(pkg.resources) {
|
||||
buffer := &bytes.Buffer{}
|
||||
pkg.genResourceModule(buffer)
|
||||
|
||||
|
@ -3259,6 +3301,15 @@ func GeneratePackage(tool string, pkg *schema.Package) (map[string][]byte, error
|
|||
return files, nil
|
||||
}
|
||||
|
||||
func allResourcesAreOverlays(resources []*schema.Resource) bool {
|
||||
for _, r := range resources {
|
||||
if !r.IsOverlay {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
// goPackage returns the suggested package name for the given string.
|
||||
func goPackage(name string) string {
|
||||
return strings.ReplaceAll(name, "-", "")
|
||||
|
|
|
@ -217,11 +217,11 @@ type SDKCodegenOptions struct {
|
|||
Checks map[string]CodegenCheck
|
||||
}
|
||||
|
||||
// `TestSDKCodegen` runs the complete set of SDK code generation tests
|
||||
// TestSDKCodegen runs the complete set of SDK code generation tests
|
||||
// against a particular language's code generator. It also verifies
|
||||
// that the generated code is structurally sound.
|
||||
//
|
||||
// The tests files live in `pkg/codegen/internal/test/testdata` and
|
||||
// The test files live in `pkg/codegen/internal/test/testdata` and
|
||||
// are registered in `var sdkTests` in `sdk_driver.go`.
|
||||
//
|
||||
// An SDK code generation test files consists of a schema and a set of
|
||||
|
@ -245,7 +245,7 @@ type SDKCodegenOptions struct {
|
|||
// PULUMI_ACCEPT=true go test ./...
|
||||
//
|
||||
// This will rebuild subfolders such as `go/` from scratch and store
|
||||
// the set of code-generated file names in `go/codegen-manfiest.json`.
|
||||
// the set of code-generated file names in `go/codegen-manifest.json`.
|
||||
// If these outputs look correct, they need to be checked into git and
|
||||
// will then serve as the expected values for the normal test runs:
|
||||
//
|
||||
|
|
87
pkg/codegen/internal/test/testdata/schema/overlay.json
vendored
Normal file
87
pkg/codegen/internal/test/testdata/schema/overlay.json
vendored
Normal file
|
@ -0,0 +1,87 @@
|
|||
{
|
||||
"version": "0.0.1",
|
||||
"name": "example",
|
||||
"types": {
|
||||
"example::ConfigMap": {
|
||||
"properties": {
|
||||
"config": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"type": "object"
|
||||
},
|
||||
"example::ConfigMapOverlay": {
|
||||
"isOverlay": true,
|
||||
"properties": {
|
||||
"config": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"type": "object"
|
||||
}
|
||||
},
|
||||
"resources": {
|
||||
"example::Resource": {
|
||||
"properties": {
|
||||
"foo": {
|
||||
"$ref": "#/types/example::ConfigMapOverlay"
|
||||
}
|
||||
},
|
||||
"inputProperties": {
|
||||
"foo": {
|
||||
"$ref": "#/types/example::ConfigMapOverlay"
|
||||
}
|
||||
},
|
||||
"type": "object"
|
||||
},
|
||||
"example::OverlayResource": {
|
||||
"isOverlay": true,
|
||||
"properties": {
|
||||
"foo": {
|
||||
"$ref": "#/types/example::ConfigMapOverlay"
|
||||
}
|
||||
},
|
||||
"inputProperties": {
|
||||
"foo": {
|
||||
"$ref": "#/types/example::ConfigMapOverlay"
|
||||
}
|
||||
},
|
||||
"type": "object"
|
||||
}
|
||||
},
|
||||
"functions": {
|
||||
"example::Function": {
|
||||
"inputs": {
|
||||
"properties": {
|
||||
"arg1": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"outputs": {
|
||||
"properties": {
|
||||
"result": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"example::OverlayFunction": {
|
||||
"isOverlay": true,
|
||||
"inputs": {
|
||||
"properties": {
|
||||
"arg1": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"outputs": {
|
||||
"properties": {
|
||||
"result": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -14,6 +14,7 @@ no_edit_this_page: true
|
|||
<h2 id="resources">Resources</h2>
|
||||
<ul class="api">
|
||||
<li><a href="otherresource" title="OtherResource"><span class="api-symbol api-symbol--resource"></span>OtherResource</a></li>
|
||||
<li><a href="overlayresource" title="OverlayResource"><span class="api-symbol api-symbol--resource"></span>OverlayResource</a></li>
|
||||
<li><a href="provider" title="Provider"><span class="api-symbol api-symbol--resource"></span>Provider</a></li>
|
||||
<li><a href="resource" title="Resource"><span class="api-symbol api-symbol--resource"></span>Resource</a></li>
|
||||
<li><a href="typeuses" title="TypeUses"><span class="api-symbol api-symbol--resource"></span>TypeUses</a></li>
|
||||
|
@ -22,6 +23,7 @@ no_edit_this_page: true
|
|||
<h2 id="functions">Functions</h2>
|
||||
<ul class="api">
|
||||
<li><a href="argfunction" title="ArgFunction"><span class="api-symbol api-symbol--function"></span>ArgFunction</a></li>
|
||||
<li><a href="overlayfunction" title="OverlayFunction"><span class="api-symbol api-symbol--function"></span>OverlayFunction</a></li>
|
||||
</ul>
|
||||
|
||||
<h2 id="package-details">Package Details</h2>
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
"_index.md",
|
||||
"argfunction/_index.md",
|
||||
"otherresource/_index.md",
|
||||
"overlayfunction/_index.md",
|
||||
"overlayresource/_index.md",
|
||||
"provider/_index.md",
|
||||
"resource/_index.md",
|
||||
"typeuses/_index.md"
|
||||
|
|
190
pkg/codegen/internal/test/testdata/simple-resource-schema/docs/overlayfunction/_index.md
vendored
Normal file
190
pkg/codegen/internal/test/testdata/simple-resource-schema/docs/overlayfunction/_index.md
vendored
Normal file
|
@ -0,0 +1,190 @@
|
|||
|
||||
---
|
||||
title: "overlayFunction"
|
||||
title_tag: "example.overlayFunction"
|
||||
meta_desc: "Documentation for the example.overlayFunction function with examples, input properties, output properties, 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! -->
|
||||
|
||||
|
||||
|
||||
|
||||
## Using overlayFunction {#using}
|
||||
|
||||
Two invocation forms are available. The direct form accepts plain
|
||||
arguments and either blocks until the result value is available, or
|
||||
returns a Promise-wrapped result. The output form accepts
|
||||
Input-wrapped arguments and returns an Output-wrapped result.
|
||||
|
||||
{{< chooser language "typescript,python,go,csharp" / >}}
|
||||
|
||||
|
||||
{{% choosable language nodejs %}}
|
||||
<div class="highlight"
|
||||
><pre class="chroma"><code class="language-typescript" data-lang="typescript"
|
||||
><span class="k">function </span>overlayFunction<span class="p">(</span><span class="nx">args</span><span class="p">:</span> <span class="nx">OverlayFunctionArgs</span><span class="p">,</span> <span class="nx">opts</span><span class="p">?:</span> <span class="nx"><a href="/docs/reference/pkg/nodejs/pulumi/pulumi/#InvokeOptions">InvokeOptions</a></span><span class="p">): Promise<<span class="nx"><a href="#result">OverlayFunctionResult</a></span>></span
|
||||
><span class="k">
|
||||
function </span>overlayFunctionOutput<span class="p">(</span><span class="nx">args</span><span class="p">:</span> <span class="nx">OverlayFunctionOutputArgs</span><span class="p">,</span> <span class="nx">opts</span><span class="p">?:</span> <span class="nx"><a href="/docs/reference/pkg/nodejs/pulumi/pulumi/#InvokeOptions">InvokeOptions</a></span><span class="p">): Output<<span class="nx"><a href="#result">OverlayFunctionResult</a></span>></span
|
||||
></code></pre></div>
|
||||
{{% /choosable %}}
|
||||
|
||||
|
||||
{{% choosable language python %}}
|
||||
<div class="highlight"><pre class="chroma"><code class="language-python" data-lang="python"
|
||||
><span class="k">def </span>overlay_function<span class="p">(</span><span class="nx">arg1</span><span class="p">:</span> <span class="nx">Optional[Resource]</span> = None<span class="p">,</span>
|
||||
<span class="nx">opts</span><span class="p">:</span> <span class="nx"><a href="/docs/reference/pkg/python/pulumi/#pulumi.InvokeOptions">Optional[InvokeOptions]</a></span> = None<span class="p">) -></span> <span>OverlayFunctionResult</span
|
||||
><span class="k">
|
||||
def </span>overlay_function_output<span class="p">(</span><span class="nx">arg1</span><span class="p">:</span> <span class="nx">Optional[pulumi.Input[Resource]]</span> = None<span class="p">,</span>
|
||||
<span class="nx">opts</span><span class="p">:</span> <span class="nx"><a href="/docs/reference/pkg/python/pulumi/#pulumi.InvokeOptions">Optional[InvokeOptions]</a></span> = None<span class="p">) -></span> <span>Output[OverlayFunctionResult]</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>OverlayFunction<span class="p">(</span><span class="nx">ctx</span><span class="p"> *</span><span class="nx"><a href="https://pkg.go.dev/github.com/pulumi/pulumi/sdk/v3/go/pulumi?tab=doc#Context">Context</a></span><span class="p">,</span> <span class="nx">args</span><span class="p"> *</span><span class="nx">OverlayFunctionArgs</span><span class="p">,</span> <span class="nx">opts</span><span class="p"> ...</span><span class="nx"><a href="https://pkg.go.dev/github.com/pulumi/pulumi/sdk/v3/go/pulumi?tab=doc#InvokeOption">InvokeOption</a></span><span class="p">) (*<span class="nx"><a href="#result">OverlayFunctionResult</a></span>, error)</span
|
||||
><span class="k">
|
||||
func </span>OverlayFunctionOutput<span class="p">(</span><span class="nx">ctx</span><span class="p"> *</span><span class="nx"><a href="https://pkg.go.dev/github.com/pulumi/pulumi/sdk/v3/go/pulumi?tab=doc#Context">Context</a></span><span class="p">,</span> <span class="nx">args</span><span class="p"> *</span><span class="nx">OverlayFunctionOutputArgs</span><span class="p">,</span> <span class="nx">opts</span><span class="p"> ...</span><span class="nx"><a href="https://pkg.go.dev/github.com/pulumi/pulumi/sdk/v3/go/pulumi?tab=doc#InvokeOption">InvokeOption</a></span><span class="p">) OverlayFunctionResultOutput</span
|
||||
></code></pre></div>
|
||||
|
||||
> Note: This function is named `OverlayFunction` in the Go SDK.
|
||||
|
||||
{{% /choosable %}}
|
||||
|
||||
|
||||
{{% choosable language csharp %}}
|
||||
<div class="highlight"><pre class="chroma"><code class="language-csharp" data-lang="csharp"><span class="k">public static class </span><span class="nx">OverlayFunction </span><span class="p">
|
||||
{</span><span class="k">
|
||||
public static </span>Task<<span class="nx"><a href="#result">OverlayFunctionResult</a></span>> <span class="p">InvokeAsync(</span><span class="nx">OverlayFunctionArgs</span><span class="p"> </span><span class="nx">args<span class="p">,</span> <span class="nx"><a href="/docs/reference/pkg/dotnet/Pulumi/Pulumi.InvokeOptions.html">InvokeOptions</a></span><span class="p">? </span><span class="nx">opts = null<span class="p">)</span><span class="k">
|
||||
public static </span>Output<<span class="nx"><a href="#result">OverlayFunctionResult</a></span>> <span class="p">Invoke(</span><span class="nx">OverlayFunctionInvokeArgs</span><span class="p"> </span><span class="nx">args<span class="p">,</span> <span class="nx"><a href="/docs/reference/pkg/dotnet/Pulumi/Pulumi.InvokeOptions.html">InvokeOptions</a></span><span class="p">? </span><span class="nx">opts = null<span class="p">)</span><span class="p">
|
||||
}</span></code></pre></div>
|
||||
{{% /choosable %}}
|
||||
|
||||
|
||||
|
||||
The following arguments are supported:
|
||||
|
||||
|
||||
{{% choosable language csharp %}}
|
||||
<dl class="resources-properties"><dt class="property-optional"
|
||||
title="Optional">
|
||||
<span id="arg1_csharp">
|
||||
<a href="#arg1_csharp" style="color: inherit; text-decoration: inherit;">Arg1</a>
|
||||
</span>
|
||||
<span class="property-indicator"></span>
|
||||
<span class="property-type">Pulumi.<wbr>Example.<wbr>Resource</span>
|
||||
</dt>
|
||||
<dd>{{% md %}}{{% /md %}}</dd></dl>
|
||||
{{% /choosable %}}
|
||||
|
||||
{{% choosable language go %}}
|
||||
<dl class="resources-properties"><dt class="property-optional"
|
||||
title="Optional">
|
||||
<span id="arg1_go">
|
||||
<a href="#arg1_go" style="color: inherit; text-decoration: inherit;">Arg1</a>
|
||||
</span>
|
||||
<span class="property-indicator"></span>
|
||||
<span class="property-type">Resource</span>
|
||||
</dt>
|
||||
<dd>{{% md %}}{{% /md %}}</dd></dl>
|
||||
{{% /choosable %}}
|
||||
|
||||
{{% choosable language nodejs %}}
|
||||
<dl class="resources-properties"><dt class="property-optional"
|
||||
title="Optional">
|
||||
<span id="arg1_nodejs">
|
||||
<a href="#arg1_nodejs" style="color: inherit; text-decoration: inherit;">arg1</a>
|
||||
</span>
|
||||
<span class="property-indicator"></span>
|
||||
<span class="property-type">Resource</span>
|
||||
</dt>
|
||||
<dd>{{% md %}}{{% /md %}}</dd></dl>
|
||||
{{% /choosable %}}
|
||||
|
||||
{{% choosable language python %}}
|
||||
<dl class="resources-properties"><dt class="property-optional"
|
||||
title="Optional">
|
||||
<span id="arg1_python">
|
||||
<a href="#arg1_python" style="color: inherit; text-decoration: inherit;">arg1</a>
|
||||
</span>
|
||||
<span class="property-indicator"></span>
|
||||
<span class="property-type">Resource</span>
|
||||
</dt>
|
||||
<dd>{{% md %}}{{% /md %}}</dd></dl>
|
||||
{{% /choosable %}}
|
||||
|
||||
|
||||
|
||||
|
||||
## overlayFunction Result {#result}
|
||||
|
||||
The following output properties are available:
|
||||
|
||||
|
||||
|
||||
{{% choosable language csharp %}}
|
||||
<dl class="resources-properties"><dt class="property-"
|
||||
title="">
|
||||
<span id="result_csharp">
|
||||
<a href="#result_csharp" style="color: inherit; text-decoration: inherit;">Result</a>
|
||||
</span>
|
||||
<span class="property-indicator"></span>
|
||||
<span class="property-type">Pulumi.<wbr>Example.<wbr>Resource</span>
|
||||
</dt>
|
||||
<dd>{{% md %}}{{% /md %}}</dd></dl>
|
||||
{{% /choosable %}}
|
||||
|
||||
{{% choosable language go %}}
|
||||
<dl class="resources-properties"><dt class="property-"
|
||||
title="">
|
||||
<span id="result_go">
|
||||
<a href="#result_go" style="color: inherit; text-decoration: inherit;">Result</a>
|
||||
</span>
|
||||
<span class="property-indicator"></span>
|
||||
<span class="property-type">Resource</span>
|
||||
</dt>
|
||||
<dd>{{% md %}}{{% /md %}}</dd></dl>
|
||||
{{% /choosable %}}
|
||||
|
||||
{{% choosable language nodejs %}}
|
||||
<dl class="resources-properties"><dt class="property-"
|
||||
title="">
|
||||
<span id="result_nodejs">
|
||||
<a href="#result_nodejs" style="color: inherit; text-decoration: inherit;">result</a>
|
||||
</span>
|
||||
<span class="property-indicator"></span>
|
||||
<span class="property-type">Resource</span>
|
||||
</dt>
|
||||
<dd>{{% md %}}{{% /md %}}</dd></dl>
|
||||
{{% /choosable %}}
|
||||
|
||||
{{% choosable language python %}}
|
||||
<dl class="resources-properties"><dt class="property-"
|
||||
title="">
|
||||
<span id="result_python">
|
||||
<a href="#result_python" style="color: inherit; text-decoration: inherit;">result</a>
|
||||
</span>
|
||||
<span class="property-indicator"></span>
|
||||
<span class="property-type">Resource</span>
|
||||
</dt>
|
||||
<dd>{{% md %}}{{% /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>
|
||||
|
328
pkg/codegen/internal/test/testdata/simple-resource-schema/docs/overlayresource/_index.md
vendored
Normal file
328
pkg/codegen/internal/test/testdata/simple-resource-schema/docs/overlayresource/_index.md
vendored
Normal file
|
@ -0,0 +1,328 @@
|
|||
|
||||
---
|
||||
title: "OverlayResource"
|
||||
title_tag: "example.OverlayResource"
|
||||
meta_desc: "Documentation for the example.OverlayResource 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 OverlayResource 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">OverlayResource</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">OverlayResourceArgs</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">OverlayResource</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">foo</span><span class="p">:</span> <span class="nx">Optional[ConfigMapOverlayArgs]</span> = None<span class="p">)</span>
|
||||
<span class=nd>@overload</span>
|
||||
<span class="k">def </span><span class="nx">OverlayResource</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[OverlayResourceArgs]</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">NewOverlayResource</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">OverlayResourceArgs</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">OverlayResource</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">OverlayResource</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">OverlayResourceArgs</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">OverlayResourceArgs</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">OverlayResourceArgs</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">OverlayResourceArgs</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">OverlayResourceArgs</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 %}}
|
||||
|
||||
## OverlayResource 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 OverlayResource resource accepts the following [input]({{< relref "/docs/intro/concepts/inputs-outputs" >}}) properties:
|
||||
|
||||
|
||||
|
||||
{{% choosable language csharp %}}
|
||||
<dl class="resources-properties"><dt class="property-optional"
|
||||
title="Optional">
|
||||
<span id="foo_csharp">
|
||||
<a href="#foo_csharp" style="color: inherit; text-decoration: inherit;">Foo</a>
|
||||
</span>
|
||||
<span class="property-indicator"></span>
|
||||
<span class="property-type"><a href="#configmapoverlay">Config<wbr>Map<wbr>Overlay<wbr>Args</a></span>
|
||||
</dt>
|
||||
<dd>{{% md %}}{{% /md %}}</dd></dl>
|
||||
{{% /choosable %}}
|
||||
|
||||
{{% choosable language go %}}
|
||||
<dl class="resources-properties"><dt class="property-optional"
|
||||
title="Optional">
|
||||
<span id="foo_go">
|
||||
<a href="#foo_go" style="color: inherit; text-decoration: inherit;">Foo</a>
|
||||
</span>
|
||||
<span class="property-indicator"></span>
|
||||
<span class="property-type"><a href="#configmapoverlay">Config<wbr>Map<wbr>Overlay<wbr>Args</a></span>
|
||||
</dt>
|
||||
<dd>{{% md %}}{{% /md %}}</dd></dl>
|
||||
{{% /choosable %}}
|
||||
|
||||
{{% choosable language nodejs %}}
|
||||
<dl class="resources-properties"><dt class="property-optional"
|
||||
title="Optional">
|
||||
<span id="foo_nodejs">
|
||||
<a href="#foo_nodejs" style="color: inherit; text-decoration: inherit;">foo</a>
|
||||
</span>
|
||||
<span class="property-indicator"></span>
|
||||
<span class="property-type"><a href="#configmapoverlay">Config<wbr>Map<wbr>Overlay<wbr>Args</a></span>
|
||||
</dt>
|
||||
<dd>{{% md %}}{{% /md %}}</dd></dl>
|
||||
{{% /choosable %}}
|
||||
|
||||
{{% choosable language python %}}
|
||||
<dl class="resources-properties"><dt class="property-optional"
|
||||
title="Optional">
|
||||
<span id="foo_python">
|
||||
<a href="#foo_python" style="color: inherit; text-decoration: inherit;">foo</a>
|
||||
</span>
|
||||
<span class="property-indicator"></span>
|
||||
<span class="property-type"><a href="#configmapoverlay">Config<wbr>Map<wbr>Overlay<wbr>Args</a></span>
|
||||
</dt>
|
||||
<dd>{{% md %}}{{% /md %}}</dd></dl>
|
||||
{{% /choosable %}}
|
||||
|
||||
|
||||
### Outputs
|
||||
|
||||
All [input](#inputs) properties are implicitly available as output properties. Additionally, the OverlayResource 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="configmapoverlay">Config<wbr>Map<wbr>Overlay</h4>
|
||||
|
||||
{{% choosable language csharp %}}
|
||||
<dl class="resources-properties"><dt class="property-optional"
|
||||
title="Optional">
|
||||
<span id="config_csharp">
|
||||
<a href="#config_csharp" style="color: inherit; text-decoration: inherit;">Config</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-optional"
|
||||
title="Optional">
|
||||
<span id="config_go">
|
||||
<a href="#config_go" style="color: inherit; text-decoration: inherit;">Config</a>
|
||||
</span>
|
||||
<span class="property-indicator"></span>
|
||||
<span class="property-type">string</span>
|
||||
</dt>
|
||||
<dd>{{% md %}}{{% /md %}}</dd></dl>
|
||||
{{% /choosable %}}
|
||||
|
||||
{{% choosable language nodejs %}}
|
||||
<dl class="resources-properties"><dt class="property-optional"
|
||||
title="Optional">
|
||||
<span id="config_nodejs">
|
||||
<a href="#config_nodejs" style="color: inherit; text-decoration: inherit;">config</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-optional"
|
||||
title="Optional">
|
||||
<span id="config_python">
|
||||
<a href="#config_python" style="color: inherit; text-decoration: inherit;">config</a>
|
||||
</span>
|
||||
<span class="property-indicator"></span>
|
||||
<span class="property-type">str</span>
|
||||
</dt>
|
||||
<dd>{{% md %}}{{% /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>
|
||||
|
|
@ -66,6 +66,15 @@
|
|||
},
|
||||
"type": "object"
|
||||
},
|
||||
"example::ConfigMapOverlay": {
|
||||
"isOverlay": true,
|
||||
"properties": {
|
||||
"config": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"type": "object"
|
||||
},
|
||||
"example::ObjectWithNodeOptionalInputs": {
|
||||
"properties": {
|
||||
"foo": {
|
||||
|
@ -114,6 +123,20 @@
|
|||
},
|
||||
"type": "object"
|
||||
},
|
||||
"example::OverlayResource": {
|
||||
"isOverlay": true,
|
||||
"properties": {
|
||||
"foo": {
|
||||
"$ref": "#/types/example::ConfigMapOverlay"
|
||||
}
|
||||
},
|
||||
"inputProperties": {
|
||||
"foo": {
|
||||
"$ref": "#/types/example::ConfigMapOverlay"
|
||||
}
|
||||
},
|
||||
"type": "object"
|
||||
},
|
||||
"example::TypeUses": {
|
||||
"properties": {
|
||||
"foo": {
|
||||
|
@ -156,6 +179,23 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"example::overlayFunction": {
|
||||
"isOverlay": true,
|
||||
"inputs": {
|
||||
"properties": {
|
||||
"arg1": {
|
||||
"$ref": "#/resources/example::Resource"
|
||||
}
|
||||
}
|
||||
},
|
||||
"outputs": {
|
||||
"properties": {
|
||||
"result": {
|
||||
"$ref": "#/resources/example::Resource"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"language": {
|
||||
|
|
|
@ -1404,6 +1404,11 @@ func (mod *modContext) sdkImports(nested, utilities bool) []string {
|
|||
func (mod *modContext) genTypes() (string, string) {
|
||||
externalImports, imports := codegen.NewStringSet(), map[string]codegen.StringSet{}
|
||||
for _, t := range mod.types {
|
||||
if t.IsOverlay {
|
||||
// This type is generated by the provider, so no further action is required.
|
||||
continue
|
||||
}
|
||||
|
||||
mod.getImports(t, externalImports, imports)
|
||||
}
|
||||
|
||||
|
@ -1454,6 +1459,11 @@ func (mod *modContext) getNamespaces() map[string]*namespace {
|
|||
}
|
||||
|
||||
for _, t := range mod.types {
|
||||
if t.IsOverlay {
|
||||
// This type is generated by the provider, so no further action is required.
|
||||
continue
|
||||
}
|
||||
|
||||
modName := mod.pkg.TokenToModule(t.Token)
|
||||
if override, ok := mod.modToPkg[modName]; ok {
|
||||
modName = override
|
||||
|
@ -1599,6 +1609,11 @@ func (mod *modContext) gen(fs fs) error {
|
|||
|
||||
// Resources
|
||||
for _, r := range mod.resources {
|
||||
if r.IsOverlay {
|
||||
// This resource code is generated by the provider, so no further action is required.
|
||||
continue
|
||||
}
|
||||
|
||||
externalImports, imports := codegen.NewStringSet(), map[string]codegen.StringSet{}
|
||||
referencesNestedTypes := mod.getImportsForResource(r, externalImports, imports, r)
|
||||
|
||||
|
@ -1615,6 +1630,11 @@ func (mod *modContext) gen(fs fs) error {
|
|||
|
||||
// Functions
|
||||
for _, f := range mod.functions {
|
||||
if f.IsOverlay {
|
||||
// This function code is generated by the provider, so no further action is required.
|
||||
continue
|
||||
}
|
||||
|
||||
externalImports, imports := codegen.NewStringSet(), map[string]codegen.StringSet{}
|
||||
referencesNestedTypes := mod.getImports(f, externalImports, imports)
|
||||
|
||||
|
@ -1770,6 +1790,11 @@ func (mod *modContext) genResourceModule(w io.Writer) {
|
|||
} else {
|
||||
registrations, first := codegen.StringSet{}, true
|
||||
for _, r := range mod.resources {
|
||||
if r.IsOverlay {
|
||||
// This resource code is generated by the provider, so no further action is required.
|
||||
continue
|
||||
}
|
||||
|
||||
if r.IsProvider {
|
||||
contract.Assert(provider == nil)
|
||||
provider = r
|
||||
|
@ -1792,6 +1817,11 @@ func (mod *modContext) genResourceModule(w io.Writer) {
|
|||
fmt.Fprintf(w, " switch (type) {\n")
|
||||
|
||||
for _, r := range mod.resources {
|
||||
if r.IsOverlay {
|
||||
// This resource code is generated by the provider, so no further action is required.
|
||||
continue
|
||||
}
|
||||
|
||||
if r.IsProvider {
|
||||
continue
|
||||
}
|
||||
|
@ -2107,6 +2137,11 @@ func generateModuleContextMap(tool string, pkg *schema.Package, extraFiles map[s
|
|||
})
|
||||
|
||||
scanResource := func(r *schema.Resource) {
|
||||
if r.IsOverlay {
|
||||
// This resource code is generated by the provider, so no further action is required.
|
||||
return
|
||||
}
|
||||
|
||||
mod := getModFromToken(r.Token)
|
||||
mod.resources = append(mod.resources, r)
|
||||
visitObjectTypes(r.Properties, func(t *schema.ObjectType) {
|
||||
|
@ -2225,6 +2260,11 @@ func LanguageResources(pkg *schema.Package) (map[string]LanguageResource, error)
|
|||
|
||||
for modName, mod := range modules {
|
||||
for _, r := range mod.resources {
|
||||
if r.IsOverlay {
|
||||
// This resource code is generated by the provider, so no further action is required.
|
||||
continue
|
||||
}
|
||||
|
||||
packagePath := strings.Replace(modName, "/", ".", -1)
|
||||
lr := LanguageResource{
|
||||
Resource: r,
|
||||
|
|
|
@ -472,6 +472,11 @@ func (mod *modContext) gen(fs fs) error {
|
|||
|
||||
// Resources
|
||||
for _, r := range mod.resources {
|
||||
if r.IsOverlay {
|
||||
// This resource code is generated by the provider, so no further action is required.
|
||||
continue
|
||||
}
|
||||
|
||||
res, err := mod.genResource(r)
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -490,6 +495,11 @@ func (mod *modContext) gen(fs fs) error {
|
|||
|
||||
// Functions
|
||||
for _, f := range mod.functions {
|
||||
if f.IsOverlay {
|
||||
// This function code is generated by the provider, so no further action is required.
|
||||
continue
|
||||
}
|
||||
|
||||
fun, err := mod.genFunction(f)
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -523,6 +533,9 @@ func (mod *modContext) gen(fs fs) error {
|
|||
}
|
||||
|
||||
func (mod *modContext) hasTypes(input bool) bool {
|
||||
if allTypesAreOverlays(mod.types) {
|
||||
return false
|
||||
}
|
||||
for _, t := range mod.types {
|
||||
if input && mod.details(t).inputType {
|
||||
return true
|
||||
|
@ -875,12 +888,31 @@ func (mod *modContext) genConfigStubs(variables []*schema.Property) (string, err
|
|||
return w.String(), nil
|
||||
}
|
||||
|
||||
func allTypesAreOverlays(types []*schema.ObjectType) bool {
|
||||
for _, t := range types {
|
||||
if !t.IsOverlay {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func (mod *modContext) genTypes(dir string, fs fs) error {
|
||||
genTypes := func(file string, input bool) error {
|
||||
w := &bytes.Buffer{}
|
||||
|
||||
if allTypesAreOverlays(mod.types) {
|
||||
// If all resources in this module are overlays, skip further code generation.
|
||||
return nil
|
||||
}
|
||||
|
||||
imports := imports{}
|
||||
for _, t := range mod.types {
|
||||
if t.IsOverlay {
|
||||
// This type is generated by the provider, so no further action is required.
|
||||
continue
|
||||
}
|
||||
|
||||
if input && mod.details(t).inputType {
|
||||
visitObjectTypes(t.Properties, func(t schema.Type) {
|
||||
switch t := t.(type) {
|
||||
|
@ -909,6 +941,11 @@ func (mod *modContext) genTypes(dir string, fs fs) error {
|
|||
// Export only the symbols we want exported.
|
||||
fmt.Fprintf(w, "__all__ = [\n")
|
||||
for _, t := range mod.types {
|
||||
if t.IsOverlay {
|
||||
// This type is generated by the provider, so no further action is required.
|
||||
continue
|
||||
}
|
||||
|
||||
if input && mod.details(t).inputType || !input && mod.details(t).outputType {
|
||||
fmt.Fprintf(w, " '%s',\n", mod.unqualifiedObjectTypeName(t, input))
|
||||
}
|
||||
|
@ -917,6 +954,11 @@ func (mod *modContext) genTypes(dir string, fs fs) error {
|
|||
|
||||
var hasTypes bool
|
||||
for _, t := range mod.types {
|
||||
if t.IsOverlay {
|
||||
// This type is generated by the provider, so no further action is required.
|
||||
continue
|
||||
}
|
||||
|
||||
if input && mod.details(t).inputType {
|
||||
if err := mod.genObjectType(w, t, true); err != nil {
|
||||
return err
|
||||
|
@ -2735,6 +2777,11 @@ func LanguageResources(tool string, pkg *schema.Package) (map[string]LanguageRes
|
|||
continue
|
||||
}
|
||||
for _, r := range mod.resources {
|
||||
if r.IsOverlay {
|
||||
// This resource code is generated by the provider, so no further action is required.
|
||||
continue
|
||||
}
|
||||
|
||||
packagePath := strings.Replace(modName, "/", ".", -1)
|
||||
lr := LanguageResource{
|
||||
Resource: r,
|
||||
|
|
|
@ -103,6 +103,11 @@ func collectResourceModuleInfos(mctx *modContext) []resourceModuleInfo {
|
|||
byMod := make(map[string]resourceModuleInfo)
|
||||
|
||||
for _, res := range mctx.resources {
|
||||
if res.IsOverlay {
|
||||
// This resource code is generated by the provider, so no further action is required.
|
||||
continue
|
||||
}
|
||||
|
||||
if !res.IsProvider {
|
||||
pkg := mctx.pkg.Name
|
||||
mod := mctx.pkg.TokenToRuntimeModule(res.Token)
|
||||
|
@ -158,6 +163,11 @@ func allResourcePackageInfos(root *modContext) []resourcePackageInfo {
|
|||
func collectResourcePackageInfos(mctx *modContext) []resourcePackageInfo {
|
||||
var out []resourcePackageInfo
|
||||
for _, res := range mctx.resources {
|
||||
if res.IsOverlay {
|
||||
// This resource code is generated by the provider, so no further action is required.
|
||||
continue
|
||||
}
|
||||
|
||||
if res.IsProvider {
|
||||
pkg := mctx.pkg.Name
|
||||
token := res.Token
|
||||
|
|
|
@ -228,6 +228,9 @@ type ObjectType struct {
|
|||
Properties []*Property
|
||||
// Language specifies additional language-specific data about the object type.
|
||||
Language map[string]interface{}
|
||||
// IsOverlay indicates whether the type is an overlay provided by the package. Overlay code is generated by the
|
||||
// package rather than using the core Pulumi codegen libraries.
|
||||
IsOverlay bool
|
||||
|
||||
// InputShape is the input shape for this object. Only valid if IsPlainShape returns true.
|
||||
InputShape *ObjectType
|
||||
|
@ -398,6 +401,9 @@ type Resource struct {
|
|||
IsComponent bool
|
||||
// Methods is the list of methods for the resource.
|
||||
Methods []*Method
|
||||
// IsOverlay indicates whether the type is an overlay provided by the package. Overlay code is generated by the
|
||||
// package rather than using the core Pulumi codegen libraries.
|
||||
IsOverlay bool
|
||||
}
|
||||
|
||||
// The set of resource paths where ReplaceOnChanges is true.
|
||||
|
@ -533,6 +539,9 @@ type Function struct {
|
|||
Language map[string]interface{}
|
||||
// IsMethod indicates whether the function is a method of a resource.
|
||||
IsMethod bool
|
||||
// IsOverlay indicates whether the function is an overlay provided by the package. Overlay code is generated by the
|
||||
// package rather than using the core Pulumi codegen libraries.
|
||||
IsOverlay bool
|
||||
}
|
||||
|
||||
// Package describes a Pulumi package.
|
||||
|
@ -1011,6 +1020,7 @@ func (pkg *Package) marshalResource(r *Resource) (ResourceSpec, error) {
|
|||
if err != nil {
|
||||
return ResourceSpec{}, fmt.Errorf("marshaling properties: %w", err)
|
||||
}
|
||||
object.IsOverlay = r.IsOverlay
|
||||
|
||||
requiredInputs, inputs, err := pkg.marshalProperties(r.InputProperties, false)
|
||||
if err != nil {
|
||||
|
@ -1381,6 +1391,9 @@ type ObjectTypeSpec struct {
|
|||
Plain []string `json:"plain,omitempty" yaml:"plain,omitempty"`
|
||||
// Language specifies additional language-specific data about the type.
|
||||
Language map[string]RawMessage `json:"language,omitempty" yaml:"language,omitempty"`
|
||||
// IsOverlay indicates whether the type is an overlay provided by the package. Overlay code is generated by the
|
||||
// package rather than using the core Pulumi codegen libraries.
|
||||
IsOverlay bool `json:"isOverlay,omitempty" yaml:"isOverlay,omitempty"`
|
||||
}
|
||||
|
||||
// ComplexTypeSpec is the serializable form of an object or enum type.
|
||||
|
@ -1449,6 +1462,9 @@ type FunctionSpec struct {
|
|||
DeprecationMessage string `json:"deprecationMessage,omitempty" yaml:"deprecationMessage,omitempty"`
|
||||
// Language specifies additional language-specific data about the function.
|
||||
Language map[string]RawMessage `json:"language,omitempty" yaml:"language,omitempty"`
|
||||
// IsOverlay indicates whether the function is an overlay provided by the package. Overlay code is generated by the
|
||||
// package rather than using the core Pulumi codegen libraries.
|
||||
IsOverlay bool `json:"isOverlay,omitempty" yaml:"isOverlay,omitempty"`
|
||||
}
|
||||
|
||||
// ConfigSpec is the serializable description of a package's configuration variables.
|
||||
|
@ -2332,6 +2348,7 @@ func (t *types) bindObjectTypeDetails(path string, obj *ObjectType, token string
|
|||
obj.Language = language
|
||||
obj.Properties = properties
|
||||
obj.properties = propertyMap
|
||||
obj.IsOverlay = spec.IsOverlay
|
||||
|
||||
obj.InputShape.Package = t.pkg
|
||||
obj.InputShape.Token = token
|
||||
|
@ -2346,6 +2363,7 @@ func (t *types) bindObjectTypeDetails(path string, obj *ObjectType, token string
|
|||
func (t *types) bindObjectType(path, token string, spec ObjectTypeSpec) (*ObjectType, hcl.Diagnostics, error) {
|
||||
obj := &ObjectType{}
|
||||
obj.InputShape = &ObjectType{PlainShape: obj}
|
||||
obj.IsOverlay = spec.IsOverlay
|
||||
|
||||
diags, err := t.bindObjectTypeDetails(path, obj, token, spec)
|
||||
if err != nil {
|
||||
|
@ -2448,7 +2466,7 @@ func bindTypes(pkg *Package, complexTypes map[string]ComplexTypeSpec, loader Loa
|
|||
// object type is its token. While this doesn't affect object types directly, it breaks the interning of types
|
||||
// that reference object types (e.g. arrays, maps, unions)
|
||||
typ := &ObjectType{Token: token}
|
||||
typ.InputShape = &ObjectType{Token: token, PlainShape: typ}
|
||||
typ.InputShape = &ObjectType{Token: token, PlainShape: typ, IsOverlay: spec.IsOverlay}
|
||||
typs.objects[token] = typ
|
||||
typs.named[token] = typ
|
||||
} else if len(spec.Enum) > 0 {
|
||||
|
@ -2602,6 +2620,7 @@ func bindResource(path, token string, spec ResourceSpec, types *types,
|
|||
Language: language,
|
||||
IsComponent: spec.IsComponent,
|
||||
Methods: methods,
|
||||
IsOverlay: spec.IsOverlay,
|
||||
}, diags, nil
|
||||
}
|
||||
|
||||
|
@ -2717,6 +2736,7 @@ func bindFunction(token string, spec FunctionSpec, types *types) (*Function, hcl
|
|||
Outputs: outputs,
|
||||
DeprecationMessage: spec.DeprecationMessage,
|
||||
Language: language,
|
||||
IsOverlay: spec.IsOverlay,
|
||||
}, diags, nil
|
||||
}
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@ import (
|
|||
"path/filepath"
|
||||
"reflect"
|
||||
"sort"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/blang/semver"
|
||||
|
@ -412,6 +413,43 @@ func TestMethods(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
// TestIsOverlay tests that the IsOverlay field is set correctly for resources, types, and functions. Does not test
|
||||
// codegen.
|
||||
func TestIsOverlay(t *testing.T) {
|
||||
t.Run("overlay", func(t *testing.T) {
|
||||
pkgSpec := readSchemaFile(filepath.Join("schema", "overlay.json"))
|
||||
|
||||
pkg, err := ImportSpec(pkgSpec, nil)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
for _, v := range pkg.Resources {
|
||||
if strings.Contains(v.Token, "Overlay") {
|
||||
assert.Truef(t, v.IsOverlay, "resource %q", v.Token)
|
||||
} else {
|
||||
assert.Falsef(t, v.IsOverlay, "resource %q", v.Token)
|
||||
}
|
||||
}
|
||||
for _, v := range pkg.Types {
|
||||
switch v := v.(type) {
|
||||
case *ObjectType:
|
||||
if strings.Contains(v.Token, "Overlay") {
|
||||
assert.Truef(t, v.IsOverlay, "object type %q", v.Token)
|
||||
} else {
|
||||
assert.Falsef(t, v.IsOverlay, "object type %q", v.Token)
|
||||
}
|
||||
}
|
||||
}
|
||||
for _, v := range pkg.Functions {
|
||||
if strings.Contains(v.Token, "Overlay") {
|
||||
assert.Truef(t, v.IsOverlay, "function %q", v.Token)
|
||||
} else {
|
||||
assert.Falsef(t, v.IsOverlay, "function %q", v.Token)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// Tests that the method ReplaceOnChanges works as expected. Does not test
|
||||
// codegen.
|
||||
func TestReplaceOnChanges(t *testing.T) {
|
||||
|
|
Loading…
Reference in a new issue