-
Notifications
You must be signed in to change notification settings - Fork 0
/
branchProtection.go
161 lines (144 loc) · 6.52 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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
// *** 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 (
"github.com/pkg/errors"
"github.com/pulumi/pulumi/sdk/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 and teams, can also be configured.
//
// > This content is derived from https://github.com/terraform-providers/terraform-provider-github/blob/master/website/docs/r/branch_protection.html.markdown.
type BranchProtection struct {
s *pulumi.ResourceState
}
// NewBranchProtection registers a new resource with the given unique name, arguments, and options.
func NewBranchProtection(ctx *pulumi.Context,
name string, args *BranchProtectionArgs, opts ...pulumi.ResourceOpt) (*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'")
}
inputs := make(map[string]interface{})
if args == nil {
inputs["branch"] = nil
inputs["enforceAdmins"] = nil
inputs["repository"] = nil
inputs["requireSignedCommits"] = nil
inputs["requiredPullRequestReviews"] = nil
inputs["requiredStatusChecks"] = nil
inputs["restrictions"] = nil
} else {
inputs["branch"] = args.Branch
inputs["enforceAdmins"] = args.EnforceAdmins
inputs["repository"] = args.Repository
inputs["requireSignedCommits"] = args.RequireSignedCommits
inputs["requiredPullRequestReviews"] = args.RequiredPullRequestReviews
inputs["requiredStatusChecks"] = args.RequiredStatusChecks
inputs["restrictions"] = args.Restrictions
}
inputs["etag"] = nil
s, err := ctx.RegisterResource("github:index/branchProtection:BranchProtection", name, true, inputs, opts...)
if err != nil {
return nil, err
}
return &BranchProtection{s: s}, 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.ID, state *BranchProtectionState, opts ...pulumi.ResourceOpt) (*BranchProtection, error) {
inputs := make(map[string]interface{})
if state != nil {
inputs["branch"] = state.Branch
inputs["enforceAdmins"] = state.EnforceAdmins
inputs["etag"] = state.Etag
inputs["repository"] = state.Repository
inputs["requireSignedCommits"] = state.RequireSignedCommits
inputs["requiredPullRequestReviews"] = state.RequiredPullRequestReviews
inputs["requiredStatusChecks"] = state.RequiredStatusChecks
inputs["restrictions"] = state.Restrictions
}
s, err := ctx.ReadResource("github:index/branchProtection:BranchProtection", name, id, inputs, opts...)
if err != nil {
return nil, err
}
return &BranchProtection{s: s}, nil
}
// URN is this resource's unique name assigned by Pulumi.
func (r *BranchProtection) URN() *pulumi.URNOutput {
return r.s.URN()
}
// ID is this resource's unique identifier assigned by its provider.
func (r *BranchProtection) ID() *pulumi.IDOutput {
return r.s.ID()
}
// The Git branch to protect.
func (r *BranchProtection) Branch() *pulumi.StringOutput {
return (*pulumi.StringOutput)(r.s.State["branch"])
}
// Boolean, setting this to `true` enforces status checks for repository administrators.
func (r *BranchProtection) EnforceAdmins() *pulumi.BoolOutput {
return (*pulumi.BoolOutput)(r.s.State["enforceAdmins"])
}
func (r *BranchProtection) Etag() *pulumi.StringOutput {
return (*pulumi.StringOutput)(r.s.State["etag"])
}
// The GitHub repository name.
func (r *BranchProtection) Repository() *pulumi.StringOutput {
return (*pulumi.StringOutput)(r.s.State["repository"])
}
// Boolean, setting this to `true` requires all commits to be signed with GPG.
func (r *BranchProtection) RequireSignedCommits() *pulumi.BoolOutput {
return (*pulumi.BoolOutput)(r.s.State["requireSignedCommits"])
}
// Enforce restrictions for pull request reviews. See Required Pull Request Reviews below for details.
func (r *BranchProtection) RequiredPullRequestReviews() *pulumi.Output {
return r.s.State["requiredPullRequestReviews"]
}
// Enforce restrictions for required status checks. See Required Status Checks below for details.
func (r *BranchProtection) RequiredStatusChecks() *pulumi.Output {
return r.s.State["requiredStatusChecks"]
}
// Enforce restrictions for the users and teams that may push to the branch. See Restrictions below for details.
func (r *BranchProtection) Restrictions() *pulumi.Output {
return r.s.State["restrictions"]
}
// Input properties used for looking up and filtering BranchProtection resources.
type BranchProtectionState struct {
// The Git branch to protect.
Branch interface{}
// Boolean, setting this to `true` enforces status checks for repository administrators.
EnforceAdmins interface{}
Etag interface{}
// The GitHub repository name.
Repository interface{}
// Boolean, setting this to `true` requires all commits to be signed with GPG.
RequireSignedCommits interface{}
// Enforce restrictions for pull request reviews. See Required Pull Request Reviews below for details.
RequiredPullRequestReviews interface{}
// Enforce restrictions for required status checks. See Required Status Checks below for details.
RequiredStatusChecks interface{}
// Enforce restrictions for the users and teams that may push to the branch. See Restrictions below for details.
Restrictions interface{}
}
// The set of arguments for constructing a BranchProtection resource.
type BranchProtectionArgs struct {
// The Git branch to protect.
Branch interface{}
// Boolean, setting this to `true` enforces status checks for repository administrators.
EnforceAdmins interface{}
// The GitHub repository name.
Repository interface{}
// Boolean, setting this to `true` requires all commits to be signed with GPG.
RequireSignedCommits interface{}
// Enforce restrictions for pull request reviews. See Required Pull Request Reviews below for details.
RequiredPullRequestReviews interface{}
// Enforce restrictions for required status checks. See Required Status Checks below for details.
RequiredStatusChecks interface{}
// Enforce restrictions for the users and teams that may push to the branch. See Restrictions below for details.
Restrictions interface{}
}