-
Notifications
You must be signed in to change notification settings - Fork 9
/
branchProtection.go
146 lines (133 loc) · 7.33 KB
/
branchProtection.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
// *** 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 github
import (
"reflect"
"github.com/pkg/errors"
"github.com/pulumi/pulumi/sdk/v2/go/pulumi"
)
// Protects a GitHub branch.
//
// This resource allows you to configure branch protection for repositories in your organization. When applied, the branch will be protected from forced pushes and deletion. Additional constraints, such as required status checks or restrictions on users, teams, and apps, can also be configured.
type BranchProtection struct {
pulumi.CustomResourceState
// The Git branch to protect.
Branch pulumi.StringOutput `pulumi:"branch"`
// Boolean, setting this to `true` enforces status checks for repository administrators.
EnforceAdmins pulumi.BoolPtrOutput `pulumi:"enforceAdmins"`
Etag pulumi.StringOutput `pulumi:"etag"`
// The GitHub repository name.
Repository pulumi.StringOutput `pulumi:"repository"`
// Boolean, setting this to `true` requires all commits to be signed with GPG.
RequireSignedCommits pulumi.BoolPtrOutput `pulumi:"requireSignedCommits"`
// Enforce restrictions for pull request reviews. See Required Pull Request Reviews below for details.
RequiredPullRequestReviews BranchProtectionRequiredPullRequestReviewsPtrOutput `pulumi:"requiredPullRequestReviews"`
// Enforce restrictions for required status checks. See Required Status Checks below for details.
RequiredStatusChecks BranchProtectionRequiredStatusChecksPtrOutput `pulumi:"requiredStatusChecks"`
// Enforce restrictions for the users and teams that may push to the branch. See Restrictions below for details.
Restrictions BranchProtectionRestrictionsPtrOutput `pulumi:"restrictions"`
}
// NewBranchProtection registers a new resource with the given unique name, arguments, and options.
func NewBranchProtection(ctx *pulumi.Context,
name string, args *BranchProtectionArgs, opts ...pulumi.ResourceOption) (*BranchProtection, error) {
if args == nil || args.Branch == nil {
return nil, errors.New("missing required argument 'Branch'")
}
if args == nil || args.Repository == nil {
return nil, errors.New("missing required argument 'Repository'")
}
if args == nil {
args = &BranchProtectionArgs{}
}
var resource BranchProtection
err := ctx.RegisterResource("github:index/branchProtection:BranchProtection", name, args, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// GetBranchProtection gets an existing BranchProtection 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 GetBranchProtection(ctx *pulumi.Context,
name string, id pulumi.IDInput, state *BranchProtectionState, opts ...pulumi.ResourceOption) (*BranchProtection, error) {
var resource BranchProtection
err := ctx.ReadResource("github:index/branchProtection:BranchProtection", name, id, state, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// Input properties used for looking up and filtering BranchProtection resources.
type branchProtectionState struct {
// The Git branch to protect.
Branch *string `pulumi:"branch"`
// Boolean, setting this to `true` enforces status checks for repository administrators.
EnforceAdmins *bool `pulumi:"enforceAdmins"`
Etag *string `pulumi:"etag"`
// The GitHub repository name.
Repository *string `pulumi:"repository"`
// Boolean, setting this to `true` requires all commits to be signed with GPG.
RequireSignedCommits *bool `pulumi:"requireSignedCommits"`
// Enforce restrictions for pull request reviews. See Required Pull Request Reviews below for details.
RequiredPullRequestReviews *BranchProtectionRequiredPullRequestReviews `pulumi:"requiredPullRequestReviews"`
// Enforce restrictions for required status checks. See Required Status Checks below for details.
RequiredStatusChecks *BranchProtectionRequiredStatusChecks `pulumi:"requiredStatusChecks"`
// Enforce restrictions for the users and teams that may push to the branch. See Restrictions below for details.
Restrictions *BranchProtectionRestrictions `pulumi:"restrictions"`
}
type BranchProtectionState struct {
// The Git branch to protect.
Branch pulumi.StringPtrInput
// Boolean, setting this to `true` enforces status checks for repository administrators.
EnforceAdmins pulumi.BoolPtrInput
Etag pulumi.StringPtrInput
// The GitHub repository name.
Repository pulumi.StringPtrInput
// Boolean, setting this to `true` requires all commits to be signed with GPG.
RequireSignedCommits pulumi.BoolPtrInput
// Enforce restrictions for pull request reviews. See Required Pull Request Reviews below for details.
RequiredPullRequestReviews BranchProtectionRequiredPullRequestReviewsPtrInput
// Enforce restrictions for required status checks. See Required Status Checks below for details.
RequiredStatusChecks BranchProtectionRequiredStatusChecksPtrInput
// Enforce restrictions for the users and teams that may push to the branch. See Restrictions below for details.
Restrictions BranchProtectionRestrictionsPtrInput
}
func (BranchProtectionState) ElementType() reflect.Type {
return reflect.TypeOf((*branchProtectionState)(nil)).Elem()
}
type branchProtectionArgs struct {
// The Git branch to protect.
Branch string `pulumi:"branch"`
// Boolean, setting this to `true` enforces status checks for repository administrators.
EnforceAdmins *bool `pulumi:"enforceAdmins"`
// The GitHub repository name.
Repository string `pulumi:"repository"`
// Boolean, setting this to `true` requires all commits to be signed with GPG.
RequireSignedCommits *bool `pulumi:"requireSignedCommits"`
// Enforce restrictions for pull request reviews. See Required Pull Request Reviews below for details.
RequiredPullRequestReviews *BranchProtectionRequiredPullRequestReviews `pulumi:"requiredPullRequestReviews"`
// Enforce restrictions for required status checks. See Required Status Checks below for details.
RequiredStatusChecks *BranchProtectionRequiredStatusChecks `pulumi:"requiredStatusChecks"`
// Enforce restrictions for the users and teams that may push to the branch. See Restrictions below for details.
Restrictions *BranchProtectionRestrictions `pulumi:"restrictions"`
}
// The set of arguments for constructing a BranchProtection resource.
type BranchProtectionArgs struct {
// The Git branch to protect.
Branch pulumi.StringInput
// Boolean, setting this to `true` enforces status checks for repository administrators.
EnforceAdmins pulumi.BoolPtrInput
// The GitHub repository name.
Repository pulumi.StringInput
// Boolean, setting this to `true` requires all commits to be signed with GPG.
RequireSignedCommits pulumi.BoolPtrInput
// Enforce restrictions for pull request reviews. See Required Pull Request Reviews below for details.
RequiredPullRequestReviews BranchProtectionRequiredPullRequestReviewsPtrInput
// Enforce restrictions for required status checks. See Required Status Checks below for details.
RequiredStatusChecks BranchProtectionRequiredStatusChecksPtrInput
// Enforce restrictions for the users and teams that may push to the branch. See Restrictions below for details.
Restrictions BranchProtectionRestrictionsPtrInput
}
func (BranchProtectionArgs) ElementType() reflect.Type {
return reflect.TypeOf((*branchProtectionArgs)(nil)).Elem()
}