/
variable.go
451 lines (399 loc) · 15.4 KB
/
variable.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
// Code generated by the Pulumi Terraform Bridge (tfgen) Tool DO NOT EDIT.
// *** WARNING: Do not edit by hand unless you're certain you know what you are doing! ***
package runtimeconfig
import (
"context"
"reflect"
"errors"
"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/internal"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
// ## Example Usage
//
// Example creating a RuntimeConfig variable.
//
// ```go
// package main
//
// import (
//
// "github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/runtimeconfig"
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
//
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// _, err := runtimeconfig.NewConfig(ctx, "my-runtime-config", &runtimeconfig.ConfigArgs{
// Name: pulumi.String("my-service-runtime-config"),
// Description: pulumi.String("Runtime configuration values for my service"),
// })
// if err != nil {
// return err
// }
// _, err = runtimeconfig.NewVariable(ctx, "environment", &runtimeconfig.VariableArgs{
// Parent: my_runtime_config.Name,
// Name: pulumi.String("prod-variables/hostname"),
// Text: pulumi.String("example.com"),
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
//
// ```
//
// You can also encode binary content using the `value` argument instead. The
// value must be base64 encoded.
//
// Example of using the `value` argument.
//
// ```go
// package main
//
// import (
//
// "github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/runtimeconfig"
// "github.com/pulumi/pulumi-std/sdk/go/std"
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
//
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// _, err := runtimeconfig.NewConfig(ctx, "my-runtime-config", &runtimeconfig.ConfigArgs{
// Name: pulumi.String("my-service-runtime-config"),
// Description: pulumi.String("Runtime configuration values for my service"),
// })
// if err != nil {
// return err
// }
// invokeFilebase64, err := std.Filebase64(ctx, &std.Filebase64Args{
// Input: "my-encrypted-secret.dat",
// }, nil)
// if err != nil {
// return err
// }
// _, err = runtimeconfig.NewVariable(ctx, "my-secret", &runtimeconfig.VariableArgs{
// Parent: my_runtime_config.Name,
// Name: pulumi.String("secret"),
// Value: invokeFilebase64.Result,
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
//
// ```
//
// ## Import
//
// Runtime Config Variables can be imported using the `name` or full variable name, e.g.
//
// * `projects/my-gcp-project/configs/{{config_id}}/variables/{{name}}`
//
// * `{{config_id}}/{{name}}`
//
// When using the `pulumi import` command, Runtime Config Variables can be imported using one of the formats above. For example:
//
// ```sh
// $ pulumi import gcp:runtimeconfig/variable:Variable default projects/my-gcp-project/configs/{{config_id}}/variables/{{name}}
// ```
//
// ```sh
// $ pulumi import gcp:runtimeconfig/variable:Variable default {{config_id}}/{{name}}
// ```
//
// When importing using only the name, the provider project must be set.
type Variable struct {
pulumi.CustomResourceState
// The name of the variable to manage. Note that variable
// names can be hierarchical using slashes (e.g. "prod-variables/hostname").
Name pulumi.StringOutput `pulumi:"name"`
// The name of the RuntimeConfig resource containing this
// variable.
Parent pulumi.StringOutput `pulumi:"parent"`
// The ID of the project in which the resource belongs. If it
// is not provided, the provider project is used.
Project pulumi.StringOutput `pulumi:"project"`
// or `value` - (Required) The content to associate with the variable.
// Exactly one of `text` or `variable` must be specified. If `text` is specified,
// it must be a valid UTF-8 string and less than 4096 bytes in length. If `value`
// is specified, it must be base64 encoded and less than 4096 bytes in length.
//
// ***
Text pulumi.StringPtrOutput `pulumi:"text"`
// (Computed) The timestamp in RFC3339 UTC "Zulu" format,
// accurate to nanoseconds, representing when the variable was last updated.
// Example: "2016-10-09T12:33:37.578138407Z".
UpdateTime pulumi.StringOutput `pulumi:"updateTime"`
Value pulumi.StringPtrOutput `pulumi:"value"`
}
// NewVariable registers a new resource with the given unique name, arguments, and options.
func NewVariable(ctx *pulumi.Context,
name string, args *VariableArgs, opts ...pulumi.ResourceOption) (*Variable, error) {
if args == nil {
return nil, errors.New("missing one or more required arguments")
}
if args.Parent == nil {
return nil, errors.New("invalid value for required argument 'Parent'")
}
if args.Text != nil {
args.Text = pulumi.ToSecret(args.Text).(pulumi.StringPtrInput)
}
if args.Value != nil {
args.Value = pulumi.ToSecret(args.Value).(pulumi.StringPtrInput)
}
secrets := pulumi.AdditionalSecretOutputs([]string{
"text",
"value",
})
opts = append(opts, secrets)
opts = internal.PkgResourceDefaultOpts(opts)
var resource Variable
err := ctx.RegisterResource("gcp:runtimeconfig/variable:Variable", name, args, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// GetVariable gets an existing Variable 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 GetVariable(ctx *pulumi.Context,
name string, id pulumi.IDInput, state *VariableState, opts ...pulumi.ResourceOption) (*Variable, error) {
var resource Variable
err := ctx.ReadResource("gcp:runtimeconfig/variable:Variable", name, id, state, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// Input properties used for looking up and filtering Variable resources.
type variableState struct {
// The name of the variable to manage. Note that variable
// names can be hierarchical using slashes (e.g. "prod-variables/hostname").
Name *string `pulumi:"name"`
// The name of the RuntimeConfig resource containing this
// variable.
Parent *string `pulumi:"parent"`
// The ID of the project in which the resource belongs. If it
// is not provided, the provider project is used.
Project *string `pulumi:"project"`
// or `value` - (Required) The content to associate with the variable.
// Exactly one of `text` or `variable` must be specified. If `text` is specified,
// it must be a valid UTF-8 string and less than 4096 bytes in length. If `value`
// is specified, it must be base64 encoded and less than 4096 bytes in length.
//
// ***
Text *string `pulumi:"text"`
// (Computed) The timestamp in RFC3339 UTC "Zulu" format,
// accurate to nanoseconds, representing when the variable was last updated.
// Example: "2016-10-09T12:33:37.578138407Z".
UpdateTime *string `pulumi:"updateTime"`
Value *string `pulumi:"value"`
}
type VariableState struct {
// The name of the variable to manage. Note that variable
// names can be hierarchical using slashes (e.g. "prod-variables/hostname").
Name pulumi.StringPtrInput
// The name of the RuntimeConfig resource containing this
// variable.
Parent pulumi.StringPtrInput
// The ID of the project in which the resource belongs. If it
// is not provided, the provider project is used.
Project pulumi.StringPtrInput
// or `value` - (Required) The content to associate with the variable.
// Exactly one of `text` or `variable` must be specified. If `text` is specified,
// it must be a valid UTF-8 string and less than 4096 bytes in length. If `value`
// is specified, it must be base64 encoded and less than 4096 bytes in length.
//
// ***
Text pulumi.StringPtrInput
// (Computed) The timestamp in RFC3339 UTC "Zulu" format,
// accurate to nanoseconds, representing when the variable was last updated.
// Example: "2016-10-09T12:33:37.578138407Z".
UpdateTime pulumi.StringPtrInput
Value pulumi.StringPtrInput
}
func (VariableState) ElementType() reflect.Type {
return reflect.TypeOf((*variableState)(nil)).Elem()
}
type variableArgs struct {
// The name of the variable to manage. Note that variable
// names can be hierarchical using slashes (e.g. "prod-variables/hostname").
Name *string `pulumi:"name"`
// The name of the RuntimeConfig resource containing this
// variable.
Parent string `pulumi:"parent"`
// The ID of the project in which the resource belongs. If it
// is not provided, the provider project is used.
Project *string `pulumi:"project"`
// or `value` - (Required) The content to associate with the variable.
// Exactly one of `text` or `variable` must be specified. If `text` is specified,
// it must be a valid UTF-8 string and less than 4096 bytes in length. If `value`
// is specified, it must be base64 encoded and less than 4096 bytes in length.
//
// ***
Text *string `pulumi:"text"`
Value *string `pulumi:"value"`
}
// The set of arguments for constructing a Variable resource.
type VariableArgs struct {
// The name of the variable to manage. Note that variable
// names can be hierarchical using slashes (e.g. "prod-variables/hostname").
Name pulumi.StringPtrInput
// The name of the RuntimeConfig resource containing this
// variable.
Parent pulumi.StringInput
// The ID of the project in which the resource belongs. If it
// is not provided, the provider project is used.
Project pulumi.StringPtrInput
// or `value` - (Required) The content to associate with the variable.
// Exactly one of `text` or `variable` must be specified. If `text` is specified,
// it must be a valid UTF-8 string and less than 4096 bytes in length. If `value`
// is specified, it must be base64 encoded and less than 4096 bytes in length.
//
// ***
Text pulumi.StringPtrInput
Value pulumi.StringPtrInput
}
func (VariableArgs) ElementType() reflect.Type {
return reflect.TypeOf((*variableArgs)(nil)).Elem()
}
type VariableInput interface {
pulumi.Input
ToVariableOutput() VariableOutput
ToVariableOutputWithContext(ctx context.Context) VariableOutput
}
func (*Variable) ElementType() reflect.Type {
return reflect.TypeOf((**Variable)(nil)).Elem()
}
func (i *Variable) ToVariableOutput() VariableOutput {
return i.ToVariableOutputWithContext(context.Background())
}
func (i *Variable) ToVariableOutputWithContext(ctx context.Context) VariableOutput {
return pulumi.ToOutputWithContext(ctx, i).(VariableOutput)
}
// VariableArrayInput is an input type that accepts VariableArray and VariableArrayOutput values.
// You can construct a concrete instance of `VariableArrayInput` via:
//
// VariableArray{ VariableArgs{...} }
type VariableArrayInput interface {
pulumi.Input
ToVariableArrayOutput() VariableArrayOutput
ToVariableArrayOutputWithContext(context.Context) VariableArrayOutput
}
type VariableArray []VariableInput
func (VariableArray) ElementType() reflect.Type {
return reflect.TypeOf((*[]*Variable)(nil)).Elem()
}
func (i VariableArray) ToVariableArrayOutput() VariableArrayOutput {
return i.ToVariableArrayOutputWithContext(context.Background())
}
func (i VariableArray) ToVariableArrayOutputWithContext(ctx context.Context) VariableArrayOutput {
return pulumi.ToOutputWithContext(ctx, i).(VariableArrayOutput)
}
// VariableMapInput is an input type that accepts VariableMap and VariableMapOutput values.
// You can construct a concrete instance of `VariableMapInput` via:
//
// VariableMap{ "key": VariableArgs{...} }
type VariableMapInput interface {
pulumi.Input
ToVariableMapOutput() VariableMapOutput
ToVariableMapOutputWithContext(context.Context) VariableMapOutput
}
type VariableMap map[string]VariableInput
func (VariableMap) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*Variable)(nil)).Elem()
}
func (i VariableMap) ToVariableMapOutput() VariableMapOutput {
return i.ToVariableMapOutputWithContext(context.Background())
}
func (i VariableMap) ToVariableMapOutputWithContext(ctx context.Context) VariableMapOutput {
return pulumi.ToOutputWithContext(ctx, i).(VariableMapOutput)
}
type VariableOutput struct{ *pulumi.OutputState }
func (VariableOutput) ElementType() reflect.Type {
return reflect.TypeOf((**Variable)(nil)).Elem()
}
func (o VariableOutput) ToVariableOutput() VariableOutput {
return o
}
func (o VariableOutput) ToVariableOutputWithContext(ctx context.Context) VariableOutput {
return o
}
// The name of the variable to manage. Note that variable
// names can be hierarchical using slashes (e.g. "prod-variables/hostname").
func (o VariableOutput) Name() pulumi.StringOutput {
return o.ApplyT(func(v *Variable) pulumi.StringOutput { return v.Name }).(pulumi.StringOutput)
}
// The name of the RuntimeConfig resource containing this
// variable.
func (o VariableOutput) Parent() pulumi.StringOutput {
return o.ApplyT(func(v *Variable) pulumi.StringOutput { return v.Parent }).(pulumi.StringOutput)
}
// The ID of the project in which the resource belongs. If it
// is not provided, the provider project is used.
func (o VariableOutput) Project() pulumi.StringOutput {
return o.ApplyT(func(v *Variable) pulumi.StringOutput { return v.Project }).(pulumi.StringOutput)
}
// or `value` - (Required) The content to associate with the variable.
// Exactly one of `text` or `variable` must be specified. If `text` is specified,
// it must be a valid UTF-8 string and less than 4096 bytes in length. If `value`
// is specified, it must be base64 encoded and less than 4096 bytes in length.
//
// ***
func (o VariableOutput) Text() pulumi.StringPtrOutput {
return o.ApplyT(func(v *Variable) pulumi.StringPtrOutput { return v.Text }).(pulumi.StringPtrOutput)
}
// (Computed) The timestamp in RFC3339 UTC "Zulu" format,
// accurate to nanoseconds, representing when the variable was last updated.
// Example: "2016-10-09T12:33:37.578138407Z".
func (o VariableOutput) UpdateTime() pulumi.StringOutput {
return o.ApplyT(func(v *Variable) pulumi.StringOutput { return v.UpdateTime }).(pulumi.StringOutput)
}
func (o VariableOutput) Value() pulumi.StringPtrOutput {
return o.ApplyT(func(v *Variable) pulumi.StringPtrOutput { return v.Value }).(pulumi.StringPtrOutput)
}
type VariableArrayOutput struct{ *pulumi.OutputState }
func (VariableArrayOutput) ElementType() reflect.Type {
return reflect.TypeOf((*[]*Variable)(nil)).Elem()
}
func (o VariableArrayOutput) ToVariableArrayOutput() VariableArrayOutput {
return o
}
func (o VariableArrayOutput) ToVariableArrayOutputWithContext(ctx context.Context) VariableArrayOutput {
return o
}
func (o VariableArrayOutput) Index(i pulumi.IntInput) VariableOutput {
return pulumi.All(o, i).ApplyT(func(vs []interface{}) *Variable {
return vs[0].([]*Variable)[vs[1].(int)]
}).(VariableOutput)
}
type VariableMapOutput struct{ *pulumi.OutputState }
func (VariableMapOutput) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*Variable)(nil)).Elem()
}
func (o VariableMapOutput) ToVariableMapOutput() VariableMapOutput {
return o
}
func (o VariableMapOutput) ToVariableMapOutputWithContext(ctx context.Context) VariableMapOutput {
return o
}
func (o VariableMapOutput) MapIndex(k pulumi.StringInput) VariableOutput {
return pulumi.All(o, k).ApplyT(func(vs []interface{}) *Variable {
return vs[0].(map[string]*Variable)[vs[1].(string)]
}).(VariableOutput)
}
func init() {
pulumi.RegisterInputType(reflect.TypeOf((*VariableInput)(nil)).Elem(), &Variable{})
pulumi.RegisterInputType(reflect.TypeOf((*VariableArrayInput)(nil)).Elem(), VariableArray{})
pulumi.RegisterInputType(reflect.TypeOf((*VariableMapInput)(nil)).Elem(), VariableMap{})
pulumi.RegisterOutputType(VariableOutput{})
pulumi.RegisterOutputType(VariableArrayOutput{})
pulumi.RegisterOutputType(VariableMapOutput{})
}