Documentation
¶
Overview ¶
Package annotations defines a data model for a feature that allows users to add metadata to tasks.
Index ¶
- Constants
- Variables
- func AddCreatedTicket(ctx context.Context, taskId string, execution int, ticket IssueLink, ...) error
- func AddSuspectedIssueToAnnotation(ctx context.Context, taskId string, execution int, issue IssueLink, ...) error
- func ByTaskId(id string) bson.M
- func ByTaskIdAndExecution(id string, execution int) bson.M
- func ByTaskIds(ids []string) db.Q
- func CreateAnnotationUpdate(annotation *TaskAnnotation, userDisplayName string) bson.M
- func RemoveSuspectedIssueFromAnnotation(ctx context.Context, taskId string, execution int, issue IssueLink) error
- func SetAnnotationMetadataLinks(ctx context.Context, taskId string, execution int, username string, ...) error
- func UpdateAnnotationNote(ctx context.Context, taskId string, execution int, ...) error
- func ValidateMetadataLinks(links ...MetadataLink) error
- type IssueLink
- type MetadataLink
- type Note
- type Source
- type TaskAnnotation
- func Find(ctx context.Context, query db.Q) ([]TaskAnnotation, error)
- func FindByTaskId(ctx context.Context, id string) ([]TaskAnnotation, error)
- func FindByTaskIds(ctx context.Context, ids []string) ([]TaskAnnotation, error)
- func FindOne(ctx context.Context, query db.Q) (*TaskAnnotation, error)
- func FindOneByTaskIdAndExecution(ctx context.Context, id string, execution int) (*TaskAnnotation, error)
- func GetLatestExecutions(annotations []TaskAnnotation) []TaskAnnotation
- type TaskData
- type TaskUpdate
Constants ¶
const ( Collection = "task_annotations" UIRequester = "ui" APIRequester = "api" WebhookRequester = "webhook" MaxMetadataLinks = 1 MaxMetadataTextLength = 40 )
Variables ¶
var ( // bson fields for the TaskAnnotation struct IdKey = bsonutil.MustHaveTag(TaskAnnotation{}, "Id") TaskIdKey = bsonutil.MustHaveTag(TaskAnnotation{}, "TaskId") TaskExecutionKey = bsonutil.MustHaveTag(TaskAnnotation{}, "TaskExecution") MetadataKey = bsonutil.MustHaveTag(TaskAnnotation{}, "Metadata") NoteKey = bsonutil.MustHaveTag(TaskAnnotation{}, "Note") IssuesKey = bsonutil.MustHaveTag(TaskAnnotation{}, "Issues") SuspectedIssuesKey = bsonutil.MustHaveTag(TaskAnnotation{}, "SuspectedIssues") CreatedIssuesKey = bsonutil.MustHaveTag(TaskAnnotation{}, "CreatedIssues") IssueLinkIssueKey = bsonutil.MustHaveTag(IssueLink{}, "IssueKey") MetadataLinksKey = bsonutil.MustHaveTag(TaskAnnotation{}, "MetadataLinks") )
Functions ¶
func AddCreatedTicket ¶
func ByTaskIdAndExecution ¶
ByTaskIdAndExecution returns the query for a given Task Id and execution number
func CreateAnnotationUpdate ¶
func CreateAnnotationUpdate(annotation *TaskAnnotation, userDisplayName string) bson.M
CreateAnnotationUpdate constructs a DB update to modify an existing task annotation.
func SetAnnotationMetadataLinks ¶
func SetAnnotationMetadataLinks(ctx context.Context, taskId string, execution int, username string, metadataLinks ...MetadataLink) error
SetAnnotationMetadataLinks sets the metadata links for a task annotation.
func UpdateAnnotationNote ¶
func ValidateMetadataLinks ¶
func ValidateMetadataLinks(links ...MetadataLink) error
ValidateMetadataLinks will validate the given metadata links, ensuring that they are valid URLs, that their text is not too long, and that there are not more than MaxMetadataLinks links provided.
Types ¶
type IssueLink ¶
type IssueLink struct {
URL string `bson:"url" json:"url"`
// Text to be displayed
IssueKey string `bson:"issue_key,omitempty" json:"issue_key,omitempty"`
Source *Source `bson:"source,omitempty" json:"source,omitempty"`
// ConfidenceScore is only set for issue suggestions; nil means no score was recorded.
ConfidenceScore *float64 `bson:"confidence_score,omitempty" json:"confidence_score,omitempty"`
}
type MetadataLink ¶
type MetadataLink struct {
// URL to link to
URL string `bson:"url" json:"url"`
// Text to be displayed
Text string `bson:"text" json:"text"`
Source *Source `bson:"source,omitempty" json:"source,omitempty"`
}
MetadataLink represents an arbitrary link to be associated with a task.
type TaskAnnotation ¶
type TaskAnnotation struct {
Id string `bson:"_id" json:"id"`
TaskId string `bson:"task_id" json:"task_id"`
TaskExecution int `bson:"task_execution" json:"task_execution"`
Metadata *birch.Document `bson:"metadata,omitempty" json:"metadata,omitempty"`
// comment about the failure
Note *Note `bson:"note,omitempty" json:"note,omitempty"`
// links to tickets definitely related.
Issues []IssueLink `bson:"issues,omitempty" json:"issues,omitempty"`
// links to tickets possibly related
SuspectedIssues []IssueLink `bson:"suspected_issues,omitempty" json:"suspected_issues,omitempty"`
// links to tickets created from the task using a custom web hook
CreatedIssues []IssueLink `bson:"created_issues,omitempty" json:"created_issues,omitempty"`
// links to be displayed in the UI metadata sidebar
MetadataLinks []MetadataLink `bson:"metadata_links,omitempty" json:"metadata_links,omitempty"`
}
func FindByTaskId ¶
func FindByTaskId(ctx context.Context, id string) ([]TaskAnnotation, error)
func FindByTaskIds ¶
func FindByTaskIds(ctx context.Context, ids []string) ([]TaskAnnotation, error)
func GetLatestExecutions ¶
func GetLatestExecutions(annotations []TaskAnnotation) []TaskAnnotation
GetLatestExecutions returns only the latest execution for each task, and filters out earlier executions
type TaskUpdate ¶
type TaskUpdate struct {
TaskData []TaskData `bson:"task_data" json:"task_data"`
Annotation TaskAnnotation `bson:"annotation" json:"annotation"`
}