github.com/myhau/pulumi/pkg/v3@v3.70.2-0.20221116134521-f2775972e587/codegen/testing/test/testdata/secrets/go/mypkg/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 mypkg 5 6 import ( 7 "context" 8 "reflect" 9 10 "github.com/pkg/errors" 11 "github.com/pulumi/pulumi/sdk/v3/go/pulumi" 12 ) 13 14 type Resource struct { 15 pulumi.CustomResourceState 16 17 Config ConfigOutput `pulumi:"config"` 18 ConfigArray ConfigArrayOutput `pulumi:"configArray"` 19 ConfigMap ConfigMapOutput `pulumi:"configMap"` 20 Foo pulumi.StringOutput `pulumi:"foo"` 21 FooArray pulumi.StringArrayOutput `pulumi:"fooArray"` 22 FooMap pulumi.StringMapOutput `pulumi:"fooMap"` 23 } 24 25 // NewResource registers a new resource with the given unique name, arguments, and options. 26 func NewResource(ctx *pulumi.Context, 27 name string, args *ResourceArgs, opts ...pulumi.ResourceOption) (*Resource, error) { 28 if args == nil { 29 return nil, errors.New("missing one or more required arguments") 30 } 31 32 if args.Config == nil { 33 return nil, errors.New("invalid value for required argument 'Config'") 34 } 35 if args.ConfigArray == nil { 36 return nil, errors.New("invalid value for required argument 'ConfigArray'") 37 } 38 if args.ConfigMap == nil { 39 return nil, errors.New("invalid value for required argument 'ConfigMap'") 40 } 41 if args.Foo == nil { 42 return nil, errors.New("invalid value for required argument 'Foo'") 43 } 44 if args.FooArray == nil { 45 return nil, errors.New("invalid value for required argument 'FooArray'") 46 } 47 if args.FooMap == nil { 48 return nil, errors.New("invalid value for required argument 'FooMap'") 49 } 50 if args.Config != nil { 51 args.Config = pulumi.ToSecret(args.Config).(ConfigOutput) 52 } 53 if args.ConfigArray != nil { 54 args.ConfigArray = pulumi.ToSecret(args.ConfigArray).(ConfigArrayOutput) 55 } 56 if args.ConfigMap != nil { 57 args.ConfigMap = pulumi.ToSecret(args.ConfigMap).(ConfigMapOutput) 58 } 59 if args.Foo != nil { 60 args.Foo = pulumi.ToSecret(args.Foo).(pulumi.StringOutput) 61 } 62 if args.FooArray != nil { 63 args.FooArray = pulumi.ToSecret(args.FooArray).(pulumi.StringArrayOutput) 64 } 65 if args.FooMap != nil { 66 args.FooMap = pulumi.ToSecret(args.FooMap).(pulumi.StringMapOutput) 67 } 68 secrets := pulumi.AdditionalSecretOutputs([]string{ 69 "config", 70 "configArray", 71 "configMap", 72 "foo", 73 "fooArray", 74 "fooMap", 75 }) 76 opts = append(opts, secrets) 77 var resource Resource 78 err := ctx.RegisterResource("mypkg::Resource", name, args, &resource, opts...) 79 if err != nil { 80 return nil, err 81 } 82 return &resource, nil 83 } 84 85 // GetResource gets an existing Resource resource's state with the given name, ID, and optional 86 // state properties that are used to uniquely qualify the lookup (nil if not required). 87 func GetResource(ctx *pulumi.Context, 88 name string, id pulumi.IDInput, state *ResourceState, opts ...pulumi.ResourceOption) (*Resource, error) { 89 var resource Resource 90 err := ctx.ReadResource("mypkg::Resource", name, id, state, &resource, opts...) 91 if err != nil { 92 return nil, err 93 } 94 return &resource, nil 95 } 96 97 // Input properties used for looking up and filtering Resource resources. 98 type resourceState struct { 99 } 100 101 type ResourceState struct { 102 } 103 104 func (ResourceState) ElementType() reflect.Type { 105 return reflect.TypeOf((*resourceState)(nil)).Elem() 106 } 107 108 type resourceArgs struct { 109 Config Config `pulumi:"config"` 110 ConfigArray []Config `pulumi:"configArray"` 111 ConfigMap map[string]Config `pulumi:"configMap"` 112 Foo string `pulumi:"foo"` 113 FooArray []string `pulumi:"fooArray"` 114 FooMap map[string]string `pulumi:"fooMap"` 115 } 116 117 // The set of arguments for constructing a Resource resource. 118 type ResourceArgs struct { 119 Config ConfigInput 120 ConfigArray ConfigArrayInput 121 ConfigMap ConfigMapInput 122 Foo pulumi.StringInput 123 FooArray pulumi.StringArrayInput 124 FooMap pulumi.StringMapInput 125 } 126 127 func (ResourceArgs) ElementType() reflect.Type { 128 return reflect.TypeOf((*resourceArgs)(nil)).Elem() 129 } 130 131 type ResourceInput interface { 132 pulumi.Input 133 134 ToResourceOutput() ResourceOutput 135 ToResourceOutputWithContext(ctx context.Context) ResourceOutput 136 } 137 138 func (*Resource) ElementType() reflect.Type { 139 return reflect.TypeOf((**Resource)(nil)).Elem() 140 } 141 142 func (i *Resource) ToResourceOutput() ResourceOutput { 143 return i.ToResourceOutputWithContext(context.Background()) 144 } 145 146 func (i *Resource) ToResourceOutputWithContext(ctx context.Context) ResourceOutput { 147 return pulumi.ToOutputWithContext(ctx, i).(ResourceOutput) 148 } 149 150 type ResourceOutput struct{ *pulumi.OutputState } 151 152 func (ResourceOutput) ElementType() reflect.Type { 153 return reflect.TypeOf((**Resource)(nil)).Elem() 154 } 155 156 func (o ResourceOutput) ToResourceOutput() ResourceOutput { 157 return o 158 } 159 160 func (o ResourceOutput) ToResourceOutputWithContext(ctx context.Context) ResourceOutput { 161 return o 162 } 163 164 func (o ResourceOutput) Config() ConfigOutput { 165 return o.ApplyT(func(v *Resource) ConfigOutput { return v.Config }).(ConfigOutput) 166 } 167 168 func (o ResourceOutput) ConfigArray() ConfigArrayOutput { 169 return o.ApplyT(func(v *Resource) ConfigArrayOutput { return v.ConfigArray }).(ConfigArrayOutput) 170 } 171 172 func (o ResourceOutput) ConfigMap() ConfigMapOutput { 173 return o.ApplyT(func(v *Resource) ConfigMapOutput { return v.ConfigMap }).(ConfigMapOutput) 174 } 175 176 func (o ResourceOutput) Foo() pulumi.StringOutput { 177 return o.ApplyT(func(v *Resource) pulumi.StringOutput { return v.Foo }).(pulumi.StringOutput) 178 } 179 180 func (o ResourceOutput) FooArray() pulumi.StringArrayOutput { 181 return o.ApplyT(func(v *Resource) pulumi.StringArrayOutput { return v.FooArray }).(pulumi.StringArrayOutput) 182 } 183 184 func (o ResourceOutput) FooMap() pulumi.StringMapOutput { 185 return o.ApplyT(func(v *Resource) pulumi.StringMapOutput { return v.FooMap }).(pulumi.StringMapOutput) 186 } 187 188 func init() { 189 pulumi.RegisterInputType(reflect.TypeOf((*ResourceInput)(nil)).Elem(), &Resource{}) 190 pulumi.RegisterOutputType(ResourceOutput{}) 191 }