Documentation
¶
Overview ¶
Package forge is what the hosted-service plugins (gitlab, github, jira, confluence, slack) share: their config, token and JSON calls.
Index ¶
- func Config(c *sdk.Ctx, key string) string
- func Connect(p *sdk.Plugin, prefix, scope string, check func(*sdk.Ctx) (string, error))
- func IssueOf(title, branch string) string
- func Lines(c *sdk.Ctx, ls []string)
- func RegisterSCM(p *sdk.Plugin, open func(*sdk.Ctx) (SCM, error), affected Affected)
- func Repo(c *sdk.Ctx, defaultHost string) (host, project string, err error)
- func Secret(c *sdk.Ctx, secrets ...string) string
- func Setting(c *sdk.Ctx, prefix, key string) string
- func Token(c *sdk.Ctx, secrets ...string) string
- type Account
- type Affected
- type Client
- type Comment
- type File
- type Issue
- type IssueDetail
- type Job
- type MR
- type Pipeline
- type Release
- type SCM
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Connect ¶ added in v1.11.0
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 ¶
IssueOf is the first tracker key in the MR's title, else its source branch (pin-12-fix reads PIN-12).
func RegisterSCM ¶
RegisterSCM serves scm/1 and tracker/1 from a forge opened per call.
func Repo ¶
Repo is a forge's web host and project path: config `url` and `project`, else the origin remote.
func Secret ¶
Secret is 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 ¶
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.
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 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 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.