Documentation ¶
Index ¶
- Constants
- Variables
- func NewBranch(branch *github.Branch) (string, error)
- func NewCommitHash(ref *github.Reference) (string, error)
- type EnrichedIssue
- type File
- type Installation
- type InstallationEvent
- type InstallationRepositoriesEvent
- type Issue
- type IssueComment
- type IssueCommentMetadata
- type IssueCommentType
- type IssueEvent
- type IssueEventAction
- type IssueMetadata
- type IssueRequest
- type IssueSeverity
- type IssueState
- type IssueType
- type IssuesEvent
- type Label
- type MarketplacePurchaseEvent
- type PullRequest
- type PullRequestMetadata
- type PullRequestState
- type PullRequestType
- type Rate
- type RateLimits
- type RepositoriesInstallation
- type Repository
- type User
Constants ¶
const ( RewardIssueCommentType IssueCommentType = "reward" EligibleIssueCommentType IssueCommentType = "eligible" UnknownCommentType IssueCommentType = "unknown" EligibleCommentHeaderLegacy = "🤖 Assignees for Issue" EligibleCommentHeaderBeginning = "🤖 Assignees for issue" ErrorRewardCommentHeader = "### Famed could not generate a reward suggestion." RewardCommentTableHeader = "| Contributor | Time | Reward |\n| ----------- | ----------- | ----------- |" )
Variables ¶
var ( ErrUnhandledEventType = errors.New("the event is not handled") ErrEventUnAssignedMissingData = errors.New("the (un)assigned event is missing the (un)assigned user") ErrEventNotFamedLabeled = errors.New("the event is missing the famed label") ErrRateLimitMissingData = errors.New("the rate limit is missing data promised by the GitHub API") ErrInstallationMissingData = errors.New("the installation is missing data promised by the GitHub API") ErrRepoMissingData = errors.New("the repo is missing data promised by the GitHub API") ErrIssueMissingData = errors.New("the issue is missing data promised by the GitHub API") ErrUserMissingData = errors.New("the user is missing data promised by the GitHub API") ErrIssueCommentMissingData = errors.New("the issue comment is missing data promised by the GitHub API") ErrIssueMissingSeverityLabel = errors.New("the issue is missing it's severity label") ErrIssueMultipleSeverityLabels = errors.New("the issue has multiple severity labels") ErrEventMissingData = errors.New("the event is missing data promised by the GitHub API") ErrPullRequestMissingData = errors.New("the pull request is missing data promised by the GitHub API") ErrRefMissingData = errors.New("the reference is missing data promised by the GitHub API") ErrLabelMissingData = errors.New("the label is missing data promised by the GitHub API") ErrBranchMissingData = errors.New("the branch is missing data promised by the GitHub API") ErrFileContentMissingData = errors.New("the file content is missing data promised by the GitHub API") ErrFileContentUnexpectedEncoding = errors.New("the file content has an unexpected encoding") ErrIssueRequestIsMissingID = errors.New("the issue request is missing an ID") )
Functions ¶
Types ¶
type EnrichedIssue ¶
type EnrichedIssue struct { Issue PullRequest *string Events []IssueEvent Comments []IssueComment }
func NewEnrichIssue ¶
func NewEnrichIssue(issue Issue, pullRequest *string, events []IssueEvent, comments []IssueComment) EnrichedIssue
type Installation ¶
func NewInstallation ¶
func NewInstallation(installation *github.Installation) (Installation, error)
type InstallationEvent ¶
type InstallationEvent struct { Action string Repositories []Repository Installation }
func NewInstallationEvent ¶
func NewInstallationEvent(event *github.InstallationEvent) (InstallationEvent, error)
type InstallationRepositoriesEvent ¶
type InstallationRepositoriesEvent struct { Action string Installation RepositoriesInstallation RepositoriesAdded []Repository }
func NewInstallationRepositoriesEvent ¶
func NewInstallationRepositoriesEvent(event *github.InstallationRepositoriesEvent) (InstallationRepositoriesEvent, error)
type Issue ¶
type Issue struct { ID int64 Number int HTMLURL string Title string State IssueState CreatedAt time.Time ClosedAt *time.Time Assignees []User Severities []IssueSeverity Migrated bool RedTeam []User BountyPoints *int // Body and IssueMetadata only present in installation issues and scanners issues. Body *string Metadata *IssueMetadata }
func (*Issue) Severity ¶
func (i *Issue) Severity() (IssueSeverity, error)
Severity returns the issue severity. If 0 or more than one severity are present it returns an error.
type IssueComment ¶
type IssueComment struct { ID int64 User Body string Metadata *IssueCommentMetadata }
IssueComment represents a GitHub comment.
func NewComment ¶
func NewComment(comment *github.IssueComment) (IssueComment, error)
NewComment returns a new IssueComment. If expected data is not available an error is returned.
type IssueCommentMetadata ¶
type IssueCommentMetadata struct { Type IssueCommentType `json:"type"` Version string `json:"version"` }
func NewIssueCommentMetadata ¶
func NewIssueCommentMetadata(commentType IssueCommentType, version string) IssueCommentMetadata
func ParseIssueCommentMetadata ¶
func ParseIssueCommentMetadata(body string) (IssueCommentMetadata, error)
func (IssueCommentMetadata) String ¶
func (i IssueCommentMetadata) String() (string, error)
type IssueCommentType ¶
type IssueCommentType string
type IssueEvent ¶
func NewIssueEvent ¶
func NewIssueEvent(event *github.IssueEvent) (IssueEvent, error)
type IssueEventAction ¶
type IssueEventAction string
const ( // IssueEventActionClosed represents a GitHub event action triggered when the Actor closed the issue. // If the issue was closed by commit message, CommitID holds the SHA1 hash of the commit. IssueEventActionClosed IssueEventAction = "closed" // IssueEventActionMerged represents a GitHub event action triggered when the Actor merged into master a branch containing a commit mentioning the issue. // CommitID holds the SHA1 of the merge commit. IssueEventActionMerged IssueEventAction = "merged" // IssueEventActionReferenced represents a GitHub event action triggered when the Actor committed to master a commit mentioning the issue in its commit message. // CommitID holds the SHA1 of the commit. IssueEventActionReferenced IssueEventAction = "referenced" // IssueEventActionReopened represents a GitHub event action triggered when the Actor reopened the issue. IssueEventActionReopened IssueEventAction = "reopened" // IssueEventActionUnlocked represents a GitHub event action triggered when the Actor unlocked the issue. IssueEventActionUnlocked IssueEventAction = "unlocked" // IssueEventActionLocked represents a GitHub event action triggered when the Actor locked the issue. // LockReason holds the reason of locking the issue (if provided while locking). IssueEventActionLocked IssueEventAction = "locked" // IssueEventActionRenamed represents a GitHub event action triggered when the Actor changed the issue title from Rename. // From to Rename.To. IssueEventActionRenamed IssueEventAction = "renamed" // IssueEventActionMentioned represents a GitHub event action triggered when someone unspecified @mentioned the Actor [sic] in an issue comment body. IssueEventActionMentioned IssueEventAction = "mentioned" // IssueEventActionAssigned represents a GitHub event action triggered when the Assigner assigned the issue to or removed the assignment from the Assignee. IssueEventActionAssigned IssueEventAction = "assigned" IssueEventActionUnassigned IssueEventAction = "unassigned" // IssueEventActionLabeled & IssueEventActionUnlabeled represents a GitHub event action triggered when the Actor added or removed the Label from the issue. IssueEventActionLabeled IssueEventAction = "labeled" IssueEventActionUnlabeled IssueEventAction = "unlabeled" // IssueEventActionMilestoned & IssueEventActionDemilestoned represents a GitHub event action triggered when the Actor added or removed the issue from the Milestone. IssueEventActionMilestoned IssueEventAction = "milestoned" IssueEventActionDemilestoned IssueEventAction = "demilestoned" // IssueEventActionSubscribed & IssueEventActionUnsubscribed represents a GitHub event action triggered when the Actor subscribed to or unsubscribed from notifications for an issue. IssueEventActionSubscribed IssueEventAction = "subscribed" IssueEventActionUnsubscribed IssueEventAction = "unsubscribed" // IssueEventActionHeadRefDeleted & IssueEventActionHeadRefRestored represents a GitHub event action triggered when the pull request’s branch was deleted or restored. IssueEventActionHeadRefDeleted IssueEventAction = "head_ref_deleted" IssueEventActionHeadRefRestored IssueEventAction = "head_ref_restored" // IssueEventActionReviewDismissed represents a GitHub event action triggered when the review was dismissed and `DismissedReview` will be populated below. IssueEventActionReviewDismissed IssueEventAction = "review_dismissed" // IssueEventActionReviewRequested represents a GitHub event action triggered when the Actor requested or removed the request for a review. // RequestedReviewer and ReviewRequester will be populated below. IssueEventActionReviewRequested IssueEventAction = "review_requested" // IssueEventUnFamed represents an internal Famed event triggered when the famed label is removed from an issue. IssueEventUnFamed IssueEventAction = "unfamed" )
type IssueMetadata ¶
type IssueMetadata struct { // ID represents an identifier for Famed issues it can be any string but should be unique per repository. ID *string `json:"id,omitempty"` Type IssueType `json:"type"` Version string `json:"version"` }
IssueMetadata represent a Issue's metadata.
func NewIssueMetadata ¶
func NewIssueMetadata(ID string, commentType IssueType, version string) IssueMetadata
NewIssueMetadata creates a new IssueMetadata struct.
func ParseIssueMetadata ¶
func ParseIssueMetadata(text string) (IssueMetadata, error)
ParseIssueMetadata return the IssueMetadata parsed from a string.
func (IssueMetadata) HasID ¶
func (i IssueMetadata) HasID() bool
HasID return true if the issue metadata has an ID.
func (IssueMetadata) IDEquals ¶
func (i IssueMetadata) IDEquals(ID string) bool
IDEquals return true if the given string is equal to the IssueMetadata ID.
func (IssueMetadata) String ¶
func (i IssueMetadata) String() (string, error)
String return the string representation of the IssueMetadata.
type IssueRequest ¶
type IssueRequest struct { Title string Body string Labels []string State IssueState Metadata IssueMetadata }
func NewIssueRequest ¶
func NewIssueRequest(title, body string, labels []string, state IssueState, metadata IssueMetadata) IssueRequest
func (*IssueRequest) GitHubIssueRequestWithLabels ¶
func (i *IssueRequest) GitHubIssueRequestWithLabels(labels []string) (*github.IssueRequest, error)
type IssueSeverity ¶
type IssueSeverity string
const ( // Info represents a CVSS of 0. Info IssueSeverity = "info" // Low represents a CVSS of 0.1-3.9. Low IssueSeverity = "low" // Medium represents a CVSS of 4.0-6.9. Medium IssueSeverity = "medium" // High represents a CVSS of 7.0-8.9. High IssueSeverity = "high" // Critical represents a CVSS of 9.0-10.0. Critical IssueSeverity = "critical" )
type IssueState ¶
type IssueState string
const ( IssueStateAll IssueState = "all" IssueStateOpened IssueState = "open" IssueStateClosed IssueState = "closed" )
type IssuesEvent ¶
type IssuesEvent struct { Action string Repo Repository Issue }
func NewIssuesEvent ¶
func NewIssuesEvent(event *github.IssuesEvent, famedLabel string) (IssuesEvent, error)
NewIssuesEvent validates issue events received through the webhook. The changes implied by the event in the case of (un)assigned are mapped to the issue to provide an after event issue state, this is done because of a suspected bug in the GitHub API.
type MarketplacePurchaseEvent ¶
type MarketplacePurchaseEvent struct{}
func NewMarketplacePurchaseEvent ¶
func NewMarketplacePurchaseEvent(event *github.MarketplacePurchaseEvent) (MarketplacePurchaseEvent, error)
type PullRequest ¶
type PullRequest struct { HTMLURL string CreatedAt time.Time State PullRequestState Metadata *PullRequestMetadata }
func NewPullRequest ¶
func NewPullRequest(pullRequest *github.PullRequest) (PullRequest, error)
type PullRequestMetadata ¶
type PullRequestMetadata struct { Type PullRequestType `json:"type"` Version string `json:"version"` }
func NewPullRequestMetadata ¶
func NewPullRequestMetadata(commentType PullRequestType, version string) PullRequestMetadata
func ParsePullRequestMetadata ¶
func ParsePullRequestMetadata(text string) (PullRequestMetadata, error)
func (PullRequestMetadata) String ¶
func (i PullRequestMetadata) String() (string, error)
type PullRequestState ¶
type PullRequestState string
const ( PullRequestStateOpen PullRequestState = "open" PullRequestStateClosed PullRequestState = "closed" PullRequestStateAll PullRequestState = "all" )
type PullRequestType ¶
type PullRequestType string
const (
InstallationPullRequestType PullRequestType = "installation"
)
type RateLimits ¶
func NewRateLimit ¶
func NewRateLimit(rateLimits *github.RateLimits) (RateLimits, error)
type RepositoriesInstallation ¶
type RepositoriesInstallation struct {
Account User
}
type Repository ¶
func NewRepo ¶
func NewRepo(repo *github.Repository) (Repository, error)
Source Files ¶
- branch.go
- commit_hash.go
- enriched_issues.go
- errors.go
- file.go
- installation.go
- installation_event.go
- installation_repositories_event.go
- issue.go
- issue_comment.go
- issue_comment_metadata.go
- issue_event.go
- issue_metadata.go
- issue_request.go
- issues_event.go
- label.go
- marketplace_event.go
- pull_request.go
- pull_request_metadata.go
- rate_limit.go
- repo.go
- severity.go
- user.go