/
team.go
328 lines (278 loc) · 9.54 KB
/
team.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
// 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 pipeline
import (
"context"
"reflect"
"errors"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
"github.com/pulumiverse/pulumi-buildkite/sdk/v2/go/buildkite/internal"
)
// ## # Resource: pipelineTeam
//
// This resource allows you to create and manage team configuration in a pipeline.
//
// Buildkite Documentation: https://buildkite.com/docs/pipelines/permissions#permissions-with-teams-pipeline-level-permissions
//
// ## Example Usage
//
// ```go
// package main
//
// import (
//
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
// "github.com/pulumiverse/pulumi-buildkite/sdk/v2/go/buildkite/Pipeline"
//
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// _, err := Pipeline.NewTeam(ctx, "developers", &Pipeline.TeamArgs{
// PipelineId: pulumi.Any(buildkite_pipeline.Repo2),
// TeamId: pulumi.Any(buildkite_team.Test.Id),
// AccessLevel: pulumi.String("MANAGE_BUILD_AND_READ"),
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
//
// ```
//
// ## Import
//
// Pipeline teams can be imported using their `GraphQL ID`, e.g.
//
// ```sh
//
// $ pulumi import buildkite:Pipeline/team:Team guests VGVhbS0tLWU1YjQyMDQyLTUzN2QtNDZjNi04MjY0LTliZjFkMzkyYjZkNQ==
//
// ```
//
// Your pipeline team's GraphQL ID can be found with the below GraphQL query below.
//
// graphql query getPipelineTeamId {
//
// pipeline(slug"ORGANIZATION_SLUG/PIPELINE_SLUG") { teams(first5, search"PIPELINE_SEARCH_TERM") {
//
// edges{
//
// node{
//
// id
//
// }
//
// }
//
// }
//
// } }
type Team struct {
pulumi.CustomResourceState
// The level of access to grant. Must be one of `READ_ONLY`, `BUILD_AND_READ` or `MANAGE_BUILD_AND_READ`.
AccessLevel pulumi.StringOutput `pulumi:"accessLevel"`
// The GraphQL ID of the pipeline.
PipelineId pulumi.StringOutput `pulumi:"pipelineId"`
// The GraphQL ID of the team to add to/remove from.
TeamId pulumi.StringOutput `pulumi:"teamId"`
// The UUID of the pipeline schedule
Uuid pulumi.StringOutput `pulumi:"uuid"`
}
// NewTeam registers a new resource with the given unique name, arguments, and options.
func NewTeam(ctx *pulumi.Context,
name string, args *TeamArgs, opts ...pulumi.ResourceOption) (*Team, error) {
if args == nil {
return nil, errors.New("missing one or more required arguments")
}
if args.AccessLevel == nil {
return nil, errors.New("invalid value for required argument 'AccessLevel'")
}
if args.PipelineId == nil {
return nil, errors.New("invalid value for required argument 'PipelineId'")
}
if args.TeamId == nil {
return nil, errors.New("invalid value for required argument 'TeamId'")
}
opts = internal.PkgResourceDefaultOpts(opts)
var resource Team
err := ctx.RegisterResource("buildkite:Pipeline/team:Team", name, args, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// GetTeam gets an existing Team 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 GetTeam(ctx *pulumi.Context,
name string, id pulumi.IDInput, state *TeamState, opts ...pulumi.ResourceOption) (*Team, error) {
var resource Team
err := ctx.ReadResource("buildkite:Pipeline/team:Team", name, id, state, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// Input properties used for looking up and filtering Team resources.
type teamState struct {
// The level of access to grant. Must be one of `READ_ONLY`, `BUILD_AND_READ` or `MANAGE_BUILD_AND_READ`.
AccessLevel *string `pulumi:"accessLevel"`
// The GraphQL ID of the pipeline.
PipelineId *string `pulumi:"pipelineId"`
// The GraphQL ID of the team to add to/remove from.
TeamId *string `pulumi:"teamId"`
// The UUID of the pipeline schedule
Uuid *string `pulumi:"uuid"`
}
type TeamState struct {
// The level of access to grant. Must be one of `READ_ONLY`, `BUILD_AND_READ` or `MANAGE_BUILD_AND_READ`.
AccessLevel pulumi.StringPtrInput
// The GraphQL ID of the pipeline.
PipelineId pulumi.StringPtrInput
// The GraphQL ID of the team to add to/remove from.
TeamId pulumi.StringPtrInput
// The UUID of the pipeline schedule
Uuid pulumi.StringPtrInput
}
func (TeamState) ElementType() reflect.Type {
return reflect.TypeOf((*teamState)(nil)).Elem()
}
type teamArgs struct {
// The level of access to grant. Must be one of `READ_ONLY`, `BUILD_AND_READ` or `MANAGE_BUILD_AND_READ`.
AccessLevel string `pulumi:"accessLevel"`
// The GraphQL ID of the pipeline.
PipelineId string `pulumi:"pipelineId"`
// The GraphQL ID of the team to add to/remove from.
TeamId string `pulumi:"teamId"`
}
// The set of arguments for constructing a Team resource.
type TeamArgs struct {
// The level of access to grant. Must be one of `READ_ONLY`, `BUILD_AND_READ` or `MANAGE_BUILD_AND_READ`.
AccessLevel pulumi.StringInput
// The GraphQL ID of the pipeline.
PipelineId pulumi.StringInput
// The GraphQL ID of the team to add to/remove from.
TeamId pulumi.StringInput
}
func (TeamArgs) ElementType() reflect.Type {
return reflect.TypeOf((*teamArgs)(nil)).Elem()
}
type TeamInput interface {
pulumi.Input
ToTeamOutput() TeamOutput
ToTeamOutputWithContext(ctx context.Context) TeamOutput
}
func (*Team) ElementType() reflect.Type {
return reflect.TypeOf((**Team)(nil)).Elem()
}
func (i *Team) ToTeamOutput() TeamOutput {
return i.ToTeamOutputWithContext(context.Background())
}
func (i *Team) ToTeamOutputWithContext(ctx context.Context) TeamOutput {
return pulumi.ToOutputWithContext(ctx, i).(TeamOutput)
}
// TeamArrayInput is an input type that accepts TeamArray and TeamArrayOutput values.
// You can construct a concrete instance of `TeamArrayInput` via:
//
// TeamArray{ TeamArgs{...} }
type TeamArrayInput interface {
pulumi.Input
ToTeamArrayOutput() TeamArrayOutput
ToTeamArrayOutputWithContext(context.Context) TeamArrayOutput
}
type TeamArray []TeamInput
func (TeamArray) ElementType() reflect.Type {
return reflect.TypeOf((*[]*Team)(nil)).Elem()
}
func (i TeamArray) ToTeamArrayOutput() TeamArrayOutput {
return i.ToTeamArrayOutputWithContext(context.Background())
}
func (i TeamArray) ToTeamArrayOutputWithContext(ctx context.Context) TeamArrayOutput {
return pulumi.ToOutputWithContext(ctx, i).(TeamArrayOutput)
}
// TeamMapInput is an input type that accepts TeamMap and TeamMapOutput values.
// You can construct a concrete instance of `TeamMapInput` via:
//
// TeamMap{ "key": TeamArgs{...} }
type TeamMapInput interface {
pulumi.Input
ToTeamMapOutput() TeamMapOutput
ToTeamMapOutputWithContext(context.Context) TeamMapOutput
}
type TeamMap map[string]TeamInput
func (TeamMap) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*Team)(nil)).Elem()
}
func (i TeamMap) ToTeamMapOutput() TeamMapOutput {
return i.ToTeamMapOutputWithContext(context.Background())
}
func (i TeamMap) ToTeamMapOutputWithContext(ctx context.Context) TeamMapOutput {
return pulumi.ToOutputWithContext(ctx, i).(TeamMapOutput)
}
type TeamOutput struct{ *pulumi.OutputState }
func (TeamOutput) ElementType() reflect.Type {
return reflect.TypeOf((**Team)(nil)).Elem()
}
func (o TeamOutput) ToTeamOutput() TeamOutput {
return o
}
func (o TeamOutput) ToTeamOutputWithContext(ctx context.Context) TeamOutput {
return o
}
// The level of access to grant. Must be one of `READ_ONLY`, `BUILD_AND_READ` or `MANAGE_BUILD_AND_READ`.
func (o TeamOutput) AccessLevel() pulumi.StringOutput {
return o.ApplyT(func(v *Team) pulumi.StringOutput { return v.AccessLevel }).(pulumi.StringOutput)
}
// The GraphQL ID of the pipeline.
func (o TeamOutput) PipelineId() pulumi.StringOutput {
return o.ApplyT(func(v *Team) pulumi.StringOutput { return v.PipelineId }).(pulumi.StringOutput)
}
// The GraphQL ID of the team to add to/remove from.
func (o TeamOutput) TeamId() pulumi.StringOutput {
return o.ApplyT(func(v *Team) pulumi.StringOutput { return v.TeamId }).(pulumi.StringOutput)
}
// The UUID of the pipeline schedule
func (o TeamOutput) Uuid() pulumi.StringOutput {
return o.ApplyT(func(v *Team) pulumi.StringOutput { return v.Uuid }).(pulumi.StringOutput)
}
type TeamArrayOutput struct{ *pulumi.OutputState }
func (TeamArrayOutput) ElementType() reflect.Type {
return reflect.TypeOf((*[]*Team)(nil)).Elem()
}
func (o TeamArrayOutput) ToTeamArrayOutput() TeamArrayOutput {
return o
}
func (o TeamArrayOutput) ToTeamArrayOutputWithContext(ctx context.Context) TeamArrayOutput {
return o
}
func (o TeamArrayOutput) Index(i pulumi.IntInput) TeamOutput {
return pulumi.All(o, i).ApplyT(func(vs []interface{}) *Team {
return vs[0].([]*Team)[vs[1].(int)]
}).(TeamOutput)
}
type TeamMapOutput struct{ *pulumi.OutputState }
func (TeamMapOutput) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*Team)(nil)).Elem()
}
func (o TeamMapOutput) ToTeamMapOutput() TeamMapOutput {
return o
}
func (o TeamMapOutput) ToTeamMapOutputWithContext(ctx context.Context) TeamMapOutput {
return o
}
func (o TeamMapOutput) MapIndex(k pulumi.StringInput) TeamOutput {
return pulumi.All(o, k).ApplyT(func(vs []interface{}) *Team {
return vs[0].(map[string]*Team)[vs[1].(string)]
}).(TeamOutput)
}
func init() {
pulumi.RegisterInputType(reflect.TypeOf((*TeamInput)(nil)).Elem(), &Team{})
pulumi.RegisterInputType(reflect.TypeOf((*TeamArrayInput)(nil)).Elem(), TeamArray{})
pulumi.RegisterInputType(reflect.TypeOf((*TeamMapInput)(nil)).Elem(), TeamMap{})
pulumi.RegisterOutputType(TeamOutput{})
pulumi.RegisterOutputType(TeamArrayOutput{})
pulumi.RegisterOutputType(TeamMapOutput{})
}