Documentation
¶
Overview ¶
Package linear is the two-way Linear integration: outbound, an approved execution plan becomes one Linear issue per task under a parent issue per initiative, kept in sync as tasks and change sets move; inbound, a poll for issues carrying a label turns each into an initiative.
Polling rather than webhooks for the same reason Slack uses Socket Mode: the daemon is loopback-only and a webhook needs a public URL.
Index ¶
- Constants
- type CheckResult
- type Client
- func (c *Client) Comment(ctx context.Context, issueID, body string) error
- func (c *Client) CreateIssue(ctx context.Context, in IssueInput) (*Issue, error)
- func (c *Client) IssuesByID(ctx context.Context, ids []string) ([]Issue, error)
- func (c *Client) LabelExists(ctx context.Context, name string) (bool, error)
- func (c *Client) LabeledIssues(ctx context.Context, teamKey, label string) ([]Issue, error)
- func (c *Client) ProjectByName(ctx context.Context, name string) (string, error)
- func (c *Client) SetIssueState(ctx context.Context, issueID, stateID string) error
- func (c *Client) TeamByKey(ctx context.Context, key string) (*Team, error)
- func (c *Client) Viewer(ctx context.Context) (string, error)
- type Issue
- type IssueInput
- type PollRecord
- type PollState
- type State
- type Syncer
- func (s *Syncer) Check(ctx context.Context) (CheckResult, error)
- func (s *Syncer) Deliver(ctx context.Context, ev integrations.Event) error
- func (s *Syncer) Name() string
- func (s *Syncer) Poll(ctx context.Context) error
- func (s *Syncer) PollNow()
- func (s *Syncer) PollState() PollState
- func (s *Syncer) RunPoller(ctx context.Context)
- func (s *Syncer) SyncPlan(ctx context.Context, initiativeID string) error
- func (s *Syncer) Wants(ev integrations.Event) bool
- type Team
- type WhyStep
Constants ¶
const ( // LinkInitiative: local = initiative id, remote = its parent issue (an // issue we created, or the labeled issue the initiative came FROM). LinkInitiative = "initiative" // LinkTask: local = task id, remote = the task's issue. LinkTask = "task" // LinkInboundRejected: local = remote = a labeled issue the daemon // refused to import (e.g. it contained a credential), so it is not // retried -- and not commented on -- every poll. LinkInboundRejected = "inbound_rejected" )
Link kinds in integration_links.
const DefaultEndpoint = "https://api.linear.app/graphql"
DefaultEndpoint is Linear's GraphQL API.
const SubscriberName = "linear"
SubscriberName keys Linear's outbox rows, cursor and links.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CheckResult ¶
type CheckResult struct {
User string `json:"user"`
Team string `json:"team"`
Project string `json:"project,omitempty"`
LabelExists bool `json:"label_exists"`
Label string `json:"label"`
}
CheckResult is what `idea integrations test linear` reports.
type Client ¶
Client is a minimal Linear GraphQL client over net/http: a handful of typed queries, no generated SDK.
func (*Client) CreateIssue ¶
CreateIssue creates an issue.
func (*Client) IssuesByID ¶
IssuesByID fetches the current state of up to 50 issues.
func (*Client) LabelExists ¶
LabelExists reports whether an issue label with this name exists.
func (*Client) LabeledIssues ¶
LabeledIssues lists a team's issues carrying label (case-insensitive), oldest first, at most 50 per poll -- a backlog drains over a few polls instead of one expensive query.
func (*Client) ProjectByName ¶
ProjectByName resolves a project name to its id.
func (*Client) SetIssueState ¶
SetIssueState moves an issue to a workflow state.
type Issue ¶
type Issue struct {
ID string `json:"id"`
Identifier string `json:"identifier"`
Title string `json:"title"`
Description string `json:"description"`
URL string `json:"url"`
State State `json:"state"`
}
Issue is the slice of a Linear issue this integration reads.
type IssueInput ¶
type IssueInput struct {
TeamID string `json:"teamId"`
Title string `json:"title"`
Description string `json:"description,omitempty"`
ParentID string `json:"parentId,omitempty"`
ProjectID string `json:"projectId,omitempty"`
StateID string `json:"stateId,omitempty"`
}
IssueInput is issueCreate's input, trimmed to what is used.
type PollRecord ¶
PollRecord is one poll, as OnPoll reports it.
type PollState ¶
type PollState struct {
LastPollAt *time.Time `json:"last_poll_at,omitempty"`
LastError string `json:"last_error,omitempty"`
}
PollState is the poller's health, for `idea integrations status`.
type State ¶
type State struct {
ID string `json:"id"`
Name string `json:"name"`
// Type is Linear's category: triage, backlog, unstarted, started,
// completed, canceled.
Type string `json:"type"`
}
State is a team workflow state.
type Syncer ¶
type Syncer struct {
ProjectID string
Cfg config.LinearConfig
Client *Client
DB *store.DB
Actions integrations.Actions
// Why returns a task's provenance chain. Optional.
Why func(ctx context.Context, initiativeID, taskID string) ([]WhyStep, error)
// Redact scrubs known secrets from outbound text (issue bodies, comments).
Redact func(string) string
Log *slog.Logger
// OnPoll, when set, is told about every poll the poller runs: when it
// started and finished, how many issues it imported, whether a person
// asked for it (PollNow), and its error. The daemon keeps the ones worth
// keeping as Automations history.
OnPoll func(PollRecord)
// contains filtered or unexported fields
}
Syncer is the Linear integration for one project: a bus Subscriber (outbound) and a poller (inbound).
func (*Syncer) Check ¶
func (s *Syncer) Check(ctx context.Context) (CheckResult, error)
Check validates the key, the team, the project, the state mapping and the inbound label, writing nothing.
func (*Syncer) Poll ¶
Poll runs one inbound pass: import newly labeled issues, then reflect Linear-side cancellations of linked issues as notes.
func (*Syncer) PollNow ¶
func (s *Syncer) PollNow()
PollNow asks a running poller to poll at once instead of waiting out its interval ("Run now" in the Automations view). A no-op when one is already pending.
func (*Syncer) RunPoller ¶
RunPoller polls every poll_interval_seconds until ctx is cancelled, waiting out a rate limit's reset when Linear reports one.
func (*Syncer) SyncPlan ¶
SyncPlan creates the initiative's parent issue (unless it has one) and one issue per task that has none. Idempotent: every issue is linked the moment it exists, so a retry after a partial failure creates only what is still missing, and a re-approved plan picks up tasks a revision added.