Documentation
¶
Overview ¶
Package gitlab implements the provider protocol and Git credential transport.
Index ¶
- Variables
- func CanonicalBase(raw string) (string, error)
- func RepositoryURL(base, raw string) (location, projectPath string, err error)
- type Client
- func (g *Client) AccountID(ctx context.Context) (int64, error)
- func (g *Client) ArchiveProject(ctx context.Context, id int64) error
- func (g *Client) ArchiveRename(ctx context.Context, pathNS, newPath string) error
- func (g *Client) AskpassEnv(dataDir string) ([]string, error)
- func (g *Client) BaseURL() string
- func (g *Client) BranchHead(ctx context.Context, projectPath, branch string) (string, error)
- func (g *Client) CreateMR(ctx context.Context, projectPath, source, target, title, description string) (*MergeRequest, error)
- func (g *Client) CreateProject(ctx context.Context, name string, namespaceID int) (cloneURL, pathNS string, err error)
- func (g *Client) CreateRepository(ctx context.Context, name string, namespaceID int, association string) (ProjectRef, error)
- func (g *Client) Do(ctx context.Context, method, path string, body any, out any) error
- func (g *Client) DoContext(ctx context.Context, method, path string, body any, out any) error
- func (g *Client) GetMR(ctx context.Context, projectPath string, iid int) (*MergeRequest, error)
- func (g *Client) MergeMR(ctx context.Context, projectPath string, iid int, sha, message string) error
- func (g *Client) MergeSettings(ctx context.Context, projectPath string) (MergeSettings, error)
- func (g *Client) Project(ctx context.Context, ref string) (ProjectRef, error)
- func (g *Client) Raw(ctx context.Context, method, path string, body any) (int, []byte, error)
- func (g *Client) RenameProject(ctx context.Context, id int64, newPath string) error
- func (g *Client) UpdateMRDescription(ctx context.Context, projectPath string, iid int, description string) error
- type HTTPError
- type MergeRequest
- type MergeSettings
- type ProjectRef
Constants ¶
This section is empty.
Variables ¶
var ErrNotConfigured = errors.New("GitLab not configured")
ErrNotConfigured: no GitLab connection is set up on this AppTown. That is an ordinary state (an AppTown may keep code only on itself), so callers can tell it apart from a GitLab that is set up but failing.
Functions ¶
func CanonicalBase ¶
CanonicalBase is the credential-free provider namespace used in durable repository identity. Ambiguous addresses are refused, not normalized across hosts, protocols or reverse-proxy mount points.
func RepositoryURL ¶
RepositoryURL checks a clone URL against the exact provider namespace and returns its credential-free location and relative project path. A username is transport metadata; a password is never accepted or retained.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func (*Client) AccountID ¶
AccountID observes the authenticated account using this client's credential snapshot. It must not be followed by resolving a different credential for the effect it admits.
func (*Client) ArchiveProject ¶
ArchiveProject makes a project read-only. Unlike ArchiveRename, a refusal is returned: the token needs Owner on the project to archive it.
func (*Client) ArchiveRename ¶
ArchiveRename frees the original path and archives the renamed remote. Archive failure is logged after a successful rename.
func (*Client) AskpassEnv ¶
AskpassEnv keeps the token out of Git configuration. The helper is published atomically so concurrent projects never observe a partial script.
func (*Client) BranchHead ¶
BranchHead is the commit a project's branch points at.
func (*Client) CreateProject ¶
func (g *Client) CreateProject(ctx context.Context, name string, namespaceID int) (cloneURL, pathNS string, err error)
CreateProject creates a private project and returns its clone URL and path.
func (*Client) CreateRepository ¶
func (g *Client) CreateRepository(ctx context.Context, name string, namespaceID int, association string) (ProjectRef, error)
CreateRepository returns the provider identity as well as its observed location.
func (*Client) MergeMR ¶
func (g *Client) MergeMR(ctx context.Context, projectPath string, iid int, sha, message string) error
MergeMR merges a merge request only if its head is sha, never squashed.
func (*Client) MergeSettings ¶
func (*Client) Raw ¶
Raw sends JSON to an API-relative path and returns the complete bounded response. It honors ctx without detaching cancellation. Status remains available if reading fails; an incomplete response does not establish the outcome of a provider write.
func (*Client) RenameProject ¶
RenameProject moves a project, addressed by its permanent id, to newPath within its namespace.
func (*Client) UpdateMRDescription ¶
func (g *Client) UpdateMRDescription(ctx context.Context, projectPath string, iid int, description string) error
UpdateMRDescription replaces a merge request's whole description. GitLab runs quick actions found in a saved description as this token's owner, so a caller sends only text it has made inert.
type HTTPError ¶
Do is DoContext for AppTown's own calls. A write, once sent, is answered though ctx has ended: GitLab makes the change either way, and AppTown must hear which (a project's id, a token). HTTPError is GitLab's answer with a failing status, so a caller can tell "not there" (404) from a refusal or an outage.
type MergeRequest ¶
type MergeRequest struct {
IID int `json:"iid"`
WebURL string `json:"web_url"`
State string `json:"state"`
SHA string `json:"sha"`
MergeCommitSHA string `json:"merge_commit_sha"`
SquashCommitSHA string `json:"squash_commit_sha"`
SourceBranch string `json:"source_branch"`
TargetBranch string `json:"target_branch"`
// Squash: the request squashes its commits when merged.
Squash bool `json:"squash"`
}
type MergeSettings ¶
type MergeSettings struct {
MergeMethod string `json:"merge_method"`
SquashOption string `json:"squash_option"`
// AutomaticRebase: GitLab rebases the source onto the target itself
// before merging, landing commits other than the source's. Nil when the
// project does not say.
AutomaticRebase *bool `json:"automatic_rebase_enabled"`
}
MergeSettings is how a GitLab project merges: its merge method ("merge", "rebase_merge" for semi-linear history, or "ff"), its squash option ("never", "always", "default_on" or "default_off"), and whether it rebases automatically before merging.
type ProjectRef ¶
type ProjectRef struct {
DefaultBranch string `json:"default_branch"`
Description string `json:"description"`
CreatorID int64 `json:"creator_id"`
ID int64 `json:"id"`
HTTPURL string `json:"http_url_to_repo"`
SSHURL string `json:"ssh_url_to_repo"`
PathNS string `json:"path_with_namespace"`
Archived bool `json:"archived"`
}
ProjectRef is a GitLab project's permanent id, current path and archive state.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package gitlabtest is a fake GitLab for tests of code that reaches GitLab through internal/gitlab.
|
Package gitlabtest is a fake GitLab for tests of code that reaches GitLab through internal/gitlab. |