2021-10-27 02:18:48 +02:00
|
|
|
// *** WARNING: this file was generated by test. ***
|
|
|
|
// *** Do not edit by hand unless you're certain you know what you are doing! ***
|
|
|
|
|
|
|
|
package foo
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"reflect"
|
|
|
|
|
|
|
|
"github.com/pkg/errors"
|
|
|
|
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
|
|
|
|
)
|
|
|
|
|
|
|
|
type ModuleResource struct {
|
|
|
|
pulumi.CustomResourceState
|
|
|
|
}
|
|
|
|
|
|
|
|
// NewModuleResource registers a new resource with the given unique name, arguments, and options.
|
|
|
|
func NewModuleResource(ctx *pulumi.Context,
|
|
|
|
name string, args *ModuleResourceArgs, opts ...pulumi.ResourceOption) (*ModuleResource, error) {
|
|
|
|
if args == nil {
|
|
|
|
return nil, errors.New("missing one or more required arguments")
|
|
|
|
}
|
|
|
|
|
2021-11-24 00:10:15 +01:00
|
|
|
if isZero(args.Optional_bool) {
|
2021-10-27 02:18:48 +02:00
|
|
|
args.Optional_bool = pulumi.BoolPtr(true)
|
|
|
|
}
|
|
|
|
args.Optional_const = pulumi.StringPtr("val")
|
2021-11-24 00:10:15 +01:00
|
|
|
if isZero(args.Optional_enum) {
|
2021-10-27 02:18:48 +02:00
|
|
|
args.Optional_enum = EnumThing(8)
|
|
|
|
}
|
2021-11-24 00:10:15 +01:00
|
|
|
if isZero(args.Optional_number) {
|
2021-10-27 02:18:48 +02:00
|
|
|
args.Optional_number = pulumi.Float64Ptr(42.0)
|
|
|
|
}
|
2021-11-24 00:10:15 +01:00
|
|
|
if isZero(args.Optional_string) {
|
2021-10-27 02:18:48 +02:00
|
|
|
args.Optional_string = pulumi.StringPtr("buzzer")
|
|
|
|
}
|
2021-11-24 00:10:15 +01:00
|
|
|
if isZero(args.Plain_optional_bool) {
|
2021-10-27 02:18:48 +02:00
|
|
|
plain_optional_bool_ := true
|
|
|
|
args.Plain_optional_bool = &plain_optional_bool_
|
|
|
|
}
|
|
|
|
plain_optional_const_ := "val"
|
|
|
|
args.Plain_optional_const = &plain_optional_const_
|
2021-11-24 00:10:15 +01:00
|
|
|
if isZero(args.Plain_optional_number) {
|
2021-10-27 02:18:48 +02:00
|
|
|
plain_optional_number_ := 42.0
|
|
|
|
args.Plain_optional_number = &plain_optional_number_
|
|
|
|
}
|
2021-11-24 00:10:15 +01:00
|
|
|
if isZero(args.Plain_optional_string) {
|
2021-10-27 02:18:48 +02:00
|
|
|
plain_optional_string_ := "buzzer"
|
|
|
|
args.Plain_optional_string = &plain_optional_string_
|
|
|
|
}
|
2021-11-24 00:10:15 +01:00
|
|
|
if isZero(args.Plain_required_bool) {
|
2021-10-27 02:18:48 +02:00
|
|
|
args.Plain_required_bool = true
|
|
|
|
}
|
|
|
|
args.Plain_required_const = "val"
|
2021-11-24 00:10:15 +01:00
|
|
|
if isZero(args.Plain_required_number) {
|
2021-10-27 02:18:48 +02:00
|
|
|
args.Plain_required_number = 42.0
|
|
|
|
}
|
2021-11-24 00:10:15 +01:00
|
|
|
if isZero(args.Plain_required_string) {
|
2021-10-27 02:18:48 +02:00
|
|
|
args.Plain_required_string = "buzzer"
|
|
|
|
}
|
2021-11-24 00:10:15 +01:00
|
|
|
if isZero(args.Required_bool) {
|
2021-10-27 02:18:48 +02:00
|
|
|
args.Required_bool = pulumi.Bool(true)
|
|
|
|
}
|
2021-11-24 00:10:15 +01:00
|
|
|
if isZero(args.Required_enum) {
|
2021-10-27 02:18:48 +02:00
|
|
|
args.Required_enum = EnumThing(4)
|
|
|
|
}
|
2021-11-24 00:10:15 +01:00
|
|
|
if isZero(args.Required_number) {
|
2021-10-27 02:18:48 +02:00
|
|
|
args.Required_number = pulumi.Float64(42.0)
|
|
|
|
}
|
2021-11-24 00:10:15 +01:00
|
|
|
if isZero(args.Required_string) {
|
2021-10-27 02:18:48 +02:00
|
|
|
args.Required_string = pulumi.String("buzzer")
|
|
|
|
}
|
|
|
|
var resource ModuleResource
|
|
|
|
err := ctx.RegisterResource("foobar::ModuleResource", name, args, &resource, opts...)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return &resource, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// GetModuleResource gets an existing ModuleResource resource's state with the given name, ID, and optional
|
|
|
|
// state properties that are used to uniquely qualify the lookup (nil if not required).
|
|
|
|
func GetModuleResource(ctx *pulumi.Context,
|
|
|
|
name string, id pulumi.IDInput, state *ModuleResourceState, opts ...pulumi.ResourceOption) (*ModuleResource, error) {
|
|
|
|
var resource ModuleResource
|
|
|
|
err := ctx.ReadResource("foobar::ModuleResource", name, id, state, &resource, opts...)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return &resource, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// Input properties used for looking up and filtering ModuleResource resources.
|
|
|
|
type moduleResourceState struct {
|
|
|
|
}
|
|
|
|
|
|
|
|
type ModuleResourceState struct {
|
|
|
|
}
|
|
|
|
|
|
|
|
func (ModuleResourceState) ElementType() reflect.Type {
|
|
|
|
return reflect.TypeOf((*moduleResourceState)(nil)).Elem()
|
|
|
|
}
|
|
|
|
|
|
|
|
type moduleResourceArgs struct {
|
|
|
|
Optional_bool *bool `pulumi:"optional_bool"`
|
|
|
|
Optional_const *string `pulumi:"optional_const"`
|
|
|
|
Optional_enum *EnumThing `pulumi:"optional_enum"`
|
|
|
|
Optional_number *float64 `pulumi:"optional_number"`
|
|
|
|
Optional_string *string `pulumi:"optional_string"`
|
|
|
|
Plain_optional_bool *bool `pulumi:"plain_optional_bool"`
|
|
|
|
Plain_optional_const *string `pulumi:"plain_optional_const"`
|
|
|
|
Plain_optional_number *float64 `pulumi:"plain_optional_number"`
|
|
|
|
Plain_optional_string *string `pulumi:"plain_optional_string"`
|
|
|
|
Plain_required_bool bool `pulumi:"plain_required_bool"`
|
|
|
|
Plain_required_const string `pulumi:"plain_required_const"`
|
|
|
|
Plain_required_number float64 `pulumi:"plain_required_number"`
|
|
|
|
Plain_required_string string `pulumi:"plain_required_string"`
|
|
|
|
Required_bool bool `pulumi:"required_bool"`
|
|
|
|
Required_enum EnumThing `pulumi:"required_enum"`
|
|
|
|
Required_number float64 `pulumi:"required_number"`
|
|
|
|
Required_string string `pulumi:"required_string"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// The set of arguments for constructing a ModuleResource resource.
|
|
|
|
type ModuleResourceArgs struct {
|
|
|
|
Optional_bool pulumi.BoolPtrInput
|
|
|
|
Optional_const pulumi.StringPtrInput
|
|
|
|
Optional_enum EnumThingPtrInput
|
|
|
|
Optional_number pulumi.Float64PtrInput
|
|
|
|
Optional_string pulumi.StringPtrInput
|
|
|
|
Plain_optional_bool *bool
|
|
|
|
Plain_optional_const *string
|
|
|
|
Plain_optional_number *float64
|
|
|
|
Plain_optional_string *string
|
|
|
|
Plain_required_bool bool
|
|
|
|
Plain_required_const string
|
|
|
|
Plain_required_number float64
|
|
|
|
Plain_required_string string
|
|
|
|
Required_bool pulumi.BoolInput
|
|
|
|
Required_enum EnumThingInput
|
|
|
|
Required_number pulumi.Float64Input
|
|
|
|
Required_string pulumi.StringInput
|
|
|
|
}
|
|
|
|
|
|
|
|
func (ModuleResourceArgs) ElementType() reflect.Type {
|
|
|
|
return reflect.TypeOf((*moduleResourceArgs)(nil)).Elem()
|
|
|
|
}
|
|
|
|
|
|
|
|
type ModuleResourceInput interface {
|
|
|
|
pulumi.Input
|
|
|
|
|
|
|
|
ToModuleResourceOutput() ModuleResourceOutput
|
|
|
|
ToModuleResourceOutputWithContext(ctx context.Context) ModuleResourceOutput
|
|
|
|
}
|
|
|
|
|
|
|
|
func (*ModuleResource) ElementType() reflect.Type {
|
[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 19:24:56 +01:00
|
|
|
return reflect.TypeOf((**ModuleResource)(nil)).Elem()
|
2021-10-27 02:18:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func (i *ModuleResource) ToModuleResourceOutput() ModuleResourceOutput {
|
|
|
|
return i.ToModuleResourceOutputWithContext(context.Background())
|
|
|
|
}
|
|
|
|
|
|
|
|
func (i *ModuleResource) ToModuleResourceOutputWithContext(ctx context.Context) ModuleResourceOutput {
|
|
|
|
return pulumi.ToOutputWithContext(ctx, i).(ModuleResourceOutput)
|
|
|
|
}
|
|
|
|
|
|
|
|
type ModuleResourceOutput struct{ *pulumi.OutputState }
|
|
|
|
|
|
|
|
func (ModuleResourceOutput) ElementType() reflect.Type {
|
[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 19:24:56 +01:00
|
|
|
return reflect.TypeOf((**ModuleResource)(nil)).Elem()
|
2021-10-27 02:18:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func (o ModuleResourceOutput) ToModuleResourceOutput() ModuleResourceOutput {
|
|
|
|
return o
|
|
|
|
}
|
|
|
|
|
|
|
|
func (o ModuleResourceOutput) ToModuleResourceOutputWithContext(ctx context.Context) ModuleResourceOutput {
|
|
|
|
return o
|
|
|
|
}
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
pulumi.RegisterInputType(reflect.TypeOf((*ModuleResourceInput)(nil)).Elem(), &ModuleResource{})
|
|
|
|
pulumi.RegisterOutputType(ModuleResourceOutput{})
|
|
|
|
}
|