52d01bb915
These changes remove the `Ptr` variants of input/ouptut types for resources. A `TPtr` input or output is normally generated for `T` if `T` is present in an `optional(input(T))` or `optional(output(T))` and if the Go representation for `T` is not nilable. The generation of `Ptr` variants for resource types breaks the latter rule: the canonical representation of a resource type named `Foo` is a pointer to a struct type named `Foo` (i.e. `*Foo`). `Foo` itself is not a resource, as it does not implement the Go `Resource` interface. Because this representation already accommodates `nil` to indicate the lack of a value, we need not generate `FooPtr{Input,Output}` types. Besides being unnecessary, the implementation of `Ptr` types for resources was incorrect. Rather than using `**Foo` as their element type, these types use `*Foo`--identical to the element type used for the normal input/output types. Furthermore, the generated code for at least `FooOutput.ToFooPtrOutputWithContext` and `FooPtrOutput.Elem` was incorrect, making these types virtually unusable in practice. Finally, these `Ptr` types should never appear on input/output properties in practice, as the logic we use to generate input and output type references never generates them for `optional({input,output}(T)). Instead, it generates references to the standard input/output types. Though this is _technically_ a breaking change--it changes the set of exported types for any package that defines resources--I believe that in practice it will be invisible to users for the reasons stated above. These types are not usable, and were never referenced. This is preparatory work for #7943.
207 lines
5.7 KiB
Go
207 lines
5.7 KiB
Go
// *** WARNING: this file was generated by test. ***
|
|
// *** Do not edit by hand unless you're certain you know what you are doing! ***
|
|
|
|
package example
|
|
|
|
import (
|
|
"context"
|
|
"reflect"
|
|
|
|
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
|
|
)
|
|
|
|
type ToyStore struct {
|
|
pulumi.CustomResourceState
|
|
|
|
Chew ChewPtrOutput `pulumi:"chew"`
|
|
Laser LaserPtrOutput `pulumi:"laser"`
|
|
Stuff ToyArrayOutput `pulumi:"stuff"`
|
|
Wanted ToyArrayOutput `pulumi:"wanted"`
|
|
}
|
|
|
|
// NewToyStore registers a new resource with the given unique name, arguments, and options.
|
|
func NewToyStore(ctx *pulumi.Context,
|
|
name string, args *ToyStoreArgs, opts ...pulumi.ResourceOption) (*ToyStore, error) {
|
|
if args == nil {
|
|
args = &ToyStoreArgs{}
|
|
}
|
|
|
|
replaceOnChanges := pulumi.ReplaceOnChanges([]string{
|
|
"chew.owner",
|
|
"laser.batteries",
|
|
"stuff[*].associated.color",
|
|
"stuff[*].color",
|
|
"wanted[*]",
|
|
})
|
|
opts = append(opts, replaceOnChanges)
|
|
var resource ToyStore
|
|
err := ctx.RegisterResource("example::ToyStore", name, args, &resource, opts...)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &resource, nil
|
|
}
|
|
|
|
// GetToyStore gets an existing ToyStore 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 GetToyStore(ctx *pulumi.Context,
|
|
name string, id pulumi.IDInput, state *ToyStoreState, opts ...pulumi.ResourceOption) (*ToyStore, error) {
|
|
var resource ToyStore
|
|
err := ctx.ReadResource("example::ToyStore", name, id, state, &resource, opts...)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &resource, nil
|
|
}
|
|
|
|
// Input properties used for looking up and filtering ToyStore resources.
|
|
type toyStoreState struct {
|
|
}
|
|
|
|
type ToyStoreState struct {
|
|
}
|
|
|
|
func (ToyStoreState) ElementType() reflect.Type {
|
|
return reflect.TypeOf((*toyStoreState)(nil)).Elem()
|
|
}
|
|
|
|
type toyStoreArgs struct {
|
|
}
|
|
|
|
// The set of arguments for constructing a ToyStore resource.
|
|
type ToyStoreArgs struct {
|
|
}
|
|
|
|
func (ToyStoreArgs) ElementType() reflect.Type {
|
|
return reflect.TypeOf((*toyStoreArgs)(nil)).Elem()
|
|
}
|
|
|
|
type ToyStoreInput interface {
|
|
pulumi.Input
|
|
|
|
ToToyStoreOutput() ToyStoreOutput
|
|
ToToyStoreOutputWithContext(ctx context.Context) ToyStoreOutput
|
|
}
|
|
|
|
func (*ToyStore) ElementType() reflect.Type {
|
|
return reflect.TypeOf((**ToyStore)(nil)).Elem()
|
|
}
|
|
|
|
func (i *ToyStore) ToToyStoreOutput() ToyStoreOutput {
|
|
return i.ToToyStoreOutputWithContext(context.Background())
|
|
}
|
|
|
|
func (i *ToyStore) ToToyStoreOutputWithContext(ctx context.Context) ToyStoreOutput {
|
|
return pulumi.ToOutputWithContext(ctx, i).(ToyStoreOutput)
|
|
}
|
|
|
|
// ToyStoreArrayInput is an input type that accepts ToyStoreArray and ToyStoreArrayOutput values.
|
|
// You can construct a concrete instance of `ToyStoreArrayInput` via:
|
|
//
|
|
// ToyStoreArray{ ToyStoreArgs{...} }
|
|
type ToyStoreArrayInput interface {
|
|
pulumi.Input
|
|
|
|
ToToyStoreArrayOutput() ToyStoreArrayOutput
|
|
ToToyStoreArrayOutputWithContext(context.Context) ToyStoreArrayOutput
|
|
}
|
|
|
|
type ToyStoreArray []ToyStoreInput
|
|
|
|
func (ToyStoreArray) ElementType() reflect.Type {
|
|
return reflect.TypeOf((*[]*ToyStore)(nil)).Elem()
|
|
}
|
|
|
|
func (i ToyStoreArray) ToToyStoreArrayOutput() ToyStoreArrayOutput {
|
|
return i.ToToyStoreArrayOutputWithContext(context.Background())
|
|
}
|
|
|
|
func (i ToyStoreArray) ToToyStoreArrayOutputWithContext(ctx context.Context) ToyStoreArrayOutput {
|
|
return pulumi.ToOutputWithContext(ctx, i).(ToyStoreArrayOutput)
|
|
}
|
|
|
|
// ToyStoreMapInput is an input type that accepts ToyStoreMap and ToyStoreMapOutput values.
|
|
// You can construct a concrete instance of `ToyStoreMapInput` via:
|
|
//
|
|
// ToyStoreMap{ "key": ToyStoreArgs{...} }
|
|
type ToyStoreMapInput interface {
|
|
pulumi.Input
|
|
|
|
ToToyStoreMapOutput() ToyStoreMapOutput
|
|
ToToyStoreMapOutputWithContext(context.Context) ToyStoreMapOutput
|
|
}
|
|
|
|
type ToyStoreMap map[string]ToyStoreInput
|
|
|
|
func (ToyStoreMap) ElementType() reflect.Type {
|
|
return reflect.TypeOf((*map[string]*ToyStore)(nil)).Elem()
|
|
}
|
|
|
|
func (i ToyStoreMap) ToToyStoreMapOutput() ToyStoreMapOutput {
|
|
return i.ToToyStoreMapOutputWithContext(context.Background())
|
|
}
|
|
|
|
func (i ToyStoreMap) ToToyStoreMapOutputWithContext(ctx context.Context) ToyStoreMapOutput {
|
|
return pulumi.ToOutputWithContext(ctx, i).(ToyStoreMapOutput)
|
|
}
|
|
|
|
type ToyStoreOutput struct{ *pulumi.OutputState }
|
|
|
|
func (ToyStoreOutput) ElementType() reflect.Type {
|
|
return reflect.TypeOf((**ToyStore)(nil)).Elem()
|
|
}
|
|
|
|
func (o ToyStoreOutput) ToToyStoreOutput() ToyStoreOutput {
|
|
return o
|
|
}
|
|
|
|
func (o ToyStoreOutput) ToToyStoreOutputWithContext(ctx context.Context) ToyStoreOutput {
|
|
return o
|
|
}
|
|
|
|
type ToyStoreArrayOutput struct{ *pulumi.OutputState }
|
|
|
|
func (ToyStoreArrayOutput) ElementType() reflect.Type {
|
|
return reflect.TypeOf((*[]*ToyStore)(nil)).Elem()
|
|
}
|
|
|
|
func (o ToyStoreArrayOutput) ToToyStoreArrayOutput() ToyStoreArrayOutput {
|
|
return o
|
|
}
|
|
|
|
func (o ToyStoreArrayOutput) ToToyStoreArrayOutputWithContext(ctx context.Context) ToyStoreArrayOutput {
|
|
return o
|
|
}
|
|
|
|
func (o ToyStoreArrayOutput) Index(i pulumi.IntInput) ToyStoreOutput {
|
|
return pulumi.All(o, i).ApplyT(func(vs []interface{}) *ToyStore {
|
|
return vs[0].([]*ToyStore)[vs[1].(int)]
|
|
}).(ToyStoreOutput)
|
|
}
|
|
|
|
type ToyStoreMapOutput struct{ *pulumi.OutputState }
|
|
|
|
func (ToyStoreMapOutput) ElementType() reflect.Type {
|
|
return reflect.TypeOf((*map[string]*ToyStore)(nil)).Elem()
|
|
}
|
|
|
|
func (o ToyStoreMapOutput) ToToyStoreMapOutput() ToyStoreMapOutput {
|
|
return o
|
|
}
|
|
|
|
func (o ToyStoreMapOutput) ToToyStoreMapOutputWithContext(ctx context.Context) ToyStoreMapOutput {
|
|
return o
|
|
}
|
|
|
|
func (o ToyStoreMapOutput) MapIndex(k pulumi.StringInput) ToyStoreOutput {
|
|
return pulumi.All(o, k).ApplyT(func(vs []interface{}) *ToyStore {
|
|
return vs[0].(map[string]*ToyStore)[vs[1].(string)]
|
|
}).(ToyStoreOutput)
|
|
}
|
|
|
|
func init() {
|
|
pulumi.RegisterOutputType(ToyStoreOutput{})
|
|
pulumi.RegisterOutputType(ToyStoreArrayOutput{})
|
|
pulumi.RegisterOutputType(ToyStoreMapOutput{})
|
|
}
|