model

package
v0.0.0-...-4cbfb34 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2022 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Overview

SPDX-Copyright: Copyright (c) Capital One Services, LLC SPDX-License-Identifier: Apache-2.0 Copyright 2017 Capital One Services, LLC

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

SPDX-Copyright: Copyright (c) Capital One Services, LLC SPDX-License-Identifier: Apache-2.0 Copyright 2017 Capital One Services, LLC

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

SPDX-Copyright: Copyright (c) Capital One Services, LLC SPDX-License-Identifier: Apache-2.0 Copyright 2017 Capital One Services, LLC

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

SPDX-Copyright: Copyright (c) Capital One Services, LLC SPDX-License-Identifier: Apache-2.0 Copyright 2017 Capital One Services, LLC

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

SPDX-Copyright: Copyright (c) Capital One Services, LLC SPDX-License-Identifier: Apache-2.0 Copyright 2017 Capital One Services, LLC

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

SPDX-Copyright: Copyright (c) Capital One Services, LLC SPDX-License-Identifier: Apache-2.0 Copyright 2017 Capital One Services, LLC

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

SPDX-Copyright: Copyright (c) Brad Rydzewski, project contributors, Capital One Services, LLC SPDX-License-Identifier: Apache-2.0 Copyright 2017 Brad Rydzewski, project contributors, Capital One Services, LLC

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

SPDX-Copyright: Copyright (c) Capital One Services, LLC SPDX-License-Identifier: Apache-2.0 Copyright 2017 Capital One Services, LLC

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

SPDX-Copyright: Copyright (c) Capital One Services, LLC SPDX-License-Identifier: Apache-2.0 Copyright 2017 Capital One Services, LLC

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

SPDX-Copyright: Copyright (c) Capital One Services, LLC SPDX-License-Identifier: Apache-2.0 Copyright 2017 Capital One Services, LLC

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Code generated by "enumer -type=CommitRange"; DO NOT EDIT

SPDX-Copyright: Copyright (c) Capital One Services, LLC SPDX-License-Identifier: Apache-2.0 Copyright 2017 Capital One Services, LLC

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

SPDX-Copyright: Copyright (c) Capital One Services, LLC SPDX-License-Identifier: Apache-2.0 Copyright 2017 Capital One Services, LLC

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

SPDX-Copyright: Copyright (c) Brad Rydzewski, project contributors, Capital One Services, LLC SPDX-License-Identifier: Apache-2.0 Copyright 2017 Brad Rydzewski, project contributors, Capital One Services, LLC

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

SPDX-Copyright: Copyright (c) Capital One Services, LLC SPDX-License-Identifier: Apache-2.0 Copyright 2017 Capital One Services, LLC

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

SPDX-Copyright: Copyright (c) Capital One Services, LLC SPDX-License-Identifier: Apache-2.0 Copyright 2017 Capital One Services, LLC

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Code generated by "enumer -type=FeedbackType"; DO NOT EDIT

SPDX-Copyright: Copyright (c) Capital One Services, LLC SPDX-License-Identifier: Apache-2.0 Copyright 2017 Capital One Services, LLC

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

SPDX-Copyright: Copyright (c) Brad Rydzewski, project contributors, Capital One Services, LLC SPDX-License-Identifier: Apache-2.0 Copyright 2017 Brad Rydzewski, project contributors, Capital One Services, LLC

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

SPDX-Copyright: Copyright (c) Brad Rydzewski, project contributors, Capital One Services, LLC SPDX-License-Identifier: Apache-2.0 Copyright 2017 Brad Rydzewski, project contributors, Capital One Services, LLC

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

SPDX-Copyright: Copyright (c) Capital One Services, LLC SPDX-License-Identifier: Apache-2.0 Copyright 2017 Capital One Services, LLC

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

SPDX-Copyright: Copyright (c) Capital One Services, LLC SPDX-License-Identifier: Apache-2.0 Copyright 2017 Capital One Services, LLC

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

SPDX-Copyright: Copyright (c) Capital One Services, LLC SPDX-License-Identifier: Apache-2.0 Copyright 2017 Capital One Services, LLC

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

SPDX-Copyright: Copyright (c) Capital One Services, LLC SPDX-License-Identifier: Apache-2.0 Copyright 2017 Capital One Services, LLC

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

SPDX-Copyright: Copyright (c) Brad Rydzewski, project contributors, Capital One Services, LLC SPDX-License-Identifier: Apache-2.0 Copyright 2017 Brad Rydzewski, project contributors, Capital One Services, LLC

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

SPDX-Copyright: Copyright (c) Capital One Services, LLC SPDX-License-Identifier: Apache-2.0 Copyright 2017 Capital One Services, LLC

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

SPDX-Copyright: Copyright (c) Capital One Services, LLC SPDX-License-Identifier: Apache-2.0 Copyright 2017 Capital One Services, LLC

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

SPDX-Copyright: Copyright (c) Capital One Services, LLC SPDX-License-Identifier: Apache-2.0 Copyright 2017 Capital One Services, LLC

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Code generated by "enumer -type=Semver"; DO NOT EDIT

SPDX-Copyright: Copyright (c) Capital One Services, LLC SPDX-License-Identifier: Apache-2.0 Copyright 2017 Capital One Services, LLC

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

SPDX-Copyright: Copyright (c) Capital One Services, LLC SPDX-License-Identifier: Apache-2.0 Copyright 2017 Capital One Services, LLC

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

SPDX-Copyright: Copyright (c) Capital One Services, LLC SPDX-License-Identifier: Apache-2.0 Copyright 2017 Capital One Services, LLC

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

SPDX-Copyright: Copyright (c) Brad Rydzewski, project contributors, Capital One Services, LLC SPDX-License-Identifier: Apache-2.0 Copyright 2017 Brad Rydzewski, project contributors, Capital One Services, LLC

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

View Source
var AuditName = fmt.Sprintf("audit/%s", envvars.Env.Branding.Name)

AuditName is the prefix of the audit context posted to remote

View Source
var CommentPrefix = fmt.Sprintf("Message from %s --", envvars.Env.Branding.ShortName)
View Source
var MaintTypes = set.New("text", "hjson", "toml", "legacy")
View Source
var ServiceName = fmt.Sprintf("approvals/%s", envvars.Env.Branding.Name)

ServiceName is the status context posted to remote

Functions

func Approve

func Approve(request *ApprovalRequest, policy *ApprovalPolicy, p Processor) (bool, error)

func Rand

func Rand() string

Rand generates a 32-bit random string.

Types

type AndMatch

type AndMatch struct {
	And []MatcherHolder `json:"and"`
}

AndMatch performs a boolean 'and' operation on two or more Matchers.

func (*AndMatch) GetType

func (match *AndMatch) GetType() string

func (AndMatch) MarshalJSON

func (match AndMatch) MarshalJSON() ([]byte, error)

func (*AndMatch) Match

func (match *AndMatch) Match(req *ApprovalRequest, proc Processor, a MatchAction, feedback []Feedback) (bool, error)

func (*AndMatch) Validate

func (match *AndMatch) Validate(m *MaintainerSnapshot) error

type AnonymousMatch

type AnonymousMatch struct {
	CommonMatch
	// restrict the approvers to this set
	Entities set.LowerSet `json:"entities"`
}

AnonymousMatch accepts the request when the number of people who have approved is greater than or equal to the threshold.

func DefaultAnonymousMatch

func DefaultAnonymousMatch() *AnonymousMatch

func (*AnonymousMatch) GetType

func (match *AnonymousMatch) GetType() string

func (AnonymousMatch) MarshalJSON

func (match AnonymousMatch) MarshalJSON() ([]byte, error)

func (*AnonymousMatch) Match

func (match *AnonymousMatch) Match(req *ApprovalRequest, proc Processor, a MatchAction, feedback []Feedback) (bool, error)

func (*AnonymousMatch) Validate

func (match *AnonymousMatch) Validate(m *MaintainerSnapshot) error

type ApprovalOp

type ApprovalOp int
const (
	Approval ApprovalOp = iota
	DisapprovalInsert
	DisapprovalRemove
	ValidAuthor
	ValidTitle
)

type ApprovalPolicy

type ApprovalPolicy struct {
	// Name is used to describe this policy to humans.
	// Optional but if specified it must be unique.
	Name string `json:"name,omitempty"`
	// Position is the 1-based index of this policy in the approval array.
	Position int `json:"-"`
	// ApprovalScope determines when the policy can be applied
	Scope *ApprovalScope `json:"scope,omitempty"`
	// Match is a JSON object that stores the approval match.
	// every approval policy needs a Match
	Match MatcherHolder `json:"match"`
	// AntiMatch is a JSON object that stores the disapproval match.
	AntiMatch *MatcherHolder `json:"antimatch,omitempty"`
	// AntiMatch is a JSON object that stores the author match.
	AuthorMatch *MatcherHolder `json:"authormatch,omitempty"`
	// Tag is an optional tag section to be used for this
	// approval scope. If this field is empty then the
	// global tag section is used.
	Tag *TagConfig `json:"tag,omitempty"`
	// Merge is an optional merge section to be used for this
	// approval scope. If this field is empty then the
	// global merge section is used.
	Merge *MergeConfig `json:"merge,omitempty"`
	// Pattern is an optional regular expression to be used for this
	// approval scope. If this field is empty then the
	// global pattern is used.
	Pattern *rxserde.RegexSerde `json:"pattern,omitempty"`
	// AntiPattern is an optional regular expression to be used for this
	// approval scope. If this field is empty then the
	// global antipattern is used.
	AntiPattern *rxserde.RegexSerde `json:"antipattern,omitempty"`
	// AntiTitle is an optional regular expression to be used for this
	// approval scope. If this field is empty then the
	// global antititle is used.
	AntiTitle *rxserde.RegexSerde `json:"antititle,omitempty"`
	// Feedback is an optional feedback section to be used for this
	// approval scope. If this field is empty then the
	// global feedback section is used.
	Feedback *FeedbackConfig `json:"feedback,omitempty"`
}

ApprovalPolicy combines an approval scope (that determines when the policy can be applied) and an approval match (that determines whether the match is successful)

func DefaultApprovalPolicy

func DefaultApprovalPolicy() *ApprovalPolicy

func FindApprovalPolicy

func FindApprovalPolicy(req *ApprovalRequest) *ApprovalPolicy

func (*ApprovalPolicy) Validate

func (a *ApprovalPolicy) Validate() error

type ApprovalRequest

type ApprovalRequest struct {
	Config              *Config
	Maintainer          *MaintainerSnapshot
	PullRequest         *PullRequest
	Repository          *Repo
	Issues              []*Issue
	ApprovalComments    []Feedback
	DisapprovalComments []Feedback
	Files               []CommitFile
	Commits             []Commit
}

func (*ApprovalRequest) IsTitleMatch

func (req *ApprovalRequest) IsTitleMatch() bool

IsTitleMatch returns true if the text matches the antititle regular expression.

type ApprovalScope

type ApprovalScope struct {
	Paths         []miniglob.MiniGlob  `json:"paths,omitempty"`
	Branches      set.Set              `json:"branches,omitempty"`
	PathRegexp    []rxserde.RegexSerde `json:"regexpaths,omitempty"`
	BaseRegexp    []rxserde.RegexSerde `json:"regexbase,omitempty"`
	CompareRegexp []rxserde.RegexSerde `json:"regexcompare,omitempty"`
}

ApprovalScope determines when the policy can be applied

func DefaultApprovalScope

func DefaultApprovalScope() *ApprovalScope

func (*ApprovalScope) ValidateFinal

func (a *ApprovalScope) ValidateFinal() error

type AtLeastMatch

type AtLeastMatch struct {
	// minimum number of approvals required
	Approvals int             `json:"approvals"`
	Choose    []MatcherHolder `json:"choose"`
}

func (*AtLeastMatch) GetType

func (match *AtLeastMatch) GetType() string

func (AtLeastMatch) MarshalJSON

func (match AtLeastMatch) MarshalJSON() ([]byte, error)

func (*AtLeastMatch) Match

func (match *AtLeastMatch) Match(req *ApprovalRequest, proc Processor, a MatchAction, feedback []Feedback) (bool, error)

func (*AtLeastMatch) Validate

func (match *AtLeastMatch) Validate(m *MaintainerSnapshot) error

type AuditConfig

type AuditConfig struct {
	// enable auditing of commits. Default is false.
	Enable bool `json:"enable"`
	// which branches to audit
	Branches set.Set `json:"branches"`
}

func DefaultAudit

func DefaultAudit() AuditConfig

type AuthorMatch

type AuthorMatch struct {
	Inner MatcherHolder `json:"inner"`
}

func (*AuthorMatch) GetType

func (match *AuthorMatch) GetType() string

func (AuthorMatch) MarshalJSON

func (match AuthorMatch) MarshalJSON() ([]byte, error)

func (*AuthorMatch) Match

func (match *AuthorMatch) Match(req *ApprovalRequest, proc Processor, _ MatchAction, feedback []Feedback) (bool, error)

func (*AuthorMatch) Validate

func (match *AuthorMatch) Validate(m *MaintainerSnapshot) error

type Branch

type Branch struct {
	CompareName    string
	CompareSHA     string
	CompareOwner   string
	Mergeable      bool
	Merged         bool
	MergeCommitSHA string
	BaseName       string
	BaseSHA        string
}

type BranchCompare

type BranchCompare struct {
	Status       string
	AheadBy      int
	BehindBy     int
	TotalCommits int
}

type Capabilities

type Capabilities struct {
	Org struct {
		Read bool
	}
	Repo struct {
		Tag              bool
		Merge            bool
		DeleteBranch     bool
		CommitStatus     bool
		PRWriteComment   bool
		DeploymentStatus bool
	}
}

func AllowAll

func AllowAll() *Capabilities

type ChangePolicy

type ChangePolicy interface {
	ChangePolicy(policy *ApprovalPolicy)
}

type CombinedStatus

type CombinedStatus struct {
	State    string
	Statuses map[string]CommitStatus
}

type Comment

type Comment struct {
	Author      lowercase.String
	Body        string
	SubmittedAt time.Time
}

func (*Comment) GetAuthor

func (c *Comment) GetAuthor() lowercase.String

func (*Comment) GetBody

func (c *Comment) GetBody() string

func (*Comment) GetSubmittedAt

func (c *Comment) GetSubmittedAt() time.Time

func (*Comment) IsApproval

func (c *Comment) IsApproval(req *ApprovalRequest) bool

IsApproval returns true if the comment body matches the regular expression pattern.

func (*Comment) IsDisapproval

func (c *Comment) IsDisapproval(req *ApprovalRequest) bool

IsDisapproval returns true if the comment body matches the antipattern regular expression.

func (*Comment) String

func (c *Comment) String() string

type CommentConfig

type CommentConfig struct {
	Enable  bool           `json:"enable"`
	Targets []TargetConfig `json:"targets"`
}

type CommentMessage

type CommentMessage int
const (

	//error while processing webhook
	CommentError CommentMessage
	//pr is opened
	CommentOpen
	//pr is closed without being merged
	CommentClose
	//pr has been closed and merged
	CommentAccept
	//an approval comment has been added to the PR
	CommentApprove
	//a blocking comment has been added to the PR
	CommentBlock
	//new push on PR branch has reset previous approvals
	CommentReset
	//a merge via the user interface has been ignored
	CommentPushIgnore
	//pr was auto-merged after all status checks passed
	CommentMerge
	//repo was tagged after merge
	CommentTag
	//branch for pr was auto-deleted after merge
	CommentDelete
	//deployment was triggered after merge
	CommentDeployment
	//pull request blocked because of author
	CommentAuthor
)

func (CommentMessage) Known

func (s CommentMessage) Known() bool

Known says whether or not this value is a known enum value.

func (CommentMessage) MarshalJSON

func (s CommentMessage) MarshalJSON() ([]byte, error)

MarshalJSON satisfies the json.Marshaler

func (CommentMessage) String

func (s CommentMessage) String() string

String is for the standard stringer interface.

func (*CommentMessage) UnmarshalJSON

func (s *CommentMessage) UnmarshalJSON(data []byte) error

UnmarshalJSON satisfies the json.Unmarshaler

type CommentTarget

type CommentTarget int
const (
	Github CommentTarget
	Slack
)

func ToCommentTarget

func ToCommentTarget(s string) CommentTarget

func (CommentTarget) Known

func (s CommentTarget) Known() bool

Known says whether or not this value is a known enum value.

func (CommentTarget) MarshalJSON

func (s CommentTarget) MarshalJSON() ([]byte, error)

MarshalJSON satisfies the json.Marshaler

func (CommentTarget) String

func (s CommentTarget) String() string

String is for the standard stringer interface.

func (*CommentTarget) UnmarshalJSON

func (s *CommentTarget) UnmarshalJSON(data []byte) error

UnmarshalJSON satisfies the json.Unmarshaler

type Commit

type Commit struct {
	Author    lowercase.String
	Committer string
	Message   string
	SHA       string
	Parents   []string
}

type CommitConfig

type CommitConfig struct {
	Range         CommitRange `json:"range"`
	AntiRange     CommitRange `json:"antirange"`
	TagRange      CommitRange `json:"tagrange"`
	IgnoreUIMerge bool        `json:"ignoreuimerge,omitempty"`
}

func DefaultCommit

func DefaultCommit() CommitConfig

type CommitFile

type CommitFile struct {
	Filename string
}

type CommitRange

type CommitRange int
const (
	Head CommitRange = iota
	All
)

func (CommitRange) Known

func (s CommitRange) Known() bool

Known says whether or not this value is a known enum value.

func (CommitRange) MarshalJSON

func (s CommitRange) MarshalJSON() ([]byte, error)

MarshalJSON satisfies the json.Marshaler

func (CommitRange) String

func (s CommitRange) String() string

String is for the standard stringer interface.

func (*CommitRange) UnmarshalJSON

func (s *CommitRange) UnmarshalJSON(data []byte) error

UnmarshalJSON satisfies the json.Unmarshaler

type CommitStatus

type CommitStatus struct {
	Context     string
	State       string
	Description string
}

type CommonMatch

type CommonMatch struct {
	// minimum number of approvals required
	Approvals int `json:"approvals"`
	// if true then author can self-approve request
	Self bool `json:"self"`
}

func (CommonMatch) Validate

func (match CommonMatch) Validate(_ *MaintainerSnapshot) error

type Config

type Config struct {
	Approvals   []*ApprovalPolicy   `json:"approvals"`
	Pattern     rxserde.RegexSerde  `json:"pattern"`
	AntiPattern *rxserde.RegexSerde `json:"antipattern,omitempty"`
	AntiTitle   *rxserde.RegexSerde `json:"antititle,omitempty"`
	Commit      CommitConfig        `json:"commit,omitempty"`
	Maintainers MaintainersConfig   `json:"maintainers,omitempty"`
	Merge       MergeConfig         `json:"merge,omitempty"`
	Feedback    FeedbackConfig      `json:"feedback,omitempty"`
	Tag         TagConfig           `json:"tag,omitempty"`
	Comment     CommentConfig       `json:"comment,omitempty"`
	Deployment  DeployConfig        `json:"deploy,omitempty"`
	Audit       AuditConfig         `json:"audit,omitempty"`
	IsOld       bool                `json:"-"`
}

func DefaultConfig

func DefaultConfig() *Config

func NonEmptyConfig

func NonEmptyConfig() *Config

func ParseConfig

func ParseConfig(data []byte, caps *Capabilities) (*Config, error)

ParseConfig parses a project configuration file.

func ParseOldConfig

func ParseOldConfig(data []byte) (*Config, error)

ParseOldConfig parses a projects .lgtm file

func (*Config) GetFeedbackConfig

func (c *Config) GetFeedbackConfig(policy *ApprovalPolicy) *FeedbackConfig

func (*Config) GetMergeConfig

func (c *Config) GetMergeConfig(policy *ApprovalPolicy) *MergeConfig

func (*Config) LoadDeploymentMap

func (c *Config) LoadDeploymentMap(deployData []byte) error

func (*Config) Validate

func (c *Config) Validate(caps *Capabilities) error

type DeployConfig

type DeployConfig struct {
	Enable        bool              `json:"enable"`
	Path          string            `json:"path"`
	DeploymentMap DeploymentConfigs `json:"-"`
}

type DeploymentConfig

type DeploymentConfig struct {
	Tasks       []string `json:"tasks"`
	Environment *string  `json:"env"`
}

type DeploymentConfigs

type DeploymentConfigs map[string]DeploymentConfig

type DeploymentInfo

type DeploymentInfo struct {
	Ref         string
	Task        string
	Environment string
}

type DisableMatch

type DisableMatch struct{}

DisableMatch always returns true and disables service.

func (*DisableMatch) ChangePolicy

func (match *DisableMatch) ChangePolicy(policy *ApprovalPolicy)

func (*DisableMatch) GetType

func (match *DisableMatch) GetType() string

func (DisableMatch) MarshalJSON

func (match DisableMatch) MarshalJSON() ([]byte, error)

func (*DisableMatch) Match

func (match *DisableMatch) Match(req *ApprovalRequest, proc Processor, a MatchAction, feedback []Feedback) (bool, error)

func (*DisableMatch) Validate

func (match *DisableMatch) Validate(_ *MaintainerSnapshot) error

type EntityMatch

type EntityMatch struct {
	CommonMatch
	// name of the group or person to match
	Entity lowercase.String `json:"entity"`
}

EntityMatch accepts the request when the group or person meets the minimum number of approvals.

func DefaultEntityMatch

func DefaultEntityMatch() *EntityMatch

func (*EntityMatch) GetType

func (match *EntityMatch) GetType() string

func (EntityMatch) MarshalJSON

func (match EntityMatch) MarshalJSON() ([]byte, error)

func (*EntityMatch) Match

func (match *EntityMatch) Match(req *ApprovalRequest, proc Processor, a MatchAction, feedback []Feedback) (bool, error)

func (*EntityMatch) Validate

func (match *EntityMatch) Validate(m *MaintainerSnapshot) error

type FalseMatch

type FalseMatch struct{}

FalseMatch always returns false.

func (*FalseMatch) GetType

func (match *FalseMatch) GetType() string

func (FalseMatch) MarshalJSON

func (match FalseMatch) MarshalJSON() ([]byte, error)

func (*FalseMatch) Match

func (match *FalseMatch) Match(req *ApprovalRequest, proc Processor, a MatchAction, feedback []Feedback) (bool, error)

func (*FalseMatch) Validate

func (match *FalseMatch) Validate(_ *MaintainerSnapshot) error

type Feedback

type Feedback interface {
	IsApproval(req *ApprovalRequest) bool
	IsDisapproval(req *ApprovalRequest) bool
	GetAuthor() lowercase.String
	GetBody() string
	GetSubmittedAt() time.Time
}

type FeedbackConfig

type FeedbackConfig struct {
	Types        []FeedbackType `json:"types,omitempty"`
	AuthorAffirm bool           `json:"authoraffirm"`
}

func DefaultFeedback

func DefaultFeedback() FeedbackConfig

func (*FeedbackConfig) UnmarshalJSON

func (c *FeedbackConfig) UnmarshalJSON(text []byte) error

type FeedbackType

type FeedbackType int
const (
	CommentType FeedbackType = iota
	ReviewType
)

func (FeedbackType) Known

func (s FeedbackType) Known() bool

Known says whether or not this value is a known enum value.

func (FeedbackType) MarshalJSON

func (s FeedbackType) MarshalJSON() ([]byte, error)

MarshalJSON satisfies the json.Marshaler

func (FeedbackType) String

func (s FeedbackType) String() string

String is for the standard stringer interface.

func (*FeedbackType) UnmarshalJSON

func (s *FeedbackType) UnmarshalJSON(data []byte) error

UnmarshalJSON satisfies the json.Unmarshaler

type GitHubOrg

type GitHubOrg struct {
	Login   string `json:"login"`
	Avatar  string `json:"avatar"`
	Enabled bool   `json:"enabled"`
	Admin   bool   `json:"admin"`
}

type Issue

type Issue struct {
	Number int
	Title  string
	Author lowercase.String
}

type IssueAuthorMatch

type IssueAuthorMatch struct{}

func (*IssueAuthorMatch) GetType

func (match *IssueAuthorMatch) GetType() string

func (IssueAuthorMatch) MarshalJSON

func (match IssueAuthorMatch) MarshalJSON() ([]byte, error)

func (*IssueAuthorMatch) Match

func (match *IssueAuthorMatch) Match(req *ApprovalRequest, proc Processor, a MatchAction, feedback []Feedback) (bool, error)

func (*IssueAuthorMatch) Validate

func (match *IssueAuthorMatch) Validate(_ *MaintainerSnapshot) error

type Maintainer

type Maintainer struct {
	RawPeople map[string]*Person   `json:"people" toml:"people"`
	RawOrg    map[string]*OrgSerde `json:"org" toml:"org"`
}

Maintainer represents a MAINTAINERS file.

type MaintainerMatch

type MaintainerMatch struct {
	CommonMatch
}

MaintainerMatch accepts the request when the number of people who have approved is greater than or equal to the threshold. Approvals are restricted to project maintainers.

func DefaultMaintainerMatch

func DefaultMaintainerMatch() *MaintainerMatch

func (*MaintainerMatch) GetType

func (match *MaintainerMatch) GetType() string

func (MaintainerMatch) MarshalJSON

func (match MaintainerMatch) MarshalJSON() ([]byte, error)

func (*MaintainerMatch) Match

func (match *MaintainerMatch) Match(req *ApprovalRequest, proc Processor, a MatchAction, feedback []Feedback) (bool, error)

type MaintainerSnapshot

type MaintainerSnapshot struct {
	People map[string]*Person
	Org    map[string]Org
}

func (*MaintainerSnapshot) PersonToOrg

func (m *MaintainerSnapshot) PersonToOrg() (map[string]set.Set, error)

type MaintainersConfig

type MaintainersConfig struct {
	Path string `json:"path"`
	Type string `json:"type"`
}

type MatchAction

type MatchAction func(*ApprovalRequest, Feedback, set.Set, Processor)

MatchAction decides whether to invoke the Processor

type Matcher

type Matcher interface {
	Match(req *ApprovalRequest, proc Processor, a MatchAction, feedback []Feedback) (bool, error)
	GetType() string
	Validate(m *MaintainerSnapshot) error
}

Matcher determines whether the match is successful)

func DefaultMatcher

func DefaultMatcher() Matcher

func GenerateMatcher

func GenerateMatcher(input string) (Matcher, error)

type MatcherHolder

type MatcherHolder struct {
	Matcher
}

MatcherHolder stores an an Matcher JSON marshal and unmarshal are implemented on this struct.

func (MatcherHolder) MarshalJSON

func (match MatcherHolder) MarshalJSON() ([]byte, error)

func (*MatcherHolder) UnmarshalJSON

func (match *MatcherHolder) UnmarshalJSON(data []byte) error

type MergeConfig

type MergeConfig struct {
	Enable   bool   `json:"enable"`
	UpToDate bool   `json:"uptodate"`
	Method   string `json:"method"`
	Delete   bool   `json:"delete"`
}

func DefaultMerge

func DefaultMerge() MergeConfig

func (*MergeConfig) UnmarshalJSON

func (m *MergeConfig) UnmarshalJSON(text []byte) error

type NotMatch

type NotMatch struct {
	Not MatcherHolder `json:"not"`
}

NotMatch performs a boolean 'not' operation on a matcher.

func (*NotMatch) GetType

func (match *NotMatch) GetType() string

func (NotMatch) MarshalJSON

func (match NotMatch) MarshalJSON() ([]byte, error)

func (*NotMatch) Match

func (match *NotMatch) Match(req *ApprovalRequest, proc Processor, a MatchAction, feedback []Feedback) (bool, error)

func (*NotMatch) Validate

func (match *NotMatch) Validate(m *MaintainerSnapshot) error

type OrMatch

type OrMatch struct {
	Or []MatcherHolder `json:"or"`
}

OrMatch performs a boolean 'or' operation on two or more Matchers.

func (*OrMatch) GetType

func (match *OrMatch) GetType() string

func (OrMatch) MarshalJSON

func (match OrMatch) MarshalJSON() ([]byte, error)

func (*OrMatch) Match

func (match *OrMatch) Match(req *ApprovalRequest, proc Processor, a MatchAction, feedback []Feedback) (bool, error)

func (*OrMatch) Validate

func (match *OrMatch) Validate(m *MaintainerSnapshot) error

type Org

type Org interface {
	GetPeople() (set.Set, error)
}

Org represents a group, team or subset of users.

type OrgDb

type OrgDb struct {
	ID      int64  `json:"id,omitempty"       meddler:"org_id,pk"`
	UserID  int64  `json:"-"                  meddler:"org_user_id"`
	Owner   string `json:"owner"              meddler:"org_owner"`
	Link    string `json:"link_url"           meddler:"org_link"`
	Private bool   `json:"private"            meddler:"org_private"`
	Secret  string `json:"-"                  meddler:"org_secret"`
}

type OrgSerde

type OrgSerde struct {
	People set.Set `json:"people"  toml:"people"`
}

func (*OrgSerde) GetPeople

func (o *OrgSerde) GetPeople() (set.Set, error)

type Perm

type Perm struct {
	Pull  bool
	Push  bool
	Admin bool
}

type Person

type Person struct {
	Name  string `json:"name"  toml:"name"`
	Email string `json:"email" toml:"email"`
	Login string `json:"login" toml:"login"`
}

Person represets an individual in the MAINTAINERS file.

type Processor

type Processor func(Feedback, ApprovalOp)

Processor updates bookkepping for comment tracking.

type PullRequest

type PullRequest struct {
	Issue
	Branch Branch
	Body   string
}

type Repo

type Repo struct {
	ID      int64  `json:"id,omitempty"       meddler:"repo_id,pk"`
	UserID  int64  `json:"-"                  meddler:"repo_user_id"`
	Owner   string `json:"owner"              meddler:"repo_owner"`
	Name    string `json:"name"               meddler:"repo_name"`
	Slug    string `json:"slug"               meddler:"repo_slug"`
	Link    string `json:"link_url"           meddler:"repo_link"`
	Private bool   `json:"private"            meddler:"repo_private"`
	Secret  string `json:"-"                  meddler:"repo_secret"`
	Org     bool   `json:"org"                meddler:"repo_org"`
}

type Review

type Review struct {
	ID          int64
	Author      lowercase.String
	Body        string
	SubmittedAt time.Time
	State       lowercase.String
}

func (*Review) GetAuthor

func (r *Review) GetAuthor() lowercase.String

func (*Review) GetBody

func (r *Review) GetBody() string

func (*Review) GetSubmittedAt

func (r *Review) GetSubmittedAt() time.Time

func (*Review) IsApproval

func (r *Review) IsApproval(req *ApprovalRequest) bool

IsApproval returns true if the review has been approved

func (*Review) IsDisapproval

func (r *Review) IsDisapproval(req *ApprovalRequest) bool

IsDisapproval returns true if changes have been requested

type Semver

type Semver int
const (
	Patch Semver = iota
	Major
	Minor
	None
)

func (Semver) Known

func (s Semver) Known() bool

Known says whether or not this value is a known enum value.

func (Semver) MarshalJSON

func (s Semver) MarshalJSON() ([]byte, error)

MarshalJSON satisfies the json.Marshaler

func (Semver) String

func (s Semver) String() string

String is for the standard stringer interface.

func (*Semver) UnmarshalJSON

func (s *Semver) UnmarshalJSON(data []byte) error

UnmarshalJSON satisfies the json.Unmarshaler

type Tag

type Tag string

type TagConfig

type TagConfig struct {
	// enable automatic tagging of merges. Default is false.
	Enable bool `json:"enable"`
	// algorithm for generating tag name. Allowed values are
	// "explicit", "semver", "timestamp-rfc3339", and "timestamp-millis".
	// Default is "semver".
	Alg string `json:"algorithm"`
	// golang text/template for producing tag name.
	// Container struct is TemplateTag.
	// Default template is "{{.Version}}"
	TemplateRaw string             `json:"template"`
	Template    *template.Template `json:"-"`
	// If true then perform stricter validation
	// of templates to comply with Docker tag requirements
	Docker bool `json:"docker"`
	// Version increment policy for the "semver" algorithm.
	// Allowed values are "major", "minor", "patch", and "none".
	// Default is "patch".
	Increment Semver `json:"increment"`
}

func DefaultTag

func DefaultTag() TagConfig

func (*TagConfig) Compile

func (t *TagConfig) Compile() error

func (*TagConfig) GenerateTag

func (t *TagConfig) GenerateTag(body TemplateTag) (string, error)

func (*TagConfig) UnmarshalJSON

func (t *TagConfig) UnmarshalJSON(text []byte) error

type TargetConfig

type TargetConfig struct {
	Target  string              `json:"target"`
	Pattern *rxserde.RegexSerde `json:"pattern"`
	Types   []CommentMessage    `json:"types"`
	Names   []string            `json:"names"`
	Url     string              `json:"-"`
}

type TemplateTag

type TemplateTag struct {
	Version string
}

type ThemMatch

type ThemMatch struct {
	CommonMatch
}

ThemMatch is restricted to maintainers who do not share a group with the author of the pull request.

func DefaultThemMatch

func DefaultThemMatch() *ThemMatch

func (*ThemMatch) GetType

func (match *ThemMatch) GetType() string

func (ThemMatch) MarshalJSON

func (match ThemMatch) MarshalJSON() ([]byte, error)

func (*ThemMatch) Match

func (match *ThemMatch) Match(req *ApprovalRequest, proc Processor, a MatchAction, feedback []Feedback) (bool, error)

type TrueMatch

type TrueMatch struct{}

TrueMatch always returns true.

func (*TrueMatch) GetType

func (match *TrueMatch) GetType() string

func (TrueMatch) MarshalJSON

func (match TrueMatch) MarshalJSON() ([]byte, error)

func (*TrueMatch) Match

func (match *TrueMatch) Match(req *ApprovalRequest, proc Processor, a MatchAction, feedback []Feedback) (bool, error)

func (*TrueMatch) Validate

func (match *TrueMatch) Validate(_ *MaintainerSnapshot) error

type UniverseMatch

type UniverseMatch struct {
	CommonMatch
}

UniverseMatch accepts the request when the number of people who have approved is greater than or equal to the threshold. Approvals are not restricted to project maintainers.

func DefaultUniverseMatch

func DefaultUniverseMatch() *UniverseMatch

func (*UniverseMatch) GetType

func (match *UniverseMatch) GetType() string

func (UniverseMatch) MarshalJSON

func (match UniverseMatch) MarshalJSON() ([]byte, error)

func (*UniverseMatch) Match

func (match *UniverseMatch) Match(req *ApprovalRequest, proc Processor, a MatchAction, feedback []Feedback) (bool, error)

type UsMatch

type UsMatch struct {
	CommonMatch
}

UsMatch is restricted to maintainers who share a group with the author of the pull request.

func DefaultUsMatch

func DefaultUsMatch() *UsMatch

func (*UsMatch) GetType

func (match *UsMatch) GetType() string

func (UsMatch) MarshalJSON

func (match UsMatch) MarshalJSON() ([]byte, error)

func (*UsMatch) Match

func (match *UsMatch) Match(req *ApprovalRequest, proc Processor, a MatchAction, feedback []Feedback) (bool, error)

type User

type User struct {
	ID     int64  `json:"id"      meddler:"user_id,pk"`
	Login  string `json:"login"   meddler:"user_login"`
	Token  string `json:"-"       meddler:"user_token"`
	Avatar string `json:"avatar"  meddler:"user_avatar"`
	Secret string `json:"-"       meddler:"user_secret"`
	Scopes string `json:"-"       meddler:"user_scopes"`
}

Jump to

Keyboard shortcuts

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