branchprotection

package
v1.0.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 25, 2021 License: Apache-2.0 Imports: 2 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Branch

type Branch struct {
	Policy
}

Branch holds protection policy overrides for a particular branch.

type Config

type Config struct {
	Policy
	// ProtectTested determines if branch protection rules are set for all repos
	// that Prow has registered jobs for, regardless of if those repos are in the
	// branch protection config.
	ProtectTested bool `json:"protect-tested-repos,omitempty"`
	// Orgs holds branch protection options for orgs by name
	Orgs map[string]Org `json:"orgs,omitempty"`
	// AllowDisabledPolicies allows a child to disable all protection even if the
	// branch has inherited protection options from a parent.
	AllowDisabledPolicies bool `json:"allow_disabled_policies,omitempty"`
	// AllowDisabledJobPolicies allows a branch to choose to opt out of branch protection
	// even if Prow has registered required jobs for that branch.
	AllowDisabledJobPolicies bool `json:"allow_disabled_job_policies,omitempty"`
}

Config specifies the global branch protection policy

func (Config) GetOrg

func (bp Config) GetOrg(name string) *Org

GetOrg returns the org config after merging in any global policies.

type ContextPolicy

type ContextPolicy struct {
	// Contexts appends required contexts that must be green to merge
	Contexts []string `json:"contexts,omitempty"`
	// Strict overrides whether new commits in the base branch require updating the PR if set
	Strict *bool `json:"strict,omitempty"`
}

ContextPolicy configures required github contexts. When merging policies, contexts are appended to context list from parent. Strict determines whether merging to the branch invalidates existing contexts.

type Org

type Org struct {
	Policy
	Repos map[string]Repo `json:"repos,omitempty"`
}

Org holds the default protection policy for an entire org, as well as any repo overrides.

func (Org) GetRepo

func (o Org) GetRepo(name string) *Repo

GetRepo returns the repo config after merging in any org policies.

type Policy

type Policy struct {
	// Protect overrides whether branch protection is enabled if set.
	Protect *bool `json:"protect,omitempty"`
	// RequiredStatusChecks configures github contexts
	RequiredStatusChecks *ContextPolicy `json:"required_status_checks,omitempty"`
	// Admins overrides whether protections apply to admins if set.
	Admins *bool `json:"enforce_admins,omitempty"`
	// Restrictions limits who can merge
	Restrictions *Restrictions `json:"restrictions,omitempty"`
	// RequiredPullRequestReviews specifies github approval/review criteria.
	RequiredPullRequestReviews *ReviewPolicy `json:"required_pull_request_reviews,omitempty"`
	// Exclude specifies a set of regular expressions which identify branches
	// that should be excluded from the protection policy
	Exclude []string `json:"exclude,omitempty"`
}

Policy for the config/org/repo/branch. When merging policies, a nil value results in inheriting the parent policy.

func (Policy) Apply

func (p Policy) Apply(child Policy) Policy

Apply returns a policy that merges the child into the parent

func (Policy) IsDefined

func (p Policy) IsDefined() bool

IsDefined returns true if at least one of its fields is defined (not nil)

type Repo

type Repo struct {
	Policy
	Branches map[string]Branch `json:"branches,omitempty"`
}

Repo holds protection policy overrides for all branches in a repo, as well as specific branch overrides.

func (Repo) GetBranch

func (r Repo) GetBranch(name string) (*Branch, error)

GetBranch returns the branch config after merging in any repo policies.

type Restrictions

type Restrictions struct {
	Users []string `json:"users"`
	Teams []string `json:"teams"`
}

Restrictions limits who can merge Users and Teams items are appended to parent lists.

type ReviewPolicy

type ReviewPolicy struct {
	// Restrictions appends users/teams that are allowed to merge
	DismissalRestrictions *Restrictions `json:"dismissal_restrictions,omitempty"`
	// DismissStale overrides whether new commits automatically dismiss old reviews if set
	DismissStale *bool `json:"dismiss_stale_reviews,omitempty"`
	// RequireOwners overrides whether CODEOWNERS must approve PRs if set
	RequireOwners *bool `json:"require_code_owner_reviews,omitempty"`
	// Approvals overrides the number of approvals required if set (set to 0 to disable)
	Approvals *int `json:"required_approving_review_count,omitempty"`
}

ReviewPolicy specifies github approval/review criteria. Any nil values inherit the policy from the parent, otherwise bool/ints are overridden. Non-empty lists are appended to parent lists.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL