Documentation
¶
Overview ¶
Package tracker reads and updates tickets in the trackers teams use besides GitHub issues — Linear and Jira Cloud — so a task can start from one and its branch and pull request can be linked back to it. Each is reached over its own HTTP API with a personal key; nothing here runs a program or keeps state.
Index ¶
- Constants
- Variables
- func CheckRef(ref string) (tracker, key string, err error)
- func Choose(cfg config.TrackersCfg, project, root, ref string, look Lookup) (name, scope string, err error)
- func Configured(cfg config.TrackersCfg, look Lookup) []string
- func KeyFrom(name string, cfg config.TrackersCfg, inEnv func(string) bool) string
- func ParseRef(ref string) (tracker, key string, err error)
- func Scope(cfg config.TrackersCfg, project, root, name string) string
- func Title(name string) string
- func ValidKey(key string) bool
- type Account
- type Area
- type Checker
- type Comment
- type Link
- type ListOptions
- type Lookup
- type Ticket
- type Tracker
Constants ¶
const ( LinearKeyEnv = "LINEAR_API_KEY" JiraTokenEnv = "JIRA_API_TOKEN" )
The variables a key is read from when config.toml names none.
const ( Linear = "linear" Jira = "jira" )
Trackers conch has code for.
const LinearAPI = "https://api.linear.app/graphql"
LinearAPI is Linear's GraphQL endpoint.
Variables ¶
var ErrNotFound = errors.New("no such ticket")
ErrNotFound is a ticket the tracker has not got, or will not show.
var Names = []string{Linear, Jira}
Names are the trackers, in the order a choice between them is offered.
Functions ¶
func CheckRef ¶
CheckRef is ParseRef for a command that hands the ticket to a server which may know more trackers than conch has code for: a tickets integration's NAME:KEY (shortcut:123), or a key alone (123) for a project tied to one, is taken as given and left to the server to make sense of. What is no ticket of anybody's is still refused here.
func Choose ¶
func Choose(cfg config.TrackersCfg, project, root, ref string, look Lookup) (name, scope string, err error)
Choose says which tracker a project's tickets come from, and the team or project in it: what ref names (linear:ENG-1, an address), else the project's [[trackers.projects]] entry, else the one tracker set up. ref may be "" when listing.
func Configured ¶
func Configured(cfg config.TrackersCfg, look Lookup) []string
Configured are the trackers cfg has enough of to reach: a key for Linear, a site for Jira (whose email and token are asked for when it is opened, so a half-set Jira says what it lacks rather than vanishing).
func KeyFrom ¶
KeyFrom says where a tracker's key is read from — config.toml, a variable, or the Keychain — never the key itself. inEnv says whether a variable is set in this process's environment.
func ParseRef ¶
ParseRef reads a ticket as somebody would give it: its key (ENG-123), its key after the tracker's name (linear:ENG-123), or its address in the tracker. tracker is "" when nothing in ref says which — Linear's keys and Jira's look alike — and key is upper case.
Types ¶
type Account ¶
type Account struct {
Who string `json:"who,omitempty"`
Email string `json:"email,omitempty"`
Workspace string `json:"workspace,omitempty"`
Scopes []Area `json:"scopes,omitempty"`
}
Account is who a tracker's key belongs to and what it can see: what Settings shows to say a key works before anything is asked of it.
type ListOptions ¶
type ListOptions struct {
// Scope is the Linear team's key or the Jira project's key; "" is
// every one the key can see.
Scope string
// Assigned keeps only the tickets assigned to the key's own person.
Assigned bool
// Limit is how many, newest first; 0 is 30.
Limit int
}
ListOptions narrow a list of tickets.
type Lookup ¶
Lookup reads a variable's value: the environment, then wherever else the caller keeps secrets (a server on a Mac, the Keychain). "" is none.
type Ticket ¶
type Ticket struct {
Tracker string `json:"tracker"`
Key string `json:"key"`
Title string `json:"title"`
Body string `json:"body,omitempty"`
URL string `json:"url,omitempty"`
Status string `json:"status,omitempty"`
Comments []Comment `json:"comments,omitempty"`
Links []Link `json:"links,omitempty"`
}
Ticket is a ticket, as much of it as a task needs.
type Tracker ¶
type Tracker interface {
Name() string
// List is the open tickets, most recently changed first.
List(ctx context.Context, opt ListOptions) ([]Ticket, error)
// Get reads one ticket, with its comments and links.
Get(ctx context.Context, key string) (Ticket, error)
// Comment adds a comment.
Comment(ctx context.Context, key, body string) error
// SetStatus moves the ticket to the status named (In Review, Done),
// matched without regard to case, and says the status it is now in.
SetStatus(ctx context.Context, key, status string) (string, error)
// Link attaches a link — a branch, a pull request — to the ticket.
Link(ctx context.Context, key, url, title string) error
}
Tracker is one tracker conch has code for.
func NewJira ¶
NewJira is the Jira Cloud site (https://acme.atlassian.net), reached as email with the token.