/
mountedfile.go
428 lines (369 loc) · 14.9 KB
/
mountedfile.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
// 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 spacelift
import (
"context"
"reflect"
"errors"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
"github.com/pulumi/pulumi/sdk/v3/go/pulumix"
"github.com/spacelift-io/pulumi-spacelift/sdk/v2/go/spacelift/internal"
)
// `Mountedfile` represents a file mounted in each Run's workspace that is part of a configuration of a context (`Context`), stack (`Stack`) or a module (`Module`). In principle, it's very similar to an environment variable (`EnvironmentVariable`) except that the value is written to the filesystem rather than passed to the environment.
//
// ## Example Usage
//
// ```go
// package main
//
// import (
//
// "encoding/base64"
// "fmt"
// "os"
//
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
// "github.com/spacelift-io/pulumi-spacelift/sdk/v2/go/spacelift"
//
// )
//
// func filebase64OrPanic(path string) pulumi.StringPtrInput {
// if fileData, err := os.ReadFile(path); err == nil {
// return pulumi.String(base64.StdEncoding.EncodeToString(fileData[:]))
// } else {
// panic(err.Error())
// }
// }
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// _, err := spacelift.NewMountedfile(ctx, "ireland-kubeconfig", &spacelift.MountedfileArgs{
// ContextId: pulumi.String("prod-k8s-ie"),
// RelativePath: pulumi.String("kubeconfig"),
// Content: filebase64OrPanic(fmt.Sprintf("%v/kubeconfig.json", path.Module)),
// })
// if err != nil {
// return err
// }
// _, err = spacelift.NewMountedfile(ctx, "module-kubeconfig", &spacelift.MountedfileArgs{
// ModuleId: pulumi.String("k8s-module"),
// RelativePath: pulumi.String("kubeconfig"),
// Content: filebase64OrPanic(fmt.Sprintf("%v/kubeconfig.json", path.Module)),
// })
// if err != nil {
// return err
// }
// _, err = spacelift.NewMountedfile(ctx, "core-kubeconfig", &spacelift.MountedfileArgs{
// StackId: pulumi.String("k8s-core"),
// RelativePath: pulumi.String("kubeconfig"),
// Content: filebase64OrPanic(fmt.Sprintf("%v/kubeconfig.json", path.Module)),
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
//
// ```
//
// ## Import
//
// ```sh
//
// $ pulumi import spacelift:index/mountedfile:Mountedfile ireland-kubeconfig context/$CONTEXT_ID/$MOUNTED_FILE_ID
//
// ```
//
// ```sh
//
// $ pulumi import spacelift:index/mountedfile:Mountedfile module-kubeconfig module/$MODULE_ID/$MOUNTED_FILE_ID
//
// ```
//
// ```sh
//
// $ pulumi import spacelift:index/mountedfile:Mountedfile core-kubeconfig stack/$STACK_ID/$MOUNTED_FILE_ID
//
// ```
type Mountedfile struct {
pulumi.CustomResourceState
// SHA-256 checksum of the value
Checksum pulumi.StringOutput `pulumi:"checksum"`
// Content of the mounted file encoded using Base-64
Content pulumi.StringOutput `pulumi:"content"`
// ID of the context on which the mounted file is defined
ContextId pulumi.StringPtrOutput `pulumi:"contextId"`
// ID of the module on which the mounted file is defined
ModuleId pulumi.StringPtrOutput `pulumi:"moduleId"`
// Relative path to the mounted file, without the /mnt/workspace/ prefix
RelativePath pulumi.StringOutput `pulumi:"relativePath"`
// ID of the stack on which the mounted file is defined
StackId pulumi.StringPtrOutput `pulumi:"stackId"`
// Indicates whether the content can be read back outside a Run. Defaults to `true`.
WriteOnly pulumi.BoolPtrOutput `pulumi:"writeOnly"`
}
// NewMountedfile registers a new resource with the given unique name, arguments, and options.
func NewMountedfile(ctx *pulumi.Context,
name string, args *MountedfileArgs, opts ...pulumi.ResourceOption) (*Mountedfile, error) {
if args == nil {
return nil, errors.New("missing one or more required arguments")
}
if args.Content == nil {
return nil, errors.New("invalid value for required argument 'Content'")
}
if args.RelativePath == nil {
return nil, errors.New("invalid value for required argument 'RelativePath'")
}
if args.Content != nil {
args.Content = pulumi.ToSecret(args.Content).(pulumi.StringInput)
}
secrets := pulumi.AdditionalSecretOutputs([]string{
"content",
})
opts = append(opts, secrets)
opts = internal.PkgResourceDefaultOpts(opts)
var resource Mountedfile
err := ctx.RegisterResource("spacelift:index/mountedfile:Mountedfile", name, args, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// GetMountedfile gets an existing Mountedfile 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 GetMountedfile(ctx *pulumi.Context,
name string, id pulumi.IDInput, state *MountedfileState, opts ...pulumi.ResourceOption) (*Mountedfile, error) {
var resource Mountedfile
err := ctx.ReadResource("spacelift:index/mountedfile:Mountedfile", name, id, state, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// Input properties used for looking up and filtering Mountedfile resources.
type mountedfileState struct {
// SHA-256 checksum of the value
Checksum *string `pulumi:"checksum"`
// Content of the mounted file encoded using Base-64
Content *string `pulumi:"content"`
// ID of the context on which the mounted file is defined
ContextId *string `pulumi:"contextId"`
// ID of the module on which the mounted file is defined
ModuleId *string `pulumi:"moduleId"`
// Relative path to the mounted file, without the /mnt/workspace/ prefix
RelativePath *string `pulumi:"relativePath"`
// ID of the stack on which the mounted file is defined
StackId *string `pulumi:"stackId"`
// Indicates whether the content can be read back outside a Run. Defaults to `true`.
WriteOnly *bool `pulumi:"writeOnly"`
}
type MountedfileState struct {
// SHA-256 checksum of the value
Checksum pulumi.StringPtrInput
// Content of the mounted file encoded using Base-64
Content pulumi.StringPtrInput
// ID of the context on which the mounted file is defined
ContextId pulumi.StringPtrInput
// ID of the module on which the mounted file is defined
ModuleId pulumi.StringPtrInput
// Relative path to the mounted file, without the /mnt/workspace/ prefix
RelativePath pulumi.StringPtrInput
// ID of the stack on which the mounted file is defined
StackId pulumi.StringPtrInput
// Indicates whether the content can be read back outside a Run. Defaults to `true`.
WriteOnly pulumi.BoolPtrInput
}
func (MountedfileState) ElementType() reflect.Type {
return reflect.TypeOf((*mountedfileState)(nil)).Elem()
}
type mountedfileArgs struct {
// Content of the mounted file encoded using Base-64
Content string `pulumi:"content"`
// ID of the context on which the mounted file is defined
ContextId *string `pulumi:"contextId"`
// ID of the module on which the mounted file is defined
ModuleId *string `pulumi:"moduleId"`
// Relative path to the mounted file, without the /mnt/workspace/ prefix
RelativePath string `pulumi:"relativePath"`
// ID of the stack on which the mounted file is defined
StackId *string `pulumi:"stackId"`
// Indicates whether the content can be read back outside a Run. Defaults to `true`.
WriteOnly *bool `pulumi:"writeOnly"`
}
// The set of arguments for constructing a Mountedfile resource.
type MountedfileArgs struct {
// Content of the mounted file encoded using Base-64
Content pulumi.StringInput
// ID of the context on which the mounted file is defined
ContextId pulumi.StringPtrInput
// ID of the module on which the mounted file is defined
ModuleId pulumi.StringPtrInput
// Relative path to the mounted file, without the /mnt/workspace/ prefix
RelativePath pulumi.StringInput
// ID of the stack on which the mounted file is defined
StackId pulumi.StringPtrInput
// Indicates whether the content can be read back outside a Run. Defaults to `true`.
WriteOnly pulumi.BoolPtrInput
}
func (MountedfileArgs) ElementType() reflect.Type {
return reflect.TypeOf((*mountedfileArgs)(nil)).Elem()
}
type MountedfileInput interface {
pulumi.Input
ToMountedfileOutput() MountedfileOutput
ToMountedfileOutputWithContext(ctx context.Context) MountedfileOutput
}
func (*Mountedfile) ElementType() reflect.Type {
return reflect.TypeOf((**Mountedfile)(nil)).Elem()
}
func (i *Mountedfile) ToMountedfileOutput() MountedfileOutput {
return i.ToMountedfileOutputWithContext(context.Background())
}
func (i *Mountedfile) ToMountedfileOutputWithContext(ctx context.Context) MountedfileOutput {
return pulumi.ToOutputWithContext(ctx, i).(MountedfileOutput)
}
func (i *Mountedfile) ToOutput(ctx context.Context) pulumix.Output[*Mountedfile] {
return pulumix.Output[*Mountedfile]{
OutputState: i.ToMountedfileOutputWithContext(ctx).OutputState,
}
}
// MountedfileArrayInput is an input type that accepts MountedfileArray and MountedfileArrayOutput values.
// You can construct a concrete instance of `MountedfileArrayInput` via:
//
// MountedfileArray{ MountedfileArgs{...} }
type MountedfileArrayInput interface {
pulumi.Input
ToMountedfileArrayOutput() MountedfileArrayOutput
ToMountedfileArrayOutputWithContext(context.Context) MountedfileArrayOutput
}
type MountedfileArray []MountedfileInput
func (MountedfileArray) ElementType() reflect.Type {
return reflect.TypeOf((*[]*Mountedfile)(nil)).Elem()
}
func (i MountedfileArray) ToMountedfileArrayOutput() MountedfileArrayOutput {
return i.ToMountedfileArrayOutputWithContext(context.Background())
}
func (i MountedfileArray) ToMountedfileArrayOutputWithContext(ctx context.Context) MountedfileArrayOutput {
return pulumi.ToOutputWithContext(ctx, i).(MountedfileArrayOutput)
}
func (i MountedfileArray) ToOutput(ctx context.Context) pulumix.Output[[]*Mountedfile] {
return pulumix.Output[[]*Mountedfile]{
OutputState: i.ToMountedfileArrayOutputWithContext(ctx).OutputState,
}
}
// MountedfileMapInput is an input type that accepts MountedfileMap and MountedfileMapOutput values.
// You can construct a concrete instance of `MountedfileMapInput` via:
//
// MountedfileMap{ "key": MountedfileArgs{...} }
type MountedfileMapInput interface {
pulumi.Input
ToMountedfileMapOutput() MountedfileMapOutput
ToMountedfileMapOutputWithContext(context.Context) MountedfileMapOutput
}
type MountedfileMap map[string]MountedfileInput
func (MountedfileMap) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*Mountedfile)(nil)).Elem()
}
func (i MountedfileMap) ToMountedfileMapOutput() MountedfileMapOutput {
return i.ToMountedfileMapOutputWithContext(context.Background())
}
func (i MountedfileMap) ToMountedfileMapOutputWithContext(ctx context.Context) MountedfileMapOutput {
return pulumi.ToOutputWithContext(ctx, i).(MountedfileMapOutput)
}
func (i MountedfileMap) ToOutput(ctx context.Context) pulumix.Output[map[string]*Mountedfile] {
return pulumix.Output[map[string]*Mountedfile]{
OutputState: i.ToMountedfileMapOutputWithContext(ctx).OutputState,
}
}
type MountedfileOutput struct{ *pulumi.OutputState }
func (MountedfileOutput) ElementType() reflect.Type {
return reflect.TypeOf((**Mountedfile)(nil)).Elem()
}
func (o MountedfileOutput) ToMountedfileOutput() MountedfileOutput {
return o
}
func (o MountedfileOutput) ToMountedfileOutputWithContext(ctx context.Context) MountedfileOutput {
return o
}
func (o MountedfileOutput) ToOutput(ctx context.Context) pulumix.Output[*Mountedfile] {
return pulumix.Output[*Mountedfile]{
OutputState: o.OutputState,
}
}
// SHA-256 checksum of the value
func (o MountedfileOutput) Checksum() pulumi.StringOutput {
return o.ApplyT(func(v *Mountedfile) pulumi.StringOutput { return v.Checksum }).(pulumi.StringOutput)
}
// Content of the mounted file encoded using Base-64
func (o MountedfileOutput) Content() pulumi.StringOutput {
return o.ApplyT(func(v *Mountedfile) pulumi.StringOutput { return v.Content }).(pulumi.StringOutput)
}
// ID of the context on which the mounted file is defined
func (o MountedfileOutput) ContextId() pulumi.StringPtrOutput {
return o.ApplyT(func(v *Mountedfile) pulumi.StringPtrOutput { return v.ContextId }).(pulumi.StringPtrOutput)
}
// ID of the module on which the mounted file is defined
func (o MountedfileOutput) ModuleId() pulumi.StringPtrOutput {
return o.ApplyT(func(v *Mountedfile) pulumi.StringPtrOutput { return v.ModuleId }).(pulumi.StringPtrOutput)
}
// Relative path to the mounted file, without the /mnt/workspace/ prefix
func (o MountedfileOutput) RelativePath() pulumi.StringOutput {
return o.ApplyT(func(v *Mountedfile) pulumi.StringOutput { return v.RelativePath }).(pulumi.StringOutput)
}
// ID of the stack on which the mounted file is defined
func (o MountedfileOutput) StackId() pulumi.StringPtrOutput {
return o.ApplyT(func(v *Mountedfile) pulumi.StringPtrOutput { return v.StackId }).(pulumi.StringPtrOutput)
}
// Indicates whether the content can be read back outside a Run. Defaults to `true`.
func (o MountedfileOutput) WriteOnly() pulumi.BoolPtrOutput {
return o.ApplyT(func(v *Mountedfile) pulumi.BoolPtrOutput { return v.WriteOnly }).(pulumi.BoolPtrOutput)
}
type MountedfileArrayOutput struct{ *pulumi.OutputState }
func (MountedfileArrayOutput) ElementType() reflect.Type {
return reflect.TypeOf((*[]*Mountedfile)(nil)).Elem()
}
func (o MountedfileArrayOutput) ToMountedfileArrayOutput() MountedfileArrayOutput {
return o
}
func (o MountedfileArrayOutput) ToMountedfileArrayOutputWithContext(ctx context.Context) MountedfileArrayOutput {
return o
}
func (o MountedfileArrayOutput) ToOutput(ctx context.Context) pulumix.Output[[]*Mountedfile] {
return pulumix.Output[[]*Mountedfile]{
OutputState: o.OutputState,
}
}
func (o MountedfileArrayOutput) Index(i pulumi.IntInput) MountedfileOutput {
return pulumi.All(o, i).ApplyT(func(vs []interface{}) *Mountedfile {
return vs[0].([]*Mountedfile)[vs[1].(int)]
}).(MountedfileOutput)
}
type MountedfileMapOutput struct{ *pulumi.OutputState }
func (MountedfileMapOutput) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*Mountedfile)(nil)).Elem()
}
func (o MountedfileMapOutput) ToMountedfileMapOutput() MountedfileMapOutput {
return o
}
func (o MountedfileMapOutput) ToMountedfileMapOutputWithContext(ctx context.Context) MountedfileMapOutput {
return o
}
func (o MountedfileMapOutput) ToOutput(ctx context.Context) pulumix.Output[map[string]*Mountedfile] {
return pulumix.Output[map[string]*Mountedfile]{
OutputState: o.OutputState,
}
}
func (o MountedfileMapOutput) MapIndex(k pulumi.StringInput) MountedfileOutput {
return pulumi.All(o, k).ApplyT(func(vs []interface{}) *Mountedfile {
return vs[0].(map[string]*Mountedfile)[vs[1].(string)]
}).(MountedfileOutput)
}
func init() {
pulumi.RegisterInputType(reflect.TypeOf((*MountedfileInput)(nil)).Elem(), &Mountedfile{})
pulumi.RegisterInputType(reflect.TypeOf((*MountedfileArrayInput)(nil)).Elem(), MountedfileArray{})
pulumi.RegisterInputType(reflect.TypeOf((*MountedfileMapInput)(nil)).Elem(), MountedfileMap{})
pulumi.RegisterOutputType(MountedfileOutput{})
pulumi.RegisterOutputType(MountedfileArrayOutput{})
pulumi.RegisterOutputType(MountedfileMapOutput{})
}