Make resource container-type generation optional

This commit is contained in:
Vivek Lakshmanan 2021-01-19 16:47:42 -08:00
parent 3aa566d286
commit 38ac84038c
8 changed files with 107 additions and 620 deletions

View file

@ -923,7 +923,7 @@ func (pkg *pkgContext) getDefaultValue(dv *schema.DefaultValue, t schema.Type) (
return val, nil
}
func (pkg *pkgContext) genResource(w io.Writer, r *schema.Resource) error {
func (pkg *pkgContext) genResource(w io.Writer, r *schema.Resource, opts *codegenerationOptions) error {
name := resourceName(r)
printCommentWithDeprecationMessage(w, r.Comment, r.DeprecationMessage, false)
@ -1120,28 +1120,32 @@ func (pkg *pkgContext) genResource(w io.Writer, r *schema.Resource) error {
fmt.Fprintf(w, "\tTo%[1]sOutput() %[1]sOutput\n", name)
fmt.Fprintf(w, "\tTo%[1]sOutputWithContext(ctx context.Context) %[1]sOutput\n", name)
fmt.Fprintf(w, "}\n\n")
genInputMethods(w, name, "*"+name, name, true, true)
// Emit the resource pointer input type.
fmt.Fprintf(w, "type %sPtrInput interface {\n", name)
fmt.Fprintf(w, "\tpulumi.Input\n\n")
fmt.Fprintf(w, "\tTo%[1]sPtrOutput() %[1]sPtrOutput\n", name)
fmt.Fprintf(w, "\tTo%[1]sPtrOutputWithContext(ctx context.Context) %[1]sPtrOutput\n", name)
fmt.Fprintf(w, "}\n\n")
ptrTypeName := camel(name) + "PtrType"
fmt.Fprintf(w, "type %s %sArgs\n\n", ptrTypeName, name)
genInputMethods(w, name+"Ptr", "*"+ptrTypeName, "*"+name, false, true)
generateContainerTypesForResources := opts != nil && opts.generateContainerTypesForResources
genInputMethods(w, name, "*"+name, name, generateContainerTypesForResources, true)
if !r.IsProvider {
// Generate the resource array input.
genInputInterface(w, name+"Array")
fmt.Fprintf(w, "type %[1]sArray []%[1]sInput\n\n", name)
genResourceContainerInput(w, name+"Array", name+"Array", "[]*"+name)
if generateContainerTypesForResources {
// Emit the resource pointer input type.
fmt.Fprintf(w, "type %sPtrInput interface {\n", name)
fmt.Fprintf(w, "\tpulumi.Input\n\n")
fmt.Fprintf(w, "\tTo%[1]sPtrOutput() %[1]sPtrOutput\n", name)
fmt.Fprintf(w, "\tTo%[1]sPtrOutputWithContext(ctx context.Context) %[1]sPtrOutput\n", name)
fmt.Fprintf(w, "}\n\n")
ptrTypeName := camel(name) + "PtrType"
fmt.Fprintf(w, "type %s %sArgs\n\n", ptrTypeName, name)
genInputMethods(w, name+"Ptr", "*"+ptrTypeName, "*"+name, false, true)
// Generate the resource map input.
genInputInterface(w, name+"Map")
fmt.Fprintf(w, "type %[1]sMap map[string]%[1]sInput\n\n", name)
genResourceContainerInput(w, name+"Map", name+"Map", "map[string]*"+name)
if !r.IsProvider {
// Generate the resource array input.
genInputInterface(w, name+"Array")
fmt.Fprintf(w, "type %[1]sArray []%[1]sInput\n\n", name)
genResourceContainerInput(w, name+"Array", name+"Array", "[]*"+name)
// Generate the resource map input.
genInputInterface(w, name+"Map")
fmt.Fprintf(w, "type %[1]sMap map[string]%[1]sInput\n\n", name)
genResourceContainerInput(w, name+"Map", name+"Map", "map[string]*"+name)
}
}
// Emit the resource output type.
@ -1150,49 +1154,53 @@ func (pkg *pkgContext) genResource(w io.Writer, r *schema.Resource) error {
fmt.Fprintf(w, "}\n\n")
genOutputMethods(w, name, name, true)
fmt.Fprintf(w, "\n")
fmt.Fprintf(w, "func (o %[1]sOutput) To%[2]sPtrOutput() %[1]sPtrOutput {\n", name, Title(name))
fmt.Fprintf(w, "\treturn o.To%sPtrOutputWithContext(context.Background())\n", Title(name))
fmt.Fprintf(w, "}\n\n")
fmt.Fprintf(w, "func (o %[1]sOutput) To%[2]sPtrOutputWithContext(ctx context.Context) %[1]sPtrOutput {\n", name, Title(name))
fmt.Fprintf(w, "\treturn o.ApplyT(func(v %[1]s) *%[1]s {\n", name)
fmt.Fprintf(w, "\t\treturn &v\n")
fmt.Fprintf(w, "\t}).(%sPtrOutput)\n", name)
fmt.Fprintf(w, "}\n")
fmt.Fprintf(w, "\n")
// Emit the resource pointer output type.
fmt.Fprintf(w, "type %sOutput struct {\n", name+"Ptr")
fmt.Fprintf(w, "\t*pulumi.OutputState\n")
fmt.Fprintf(w, "}\n\n")
genOutputMethods(w, name+"Ptr", "*"+name, true)
if !r.IsProvider {
// Emit the array output type
fmt.Fprintf(w, "type %sArrayOutput struct { *pulumi.OutputState }\n\n", name)
genOutputMethods(w, name+"Array", "[]"+name, true)
fmt.Fprintf(w, "func (o %[1]sArrayOutput) Index(i pulumi.IntInput) %[1]sOutput {\n", name)
fmt.Fprintf(w, "\treturn pulumi.All(o, i).ApplyT(func (vs []interface{}) %s {\n", name)
fmt.Fprintf(w, "\t\treturn vs[0].([]%s)[vs[1].(int)]\n", name)
fmt.Fprintf(w, "\t}).(%sOutput)\n", name)
if generateContainerTypesForResources {
fmt.Fprintf(w, "func (o %[1]sOutput) To%[2]sPtrOutput() %[1]sPtrOutput {\n", name, Title(name))
fmt.Fprintf(w, "\treturn o.To%sPtrOutputWithContext(context.Background())\n", Title(name))
fmt.Fprintf(w, "}\n\n")
// Emit the map output type
fmt.Fprintf(w, "type %sMapOutput struct { *pulumi.OutputState }\n\n", name)
genOutputMethods(w, name+"Map", "map[string]"+name, true)
fmt.Fprintf(w, "func (o %[1]sMapOutput) MapIndex(k pulumi.StringInput) %[1]sOutput {\n", name)
fmt.Fprintf(w, "\treturn pulumi.All(o, k).ApplyT(func (vs []interface{}) %s {\n", name)
fmt.Fprintf(w, "\t\treturn vs[0].(map[string]%s)[vs[1].(string)]\n", name)
fmt.Fprintf(w, "\t}).(%sOutput)\n", name)
fmt.Fprintf(w, "func (o %[1]sOutput) To%[2]sPtrOutputWithContext(ctx context.Context) %[1]sPtrOutput {\n", name, Title(name))
fmt.Fprintf(w, "\treturn o.ApplyT(func(v %[1]s) *%[1]s {\n", name)
fmt.Fprintf(w, "\t\treturn &v\n")
fmt.Fprintf(w, "\t}).(%sPtrOutput)\n", name)
fmt.Fprintf(w, "}\n")
fmt.Fprintf(w, "\n")
// Emit the resource pointer output type.
fmt.Fprintf(w, "type %sOutput struct {\n", name+"Ptr")
fmt.Fprintf(w, "\t*pulumi.OutputState\n")
fmt.Fprintf(w, "}\n\n")
genOutputMethods(w, name+"Ptr", "*"+name, true)
if !r.IsProvider {
// Emit the array output type
fmt.Fprintf(w, "type %sArrayOutput struct { *pulumi.OutputState }\n\n", name)
genOutputMethods(w, name+"Array", "[]"+name, true)
fmt.Fprintf(w, "func (o %[1]sArrayOutput) Index(i pulumi.IntInput) %[1]sOutput {\n", name)
fmt.Fprintf(w, "\treturn pulumi.All(o, i).ApplyT(func (vs []interface{}) %s {\n", name)
fmt.Fprintf(w, "\t\treturn vs[0].([]%s)[vs[1].(int)]\n", name)
fmt.Fprintf(w, "\t}).(%sOutput)\n", name)
fmt.Fprintf(w, "}\n\n")
// Emit the map output type
fmt.Fprintf(w, "type %sMapOutput struct { *pulumi.OutputState }\n\n", name)
genOutputMethods(w, name+"Map", "map[string]"+name, true)
fmt.Fprintf(w, "func (o %[1]sMapOutput) MapIndex(k pulumi.StringInput) %[1]sOutput {\n", name)
fmt.Fprintf(w, "\treturn pulumi.All(o, k).ApplyT(func (vs []interface{}) %s {\n", name)
fmt.Fprintf(w, "\t\treturn vs[0].(map[string]%s)[vs[1].(string)]\n", name)
fmt.Fprintf(w, "\t}).(%sOutput)\n", name)
fmt.Fprintf(w, "}\n\n")
}
}
// Register all output types
fmt.Fprintf(w, "func init() {\n")
fmt.Fprintf(w, "\tpulumi.RegisterOutputType(%sOutput{})\n", name)
fmt.Fprintf(w, "\tpulumi.RegisterOutputType(%sPtrOutput{})\n", name)
if !r.IsProvider {
fmt.Fprintf(w, "\tpulumi.RegisterOutputType(%sArrayOutput{})\n", name)
fmt.Fprintf(w, "\tpulumi.RegisterOutputType(%sMapOutput{})\n", name)
if opts != nil && opts.generateContainerTypesForResources {
fmt.Fprintf(w, "\tpulumi.RegisterOutputType(%sPtrOutput{})\n", name)
if !r.IsProvider {
fmt.Fprintf(w, "\tpulumi.RegisterOutputType(%sArrayOutput{})\n", name)
fmt.Fprintf(w, "\tpulumi.RegisterOutputType(%sMapOutput{})\n", name)
}
}
fmt.Fprintf(w, "}\n\n")
@ -1817,7 +1825,34 @@ func LanguageResources(tool string, pkg *schema.Package) (map[string]LanguageRes
return resources, nil
}
func GeneratePackage(tool string, pkg *schema.Package) (map[string][]byte, error) {
type CodeGenerationOption interface {
apply(options *codegenerationOptions)
}
type codegenerationFunc func(*codegenerationOptions)
func (c codegenerationFunc) apply(options *codegenerationOptions) {
c(options)
}
// EnableContainerTypesGenerationForResources enables generating
// container variant types for resources - as used for external
// resource references.
func EnableContainerTypesGenerationForResources() CodeGenerationOption {
return codegenerationFunc(func(options *codegenerationOptions) {
options.generateContainerTypesForResources = true
})
}
type codegenerationOptions struct {
generateContainerTypesForResources bool
}
func GeneratePackage(tool string, pkg *schema.Package, options ...CodeGenerationOption) (map[string][]byte, error) {
codegenOpts := codegenerationOptions{}
for _, o := range options {
o.apply(&codegenOpts)
}
if err := pkg.ImportLanguages(map[string]schema.Language{"go": Importer}); err != nil {
return nil, err
}
@ -1890,7 +1925,7 @@ func GeneratePackage(tool string, pkg *schema.Package) (map[string][]byte, error
buffer := &bytes.Buffer{}
pkg.genHeader(buffer, []string{"context", "reflect"}, importsAndAliases)
if err := pkg.genResource(buffer, r); err != nil {
if err := pkg.genResource(buffer, r, &codegenOpts); err != nil {
return nil, err
}

View file

@ -36,7 +36,7 @@ func CRDTypes(tool string, pkg *schema.Package) (map[string]*bytes.Buffer, error
pkg.getImports(r, importsAndAliases)
pkg.genHeader(buffer, []string{"context", "reflect"}, importsAndAliases)
if err := pkg.genResource(buffer, r); err != nil {
if err := pkg.genResource(buffer, r, nil); err != nil {
return nil, errors.Wrapf(err, "generating resource %s", mod)
}
}

View file

@ -54,9 +54,10 @@ func TestGoPackageName(t *testing.T) {
func TestGeneratePackage(t *testing.T) {
tests := []struct {
name string
schemaDir string
expectedFiles []string
name string
schemaDir string
expectedFiles []string
genResourceContainerTypes bool
}{
{
"Simple schema with local resource properties",
@ -71,6 +72,7 @@ func TestGeneratePackage(t *testing.T) {
filepath.Join("example", "pulumiUtilities.go"),
filepath.Join("example", "resource.go"),
},
false,
},
{
"Simple schema with enum types",
@ -87,6 +89,7 @@ func TestGeneratePackage(t *testing.T) {
filepath.Join("plant", "tree", "v1", "rubberTree.go"),
filepath.Join("plant", "tree", "v1", "pulumiEnums.go"),
},
false,
},
{
"External resource schema",
@ -102,6 +105,7 @@ func TestGeneratePackage(t *testing.T) {
filepath.Join("example", "pulumiUtilities.go"),
filepath.Join("example", "workload.go"),
},
true,
},
}
testDir := filepath.Join("..", "internal", "test", "testdata")
@ -110,7 +114,11 @@ func TestGeneratePackage(t *testing.T) {
files, err := test.GeneratePackageFilesFromSchema(
filepath.Join(testDir, tt.schemaDir, "schema.json"),
func(tool string, pkg *schema.Package, files map[string][]byte) (map[string][]byte, error) {
return GeneratePackage(tool, pkg)
var genOpts []CodeGenerationOption
if tt.genResourceContainerTypes {
genOpts = append(genOpts, EnableContainerTypesGenerationForResources())
}
return GeneratePackage(tool, pkg, genOpts...)
})
assert.NoError(t, err)

View file

@ -59,35 +59,6 @@ func (i *Provider) ToProviderOutputWithContext(ctx context.Context) ProviderOutp
return pulumi.ToOutputWithContext(ctx, i).(ProviderOutput)
}
func (i *Provider) ToProviderPtrOutput() ProviderPtrOutput {
return i.ToProviderPtrOutputWithContext(context.Background())
}
func (i *Provider) ToProviderPtrOutputWithContext(ctx context.Context) ProviderPtrOutput {
return pulumi.ToOutputWithContext(ctx, i).(ProviderPtrOutput)
}
type ProviderPtrInput interface {
pulumi.Input
ToProviderPtrOutput() ProviderPtrOutput
ToProviderPtrOutputWithContext(ctx context.Context) ProviderPtrOutput
}
type providerPtrType ProviderArgs
func (*providerPtrType) ElementType() reflect.Type {
return reflect.TypeOf((**Provider)(nil))
}
func (i *providerPtrType) ToProviderPtrOutput() ProviderPtrOutput {
return i.ToProviderPtrOutputWithContext(context.Background())
}
func (i *providerPtrType) ToProviderPtrOutputWithContext(ctx context.Context) ProviderPtrOutput {
return pulumi.ToOutputWithContext(ctx, i).(ProviderPtrOutput)
}
type ProviderOutput struct {
*pulumi.OutputState
}
@ -104,33 +75,6 @@ func (o ProviderOutput) ToProviderOutputWithContext(ctx context.Context) Provide
return o
}
func (o ProviderOutput) ToProviderPtrOutput() ProviderPtrOutput {
return o.ToProviderPtrOutputWithContext(context.Background())
}
func (o ProviderOutput) ToProviderPtrOutputWithContext(ctx context.Context) ProviderPtrOutput {
return o.ApplyT(func(v Provider) *Provider {
return &v
}).(ProviderPtrOutput)
}
type ProviderPtrOutput struct {
*pulumi.OutputState
}
func (ProviderPtrOutput) ElementType() reflect.Type {
return reflect.TypeOf((**Provider)(nil))
}
func (o ProviderPtrOutput) ToProviderPtrOutput() ProviderPtrOutput {
return o
}
func (o ProviderPtrOutput) ToProviderPtrOutputWithContext(ctx context.Context) ProviderPtrOutput {
return o
}
func init() {
pulumi.RegisterOutputType(ProviderOutput{})
pulumi.RegisterOutputType(ProviderPtrOutput{})
}

View file

@ -103,85 +103,6 @@ func (i *RubberTree) ToRubberTreeOutputWithContext(ctx context.Context) RubberTr
return pulumi.ToOutputWithContext(ctx, i).(RubberTreeOutput)
}
func (i *RubberTree) ToRubberTreePtrOutput() RubberTreePtrOutput {
return i.ToRubberTreePtrOutputWithContext(context.Background())
}
func (i *RubberTree) ToRubberTreePtrOutputWithContext(ctx context.Context) RubberTreePtrOutput {
return pulumi.ToOutputWithContext(ctx, i).(RubberTreePtrOutput)
}
type RubberTreePtrInput interface {
pulumi.Input
ToRubberTreePtrOutput() RubberTreePtrOutput
ToRubberTreePtrOutputWithContext(ctx context.Context) RubberTreePtrOutput
}
type rubberTreePtrType RubberTreeArgs
func (*rubberTreePtrType) ElementType() reflect.Type {
return reflect.TypeOf((**RubberTree)(nil))
}
func (i *rubberTreePtrType) ToRubberTreePtrOutput() RubberTreePtrOutput {
return i.ToRubberTreePtrOutputWithContext(context.Background())
}
func (i *rubberTreePtrType) ToRubberTreePtrOutputWithContext(ctx context.Context) RubberTreePtrOutput {
return pulumi.ToOutputWithContext(ctx, i).(RubberTreePtrOutput)
}
// RubberTreeArrayInput is an input type that accepts RubberTreeArray and RubberTreeArrayOutput values.
// You can construct a concrete instance of `RubberTreeArrayInput` via:
//
// RubberTreeArray{ RubberTreeArgs{...} }
type RubberTreeArrayInput interface {
pulumi.Input
ToRubberTreeArrayOutput() RubberTreeArrayOutput
ToRubberTreeArrayOutputWithContext(context.Context) RubberTreeArrayOutput
}
type RubberTreeArray []RubberTreeInput
func (RubberTreeArray) ElementType() reflect.Type {
return reflect.TypeOf(([]*RubberTree)(nil))
}
func (i RubberTreeArray) ToRubberTreeArrayOutput() RubberTreeArrayOutput {
return i.ToRubberTreeArrayOutputWithContext(context.Background())
}
func (i RubberTreeArray) ToRubberTreeArrayOutputWithContext(ctx context.Context) RubberTreeArrayOutput {
return pulumi.ToOutputWithContext(ctx, i).(RubberTreeArrayOutput)
}
// RubberTreeMapInput is an input type that accepts RubberTreeMap and RubberTreeMapOutput values.
// You can construct a concrete instance of `RubberTreeMapInput` via:
//
// RubberTreeMap{ "key": RubberTreeArgs{...} }
type RubberTreeMapInput interface {
pulumi.Input
ToRubberTreeMapOutput() RubberTreeMapOutput
ToRubberTreeMapOutputWithContext(context.Context) RubberTreeMapOutput
}
type RubberTreeMap map[string]RubberTreeInput
func (RubberTreeMap) ElementType() reflect.Type {
return reflect.TypeOf((map[string]*RubberTree)(nil))
}
func (i RubberTreeMap) ToRubberTreeMapOutput() RubberTreeMapOutput {
return i.ToRubberTreeMapOutputWithContext(context.Background())
}
func (i RubberTreeMap) ToRubberTreeMapOutputWithContext(ctx context.Context) RubberTreeMapOutput {
return pulumi.ToOutputWithContext(ctx, i).(RubberTreeMapOutput)
}
type RubberTreeOutput struct {
*pulumi.OutputState
}
@ -198,75 +119,6 @@ func (o RubberTreeOutput) ToRubberTreeOutputWithContext(ctx context.Context) Rub
return o
}
func (o RubberTreeOutput) ToRubberTreePtrOutput() RubberTreePtrOutput {
return o.ToRubberTreePtrOutputWithContext(context.Background())
}
func (o RubberTreeOutput) ToRubberTreePtrOutputWithContext(ctx context.Context) RubberTreePtrOutput {
return o.ApplyT(func(v RubberTree) *RubberTree {
return &v
}).(RubberTreePtrOutput)
}
type RubberTreePtrOutput struct {
*pulumi.OutputState
}
func (RubberTreePtrOutput) ElementType() reflect.Type {
return reflect.TypeOf((**RubberTree)(nil))
}
func (o RubberTreePtrOutput) ToRubberTreePtrOutput() RubberTreePtrOutput {
return o
}
func (o RubberTreePtrOutput) ToRubberTreePtrOutputWithContext(ctx context.Context) RubberTreePtrOutput {
return o
}
type RubberTreeArrayOutput struct{ *pulumi.OutputState }
func (RubberTreeArrayOutput) ElementType() reflect.Type {
return reflect.TypeOf((*[]RubberTree)(nil))
}
func (o RubberTreeArrayOutput) ToRubberTreeArrayOutput() RubberTreeArrayOutput {
return o
}
func (o RubberTreeArrayOutput) ToRubberTreeArrayOutputWithContext(ctx context.Context) RubberTreeArrayOutput {
return o
}
func (o RubberTreeArrayOutput) Index(i pulumi.IntInput) RubberTreeOutput {
return pulumi.All(o, i).ApplyT(func(vs []interface{}) RubberTree {
return vs[0].([]RubberTree)[vs[1].(int)]
}).(RubberTreeOutput)
}
type RubberTreeMapOutput struct{ *pulumi.OutputState }
func (RubberTreeMapOutput) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]RubberTree)(nil))
}
func (o RubberTreeMapOutput) ToRubberTreeMapOutput() RubberTreeMapOutput {
return o
}
func (o RubberTreeMapOutput) ToRubberTreeMapOutputWithContext(ctx context.Context) RubberTreeMapOutput {
return o
}
func (o RubberTreeMapOutput) MapIndex(k pulumi.StringInput) RubberTreeOutput {
return pulumi.All(o, k).ApplyT(func(vs []interface{}) RubberTree {
return vs[0].(map[string]RubberTree)[vs[1].(string)]
}).(RubberTreeOutput)
}
func init() {
pulumi.RegisterOutputType(RubberTreeOutput{})
pulumi.RegisterOutputType(RubberTreePtrOutput{})
pulumi.RegisterOutputType(RubberTreeArrayOutput{})
pulumi.RegisterOutputType(RubberTreeMapOutput{})
}

View file

@ -63,85 +63,6 @@ func (i *OtherResource) ToOtherResourceOutputWithContext(ctx context.Context) Ot
return pulumi.ToOutputWithContext(ctx, i).(OtherResourceOutput)
}
func (i *OtherResource) ToOtherResourcePtrOutput() OtherResourcePtrOutput {
return i.ToOtherResourcePtrOutputWithContext(context.Background())
}
func (i *OtherResource) ToOtherResourcePtrOutputWithContext(ctx context.Context) OtherResourcePtrOutput {
return pulumi.ToOutputWithContext(ctx, i).(OtherResourcePtrOutput)
}
type OtherResourcePtrInput interface {
pulumi.Input
ToOtherResourcePtrOutput() OtherResourcePtrOutput
ToOtherResourcePtrOutputWithContext(ctx context.Context) OtherResourcePtrOutput
}
type otherResourcePtrType OtherResourceArgs
func (*otherResourcePtrType) ElementType() reflect.Type {
return reflect.TypeOf((**OtherResource)(nil))
}
func (i *otherResourcePtrType) ToOtherResourcePtrOutput() OtherResourcePtrOutput {
return i.ToOtherResourcePtrOutputWithContext(context.Background())
}
func (i *otherResourcePtrType) ToOtherResourcePtrOutputWithContext(ctx context.Context) OtherResourcePtrOutput {
return pulumi.ToOutputWithContext(ctx, i).(OtherResourcePtrOutput)
}
// OtherResourceArrayInput is an input type that accepts OtherResourceArray and OtherResourceArrayOutput values.
// You can construct a concrete instance of `OtherResourceArrayInput` via:
//
// OtherResourceArray{ OtherResourceArgs{...} }
type OtherResourceArrayInput interface {
pulumi.Input
ToOtherResourceArrayOutput() OtherResourceArrayOutput
ToOtherResourceArrayOutputWithContext(context.Context) OtherResourceArrayOutput
}
type OtherResourceArray []OtherResourceInput
func (OtherResourceArray) ElementType() reflect.Type {
return reflect.TypeOf(([]*OtherResource)(nil))
}
func (i OtherResourceArray) ToOtherResourceArrayOutput() OtherResourceArrayOutput {
return i.ToOtherResourceArrayOutputWithContext(context.Background())
}
func (i OtherResourceArray) ToOtherResourceArrayOutputWithContext(ctx context.Context) OtherResourceArrayOutput {
return pulumi.ToOutputWithContext(ctx, i).(OtherResourceArrayOutput)
}
// OtherResourceMapInput is an input type that accepts OtherResourceMap and OtherResourceMapOutput values.
// You can construct a concrete instance of `OtherResourceMapInput` via:
//
// OtherResourceMap{ "key": OtherResourceArgs{...} }
type OtherResourceMapInput interface {
pulumi.Input
ToOtherResourceMapOutput() OtherResourceMapOutput
ToOtherResourceMapOutputWithContext(context.Context) OtherResourceMapOutput
}
type OtherResourceMap map[string]OtherResourceInput
func (OtherResourceMap) ElementType() reflect.Type {
return reflect.TypeOf((map[string]*OtherResource)(nil))
}
func (i OtherResourceMap) ToOtherResourceMapOutput() OtherResourceMapOutput {
return i.ToOtherResourceMapOutputWithContext(context.Background())
}
func (i OtherResourceMap) ToOtherResourceMapOutputWithContext(ctx context.Context) OtherResourceMapOutput {
return pulumi.ToOutputWithContext(ctx, i).(OtherResourceMapOutput)
}
type OtherResourceOutput struct {
*pulumi.OutputState
}
@ -158,75 +79,6 @@ func (o OtherResourceOutput) ToOtherResourceOutputWithContext(ctx context.Contex
return o
}
func (o OtherResourceOutput) ToOtherResourcePtrOutput() OtherResourcePtrOutput {
return o.ToOtherResourcePtrOutputWithContext(context.Background())
}
func (o OtherResourceOutput) ToOtherResourcePtrOutputWithContext(ctx context.Context) OtherResourcePtrOutput {
return o.ApplyT(func(v OtherResource) *OtherResource {
return &v
}).(OtherResourcePtrOutput)
}
type OtherResourcePtrOutput struct {
*pulumi.OutputState
}
func (OtherResourcePtrOutput) ElementType() reflect.Type {
return reflect.TypeOf((**OtherResource)(nil))
}
func (o OtherResourcePtrOutput) ToOtherResourcePtrOutput() OtherResourcePtrOutput {
return o
}
func (o OtherResourcePtrOutput) ToOtherResourcePtrOutputWithContext(ctx context.Context) OtherResourcePtrOutput {
return o
}
type OtherResourceArrayOutput struct{ *pulumi.OutputState }
func (OtherResourceArrayOutput) ElementType() reflect.Type {
return reflect.TypeOf((*[]OtherResource)(nil))
}
func (o OtherResourceArrayOutput) ToOtherResourceArrayOutput() OtherResourceArrayOutput {
return o
}
func (o OtherResourceArrayOutput) ToOtherResourceArrayOutputWithContext(ctx context.Context) OtherResourceArrayOutput {
return o
}
func (o OtherResourceArrayOutput) Index(i pulumi.IntInput) OtherResourceOutput {
return pulumi.All(o, i).ApplyT(func(vs []interface{}) OtherResource {
return vs[0].([]OtherResource)[vs[1].(int)]
}).(OtherResourceOutput)
}
type OtherResourceMapOutput struct{ *pulumi.OutputState }
func (OtherResourceMapOutput) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]OtherResource)(nil))
}
func (o OtherResourceMapOutput) ToOtherResourceMapOutput() OtherResourceMapOutput {
return o
}
func (o OtherResourceMapOutput) ToOtherResourceMapOutputWithContext(ctx context.Context) OtherResourceMapOutput {
return o
}
func (o OtherResourceMapOutput) MapIndex(k pulumi.StringInput) OtherResourceOutput {
return pulumi.All(o, k).ApplyT(func(vs []interface{}) OtherResource {
return vs[0].(map[string]OtherResource)[vs[1].(string)]
}).(OtherResourceOutput)
}
func init() {
pulumi.RegisterOutputType(OtherResourceOutput{})
pulumi.RegisterOutputType(OtherResourcePtrOutput{})
pulumi.RegisterOutputType(OtherResourceArrayOutput{})
pulumi.RegisterOutputType(OtherResourceMapOutput{})
}

View file

@ -59,35 +59,6 @@ func (i *Provider) ToProviderOutputWithContext(ctx context.Context) ProviderOutp
return pulumi.ToOutputWithContext(ctx, i).(ProviderOutput)
}
func (i *Provider) ToProviderPtrOutput() ProviderPtrOutput {
return i.ToProviderPtrOutputWithContext(context.Background())
}
func (i *Provider) ToProviderPtrOutputWithContext(ctx context.Context) ProviderPtrOutput {
return pulumi.ToOutputWithContext(ctx, i).(ProviderPtrOutput)
}
type ProviderPtrInput interface {
pulumi.Input
ToProviderPtrOutput() ProviderPtrOutput
ToProviderPtrOutputWithContext(ctx context.Context) ProviderPtrOutput
}
type providerPtrType ProviderArgs
func (*providerPtrType) ElementType() reflect.Type {
return reflect.TypeOf((**Provider)(nil))
}
func (i *providerPtrType) ToProviderPtrOutput() ProviderPtrOutput {
return i.ToProviderPtrOutputWithContext(context.Background())
}
func (i *providerPtrType) ToProviderPtrOutputWithContext(ctx context.Context) ProviderPtrOutput {
return pulumi.ToOutputWithContext(ctx, i).(ProviderPtrOutput)
}
type ProviderOutput struct {
*pulumi.OutputState
}
@ -104,33 +75,6 @@ func (o ProviderOutput) ToProviderOutputWithContext(ctx context.Context) Provide
return o
}
func (o ProviderOutput) ToProviderPtrOutput() ProviderPtrOutput {
return o.ToProviderPtrOutputWithContext(context.Background())
}
func (o ProviderOutput) ToProviderPtrOutputWithContext(ctx context.Context) ProviderPtrOutput {
return o.ApplyT(func(v Provider) *Provider {
return &v
}).(ProviderPtrOutput)
}
type ProviderPtrOutput struct {
*pulumi.OutputState
}
func (ProviderPtrOutput) ElementType() reflect.Type {
return reflect.TypeOf((**Provider)(nil))
}
func (o ProviderPtrOutput) ToProviderPtrOutput() ProviderPtrOutput {
return o
}
func (o ProviderPtrOutput) ToProviderPtrOutputWithContext(ctx context.Context) ProviderPtrOutput {
return o
}
func init() {
pulumi.RegisterOutputType(ProviderOutput{})
pulumi.RegisterOutputType(ProviderPtrOutput{})
}

View file

@ -88,85 +88,6 @@ func (i *Resource) ToResourceOutputWithContext(ctx context.Context) ResourceOutp
return pulumi.ToOutputWithContext(ctx, i).(ResourceOutput)
}
func (i *Resource) ToResourcePtrOutput() ResourcePtrOutput {
return i.ToResourcePtrOutputWithContext(context.Background())
}
func (i *Resource) ToResourcePtrOutputWithContext(ctx context.Context) ResourcePtrOutput {
return pulumi.ToOutputWithContext(ctx, i).(ResourcePtrOutput)
}
type ResourcePtrInput interface {
pulumi.Input
ToResourcePtrOutput() ResourcePtrOutput
ToResourcePtrOutputWithContext(ctx context.Context) ResourcePtrOutput
}
type resourcePtrType ResourceArgs
func (*resourcePtrType) ElementType() reflect.Type {
return reflect.TypeOf((**Resource)(nil))
}
func (i *resourcePtrType) ToResourcePtrOutput() ResourcePtrOutput {
return i.ToResourcePtrOutputWithContext(context.Background())
}
func (i *resourcePtrType) ToResourcePtrOutputWithContext(ctx context.Context) ResourcePtrOutput {
return pulumi.ToOutputWithContext(ctx, i).(ResourcePtrOutput)
}
// ResourceArrayInput is an input type that accepts ResourceArray and ResourceArrayOutput values.
// You can construct a concrete instance of `ResourceArrayInput` via:
//
// ResourceArray{ ResourceArgs{...} }
type ResourceArrayInput interface {
pulumi.Input
ToResourceArrayOutput() ResourceArrayOutput
ToResourceArrayOutputWithContext(context.Context) ResourceArrayOutput
}
type ResourceArray []ResourceInput
func (ResourceArray) ElementType() reflect.Type {
return reflect.TypeOf(([]*Resource)(nil))
}
func (i ResourceArray) ToResourceArrayOutput() ResourceArrayOutput {
return i.ToResourceArrayOutputWithContext(context.Background())
}
func (i ResourceArray) ToResourceArrayOutputWithContext(ctx context.Context) ResourceArrayOutput {
return pulumi.ToOutputWithContext(ctx, i).(ResourceArrayOutput)
}
// ResourceMapInput is an input type that accepts ResourceMap and ResourceMapOutput values.
// You can construct a concrete instance of `ResourceMapInput` via:
//
// ResourceMap{ "key": ResourceArgs{...} }
type ResourceMapInput interface {
pulumi.Input
ToResourceMapOutput() ResourceMapOutput
ToResourceMapOutputWithContext(context.Context) ResourceMapOutput
}
type ResourceMap map[string]ResourceInput
func (ResourceMap) ElementType() reflect.Type {
return reflect.TypeOf((map[string]*Resource)(nil))
}
func (i ResourceMap) ToResourceMapOutput() ResourceMapOutput {
return i.ToResourceMapOutputWithContext(context.Background())
}
func (i ResourceMap) ToResourceMapOutputWithContext(ctx context.Context) ResourceMapOutput {
return pulumi.ToOutputWithContext(ctx, i).(ResourceMapOutput)
}
type ResourceOutput struct {
*pulumi.OutputState
}
@ -183,75 +104,6 @@ func (o ResourceOutput) ToResourceOutputWithContext(ctx context.Context) Resourc
return o
}
func (o ResourceOutput) ToResourcePtrOutput() ResourcePtrOutput {
return o.ToResourcePtrOutputWithContext(context.Background())
}
func (o ResourceOutput) ToResourcePtrOutputWithContext(ctx context.Context) ResourcePtrOutput {
return o.ApplyT(func(v Resource) *Resource {
return &v
}).(ResourcePtrOutput)
}
type ResourcePtrOutput struct {
*pulumi.OutputState
}
func (ResourcePtrOutput) ElementType() reflect.Type {
return reflect.TypeOf((**Resource)(nil))
}
func (o ResourcePtrOutput) ToResourcePtrOutput() ResourcePtrOutput {
return o
}
func (o ResourcePtrOutput) ToResourcePtrOutputWithContext(ctx context.Context) ResourcePtrOutput {
return o
}
type ResourceArrayOutput struct{ *pulumi.OutputState }
func (ResourceArrayOutput) ElementType() reflect.Type {
return reflect.TypeOf((*[]Resource)(nil))
}
func (o ResourceArrayOutput) ToResourceArrayOutput() ResourceArrayOutput {
return o
}
func (o ResourceArrayOutput) ToResourceArrayOutputWithContext(ctx context.Context) ResourceArrayOutput {
return o
}
func (o ResourceArrayOutput) Index(i pulumi.IntInput) ResourceOutput {
return pulumi.All(o, i).ApplyT(func(vs []interface{}) Resource {
return vs[0].([]Resource)[vs[1].(int)]
}).(ResourceOutput)
}
type ResourceMapOutput struct{ *pulumi.OutputState }
func (ResourceMapOutput) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]Resource)(nil))
}
func (o ResourceMapOutput) ToResourceMapOutput() ResourceMapOutput {
return o
}
func (o ResourceMapOutput) ToResourceMapOutputWithContext(ctx context.Context) ResourceMapOutput {
return o
}
func (o ResourceMapOutput) MapIndex(k pulumi.StringInput) ResourceOutput {
return pulumi.All(o, k).ApplyT(func(vs []interface{}) Resource {
return vs[0].(map[string]Resource)[vs[1].(string)]
}).(ResourceOutput)
}
func init() {
pulumi.RegisterOutputType(ResourceOutput{})
pulumi.RegisterOutputType(ResourcePtrOutput{})
pulumi.RegisterOutputType(ResourceArrayOutput{})
pulumi.RegisterOutputType(ResourceMapOutput{})
}