Help us shape the future of Go! Take the 2026 Go Developer Survey

forge

package
v1.11.0 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package forge is what the hosted-service plugins (gitlab, github, jira, confluence, slack) share: their config, token and JSON calls.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Config

func Config(c *sdk.Ctx, key string) string

Config reads a string key of the plugin's config.

func Connect added in v1.11.0

func Connect(p *sdk.Plugin, prefix, scope string, check func(*sdk.Ctx) (string, error))

Connect registers connect, disconnect and connection: a form that keeps a service's account in the plugin's secrets PREFIX_URL, _USER, _TOKEN and _<SCOPE>, which the manifest must declare. check proves the account works and says who it is.

func IssueOf

func IssueOf(title, branch string) string

IssueOf is the first tracker key in the MR's title, else its source branch (pin-12-fix reads PIN-12).

func Lines

func Lines(c *sdk.Ctx, ls []string)

Lines sends a run's text to its output.

func RegisterSCM

func RegisterSCM(p *sdk.Plugin, open func(*sdk.Ctx) (SCM, error), affected Affected)

RegisterSCM serves scm/1 and tracker/1 from a forge opened per call.

func Repo

func Repo(c *sdk.Ctx, defaultHost string) (host, project string, err error)

Repo is a forge's web host and project path: config `url` and `project`, else the origin remote.

func Secret

func Secret(c *sdk.Ctx, secrets ...string) string

Secret is the first of the secrets rig has a value for, else the same names in the environment.

func Setting added in v1.11.0

func Setting(c *sdk.Ctx, prefix, key string) string

Setting is config key, else the secret <PREFIX>_<KEY> a connect form stored.

func Token

func Token(c *sdk.Ctx, secrets ...string) string

Token is config `token`, else the first of the secrets rig has a value for, else the same names in the environment.

Types

type Account added in v1.11.0

type Account struct {
	URL   string `json:"url" title:"Address" rig:"required" desc:"https://your-org.atlassian.net"`
	User  string `json:"user" title:"Email or user" desc:"Cloud: the account email; empty for a Server personal token"`
	Token string `json:"token" title:"API token" format:"password" desc:"empty keeps the stored one"`
	Scope string `json:"scope" title:"Project or space key"`
}

Account is what a connect form asks of a hosted service; Scope is its project or space key.

type Affected

type Affected func(ctx context.Context, files []string) ([]string, error)

Affected names the project's services that files touch (the core engine knows); nil when unknown.

type Client

type Client struct {
	Base string
	// Project is the repository path (group/app) for a forge, from config or the origin remote.
	Project string
	// Host is the service's web host, for links.
	Host string
	httpx.Endpoint
}

Client is one service's API at Base, authenticated.

func (*Client) Get

func (c *Client) Get(ctx context.Context, path string, out any) error

func (*Client) Send

func (c *Client) Send(ctx context.Context, method, path string, body, out any) error

func (*Client) Text

func (c *Client) Text(ctx context.Context, path string) ([]string, error)

Text is a plain-text answer (a job log), as lines.

type Comment

type Comment struct {
	Author string    `json:"author"`
	Time   time.Time `json:"time"`
	Body   string    `json:"body"`
}

type File

type File struct {
	Path    string `json:"path"`
	Status  string `json:"status"`
	Patch   string `json:"-"`
	Changed int    `json:"changed"`
}

type Issue

type Issue struct {
	Key      string    `json:"key"`
	Title    string    `json:"title"`
	Status   string    `json:"status"`
	Assignee string    `json:"assignee"`
	Priority string    `json:"priority"`
	Type     string    `json:"type"`
	Updated  time.Time `json:"updated"`
	URL      string    `json:"url"`
}

type IssueDetail

type IssueDetail struct {
	Key         string    `json:"key"`
	Title       string    `json:"title"`
	Status      string    `json:"status"`
	Assignee    string    `json:"assignee"`
	Description string    `json:"description"`
	Comments    []Comment `json:"comments"`
	URL         string    `json:"url"`
	// Markdown is the whole issue as one page, for a preview pane
	Markdown string `json:"markdown"`
}

func (*IssueDetail) Render

func (d *IssueDetail) Render() *IssueDetail

Render fills Markdown from the other fields.

type Job

type Job struct {
	ID       string        `json:"id"`
	Name     string        `json:"name"`
	Stage    string        `json:"stage"`
	Status   string        `json:"status"`
	Duration time.Duration `json:"duration"`
}

type MR

type MR struct {
	ID    string `json:"id"`
	Title string `json:"title"`
	// Issue is the tracker key (PIN-12) the title or branch names, to jump between the two
	Issue  string `json:"issue"`
	Author string `json:"author"`
	State  string `json:"state"`
	// Merge says whether it can merge: draft, conflicts, blocked by threads or checks
	Merge   string    `json:"merge"`
	Notes   int       `json:"notes"`
	Source  string    `json:"source"`
	Target  string    `json:"target"`
	Updated time.Time `json:"updated"`
	URL     string    `json:"url"`
}

type Pipeline

type Pipeline struct {
	ID       string        `json:"id"`
	Ref      string        `json:"ref"`
	Status   string        `json:"status"`
	Started  time.Time     `json:"started"`
	Duration time.Duration `json:"duration"`
	URL      string        `json:"url"`
}

type Release

type Release struct {
	Tag      string    `json:"tag"`
	Name     string    `json:"name"`
	Released time.Time `json:"released"`
	URL      string    `json:"url"`
}

type SCM

type SCM interface {
	// MRs lists merge requests: author "me" keeps those you opened, "review" those you review; query matches title and branch.
	MRs(ctx context.Context, state, author, query string) ([]MR, error)
	// MR is one merge request as a page: description, approvals, discussions and the files it changes.
	MR(ctx context.Context, mr string) (string, error)
	Rebase(ctx context.Context, mr string) error
	Files(ctx context.Context, mr string) ([]File, error)
	Approve(ctx context.Context, mr string) error
	Merge(ctx context.Context, mr string) error
	Comment(ctx context.Context, mr, body string) error
	// Open opens a merge request from source into target (the default branch when empty).
	Open(ctx context.Context, source, target, title, body string) (*MR, error)
	Pipelines(ctx context.Context, ref string, limit int) ([]Pipeline, error)
	Jobs(ctx context.Context, pipeline string) ([]Job, error)
	// Log is a job's output so far and whether the job has finished.
	Log(ctx context.Context, job string) ([]string, bool, error)
	Retry(ctx context.Context, job string) error
	// Releases is the latest ones, or those whose tag or name match query across all of them.
	Releases(ctx context.Context, query string) ([]Release, error)
	Issues(ctx context.Context, query, assignee string) ([]Issue, error)
	Issue(ctx context.Context, key string) (*IssueDetail, error)
	Transition(ctx context.Context, key, status string) error
	IssueComment(ctx context.Context, key, body string) error
}

SCM is a hosted forge as scm/1 and tracker/1 see it; gitlab and github implement it.

Directories

Path Synopsis
Package forgetest is a canned forge API for adapter tests.
Package forgetest is a canned forge API for adapter tests.

Jump to

Keyboard shortcuts

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