Documentation ¶
Overview ¶
Package monorail contains monorail-specific logic for creating and updating bugs.
Index ¶
- Constants
- Variables
- func ChromiumTestConfig() *configpb.MonorailProject
- func ChromiumTestIssuePriority(issue *mpb.Issue) string
- func CopyComments(comments []*mpb.Comment) []*mpb.Comment
- func CopyIssue(issue *mpb.Issue) *mpb.Issue
- func NewComment(issueName string, number int) *mpb.Comment
- func NewIssue(uniqifier int) *mpb.Issue
- func SortFieldValues(input []*mpb.FieldValue)
- func SortLabels(input []*mpb.Issue_LabelValue)
- func ToMonorailIssueName(bug string) (string, error)
- func UseFakeIssuesClient(ctx context.Context, store *FakeIssuesStore, user string) context.Context
- type BugManager
- func (m *BugManager) Create(ctx context.Context, request bugs.BugCreateRequest) bugs.BugCreateResponse
- func (m *BugManager) GetMergedInto(ctx context.Context, bug bugs.BugID) (*bugs.BugID, error)
- func (m *BugManager) Update(ctx context.Context, request []bugs.BugUpdateRequest) ([]bugs.BugUpdateResponse, error)
- func (m *BugManager) UpdateDuplicateSource(ctx context.Context, request bugs.UpdateDuplicateSourceRequest) error
- type Client
- func (c *Client) BatchGetIssues(ctx context.Context, project string, ids []string) ([]*mpb.Issue, error)
- func (c *Client) GetComponentExistsAndActive(ctx context.Context, project string, component string) (bool, error)
- func (c *Client) GetIssue(ctx context.Context, name string) (*mpb.Issue, error)
- func (c *Client) ListComments(ctx context.Context, name string) ([]*mpb.Comment, error)
- func (c *Client) MakeIssue(ctx context.Context, req *mpb.MakeIssueRequest) (*mpb.Issue, error)
- func (c *Client) ModifyIssues(ctx context.Context, req *mpb.ModifyIssuesRequest) error
- type FakeIssuesStore
- type IssueData
- type MakeUpdateOptions
- type MakeUpdateResult
- type RequestGenerator
- func (rg *RequestGenerator) IssuePriority(issue *mpb.Issue) (configpb.BuganizerPriority, error)
- func (rg *RequestGenerator) MakePriorityOrVerifiedUpdate(options MakeUpdateOptions) (MakeUpdateResult, error)
- func (rg *RequestGenerator) NeedsPriorityOrVerifiedUpdate(bms *bugspb.BugManagementState, issue *mpb.Issue, isManagingBugPriority bool) (bool, error)
- func (rg *RequestGenerator) PrepareNew(ruleID string, activePolicyIDs map[bugs.PolicyID]struct{}, ...) (*mpb.MakeIssueRequest, error)
- func (rg *RequestGenerator) PreparePolicyActivatedComment(ruleID, bugID string, policyID bugs.PolicyID) (*mpb.ModifyIssuesRequest, error)
- func (rg *RequestGenerator) PrepareRuleAssociatedComment(ruleID, bugID string) (*mpb.ModifyIssuesRequest, error)
- func (rg *RequestGenerator) SortPolicyIDsByPriorityDescending(policyIDs map[bugs.PolicyID]struct{}) []bugs.PolicyID
- func (rg *RequestGenerator) UpdateDuplicateSource(bugID, errorMessage, sourceRuleID, destinationRuleID string) (*mpb.ModifyIssuesRequest, error)
Constants ¶
const AssignedStatus = "Assigned"
AssignedStatus is the status of bugs that are open and assigned to an owner.
const ChromiumTestPriorityField = "projects/chromium/fieldDefs/11"
ChromiumTestPriorityField is the resource name of the priority field that is consistent with ChromiumTestConfig.
const ChromiumTestTypeField = "projects/chromium/fieldDefs/10"
ChromiumTestTypeField is the resource name of the type field that is consistent with ChromiumTestConfig.
const DuplicateStatus = "Duplicate"
DuplicateStatus is the status of bugs which are closed as duplicate.
const FixedStatus = "Fixed"
FixedStatus is the status of bugs which have been fixed, but not verified.
const UntriagedStatus = "Untriaged"
UntriagedStatus is the status of bugs that have just been opened.
const VerifiedStatus = "Verified"
VerifiedStatus is that status of bugs that have been fixed and verified.
Variables ¶
var ArchivedStatuses = map[string]struct{}{
"Archived": {},
"Obsolete": {},
}
ArchivedStatuses is the subset of closed statuses that indicate a bug that should no longer be used.
var AutomationUsers = []string{
"users/3816576959",
"users/4149141945",
"users/3371420746",
"users/641595106",
"users/1503471452",
"users/3692272382",
}
AutomationUsers are the identifiers of LUCI Analysis automation users in monorail.
var ClosedStatuses = map[string]struct{}{
"Fixed": {},
"Verified": {},
"WontFix": {},
"Done": {},
"NotReproducible": {},
"Archived": {},
"Obsolete": {},
}
ClosedStatuses is the status of bugs which are closed. Comprises statuses configured on chromium and fuchsia projects. Ideally this would be configuration, but given the coming monorail deprecation, there is limited value.
Functions ¶
func ChromiumTestConfig ¶
func ChromiumTestConfig() *configpb.MonorailProject
ChromiumTestConfig provides chromium-like configuration for tests to use.
func ChromiumTestIssuePriority ¶
ChromiumTestIssuePriority returns the priority of an issue, assuming it has been created consistent with ChromiumTestConfig.
func CopyComments ¶
CopyComments performs a deep copy of the given Comment.
func NewComment ¶
NewComment returns a new monorail comment proto for testing.
func SortFieldValues ¶
func SortFieldValues(input []*mpb.FieldValue)
SortFieldValues sorts the given labels in alphabetical order.
func SortLabels ¶
func SortLabels(input []*mpb.Issue_LabelValue)
SortLabels sorts the given labels in alphabetical order.
func ToMonorailIssueName ¶
ToMonorailIssueName converts an internal bug name like "{monorail_project}/{numeric_id}" to a monorail issue name like "projects/{project}/issues/{numeric_id}".
func UseFakeIssuesClient ¶
UseFakeIssuesClient installs a given fake IssuesClient into the context so that it is used instead of making RPCs to monorail. The client will behave as if the given user is authenticated.
Types ¶
type BugManager ¶
type BugManager struct { // Simulate, if set, tells BugManager not to make mutating changes // to monorail but only log the changes it would make. Must be set // when running locally as RPCs made from developer systems will // appear as that user, which breaks the detection of user-made // priority changes vs system-made priority changes. Simulate bool // contains filtered or unexported fields }
BugManager controls the creation of, and updates to, monorail bugs for clusters.
func NewBugManager ¶
func NewBugManager(client *Client, uiBaseURL, project string, projectCfg *configpb.ProjectConfig) (*BugManager, error)
NewBugManager initialises a new bug manager, using the specified monorail client.
func (*BugManager) Create ¶
func (m *BugManager) Create(ctx context.Context, request bugs.BugCreateRequest) bugs.BugCreateResponse
Create creates a new bug for the given request, returning its name, or any encountered error.
func (*BugManager) GetMergedInto ¶
GetMergedInto reads the bug (if any) the given bug was merged into. If the given bug is not merged into another bug, this returns nil.
func (*BugManager) Update ¶
func (m *BugManager) Update(ctx context.Context, request []bugs.BugUpdateRequest) ([]bugs.BugUpdateResponse, error)
Update updates the specified list of bugs.
func (*BugManager) UpdateDuplicateSource ¶
func (m *BugManager) UpdateDuplicateSource(ctx context.Context, request bugs.UpdateDuplicateSourceRequest) error
Unduplicate updates the given bug to no longer be marked as duplicating another bug, posting the given message on the bug.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a client to communicate with the Monorail issue tracker.
func NewClient ¶
Creates a new Monorail client. Host is the monorail host to use, e.g. monorail-prod.appspot.com.
func (*Client) BatchGetIssues ¶
func (c *Client) BatchGetIssues(ctx context.Context, project string, ids []string) ([]*mpb.Issue, error)
BatchGetIssues gets the details of the specified monorail issues. At most <monorailPageSize> issues can be queried at once. It is guaranteed that the i_th issue in the result will match the i_th issue requested. It is valid to request the same issue multiple times in the same request. If an issue does not exist, the issue in the returned slice will be nil.
func (*Client) GetComponentExistsAndActive ¶
func (c *Client) GetComponentExistsAndActive(ctx context.Context, project string, component string) (bool, error)
GetComponentExistsAndActive returns true if the given component exists and is active in monorail.
func (*Client) GetIssue ¶
GetIssue retrieves the details of a monorail issue. Name should follow the format "projects/<projectid>/issues/<issueid>".
func (*Client) ListComments ¶
ListComments lists comments present on the given issue. At most 1000 comments are returned.
func (*Client) MakeIssue ¶
MakeIssue creates the given issue in monorail, adding the specified description.
func (*Client) ModifyIssues ¶
ModifyIssues modifies the given issue.
type FakeIssuesStore ¶
type FakeIssuesStore struct { Issues []*IssueData // Resource names of valid components. // E.g. projects/chromium/componentDefs/Blink>Workers. ComponentNames []string NextID int PriorityFieldName string // The error to return on an attempt to update any issue. // This is an alternative Issues[i].UpdateError for // the case where the issue is not known. UpdateError error }
FakeIssuesSystem stores the state of bugs for a fake implementation of monorail.
func CopyIssuesStore ¶
func CopyIssuesStore(s *FakeIssuesStore) *FakeIssuesStore
CopyIssuesStore performs a deep copy of the given FakeIssuesStore.
type IssueData ¶
type IssueData struct { Issue *mpb.Issue Comments []*mpb.Comment // NotifyCount is the number of times a notification has been generated // for the issue. NotifyCount int // The error that should be returned if an attempt is made to modify the // issue, if any. UpdateError error }
IssueData is a representation of all data stored for an issue, used by FakeIssuesClient.
func CopyIssueData ¶
CopyIssuesStore performs a deep copy of the given IssueData.
func NewIssueData ¶
NewIssueData creates new monorail issue data for testing.
type MakeUpdateOptions ¶
type MakeUpdateOptions struct { // The LUCI Analysis Rule ID. RuleID string // The bug management state. BugManagementState *bugspb.BugManagementState // The issue to update. Issue *mpb.Issue // Indicates whether the rule is managing bug priority or not. // Use the value on the rule; do not yet set it to false if // HasManuallySetPriority is true. IsManagingBugPriority bool // Whether the user has manually taken control of the bug priority. HasManuallySetPriority bool }
type MakeUpdateResult ¶
type MakeUpdateResult struct {
// contains filtered or unexported fields
}
MakeUpdateResult is the result of MakePriorityOrVerifiedUpdate.
type RequestGenerator ¶
type RequestGenerator struct {
// contains filtered or unexported fields
}
RequestGenerator provides access to methods to generate a new bug and/or bug updates for a cluster.
func NewGenerator ¶
func NewGenerator(uiBaseURL, project string, projectCfg *configpb.ProjectConfig) (*RequestGenerator, error)
NewGenerator initialises a new Generator.
func (*RequestGenerator) IssuePriority ¶
func (rg *RequestGenerator) IssuePriority(issue *mpb.Issue) (configpb.BuganizerPriority, error)
IssuePriority returns the priority of the given issue.
func (*RequestGenerator) MakePriorityOrVerifiedUpdate ¶
func (rg *RequestGenerator) MakePriorityOrVerifiedUpdate(options MakeUpdateOptions) (MakeUpdateResult, error)
MakePriorityOrVerifiedUpdate prepares an update for the bug with the given bug management state. **Must** ONLY be called if NeedsPriorityOrVerifiedUpdate(...) returns true.
func (*RequestGenerator) NeedsPriorityOrVerifiedUpdate ¶
func (rg *RequestGenerator) NeedsPriorityOrVerifiedUpdate(bms *bugspb.BugManagementState, issue *mpb.Issue, isManagingBugPriority bool) (bool, error)
NeedsPriorityOrVerifiedUpdate returns whether the bug priority and/or verified status needs to be updated.
func (*RequestGenerator) PrepareNew ¶
func (rg *RequestGenerator) PrepareNew(ruleID string, activePolicyIDs map[bugs.PolicyID]struct{}, description *clustering.ClusterDescription, components []string) (*mpb.MakeIssueRequest, error)
func (*RequestGenerator) PreparePolicyActivatedComment ¶
func (rg *RequestGenerator) PreparePolicyActivatedComment(ruleID, bugID string, policyID bugs.PolicyID) (*mpb.ModifyIssuesRequest, error)
PreparePolicyActivatedComment prepares a request that notifies a bug that a policy has activated for the first time. This method returns nil if the policy has not specified any comment to post.
func (*RequestGenerator) PrepareRuleAssociatedComment ¶
func (rg *RequestGenerator) PrepareRuleAssociatedComment(ruleID, bugID string) (*mpb.ModifyIssuesRequest, error)
PrepareRuleAssociatedComment prepares a request that notifies the bug it is associated with failures in LUCI Analysis.
func (*RequestGenerator) SortPolicyIDsByPriorityDescending ¶
func (rg *RequestGenerator) SortPolicyIDsByPriorityDescending(policyIDs map[bugs.PolicyID]struct{}) []bugs.PolicyID
SortPolicyIDsByPriorityDescending sorts policy IDs in descending priority order (i.e. P0 policies first, then P1, then P2, ...).
func (*RequestGenerator) UpdateDuplicateSource ¶
func (rg *RequestGenerator) UpdateDuplicateSource(bugID, errorMessage, sourceRuleID, destinationRuleID string) (*mpb.ModifyIssuesRequest, error)
UpdateDuplicateSource updates the source bug of a (source, destination) duplicate bug pair, after LUCI Analysis has attempted to merge their failure association rules.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package migration handles migration rules from monorail to buganizer.
|
Package migration handles migration rules from monorail to buganizer. |
proto
Package migrationpb contains RPC definitions for the monorail migration service.
|
Package migrationpb contains RPC definitions for the monorail migration service. |