Documentation
¶
Overview ¶
Package tracker reads tickets from the team's issue tracker (Jira).
It is read-only on purpose: okvault never posts to the tracker on a person's behalf. Credentials come from the environment, never from the vault.
Index ¶
Constants ¶
const ( EnvToken = "JIRA_API_TOKEN" // Cloud API token (with JIRA_EMAIL) or Data Center personal access token EnvEmail = "JIRA_EMAIL" // Cloud account email; when empty the token is sent as a bearer PAT )
Environment variables holding Jira credentials.
const MaxSearch = 50
MaxSearch caps the tickets one search returns.
Variables ¶
var ErrNotConfigured = errors.New("tracker: not configured")
ErrNotConfigured means the vault has no fetchable tracker, or no credentials are set.
var ErrNotFound = errors.New("tracker: ticket not found")
ErrNotFound means the ticket does not exist or the credentials cannot see it.
Functions ¶
func Text ¶
func Text(raw json.RawMessage) string
Text converts a Jira rich-text field to plain text. REST v2 returns a string (wiki markup, kept as is); REST v3 returns an Atlassian Document Format (ADF) tree, which is flattened.
Types ¶
type Check ¶ added in v0.2.0
type Check struct {
URL string `json:"url"`
API string `json:"api"`
Credentials string `json:"credentials"` // e.g. "JIRA_API_TOKEN + JIRA_EMAIL", or "none"
User string `json:"user,omitempty"`
Projects []Project `json:"projects,omitempty"`
Truncated bool `json:"truncated,omitempty"` // more projects than listed
Problem string `json:"problem,omitempty"`
}
Check is what okvault can reach of a Jira site with this machine's credentials. It names where the credentials came from, never their values.
func CheckJira ¶ added in v0.2.0
func CheckJira(ctx context.Context, base, api string, env func(string) string, hc *http.Client) Check
CheckJira signs in to the Jira site at base with the credentials in env and lists its projects. api is "2" or "3"; empty picks 3 on *.atlassian.net and 2 elsewhere, as okvault does. hc nil uses a 15-second client.
type Comment ¶
type Comment struct {
Author string `json:"author"`
Created string `json:"created"`
Body string `json:"body"`
}
Comment is a ticket comment, as plain text.
type Issue ¶
type Issue struct {
Key string `json:"key"`
URL string `json:"url,omitempty"`
Summary string `json:"summary"`
Type string `json:"type,omitempty"`
Status string `json:"status,omitempty"`
Category string `json:"status_category,omitempty"` // To Do, In Progress, Done
Priority string `json:"priority,omitempty"`
Assignee string `json:"assignee,omitempty"`
Reporter string `json:"reporter,omitempty"`
Labels []string `json:"labels,omitempty"`
Parent string `json:"parent,omitempty"`
Updated string `json:"updated,omitempty"`
Description string `json:"description,omitempty"` // plain text, truncated
Comments []Comment `json:"recent_comments,omitempty"`
}
Issue is a compact view of a ticket.
type Jira ¶
type Jira struct {
// contains filtered or unexported fields
}
Jira is a read-only Jira Cloud (REST v3) or Data Center (REST v2) client.
type Tracker ¶
type Tracker interface {
Issue(ctx context.Context, key string) (*Issue, error)
// Search lists the tickets a JQL query matches, compact (no description
// or comments), at most limit (capped at MaxSearch).
Search(ctx context.Context, jql string, limit int) ([]Issue, error)
}
Tracker fetches tickets.