generated from pulumi/pulumi-tf-provider-boilerplate
/
context.go
394 lines (346 loc) · 10.9 KB
/
context.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
// 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 codefresh
import (
"context"
"reflect"
"github.com/pkg/errors"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
// ## # Context Resource
//
// A Context is an authentication/configuration that is used by Codefresh system and engine.
// There are multiple types of context available in Codefresh but they all have the following main components to define them:
// - Name: A unique identifier for the context
// - Type: A string representing the type of context
// - Data: A data structure that provide the information related to the Context. This differs based on the type of context selected
// For more details of the Context spec see in the [CLI official documentation](https://codefresh-io.github.io/cli/contexts/spec/)
//
// ## Supported types
//
// Currently the provider support the following types of Context:
// * config (Shared Config )
// * secret (Shared Secret)
// * yaml (YAML Configuration Context)
// * secret-yaml (Secret YAML Configuration Context)
//
// ### Shared Configuration
// A Shared Configuration is the entity in Codefresh that allow to create values in a central place that can then be consumed in pipelines to keep them DRY.
// More details in the official [Shared Configuration documentation](https://codefresh.io/docs/docs/configure-ci-cd-pipeline/shared-configuration/)
//
// #### Example Usage of config (Shared Config)
// ```go
// package main
//
// import (
//
// "github.com/pierskarsenbarg/pulumi-codefresh/sdk/go/codefresh"
// "github.com/pulumi/pulumi-codefresh/sdk/go/codefresh"
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
//
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// _, err := codefresh.NewContext(ctx, "test-config", &codefresh.ContextArgs{
// Spec: &ContextSpecArgs{
// Config: &ContextSpecConfigArgs{
// Data: pulumi.StringMap{
// "var1": pulumi.String("value1"),
// "var2": pulumi.String("value2"),
// },
// },
// },
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
//
// ```
//
// #### Example Usage of secret (Shared Secret)
// ```go
// package main
//
// import (
//
// "github.com/pierskarsenbarg/pulumi-codefresh/sdk/go/codefresh"
// "github.com/pulumi/pulumi-codefresh/sdk/go/codefresh"
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
//
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// _, err := codefresh.NewContext(ctx, "test-secret", &codefresh.ContextArgs{
// Spec: &ContextSpecArgs{
// Secret: &ContextSpecSecretArgs{
// Data: pulumi.StringMap{
// "var1": pulumi.String("value1"),
// "var2": pulumi.String("value2"),
// },
// },
// },
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
//
// ```
//
// #### Example Usage of yaml (YAML Configuration Context)
// ```go
// package main
//
// import (
//
// "fmt"
//
// "github.com/pierskarsenbarg/pulumi-codefresh/sdk/go/codefresh"
// "github.com/pulumi/pulumi-codefresh/sdk/go/codefresh"
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
//
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// _, err := codefresh.NewContext(ctx, "test-yaml", &codefresh.ContextArgs{
// Spec: &ContextSpecArgs{
// Yaml: fmt.Sprintf(`test:
// nested_value: value1
// list:
// - test2
// - test3
//
// another_element: value
//
// `),
//
// },
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
//
// ```
//
// #### Example Usage of secret-yaml (Secret YAML Configuration Context)
// ```go
// package main
//
// import (
//
// "io/ioutil"
//
// "github.com/pierskarsenbarg/pulumi-codefresh/sdk/go/codefresh"
// "github.com/pulumi/pulumi-codefresh/sdk/go/codefresh"
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
//
// )
//
// func readFileOrPanic(path string) pulumi.StringPtrInput {
// data, err := ioutil.ReadFile(path)
// if err != nil {
// panic(err.Error())
// }
// return pulumi.String(string(data))
// }
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// _, err := codefresh.NewContext(ctx, "test-secret-yaml", &codefresh.ContextArgs{
// Spec: &ContextSpecArgs{
// Secretyaml: readFileOrPanic("test.yaml"),
// },
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
//
// ```
type Context struct {
pulumi.CustomResourceState
// The display name for the context.
Name pulumi.StringOutput `pulumi:"name"`
// A `spec` block as documented below.
Spec ContextSpecOutput `pulumi:"spec"`
}
// NewContext registers a new resource with the given unique name, arguments, and options.
func NewContext(ctx *pulumi.Context,
name string, args *ContextArgs, opts ...pulumi.ResourceOption) (*Context, error) {
if args == nil {
return nil, errors.New("missing one or more required arguments")
}
if args.Spec == nil {
return nil, errors.New("invalid value for required argument 'Spec'")
}
var resource Context
err := ctx.RegisterResource("codefresh:index/context:Context", name, args, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// GetContext gets an existing Context 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 GetContext(ctx *pulumi.Context,
name string, id pulumi.IDInput, state *ContextState, opts ...pulumi.ResourceOption) (*Context, error) {
var resource Context
err := ctx.ReadResource("codefresh:index/context:Context", name, id, state, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// Input properties used for looking up and filtering Context resources.
type contextState struct {
// The display name for the context.
Name *string `pulumi:"name"`
// A `spec` block as documented below.
Spec *ContextSpec `pulumi:"spec"`
}
type ContextState struct {
// The display name for the context.
Name pulumi.StringPtrInput
// A `spec` block as documented below.
Spec ContextSpecPtrInput
}
func (ContextState) ElementType() reflect.Type {
return reflect.TypeOf((*contextState)(nil)).Elem()
}
type contextArgs struct {
// The display name for the context.
Name *string `pulumi:"name"`
// A `spec` block as documented below.
Spec ContextSpec `pulumi:"spec"`
}
// The set of arguments for constructing a Context resource.
type ContextArgs struct {
// The display name for the context.
Name pulumi.StringPtrInput
// A `spec` block as documented below.
Spec ContextSpecInput
}
func (ContextArgs) ElementType() reflect.Type {
return reflect.TypeOf((*contextArgs)(nil)).Elem()
}
type ContextInput interface {
pulumi.Input
ToContextOutput() ContextOutput
ToContextOutputWithContext(ctx context.Context) ContextOutput
}
func (*Context) ElementType() reflect.Type {
return reflect.TypeOf((**Context)(nil)).Elem()
}
func (i *Context) ToContextOutput() ContextOutput {
return i.ToContextOutputWithContext(context.Background())
}
func (i *Context) ToContextOutputWithContext(ctx context.Context) ContextOutput {
return pulumi.ToOutputWithContext(ctx, i).(ContextOutput)
}
// ContextArrayInput is an input type that accepts ContextArray and ContextArrayOutput values.
// You can construct a concrete instance of `ContextArrayInput` via:
//
// ContextArray{ ContextArgs{...} }
type ContextArrayInput interface {
pulumi.Input
ToContextArrayOutput() ContextArrayOutput
ToContextArrayOutputWithContext(context.Context) ContextArrayOutput
}
type ContextArray []ContextInput
func (ContextArray) ElementType() reflect.Type {
return reflect.TypeOf((*[]*Context)(nil)).Elem()
}
func (i ContextArray) ToContextArrayOutput() ContextArrayOutput {
return i.ToContextArrayOutputWithContext(context.Background())
}
func (i ContextArray) ToContextArrayOutputWithContext(ctx context.Context) ContextArrayOutput {
return pulumi.ToOutputWithContext(ctx, i).(ContextArrayOutput)
}
// ContextMapInput is an input type that accepts ContextMap and ContextMapOutput values.
// You can construct a concrete instance of `ContextMapInput` via:
//
// ContextMap{ "key": ContextArgs{...} }
type ContextMapInput interface {
pulumi.Input
ToContextMapOutput() ContextMapOutput
ToContextMapOutputWithContext(context.Context) ContextMapOutput
}
type ContextMap map[string]ContextInput
func (ContextMap) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*Context)(nil)).Elem()
}
func (i ContextMap) ToContextMapOutput() ContextMapOutput {
return i.ToContextMapOutputWithContext(context.Background())
}
func (i ContextMap) ToContextMapOutputWithContext(ctx context.Context) ContextMapOutput {
return pulumi.ToOutputWithContext(ctx, i).(ContextMapOutput)
}
type ContextOutput struct{ *pulumi.OutputState }
func (ContextOutput) ElementType() reflect.Type {
return reflect.TypeOf((**Context)(nil)).Elem()
}
func (o ContextOutput) ToContextOutput() ContextOutput {
return o
}
func (o ContextOutput) ToContextOutputWithContext(ctx context.Context) ContextOutput {
return o
}
// The display name for the context.
func (o ContextOutput) Name() pulumi.StringOutput {
return o.ApplyT(func(v *Context) pulumi.StringOutput { return v.Name }).(pulumi.StringOutput)
}
// A `spec` block as documented below.
func (o ContextOutput) Spec() ContextSpecOutput {
return o.ApplyT(func(v *Context) ContextSpecOutput { return v.Spec }).(ContextSpecOutput)
}
type ContextArrayOutput struct{ *pulumi.OutputState }
func (ContextArrayOutput) ElementType() reflect.Type {
return reflect.TypeOf((*[]*Context)(nil)).Elem()
}
func (o ContextArrayOutput) ToContextArrayOutput() ContextArrayOutput {
return o
}
func (o ContextArrayOutput) ToContextArrayOutputWithContext(ctx context.Context) ContextArrayOutput {
return o
}
func (o ContextArrayOutput) Index(i pulumi.IntInput) ContextOutput {
return pulumi.All(o, i).ApplyT(func(vs []interface{}) *Context {
return vs[0].([]*Context)[vs[1].(int)]
}).(ContextOutput)
}
type ContextMapOutput struct{ *pulumi.OutputState }
func (ContextMapOutput) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*Context)(nil)).Elem()
}
func (o ContextMapOutput) ToContextMapOutput() ContextMapOutput {
return o
}
func (o ContextMapOutput) ToContextMapOutputWithContext(ctx context.Context) ContextMapOutput {
return o
}
func (o ContextMapOutput) MapIndex(k pulumi.StringInput) ContextOutput {
return pulumi.All(o, k).ApplyT(func(vs []interface{}) *Context {
return vs[0].(map[string]*Context)[vs[1].(string)]
}).(ContextOutput)
}
func init() {
pulumi.RegisterInputType(reflect.TypeOf((*ContextInput)(nil)).Elem(), &Context{})
pulumi.RegisterInputType(reflect.TypeOf((*ContextArrayInput)(nil)).Elem(), ContextArray{})
pulumi.RegisterInputType(reflect.TypeOf((*ContextMapInput)(nil)).Elem(), ContextMap{})
pulumi.RegisterOutputType(ContextOutput{})
pulumi.RegisterOutputType(ContextArrayOutput{})
pulumi.RegisterOutputType(ContextMapOutput{})
}