Documentation
¶
Overview ¶
Package tracker is the interface every issue tracker implements: Linear, Jira Cloud and Asana. A ticket there starts a session on a code repository, and the result is posted back to the ticket.
Everything a ticket holds (its title, description and comments) and every name on it is data written by people: the core puts it inside the untrusted fence, never into a model's instructions.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrBadSignature is returned by ParseWebhook for a delivery whose // signature does not verify, or that is too old to be fresh. ErrBadSignature = errors.New("tracker: webhook signature does not verify") // ErrIgnored is returned by ParseWebhook for a delivery kōjō has no use // for: a heartbeat, an event type it does not handle, its own comment. ErrIgnored = errors.New("tracker: event ignored") // ErrNotFound is a ticket the tracker does not know, or that kōjō's // account cannot see. ErrNotFound = errors.New("tracker: not found") )
Errors a tracker returns for the cases the core handles.
Functions ¶
Types ¶
type Comment ¶
type Comment struct {
ID string `json:"id"`
Author Person `json:"author"`
Body string `json:"body"`
CreatedAt time.Time `json:"created_at"`
}
Comment is a comment on a ticket.
type Delivery ¶
type Delivery struct {
Events []Event
// Reply holds headers to set on the answer (Asana's handshake echoes
// X-Hook-Secret).
Reply http.Header
}
Delivery is one verified webhook request: the events it carries, and the headers its answer must carry.
type Event ¶
type Event struct {
Kind EventKind `json:"kind"`
TicketID string `json:"ticket_id"`
// Actor is who assigned the ticket, added the label or wrote the
// comment.
Actor Person `json:"actor"`
// CommentID, Text and URL are the comment of an EventMentioned.
CommentID string `json:"comment_id,omitempty"`
Text string `json:"text,omitempty"`
URL string `json:"url,omitempty"`
// Label is the label of an EventLabeled.
Label string `json:"label,omitempty"`
// DeliveryID names the change, so the same change delivered twice is
// handled once.
DeliveryID string `json:"delivery_id"`
}
Event is one change on a tracker that is addressed to kōjō.
type EventKind ¶
type EventKind string
EventKind is what happened to a ticket.
const ( // EventAssigned is a ticket assigned to kōjō's account, or created // with kōjō as its assignee. EventAssigned EventKind = "assigned" // EventMentioned is a comment that mentions kōjō's account. Text holds // the comment. EventMentioned EventKind = "mentioned" // EventLabeled is one of the labels kojo.yaml names (labels) added to // a ticket, or a ticket created with one. EventLabeled EventKind = "labeled" )
Event kinds kōjō acts on.
type Person ¶
type Person struct {
// ID is the tracker's ID of the account.
ID string `json:"id"`
Name string `json:"name,omitempty"`
// Email is an address the adapter vouches for: the one kojo.yaml maps
// the account to (users), or, on a tracker whose addresses are
// verified (Linear), the one the tracker reports. Empty otherwise: the
// person then has no role in kōjō, and their requests are read-only.
Email string `json:"email,omitempty"`
}
Person is someone on the tracker.
type Ticket ¶
type Ticket struct {
// Tracker is linear, jira or asana.
Tracker string `json:"tracker"`
// ID is the tracker's own ID.
ID string `json:"id"`
// Key is the ticket's key (ENG-123, PAY-7). Asana tasks have none.
Key string `json:"key,omitempty"`
URL string `json:"url,omitempty"`
// Title, Description and the comments' bodies are what people wrote,
// as Markdown or plain text.
Title string `json:"title"`
Description string `json:"description,omitempty"`
// Team is the Linear team's key. Empty on the other trackers.
Team string `json:"team,omitempty"`
// Projects are the projects the ticket belongs to, as the repos
// object names them (tickets): a Linear project's name and ID, the
// Jira project's key, Asana project IDs.
Projects []string `json:"projects,omitempty"`
// Labels are its labels (Asana: tags).
Labels []string `json:"labels,omitempty"`
// Status is its workflow state (Asana: the section it is in).
Status string `json:"status,omitempty"`
Comments []Comment `json:"comments,omitempty"`
}
Ticket is an issue (Linear, Jira) or a task (Asana).
type Tracker ¶
type Tracker interface {
// Name is linear, jira or asana.
Name() string
// ParseWebhook verifies and decodes one webhook delivery. It returns
// ErrBadSignature for a delivery that does not verify and ErrIgnored
// for one with nothing for kōjō.
ParseWebhook(r *http.Request, body []byte) (*Delivery, error)
// GetTicket reads a ticket with its comments.
GetTicket(ctx context.Context, id string) (*Ticket, error)
// Comment posts text (Markdown) on a ticket, in the tracker's own
// format, and returns the comment's URL when the tracker gives one.
Comment(ctx context.Context, id, text string) (string, error)
// Move sets a ticket's status to the one kojo.yaml names for stage
// (status), and does nothing when it names none, which is the
// default. A ticket already in that status is left as it is.
Move(ctx context.Context, id string, stage Stage) error
// Check verifies the credentials work. It is what kojo doctor runs.
Check(ctx context.Context) error
}
Tracker is one configured issue tracker.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package trackertest is an in-memory issue tracker for the core's tests, as forgetest is for forges.
|
Package trackertest is an in-memory issue tracker for the core's tests, as forgetest is for forges. |