github.com/myhau/pulumi/pkg/v3@v3.70.2-0.20221116134521-f2775972e587/codegen/testing/test/testdata/simple-yaml-schema/go/example/resource.go (about) 1 // Code generated by test DO NOT EDIT. 2 // *** WARNING: Do not edit by hand unless you're certain you know what you are doing! *** 3 4 package example 5 6 import ( 7 "context" 8 "reflect" 9 10 "github.com/pulumi/pulumi/sdk/v3/go/pulumi" 11 ) 12 13 type Resource struct { 14 pulumi.CustomResourceState 15 16 Bar pulumi.StringPtrOutput `pulumi:"bar"` 17 } 18 19 // NewResource registers a new resource with the given unique name, arguments, and options. 20 func NewResource(ctx *pulumi.Context, 21 name string, args *ResourceArgs, opts ...pulumi.ResourceOption) (*Resource, error) { 22 if args == nil { 23 args = &ResourceArgs{} 24 } 25 26 if args.Bar != nil { 27 args.Bar = pulumi.ToSecret(args.Bar).(pulumi.StringPtrOutput) 28 } 29 secrets := pulumi.AdditionalSecretOutputs([]string{ 30 "bar", 31 }) 32 opts = append(opts, secrets) 33 var resource Resource 34 err := ctx.RegisterResource("example::Resource", name, args, &resource, opts...) 35 if err != nil { 36 return nil, err 37 } 38 return &resource, nil 39 } 40 41 // GetResource gets an existing Resource resource's state with the given name, ID, and optional 42 // state properties that are used to uniquely qualify the lookup (nil if not required). 43 func GetResource(ctx *pulumi.Context, 44 name string, id pulumi.IDInput, state *ResourceState, opts ...pulumi.ResourceOption) (*Resource, error) { 45 var resource Resource 46 err := ctx.ReadResource("example::Resource", name, id, state, &resource, opts...) 47 if err != nil { 48 return nil, err 49 } 50 return &resource, nil 51 } 52 53 // Input properties used for looking up and filtering Resource resources. 54 type resourceState struct { 55 } 56 57 type ResourceState struct { 58 } 59 60 func (ResourceState) ElementType() reflect.Type { 61 return reflect.TypeOf((*resourceState)(nil)).Elem() 62 } 63 64 type resourceArgs struct { 65 Bar *string `pulumi:"bar"` 66 } 67 68 // The set of arguments for constructing a Resource resource. 69 type ResourceArgs struct { 70 Bar pulumi.StringPtrInput 71 } 72 73 func (ResourceArgs) ElementType() reflect.Type { 74 return reflect.TypeOf((*resourceArgs)(nil)).Elem() 75 } 76 77 type ResourceInput interface { 78 pulumi.Input 79 80 ToResourceOutput() ResourceOutput 81 ToResourceOutputWithContext(ctx context.Context) ResourceOutput 82 } 83 84 func (*Resource) ElementType() reflect.Type { 85 return reflect.TypeOf((**Resource)(nil)).Elem() 86 } 87 88 func (i *Resource) ToResourceOutput() ResourceOutput { 89 return i.ToResourceOutputWithContext(context.Background()) 90 } 91 92 func (i *Resource) ToResourceOutputWithContext(ctx context.Context) ResourceOutput { 93 return pulumi.ToOutputWithContext(ctx, i).(ResourceOutput) 94 } 95 96 type ResourceOutput struct{ *pulumi.OutputState } 97 98 func (ResourceOutput) ElementType() reflect.Type { 99 return reflect.TypeOf((**Resource)(nil)).Elem() 100 } 101 102 func (o ResourceOutput) ToResourceOutput() ResourceOutput { 103 return o 104 } 105 106 func (o ResourceOutput) ToResourceOutputWithContext(ctx context.Context) ResourceOutput { 107 return o 108 } 109 110 func (o ResourceOutput) Bar() pulumi.StringPtrOutput { 111 return o.ApplyT(func(v *Resource) pulumi.StringPtrOutput { return v.Bar }).(pulumi.StringPtrOutput) 112 } 113 114 func init() { 115 pulumi.RegisterInputType(reflect.TypeOf((*ResourceInput)(nil)).Elem(), &Resource{}) 116 pulumi.RegisterOutputType(ResourceOutput{}) 117 }