-
Notifications
You must be signed in to change notification settings - Fork 9
/
repositoryRuleset.go
421 lines (365 loc) · 17.3 KB
/
repositoryRuleset.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
// 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 github
import (
"context"
"reflect"
"errors"
"github.com/pulumi/pulumi-github/sdk/v6/go/github/internal"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
// Creates a GitHub repository ruleset.
//
// This resource allows you to create and manage rulesets on the repository level. When applied, a new ruleset will be created. When destroyed, that ruleset will be removed.
//
// ## Example Usage
//
// <!--Start PulumiCodeChooser -->
// ```go
// package main
//
// import (
//
// "github.com/pulumi/pulumi-github/sdk/v6/go/github"
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
//
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// exampleRepository, err := github.NewRepository(ctx, "exampleRepository", &github.RepositoryArgs{
// Description: pulumi.String("Example repository"),
// })
// if err != nil {
// return err
// }
// _, err = github.NewRepositoryRuleset(ctx, "exampleRepositoryRuleset", &github.RepositoryRulesetArgs{
// Repository: exampleRepository.Name,
// Target: pulumi.String("branch"),
// Enforcement: pulumi.String("active"),
// Conditions: &github.RepositoryRulesetConditionsArgs{
// RefName: &github.RepositoryRulesetConditionsRefNameArgs{
// Includes: pulumi.StringArray{
// pulumi.String("~ALL"),
// },
// Excludes: pulumi.StringArray{},
// },
// },
// BypassActors: github.RepositoryRulesetBypassActorArray{
// &github.RepositoryRulesetBypassActorArgs{
// ActorId: pulumi.Int(13473),
// ActorType: pulumi.String("Integration"),
// BypassMode: pulumi.String("always"),
// },
// },
// Rules: &github.RepositoryRulesetRulesArgs{
// Creation: pulumi.Bool(true),
// Update: pulumi.Bool(true),
// Deletion: pulumi.Bool(true),
// RequiredLinearHistory: pulumi.Bool(true),
// RequiredSignatures: pulumi.Bool(true),
// RequiredDeployments: &github.RepositoryRulesetRulesRequiredDeploymentsArgs{
// RequiredDeploymentEnvironments: pulumi.StringArray{
// pulumi.String("test"),
// },
// },
// },
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
//
// ```
// <!--End PulumiCodeChooser -->
//
// ## Import
//
// GitHub Repository Rulesets can be imported using the GitHub repository name and ruleset ID e.g.
//
// ```sh
// $ pulumi import github:index/repositoryRuleset:RepositoryRuleset example example:12345`
// ```
type RepositoryRuleset struct {
pulumi.CustomResourceState
// (Block List) The actors that can bypass the rules in this ruleset. (see below for nested schema)
BypassActors RepositoryRulesetBypassActorArrayOutput `pulumi:"bypassActors"`
// (Block List, Max: 1) Parameters for a repository ruleset ref name condition. (see below for nested schema)
Conditions RepositoryRulesetConditionsPtrOutput `pulumi:"conditions"`
// (String) Possible values for Enforcement are `disabled`, `active`, `evaluate`. Note: `evaluate` is currently only supported for owners of type `organization`.
Enforcement pulumi.StringOutput `pulumi:"enforcement"`
// (String)
Etag pulumi.StringOutput `pulumi:"etag"`
// (String) The name of the ruleset.
Name pulumi.StringOutput `pulumi:"name"`
// (String) GraphQL global node id for use with v4 API.
NodeId pulumi.StringOutput `pulumi:"nodeId"`
// (String) Name of the repository to apply rulset to.
Repository pulumi.StringPtrOutput `pulumi:"repository"`
// (Block List, Min: 1, Max: 1) Rules within the ruleset. (see below for nested schema)
Rules RepositoryRulesetRulesOutput `pulumi:"rules"`
// (Number) GitHub ID for the ruleset.
RulesetId pulumi.IntOutput `pulumi:"rulesetId"`
// (String) Possible values are `branch` and `tag`.
Target pulumi.StringOutput `pulumi:"target"`
}
// NewRepositoryRuleset registers a new resource with the given unique name, arguments, and options.
func NewRepositoryRuleset(ctx *pulumi.Context,
name string, args *RepositoryRulesetArgs, opts ...pulumi.ResourceOption) (*RepositoryRuleset, error) {
if args == nil {
return nil, errors.New("missing one or more required arguments")
}
if args.Enforcement == nil {
return nil, errors.New("invalid value for required argument 'Enforcement'")
}
if args.Rules == nil {
return nil, errors.New("invalid value for required argument 'Rules'")
}
if args.Target == nil {
return nil, errors.New("invalid value for required argument 'Target'")
}
opts = internal.PkgResourceDefaultOpts(opts)
var resource RepositoryRuleset
err := ctx.RegisterResource("github:index/repositoryRuleset:RepositoryRuleset", name, args, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// GetRepositoryRuleset gets an existing RepositoryRuleset 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 GetRepositoryRuleset(ctx *pulumi.Context,
name string, id pulumi.IDInput, state *RepositoryRulesetState, opts ...pulumi.ResourceOption) (*RepositoryRuleset, error) {
var resource RepositoryRuleset
err := ctx.ReadResource("github:index/repositoryRuleset:RepositoryRuleset", name, id, state, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// Input properties used for looking up and filtering RepositoryRuleset resources.
type repositoryRulesetState struct {
// (Block List) The actors that can bypass the rules in this ruleset. (see below for nested schema)
BypassActors []RepositoryRulesetBypassActor `pulumi:"bypassActors"`
// (Block List, Max: 1) Parameters for a repository ruleset ref name condition. (see below for nested schema)
Conditions *RepositoryRulesetConditions `pulumi:"conditions"`
// (String) Possible values for Enforcement are `disabled`, `active`, `evaluate`. Note: `evaluate` is currently only supported for owners of type `organization`.
Enforcement *string `pulumi:"enforcement"`
// (String)
Etag *string `pulumi:"etag"`
// (String) The name of the ruleset.
Name *string `pulumi:"name"`
// (String) GraphQL global node id for use with v4 API.
NodeId *string `pulumi:"nodeId"`
// (String) Name of the repository to apply rulset to.
Repository *string `pulumi:"repository"`
// (Block List, Min: 1, Max: 1) Rules within the ruleset. (see below for nested schema)
Rules *RepositoryRulesetRules `pulumi:"rules"`
// (Number) GitHub ID for the ruleset.
RulesetId *int `pulumi:"rulesetId"`
// (String) Possible values are `branch` and `tag`.
Target *string `pulumi:"target"`
}
type RepositoryRulesetState struct {
// (Block List) The actors that can bypass the rules in this ruleset. (see below for nested schema)
BypassActors RepositoryRulesetBypassActorArrayInput
// (Block List, Max: 1) Parameters for a repository ruleset ref name condition. (see below for nested schema)
Conditions RepositoryRulesetConditionsPtrInput
// (String) Possible values for Enforcement are `disabled`, `active`, `evaluate`. Note: `evaluate` is currently only supported for owners of type `organization`.
Enforcement pulumi.StringPtrInput
// (String)
Etag pulumi.StringPtrInput
// (String) The name of the ruleset.
Name pulumi.StringPtrInput
// (String) GraphQL global node id for use with v4 API.
NodeId pulumi.StringPtrInput
// (String) Name of the repository to apply rulset to.
Repository pulumi.StringPtrInput
// (Block List, Min: 1, Max: 1) Rules within the ruleset. (see below for nested schema)
Rules RepositoryRulesetRulesPtrInput
// (Number) GitHub ID for the ruleset.
RulesetId pulumi.IntPtrInput
// (String) Possible values are `branch` and `tag`.
Target pulumi.StringPtrInput
}
func (RepositoryRulesetState) ElementType() reflect.Type {
return reflect.TypeOf((*repositoryRulesetState)(nil)).Elem()
}
type repositoryRulesetArgs struct {
// (Block List) The actors that can bypass the rules in this ruleset. (see below for nested schema)
BypassActors []RepositoryRulesetBypassActor `pulumi:"bypassActors"`
// (Block List, Max: 1) Parameters for a repository ruleset ref name condition. (see below for nested schema)
Conditions *RepositoryRulesetConditions `pulumi:"conditions"`
// (String) Possible values for Enforcement are `disabled`, `active`, `evaluate`. Note: `evaluate` is currently only supported for owners of type `organization`.
Enforcement string `pulumi:"enforcement"`
// (String) The name of the ruleset.
Name *string `pulumi:"name"`
// (String) Name of the repository to apply rulset to.
Repository *string `pulumi:"repository"`
// (Block List, Min: 1, Max: 1) Rules within the ruleset. (see below for nested schema)
Rules RepositoryRulesetRules `pulumi:"rules"`
// (String) Possible values are `branch` and `tag`.
Target string `pulumi:"target"`
}
// The set of arguments for constructing a RepositoryRuleset resource.
type RepositoryRulesetArgs struct {
// (Block List) The actors that can bypass the rules in this ruleset. (see below for nested schema)
BypassActors RepositoryRulesetBypassActorArrayInput
// (Block List, Max: 1) Parameters for a repository ruleset ref name condition. (see below for nested schema)
Conditions RepositoryRulesetConditionsPtrInput
// (String) Possible values for Enforcement are `disabled`, `active`, `evaluate`. Note: `evaluate` is currently only supported for owners of type `organization`.
Enforcement pulumi.StringInput
// (String) The name of the ruleset.
Name pulumi.StringPtrInput
// (String) Name of the repository to apply rulset to.
Repository pulumi.StringPtrInput
// (Block List, Min: 1, Max: 1) Rules within the ruleset. (see below for nested schema)
Rules RepositoryRulesetRulesInput
// (String) Possible values are `branch` and `tag`.
Target pulumi.StringInput
}
func (RepositoryRulesetArgs) ElementType() reflect.Type {
return reflect.TypeOf((*repositoryRulesetArgs)(nil)).Elem()
}
type RepositoryRulesetInput interface {
pulumi.Input
ToRepositoryRulesetOutput() RepositoryRulesetOutput
ToRepositoryRulesetOutputWithContext(ctx context.Context) RepositoryRulesetOutput
}
func (*RepositoryRuleset) ElementType() reflect.Type {
return reflect.TypeOf((**RepositoryRuleset)(nil)).Elem()
}
func (i *RepositoryRuleset) ToRepositoryRulesetOutput() RepositoryRulesetOutput {
return i.ToRepositoryRulesetOutputWithContext(context.Background())
}
func (i *RepositoryRuleset) ToRepositoryRulesetOutputWithContext(ctx context.Context) RepositoryRulesetOutput {
return pulumi.ToOutputWithContext(ctx, i).(RepositoryRulesetOutput)
}
// RepositoryRulesetArrayInput is an input type that accepts RepositoryRulesetArray and RepositoryRulesetArrayOutput values.
// You can construct a concrete instance of `RepositoryRulesetArrayInput` via:
//
// RepositoryRulesetArray{ RepositoryRulesetArgs{...} }
type RepositoryRulesetArrayInput interface {
pulumi.Input
ToRepositoryRulesetArrayOutput() RepositoryRulesetArrayOutput
ToRepositoryRulesetArrayOutputWithContext(context.Context) RepositoryRulesetArrayOutput
}
type RepositoryRulesetArray []RepositoryRulesetInput
func (RepositoryRulesetArray) ElementType() reflect.Type {
return reflect.TypeOf((*[]*RepositoryRuleset)(nil)).Elem()
}
func (i RepositoryRulesetArray) ToRepositoryRulesetArrayOutput() RepositoryRulesetArrayOutput {
return i.ToRepositoryRulesetArrayOutputWithContext(context.Background())
}
func (i RepositoryRulesetArray) ToRepositoryRulesetArrayOutputWithContext(ctx context.Context) RepositoryRulesetArrayOutput {
return pulumi.ToOutputWithContext(ctx, i).(RepositoryRulesetArrayOutput)
}
// RepositoryRulesetMapInput is an input type that accepts RepositoryRulesetMap and RepositoryRulesetMapOutput values.
// You can construct a concrete instance of `RepositoryRulesetMapInput` via:
//
// RepositoryRulesetMap{ "key": RepositoryRulesetArgs{...} }
type RepositoryRulesetMapInput interface {
pulumi.Input
ToRepositoryRulesetMapOutput() RepositoryRulesetMapOutput
ToRepositoryRulesetMapOutputWithContext(context.Context) RepositoryRulesetMapOutput
}
type RepositoryRulesetMap map[string]RepositoryRulesetInput
func (RepositoryRulesetMap) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*RepositoryRuleset)(nil)).Elem()
}
func (i RepositoryRulesetMap) ToRepositoryRulesetMapOutput() RepositoryRulesetMapOutput {
return i.ToRepositoryRulesetMapOutputWithContext(context.Background())
}
func (i RepositoryRulesetMap) ToRepositoryRulesetMapOutputWithContext(ctx context.Context) RepositoryRulesetMapOutput {
return pulumi.ToOutputWithContext(ctx, i).(RepositoryRulesetMapOutput)
}
type RepositoryRulesetOutput struct{ *pulumi.OutputState }
func (RepositoryRulesetOutput) ElementType() reflect.Type {
return reflect.TypeOf((**RepositoryRuleset)(nil)).Elem()
}
func (o RepositoryRulesetOutput) ToRepositoryRulesetOutput() RepositoryRulesetOutput {
return o
}
func (o RepositoryRulesetOutput) ToRepositoryRulesetOutputWithContext(ctx context.Context) RepositoryRulesetOutput {
return o
}
// (Block List) The actors that can bypass the rules in this ruleset. (see below for nested schema)
func (o RepositoryRulesetOutput) BypassActors() RepositoryRulesetBypassActorArrayOutput {
return o.ApplyT(func(v *RepositoryRuleset) RepositoryRulesetBypassActorArrayOutput { return v.BypassActors }).(RepositoryRulesetBypassActorArrayOutput)
}
// (Block List, Max: 1) Parameters for a repository ruleset ref name condition. (see below for nested schema)
func (o RepositoryRulesetOutput) Conditions() RepositoryRulesetConditionsPtrOutput {
return o.ApplyT(func(v *RepositoryRuleset) RepositoryRulesetConditionsPtrOutput { return v.Conditions }).(RepositoryRulesetConditionsPtrOutput)
}
// (String) Possible values for Enforcement are `disabled`, `active`, `evaluate`. Note: `evaluate` is currently only supported for owners of type `organization`.
func (o RepositoryRulesetOutput) Enforcement() pulumi.StringOutput {
return o.ApplyT(func(v *RepositoryRuleset) pulumi.StringOutput { return v.Enforcement }).(pulumi.StringOutput)
}
// (String)
func (o RepositoryRulesetOutput) Etag() pulumi.StringOutput {
return o.ApplyT(func(v *RepositoryRuleset) pulumi.StringOutput { return v.Etag }).(pulumi.StringOutput)
}
// (String) The name of the ruleset.
func (o RepositoryRulesetOutput) Name() pulumi.StringOutput {
return o.ApplyT(func(v *RepositoryRuleset) pulumi.StringOutput { return v.Name }).(pulumi.StringOutput)
}
// (String) GraphQL global node id for use with v4 API.
func (o RepositoryRulesetOutput) NodeId() pulumi.StringOutput {
return o.ApplyT(func(v *RepositoryRuleset) pulumi.StringOutput { return v.NodeId }).(pulumi.StringOutput)
}
// (String) Name of the repository to apply rulset to.
func (o RepositoryRulesetOutput) Repository() pulumi.StringPtrOutput {
return o.ApplyT(func(v *RepositoryRuleset) pulumi.StringPtrOutput { return v.Repository }).(pulumi.StringPtrOutput)
}
// (Block List, Min: 1, Max: 1) Rules within the ruleset. (see below for nested schema)
func (o RepositoryRulesetOutput) Rules() RepositoryRulesetRulesOutput {
return o.ApplyT(func(v *RepositoryRuleset) RepositoryRulesetRulesOutput { return v.Rules }).(RepositoryRulesetRulesOutput)
}
// (Number) GitHub ID for the ruleset.
func (o RepositoryRulesetOutput) RulesetId() pulumi.IntOutput {
return o.ApplyT(func(v *RepositoryRuleset) pulumi.IntOutput { return v.RulesetId }).(pulumi.IntOutput)
}
// (String) Possible values are `branch` and `tag`.
func (o RepositoryRulesetOutput) Target() pulumi.StringOutput {
return o.ApplyT(func(v *RepositoryRuleset) pulumi.StringOutput { return v.Target }).(pulumi.StringOutput)
}
type RepositoryRulesetArrayOutput struct{ *pulumi.OutputState }
func (RepositoryRulesetArrayOutput) ElementType() reflect.Type {
return reflect.TypeOf((*[]*RepositoryRuleset)(nil)).Elem()
}
func (o RepositoryRulesetArrayOutput) ToRepositoryRulesetArrayOutput() RepositoryRulesetArrayOutput {
return o
}
func (o RepositoryRulesetArrayOutput) ToRepositoryRulesetArrayOutputWithContext(ctx context.Context) RepositoryRulesetArrayOutput {
return o
}
func (o RepositoryRulesetArrayOutput) Index(i pulumi.IntInput) RepositoryRulesetOutput {
return pulumi.All(o, i).ApplyT(func(vs []interface{}) *RepositoryRuleset {
return vs[0].([]*RepositoryRuleset)[vs[1].(int)]
}).(RepositoryRulesetOutput)
}
type RepositoryRulesetMapOutput struct{ *pulumi.OutputState }
func (RepositoryRulesetMapOutput) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*RepositoryRuleset)(nil)).Elem()
}
func (o RepositoryRulesetMapOutput) ToRepositoryRulesetMapOutput() RepositoryRulesetMapOutput {
return o
}
func (o RepositoryRulesetMapOutput) ToRepositoryRulesetMapOutputWithContext(ctx context.Context) RepositoryRulesetMapOutput {
return o
}
func (o RepositoryRulesetMapOutput) MapIndex(k pulumi.StringInput) RepositoryRulesetOutput {
return pulumi.All(o, k).ApplyT(func(vs []interface{}) *RepositoryRuleset {
return vs[0].(map[string]*RepositoryRuleset)[vs[1].(string)]
}).(RepositoryRulesetOutput)
}
func init() {
pulumi.RegisterInputType(reflect.TypeOf((*RepositoryRulesetInput)(nil)).Elem(), &RepositoryRuleset{})
pulumi.RegisterInputType(reflect.TypeOf((*RepositoryRulesetArrayInput)(nil)).Elem(), RepositoryRulesetArray{})
pulumi.RegisterInputType(reflect.TypeOf((*RepositoryRulesetMapInput)(nil)).Elem(), RepositoryRulesetMap{})
pulumi.RegisterOutputType(RepositoryRulesetOutput{})
pulumi.RegisterOutputType(RepositoryRulesetArrayOutput{})
pulumi.RegisterOutputType(RepositoryRulesetMapOutput{})
}