Documentation ¶
Overview ¶
Package annotations defines a data model for a feature that allows users to add metadata to tasks.
Index ¶
- Constants
- Variables
- func AddCreatedTicket(taskId string, execution int, ticket IssueLink, userDisplayName string) error
- func AddSuspectedIssueToAnnotation(taskId string, execution int, issue IssueLink, username string) 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(taskId string, execution int, issue IssueLink) error
- func SetAnnotationMetadataLinks(ctx context.Context, taskId string, execution int, username string, ...) error
- func UpdateAnnotationNote(taskId string, execution int, originalMessage, newMessage, username string) error
- func ValidateMetadataLinks(links ...MetadataLink) error
- type IssueLink
- type MetadataLink
- type Note
- type Source
- type TaskAnnotation
- func Find(query db.Q) ([]TaskAnnotation, error)
- func FindByTaskId(id string) ([]TaskAnnotation, error)
- func FindByTaskIds(ids []string) ([]TaskAnnotation, error)
- func FindOne(query db.Q) (*TaskAnnotation, error)
- func FindOneByTaskIdAndExecution(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 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 Find ¶
func Find(query db.Q) ([]TaskAnnotation, error)
Find gets every TaskAnnotation matching the given query.
func FindByTaskId ¶
func FindByTaskId(id string) ([]TaskAnnotation, error)
func FindByTaskIds ¶
func FindByTaskIds(ids []string) ([]TaskAnnotation, error)
func FindOne ¶
func FindOne(query db.Q) (*TaskAnnotation, error)
FindOne gets one TaskAnnotation for the given query.
func FindOneByTaskIdAndExecution ¶
func FindOneByTaskIdAndExecution(id string, execution int) (*TaskAnnotation, error)
func GetLatestExecutions ¶
func GetLatestExecutions(annotations []TaskAnnotation) []TaskAnnotation
GetLatestExecutions returns only the latest execution for each task, and filters out earlier executions
func (*TaskAnnotation) Upsert ¶
func (a *TaskAnnotation) Upsert() error
Upsert writes the task_annotation to the database.
type TaskUpdate ¶
type TaskUpdate struct { TaskData []TaskData `bson:"task_data" json:"task_data"` Annotation TaskAnnotation `bson:"annotation" json:"annotation"` }