pulumi/tests/testdata/codegen/resource-property-overlap/go/example/rec.go

205 lines
5.2 KiB
Go
Raw Normal View History

// Code generated by test DO NOT EDIT.
// *** WARNING: 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"
2023-06-14 16:34:49 +00:00
"resource-property-overlap/example/internal"
)
type Rec struct {
pulumi.CustomResourceState
[codegen/go] Remove ResourcePtr input/output types (#8449) 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.
2021-11-23 18:24:56 +00:00
Rec RecOutput `pulumi:"rec"`
}
// NewRec registers a new resource with the given unique name, arguments, and options.
func NewRec(ctx *pulumi.Context,
name string, args *RecArgs, opts ...pulumi.ResourceOption) (*Rec, error) {
if args == nil {
args = &RecArgs{}
}
2023-06-14 16:34:49 +00:00
opts = internal.PkgResourceDefaultOpts(opts)
var resource Rec
err := ctx.RegisterResource("example::Rec", name, args, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// GetRec gets an existing Rec 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 GetRec(ctx *pulumi.Context,
name string, id pulumi.IDInput, state *RecState, opts ...pulumi.ResourceOption) (*Rec, error) {
var resource Rec
err := ctx.ReadResource("example::Rec", name, id, state, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// Input properties used for looking up and filtering Rec resources.
type recState struct {
}
type RecState struct {
}
func (RecState) ElementType() reflect.Type {
return reflect.TypeOf((*recState)(nil)).Elem()
}
type recArgs struct {
}
// The set of arguments for constructing a Rec resource.
type RecArgs struct {
}
func (RecArgs) ElementType() reflect.Type {
return reflect.TypeOf((*recArgs)(nil)).Elem()
}
type RecInput interface {
pulumi.Input
ToRecOutput() RecOutput
ToRecOutputWithContext(ctx context.Context) RecOutput
}
func (*Rec) ElementType() reflect.Type {
[codegen/go] Remove ResourcePtr input/output types (#8449) 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.
2021-11-23 18:24:56 +00:00
return reflect.TypeOf((**Rec)(nil)).Elem()
}
func (i *Rec) ToRecOutput() RecOutput {
return i.ToRecOutputWithContext(context.Background())
}
func (i *Rec) ToRecOutputWithContext(ctx context.Context) RecOutput {
return pulumi.ToOutputWithContext(ctx, i).(RecOutput)
}
// RecArrayInput is an input type that accepts RecArray and RecArrayOutput values.
// You can construct a concrete instance of `RecArrayInput` via:
//
2022-09-14 02:12:02 +00:00
// RecArray{ RecArgs{...} }
type RecArrayInput interface {
pulumi.Input
ToRecArrayOutput() RecArrayOutput
ToRecArrayOutputWithContext(context.Context) RecArrayOutput
}
type RecArray []RecInput
func (RecArray) ElementType() reflect.Type {
return reflect.TypeOf((*[]*Rec)(nil)).Elem()
}
func (i RecArray) ToRecArrayOutput() RecArrayOutput {
return i.ToRecArrayOutputWithContext(context.Background())
}
func (i RecArray) ToRecArrayOutputWithContext(ctx context.Context) RecArrayOutput {
return pulumi.ToOutputWithContext(ctx, i).(RecArrayOutput)
}
// RecMapInput is an input type that accepts RecMap and RecMapOutput values.
// You can construct a concrete instance of `RecMapInput` via:
//
2022-09-14 02:12:02 +00:00
// RecMap{ "key": RecArgs{...} }
type RecMapInput interface {
pulumi.Input
ToRecMapOutput() RecMapOutput
ToRecMapOutputWithContext(context.Context) RecMapOutput
}
type RecMap map[string]RecInput
func (RecMap) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*Rec)(nil)).Elem()
}
func (i RecMap) ToRecMapOutput() RecMapOutput {
return i.ToRecMapOutputWithContext(context.Background())
}
func (i RecMap) ToRecMapOutputWithContext(ctx context.Context) RecMapOutput {
return pulumi.ToOutputWithContext(ctx, i).(RecMapOutput)
}
type RecOutput struct{ *pulumi.OutputState }
func (RecOutput) ElementType() reflect.Type {
[codegen/go] Remove ResourcePtr input/output types (#8449) 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.
2021-11-23 18:24:56 +00:00
return reflect.TypeOf((**Rec)(nil)).Elem()
}
func (o RecOutput) ToRecOutput() RecOutput {
return o
}
func (o RecOutput) ToRecOutputWithContext(ctx context.Context) RecOutput {
return o
}
func (o RecOutput) Rec() RecOutput {
return o.ApplyT(func(v *Rec) RecOutput { return v.Rec }).(RecOutput)
}
type RecArrayOutput struct{ *pulumi.OutputState }
func (RecArrayOutput) ElementType() reflect.Type {
[codegen/go] Remove ResourcePtr input/output types (#8449) 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.
2021-11-23 18:24:56 +00:00
return reflect.TypeOf((*[]*Rec)(nil)).Elem()
}
func (o RecArrayOutput) ToRecArrayOutput() RecArrayOutput {
return o
}
func (o RecArrayOutput) ToRecArrayOutputWithContext(ctx context.Context) RecArrayOutput {
return o
}
func (o RecArrayOutput) Index(i pulumi.IntInput) RecOutput {
[codegen/go] Remove ResourcePtr input/output types (#8449) 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.
2021-11-23 18:24:56 +00:00
return pulumi.All(o, i).ApplyT(func(vs []interface{}) *Rec {
return vs[0].([]*Rec)[vs[1].(int)]
}).(RecOutput)
}
type RecMapOutput struct{ *pulumi.OutputState }
func (RecMapOutput) ElementType() reflect.Type {
[codegen/go] Remove ResourcePtr input/output types (#8449) 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.
2021-11-23 18:24:56 +00:00
return reflect.TypeOf((*map[string]*Rec)(nil)).Elem()
}
func (o RecMapOutput) ToRecMapOutput() RecMapOutput {
return o
}
func (o RecMapOutput) ToRecMapOutputWithContext(ctx context.Context) RecMapOutput {
return o
}
func (o RecMapOutput) MapIndex(k pulumi.StringInput) RecOutput {
[codegen/go] Remove ResourcePtr input/output types (#8449) 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.
2021-11-23 18:24:56 +00:00
return pulumi.All(o, k).ApplyT(func(vs []interface{}) *Rec {
return vs[0].(map[string]*Rec)[vs[1].(string)]
}).(RecOutput)
}
func init() {
pulumi.RegisterInputType(reflect.TypeOf((*RecInput)(nil)).Elem(), &Rec{})
pulumi.RegisterInputType(reflect.TypeOf((*RecArrayInput)(nil)).Elem(), RecArray{})
pulumi.RegisterInputType(reflect.TypeOf((*RecMapInput)(nil)).Elem(), RecMap{})
pulumi.RegisterOutputType(RecOutput{})
pulumi.RegisterOutputType(RecArrayOutput{})
pulumi.RegisterOutputType(RecMapOutput{})
}