/
getImage.go
269 lines (239 loc) · 8.88 KB
/
getImage.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
// *** WARNING: this file was generated by the Pulumi Terraform Bridge (tfgen) Tool. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***
package digitalocean
import (
"context"
"reflect"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
// Get information on an image for use in other resources (e.g. creating a Droplet
// based on snapshot). This data source provides all of the image properties as
// configured on your DigitalOcean account. This is useful if the image in question
// is not managed by the provider or you need to utilize any of the image's data.
//
// An error is triggered if zero or more than one result is returned by the query.
//
// ## Example Usage
//
// Get the data about a snapshot:
//
// ```go
// package main
//
// import (
// "github.com/pulumi/pulumi-digitalocean/sdk/v4/go/digitalocean"
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// _, err := digitalocean.GetImage(ctx, &GetImageArgs{
// Name: pulumi.StringRef("example-1.0.0"),
// }, nil)
// if err != nil {
// return err
// }
// return nil
// })
// }
// ```
//
// Reuse the data about a snapshot to create a Droplet:
//
// ```go
// package main
//
// import (
// "github.com/pulumi/pulumi-digitalocean/sdk/v4/go/digitalocean"
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// exampleImage, err := digitalocean.GetImage(ctx, &GetImageArgs{
// Name: pulumi.StringRef("example-1.0.0"),
// }, nil)
// if err != nil {
// return err
// }
// _, err = digitalocean.NewDroplet(ctx, "exampleDroplet", &digitalocean.DropletArgs{
// Image: pulumi.Int(exampleImage.Id),
// Region: pulumi.String("nyc2"),
// Size: pulumi.String("s-1vcpu-1gb"),
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
// ```
//
// Get the data about an official image:
//
// ```go
// package main
//
// import (
// "github.com/pulumi/pulumi-digitalocean/sdk/v4/go/digitalocean"
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// _, err := digitalocean.GetImage(ctx, &GetImageArgs{
// Slug: pulumi.StringRef("ubuntu-18-04-x64"),
// }, nil)
// if err != nil {
// return err
// }
// return nil
// })
// }
// ```
func GetImage(ctx *pulumi.Context, args *GetImageArgs, opts ...pulumi.InvokeOption) (*GetImageResult, error) {
var rv GetImageResult
err := ctx.Invoke("digitalocean:index/getImage:getImage", args, &rv, opts...)
if err != nil {
return nil, err
}
return &rv, nil
}
// A collection of arguments for invoking getImage.
type GetImageArgs struct {
// The id of the image
Id *int `pulumi:"id"`
// The name of the image.
Name *string `pulumi:"name"`
// The slug of the official image.
Slug *string `pulumi:"slug"`
// Restrict the search to one of the following categories of images:
Source *string `pulumi:"source"`
}
// A collection of values returned by getImage.
type GetImageResult struct {
Created string `pulumi:"created"`
Description string `pulumi:"description"`
// The name of the distribution of the OS of the image.
// * `minDiskSize`: The minimum 'disk' required for the image.
// * `sizeGigabytes`: The size of the image in GB.
Distribution string `pulumi:"distribution"`
ErrorMessage string `pulumi:"errorMessage"`
Id int `pulumi:"id"`
// The id of the image (legacy parameter).
Image string `pulumi:"image"`
MinDiskSize int `pulumi:"minDiskSize"`
Name string `pulumi:"name"`
// Is image a public image or not. Public images represent
// Linux distributions or One-Click Applications, while non-public images represent
// snapshots and backups and are only available within your account.
// * `regions`: A set of the regions that the image is available in.
// * `tags`: A set of tags applied to the image
// * `created`: When the image was created
// * `status`: Current status of the image
// * `errorMessage`: Any applicable error message pertaining to the image
Private bool `pulumi:"private"`
Regions []string `pulumi:"regions"`
SizeGigabytes float64 `pulumi:"sizeGigabytes"`
Slug string `pulumi:"slug"`
Source *string `pulumi:"source"`
Status string `pulumi:"status"`
Tags []string `pulumi:"tags"`
Type string `pulumi:"type"`
}
func GetImageOutput(ctx *pulumi.Context, args GetImageOutputArgs, opts ...pulumi.InvokeOption) GetImageResultOutput {
return pulumi.ToOutputWithContext(context.Background(), args).
ApplyT(func(v interface{}) (GetImageResult, error) {
args := v.(GetImageArgs)
r, err := GetImage(ctx, &args, opts...)
return *r, err
}).(GetImageResultOutput)
}
// A collection of arguments for invoking getImage.
type GetImageOutputArgs struct {
// The id of the image
Id pulumi.IntPtrInput `pulumi:"id"`
// The name of the image.
Name pulumi.StringPtrInput `pulumi:"name"`
// The slug of the official image.
Slug pulumi.StringPtrInput `pulumi:"slug"`
// Restrict the search to one of the following categories of images:
Source pulumi.StringPtrInput `pulumi:"source"`
}
func (GetImageOutputArgs) ElementType() reflect.Type {
return reflect.TypeOf((*GetImageArgs)(nil)).Elem()
}
// A collection of values returned by getImage.
type GetImageResultOutput struct{ *pulumi.OutputState }
func (GetImageResultOutput) ElementType() reflect.Type {
return reflect.TypeOf((*GetImageResult)(nil)).Elem()
}
func (o GetImageResultOutput) ToGetImageResultOutput() GetImageResultOutput {
return o
}
func (o GetImageResultOutput) ToGetImageResultOutputWithContext(ctx context.Context) GetImageResultOutput {
return o
}
func (o GetImageResultOutput) Created() pulumi.StringOutput {
return o.ApplyT(func(v GetImageResult) string { return v.Created }).(pulumi.StringOutput)
}
func (o GetImageResultOutput) Description() pulumi.StringOutput {
return o.ApplyT(func(v GetImageResult) string { return v.Description }).(pulumi.StringOutput)
}
// The name of the distribution of the OS of the image.
// * `minDiskSize`: The minimum 'disk' required for the image.
// * `sizeGigabytes`: The size of the image in GB.
func (o GetImageResultOutput) Distribution() pulumi.StringOutput {
return o.ApplyT(func(v GetImageResult) string { return v.Distribution }).(pulumi.StringOutput)
}
func (o GetImageResultOutput) ErrorMessage() pulumi.StringOutput {
return o.ApplyT(func(v GetImageResult) string { return v.ErrorMessage }).(pulumi.StringOutput)
}
func (o GetImageResultOutput) Id() pulumi.IntOutput {
return o.ApplyT(func(v GetImageResult) int { return v.Id }).(pulumi.IntOutput)
}
// The id of the image (legacy parameter).
func (o GetImageResultOutput) Image() pulumi.StringOutput {
return o.ApplyT(func(v GetImageResult) string { return v.Image }).(pulumi.StringOutput)
}
func (o GetImageResultOutput) MinDiskSize() pulumi.IntOutput {
return o.ApplyT(func(v GetImageResult) int { return v.MinDiskSize }).(pulumi.IntOutput)
}
func (o GetImageResultOutput) Name() pulumi.StringOutput {
return o.ApplyT(func(v GetImageResult) string { return v.Name }).(pulumi.StringOutput)
}
// Is image a public image or not. Public images represent
// Linux distributions or One-Click Applications, while non-public images represent
// snapshots and backups and are only available within your account.
// * `regions`: A set of the regions that the image is available in.
// * `tags`: A set of tags applied to the image
// * `created`: When the image was created
// * `status`: Current status of the image
// * `errorMessage`: Any applicable error message pertaining to the image
func (o GetImageResultOutput) Private() pulumi.BoolOutput {
return o.ApplyT(func(v GetImageResult) bool { return v.Private }).(pulumi.BoolOutput)
}
func (o GetImageResultOutput) Regions() pulumi.StringArrayOutput {
return o.ApplyT(func(v GetImageResult) []string { return v.Regions }).(pulumi.StringArrayOutput)
}
func (o GetImageResultOutput) SizeGigabytes() pulumi.Float64Output {
return o.ApplyT(func(v GetImageResult) float64 { return v.SizeGigabytes }).(pulumi.Float64Output)
}
func (o GetImageResultOutput) Slug() pulumi.StringOutput {
return o.ApplyT(func(v GetImageResult) string { return v.Slug }).(pulumi.StringOutput)
}
func (o GetImageResultOutput) Source() pulumi.StringPtrOutput {
return o.ApplyT(func(v GetImageResult) *string { return v.Source }).(pulumi.StringPtrOutput)
}
func (o GetImageResultOutput) Status() pulumi.StringOutput {
return o.ApplyT(func(v GetImageResult) string { return v.Status }).(pulumi.StringOutput)
}
func (o GetImageResultOutput) Tags() pulumi.StringArrayOutput {
return o.ApplyT(func(v GetImageResult) []string { return v.Tags }).(pulumi.StringArrayOutput)
}
func (o GetImageResultOutput) Type() pulumi.StringOutput {
return o.ApplyT(func(v GetImageResult) string { return v.Type }).(pulumi.StringOutput)
}
func init() {
pulumi.RegisterOutputType(GetImageResultOutput{})
}