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