tracker

package
v0.6.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 27, 2026 License: MIT Imports: 14 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
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.

View Source
const MaxSearch = 50

MaxSearch caps the tickets one search returns.

Variables

View Source
var ErrNotConfigured = errors.New("tracker: not configured")

ErrNotConfigured means the vault has no fetchable tracker, or no credentials are set.

View Source
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.

func (*Jira) Issue

func (j *Jira) Issue(ctx context.Context, key string) (*Issue, error)

Issue fetches one ticket, cached for a minute.

func (*Jira) Search added in v0.5.0

func (j *Jira) Search(ctx context.Context, jql string, limit int) ([]Issue, error)

Search runs a JQL query: /rest/api/3/search/jql on Jira Cloud, /rest/api/2/search on Data Center.

type Project added in v0.2.0

type Project struct {
	Key  string `json:"key"`
	Name string `json:"name"`
}

Project is a Jira project this machine's credentials can see.

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.

func New

func New(cfg *config.Config, env func(string) string) (Tracker, error)

New returns the tracker the config describes, with credentials from env (os.Getenv in production). It returns ErrNotConfigured, with a reason, when the vault has no Jira tracker or no token is set.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL