/
projectLevelMrApprovals.go
350 lines (298 loc) · 16 KB
/
projectLevelMrApprovals.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
// 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 gitlab
import (
"context"
"reflect"
"errors"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
// The `gitlabProjectLevelMrApprovalRule` resource allows to manage the lifecycle of a Merge Request-level approval rule.
//
// > This resource requires a GitLab Enterprise instance.
//
// **Upstream API**: [GitLab REST API docs](https://docs.gitlab.com/ee/api/merge_request_approvals.html#merge-request-level-mr-approvals)
//
// ## Example Usage
//
// ```go
// package main
//
// import (
//
// "github.com/pulumi/pulumi-gitlab/sdk/v4/go/gitlab"
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
//
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// fooProject, err := gitlab.NewProject(ctx, "fooProject", &gitlab.ProjectArgs{
// Description: pulumi.String("My example project"),
// })
// if err != nil {
// return err
// }
// _, err = gitlab.NewProjectLevelMrApprovals(ctx, "fooProjectLevelMrApprovals", &gitlab.ProjectLevelMrApprovalsArgs{
// ProjectId: fooProject.ID(),
// ResetApprovalsOnPush: pulumi.Bool(true),
// DisableOverridingApproversPerMergeRequest: pulumi.Bool(false),
// MergeRequestsAuthorApproval: pulumi.Bool(false),
// MergeRequestsDisableCommittersApproval: pulumi.Bool(true),
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
//
// ```
//
// ## Import
//
// ```sh
//
// $ pulumi import gitlab:index/projectLevelMrApprovals:ProjectLevelMrApprovals You can import an approval configuration state using `<resource> <project_id>`.
//
// ```
//
// # For example
//
// ```sh
//
// $ pulumi import gitlab:index/projectLevelMrApprovals:ProjectLevelMrApprovals foo 1234
//
// ```
type ProjectLevelMrApprovals struct {
pulumi.CustomResourceState
// By default, users are able to edit the approval rules in merge requests. If set to true,
DisableOverridingApproversPerMergeRequest pulumi.BoolPtrOutput `pulumi:"disableOverridingApproversPerMergeRequest"`
// Set to `true` if you want to allow merge request authors to self-approve merge requests. Authors
MergeRequestsAuthorApproval pulumi.BoolPtrOutput `pulumi:"mergeRequestsAuthorApproval"`
// Set to `true` if you want to prevent approval of merge requests by merge request committers.
MergeRequestsDisableCommittersApproval pulumi.BoolPtrOutput `pulumi:"mergeRequestsDisableCommittersApproval"`
// The ID of the project to change MR approval configuration.
ProjectId pulumi.IntOutput `pulumi:"projectId"`
// Set to `true` if you want to require authentication when approving a merge request.
RequirePasswordToApprove pulumi.BoolPtrOutput `pulumi:"requirePasswordToApprove"`
// Set to `true` if you want to remove all approvals in a merge request when new commits are pushed to its source branch. Default is `true`.
ResetApprovalsOnPush pulumi.BoolPtrOutput `pulumi:"resetApprovalsOnPush"`
}
// NewProjectLevelMrApprovals registers a new resource with the given unique name, arguments, and options.
func NewProjectLevelMrApprovals(ctx *pulumi.Context,
name string, args *ProjectLevelMrApprovalsArgs, opts ...pulumi.ResourceOption) (*ProjectLevelMrApprovals, error) {
if args == nil {
return nil, errors.New("missing one or more required arguments")
}
if args.ProjectId == nil {
return nil, errors.New("invalid value for required argument 'ProjectId'")
}
var resource ProjectLevelMrApprovals
err := ctx.RegisterResource("gitlab:index/projectLevelMrApprovals:ProjectLevelMrApprovals", name, args, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// GetProjectLevelMrApprovals gets an existing ProjectLevelMrApprovals 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 GetProjectLevelMrApprovals(ctx *pulumi.Context,
name string, id pulumi.IDInput, state *ProjectLevelMrApprovalsState, opts ...pulumi.ResourceOption) (*ProjectLevelMrApprovals, error) {
var resource ProjectLevelMrApprovals
err := ctx.ReadResource("gitlab:index/projectLevelMrApprovals:ProjectLevelMrApprovals", name, id, state, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// Input properties used for looking up and filtering ProjectLevelMrApprovals resources.
type projectLevelMrApprovalsState struct {
// By default, users are able to edit the approval rules in merge requests. If set to true,
DisableOverridingApproversPerMergeRequest *bool `pulumi:"disableOverridingApproversPerMergeRequest"`
// Set to `true` if you want to allow merge request authors to self-approve merge requests. Authors
MergeRequestsAuthorApproval *bool `pulumi:"mergeRequestsAuthorApproval"`
// Set to `true` if you want to prevent approval of merge requests by merge request committers.
MergeRequestsDisableCommittersApproval *bool `pulumi:"mergeRequestsDisableCommittersApproval"`
// The ID of the project to change MR approval configuration.
ProjectId *int `pulumi:"projectId"`
// Set to `true` if you want to require authentication when approving a merge request.
RequirePasswordToApprove *bool `pulumi:"requirePasswordToApprove"`
// Set to `true` if you want to remove all approvals in a merge request when new commits are pushed to its source branch. Default is `true`.
ResetApprovalsOnPush *bool `pulumi:"resetApprovalsOnPush"`
}
type ProjectLevelMrApprovalsState struct {
// By default, users are able to edit the approval rules in merge requests. If set to true,
DisableOverridingApproversPerMergeRequest pulumi.BoolPtrInput
// Set to `true` if you want to allow merge request authors to self-approve merge requests. Authors
MergeRequestsAuthorApproval pulumi.BoolPtrInput
// Set to `true` if you want to prevent approval of merge requests by merge request committers.
MergeRequestsDisableCommittersApproval pulumi.BoolPtrInput
// The ID of the project to change MR approval configuration.
ProjectId pulumi.IntPtrInput
// Set to `true` if you want to require authentication when approving a merge request.
RequirePasswordToApprove pulumi.BoolPtrInput
// Set to `true` if you want to remove all approvals in a merge request when new commits are pushed to its source branch. Default is `true`.
ResetApprovalsOnPush pulumi.BoolPtrInput
}
func (ProjectLevelMrApprovalsState) ElementType() reflect.Type {
return reflect.TypeOf((*projectLevelMrApprovalsState)(nil)).Elem()
}
type projectLevelMrApprovalsArgs struct {
// By default, users are able to edit the approval rules in merge requests. If set to true,
DisableOverridingApproversPerMergeRequest *bool `pulumi:"disableOverridingApproversPerMergeRequest"`
// Set to `true` if you want to allow merge request authors to self-approve merge requests. Authors
MergeRequestsAuthorApproval *bool `pulumi:"mergeRequestsAuthorApproval"`
// Set to `true` if you want to prevent approval of merge requests by merge request committers.
MergeRequestsDisableCommittersApproval *bool `pulumi:"mergeRequestsDisableCommittersApproval"`
// The ID of the project to change MR approval configuration.
ProjectId int `pulumi:"projectId"`
// Set to `true` if you want to require authentication when approving a merge request.
RequirePasswordToApprove *bool `pulumi:"requirePasswordToApprove"`
// Set to `true` if you want to remove all approvals in a merge request when new commits are pushed to its source branch. Default is `true`.
ResetApprovalsOnPush *bool `pulumi:"resetApprovalsOnPush"`
}
// The set of arguments for constructing a ProjectLevelMrApprovals resource.
type ProjectLevelMrApprovalsArgs struct {
// By default, users are able to edit the approval rules in merge requests. If set to true,
DisableOverridingApproversPerMergeRequest pulumi.BoolPtrInput
// Set to `true` if you want to allow merge request authors to self-approve merge requests. Authors
MergeRequestsAuthorApproval pulumi.BoolPtrInput
// Set to `true` if you want to prevent approval of merge requests by merge request committers.
MergeRequestsDisableCommittersApproval pulumi.BoolPtrInput
// The ID of the project to change MR approval configuration.
ProjectId pulumi.IntInput
// Set to `true` if you want to require authentication when approving a merge request.
RequirePasswordToApprove pulumi.BoolPtrInput
// Set to `true` if you want to remove all approvals in a merge request when new commits are pushed to its source branch. Default is `true`.
ResetApprovalsOnPush pulumi.BoolPtrInput
}
func (ProjectLevelMrApprovalsArgs) ElementType() reflect.Type {
return reflect.TypeOf((*projectLevelMrApprovalsArgs)(nil)).Elem()
}
type ProjectLevelMrApprovalsInput interface {
pulumi.Input
ToProjectLevelMrApprovalsOutput() ProjectLevelMrApprovalsOutput
ToProjectLevelMrApprovalsOutputWithContext(ctx context.Context) ProjectLevelMrApprovalsOutput
}
func (*ProjectLevelMrApprovals) ElementType() reflect.Type {
return reflect.TypeOf((**ProjectLevelMrApprovals)(nil)).Elem()
}
func (i *ProjectLevelMrApprovals) ToProjectLevelMrApprovalsOutput() ProjectLevelMrApprovalsOutput {
return i.ToProjectLevelMrApprovalsOutputWithContext(context.Background())
}
func (i *ProjectLevelMrApprovals) ToProjectLevelMrApprovalsOutputWithContext(ctx context.Context) ProjectLevelMrApprovalsOutput {
return pulumi.ToOutputWithContext(ctx, i).(ProjectLevelMrApprovalsOutput)
}
// ProjectLevelMrApprovalsArrayInput is an input type that accepts ProjectLevelMrApprovalsArray and ProjectLevelMrApprovalsArrayOutput values.
// You can construct a concrete instance of `ProjectLevelMrApprovalsArrayInput` via:
//
// ProjectLevelMrApprovalsArray{ ProjectLevelMrApprovalsArgs{...} }
type ProjectLevelMrApprovalsArrayInput interface {
pulumi.Input
ToProjectLevelMrApprovalsArrayOutput() ProjectLevelMrApprovalsArrayOutput
ToProjectLevelMrApprovalsArrayOutputWithContext(context.Context) ProjectLevelMrApprovalsArrayOutput
}
type ProjectLevelMrApprovalsArray []ProjectLevelMrApprovalsInput
func (ProjectLevelMrApprovalsArray) ElementType() reflect.Type {
return reflect.TypeOf((*[]*ProjectLevelMrApprovals)(nil)).Elem()
}
func (i ProjectLevelMrApprovalsArray) ToProjectLevelMrApprovalsArrayOutput() ProjectLevelMrApprovalsArrayOutput {
return i.ToProjectLevelMrApprovalsArrayOutputWithContext(context.Background())
}
func (i ProjectLevelMrApprovalsArray) ToProjectLevelMrApprovalsArrayOutputWithContext(ctx context.Context) ProjectLevelMrApprovalsArrayOutput {
return pulumi.ToOutputWithContext(ctx, i).(ProjectLevelMrApprovalsArrayOutput)
}
// ProjectLevelMrApprovalsMapInput is an input type that accepts ProjectLevelMrApprovalsMap and ProjectLevelMrApprovalsMapOutput values.
// You can construct a concrete instance of `ProjectLevelMrApprovalsMapInput` via:
//
// ProjectLevelMrApprovalsMap{ "key": ProjectLevelMrApprovalsArgs{...} }
type ProjectLevelMrApprovalsMapInput interface {
pulumi.Input
ToProjectLevelMrApprovalsMapOutput() ProjectLevelMrApprovalsMapOutput
ToProjectLevelMrApprovalsMapOutputWithContext(context.Context) ProjectLevelMrApprovalsMapOutput
}
type ProjectLevelMrApprovalsMap map[string]ProjectLevelMrApprovalsInput
func (ProjectLevelMrApprovalsMap) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*ProjectLevelMrApprovals)(nil)).Elem()
}
func (i ProjectLevelMrApprovalsMap) ToProjectLevelMrApprovalsMapOutput() ProjectLevelMrApprovalsMapOutput {
return i.ToProjectLevelMrApprovalsMapOutputWithContext(context.Background())
}
func (i ProjectLevelMrApprovalsMap) ToProjectLevelMrApprovalsMapOutputWithContext(ctx context.Context) ProjectLevelMrApprovalsMapOutput {
return pulumi.ToOutputWithContext(ctx, i).(ProjectLevelMrApprovalsMapOutput)
}
type ProjectLevelMrApprovalsOutput struct{ *pulumi.OutputState }
func (ProjectLevelMrApprovalsOutput) ElementType() reflect.Type {
return reflect.TypeOf((**ProjectLevelMrApprovals)(nil)).Elem()
}
func (o ProjectLevelMrApprovalsOutput) ToProjectLevelMrApprovalsOutput() ProjectLevelMrApprovalsOutput {
return o
}
func (o ProjectLevelMrApprovalsOutput) ToProjectLevelMrApprovalsOutputWithContext(ctx context.Context) ProjectLevelMrApprovalsOutput {
return o
}
// By default, users are able to edit the approval rules in merge requests. If set to true,
func (o ProjectLevelMrApprovalsOutput) DisableOverridingApproversPerMergeRequest() pulumi.BoolPtrOutput {
return o.ApplyT(func(v *ProjectLevelMrApprovals) pulumi.BoolPtrOutput {
return v.DisableOverridingApproversPerMergeRequest
}).(pulumi.BoolPtrOutput)
}
// Set to `true` if you want to allow merge request authors to self-approve merge requests. Authors
func (o ProjectLevelMrApprovalsOutput) MergeRequestsAuthorApproval() pulumi.BoolPtrOutput {
return o.ApplyT(func(v *ProjectLevelMrApprovals) pulumi.BoolPtrOutput { return v.MergeRequestsAuthorApproval }).(pulumi.BoolPtrOutput)
}
// Set to `true` if you want to prevent approval of merge requests by merge request committers.
func (o ProjectLevelMrApprovalsOutput) MergeRequestsDisableCommittersApproval() pulumi.BoolPtrOutput {
return o.ApplyT(func(v *ProjectLevelMrApprovals) pulumi.BoolPtrOutput { return v.MergeRequestsDisableCommittersApproval }).(pulumi.BoolPtrOutput)
}
// The ID of the project to change MR approval configuration.
func (o ProjectLevelMrApprovalsOutput) ProjectId() pulumi.IntOutput {
return o.ApplyT(func(v *ProjectLevelMrApprovals) pulumi.IntOutput { return v.ProjectId }).(pulumi.IntOutput)
}
// Set to `true` if you want to require authentication when approving a merge request.
func (o ProjectLevelMrApprovalsOutput) RequirePasswordToApprove() pulumi.BoolPtrOutput {
return o.ApplyT(func(v *ProjectLevelMrApprovals) pulumi.BoolPtrOutput { return v.RequirePasswordToApprove }).(pulumi.BoolPtrOutput)
}
// Set to `true` if you want to remove all approvals in a merge request when new commits are pushed to its source branch. Default is `true`.
func (o ProjectLevelMrApprovalsOutput) ResetApprovalsOnPush() pulumi.BoolPtrOutput {
return o.ApplyT(func(v *ProjectLevelMrApprovals) pulumi.BoolPtrOutput { return v.ResetApprovalsOnPush }).(pulumi.BoolPtrOutput)
}
type ProjectLevelMrApprovalsArrayOutput struct{ *pulumi.OutputState }
func (ProjectLevelMrApprovalsArrayOutput) ElementType() reflect.Type {
return reflect.TypeOf((*[]*ProjectLevelMrApprovals)(nil)).Elem()
}
func (o ProjectLevelMrApprovalsArrayOutput) ToProjectLevelMrApprovalsArrayOutput() ProjectLevelMrApprovalsArrayOutput {
return o
}
func (o ProjectLevelMrApprovalsArrayOutput) ToProjectLevelMrApprovalsArrayOutputWithContext(ctx context.Context) ProjectLevelMrApprovalsArrayOutput {
return o
}
func (o ProjectLevelMrApprovalsArrayOutput) Index(i pulumi.IntInput) ProjectLevelMrApprovalsOutput {
return pulumi.All(o, i).ApplyT(func(vs []interface{}) *ProjectLevelMrApprovals {
return vs[0].([]*ProjectLevelMrApprovals)[vs[1].(int)]
}).(ProjectLevelMrApprovalsOutput)
}
type ProjectLevelMrApprovalsMapOutput struct{ *pulumi.OutputState }
func (ProjectLevelMrApprovalsMapOutput) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*ProjectLevelMrApprovals)(nil)).Elem()
}
func (o ProjectLevelMrApprovalsMapOutput) ToProjectLevelMrApprovalsMapOutput() ProjectLevelMrApprovalsMapOutput {
return o
}
func (o ProjectLevelMrApprovalsMapOutput) ToProjectLevelMrApprovalsMapOutputWithContext(ctx context.Context) ProjectLevelMrApprovalsMapOutput {
return o
}
func (o ProjectLevelMrApprovalsMapOutput) MapIndex(k pulumi.StringInput) ProjectLevelMrApprovalsOutput {
return pulumi.All(o, k).ApplyT(func(vs []interface{}) *ProjectLevelMrApprovals {
return vs[0].(map[string]*ProjectLevelMrApprovals)[vs[1].(string)]
}).(ProjectLevelMrApprovalsOutput)
}
func init() {
pulumi.RegisterInputType(reflect.TypeOf((*ProjectLevelMrApprovalsInput)(nil)).Elem(), &ProjectLevelMrApprovals{})
pulumi.RegisterInputType(reflect.TypeOf((*ProjectLevelMrApprovalsArrayInput)(nil)).Elem(), ProjectLevelMrApprovalsArray{})
pulumi.RegisterInputType(reflect.TypeOf((*ProjectLevelMrApprovalsMapInput)(nil)).Elem(), ProjectLevelMrApprovalsMap{})
pulumi.RegisterOutputType(ProjectLevelMrApprovalsOutput{})
pulumi.RegisterOutputType(ProjectLevelMrApprovalsArrayOutput{})
pulumi.RegisterOutputType(ProjectLevelMrApprovalsMapOutput{})
}