Documentation
¶
Overview ¶
Package client calls a gitd, on its Unix socket or on the network: for programs written in Go, and for gitd's own command line and MCP server.
It speaks the Connect protocol over HTTP/1.1, which the server answers besides gRPC, so a stream of progress needs nothing more than the standard library.
Example ¶
An agent's round trip: a workspace, the agent's work in it with plain git, its commits published as a branch, and the workspace removed. No call takes a credential.
package main
import (
"context"
"fmt"
"github.com/dooservice/gitd/client"
gitdv1 "github.com/dooservice/gitd/gen/go/gitd/v1"
)
func main() {
ctx := context.Background()
gitd, err := client.Open(client.Options{})
if err != nil {
panic(err)
}
path := "/var/lib/gitd/workspaces/agent-1"
workspace, err := gitd.Prepare(ctx, &gitdv1.PrepareRequest{Url: "https://github.com/acme/web", Path: path}, nil)
if reason, said := client.Reason(err); reason != "" {
fmt.Println("refused:", reason, said)
return
}
fmt.Println(path, workspace.GetCommit(), workspace.GetStrategy())
published, err := gitd.Publish(ctx, &gitdv1.PublishRequest{Path: path, Branch: "agents/fix-login"})
if err != nil {
panic(err)
}
fmt.Println(published.GetBranch())
_ = gitd.Remove(ctx, path)
}
Output:
Index ¶
- Constants
- func Reason(err error) (reason, said string)
- type Client
- func (client *Client) AddGitHubApp(ctx context.Context, request *gitdv1.AddGitHubAppRequest) (*gitdv1.AddGitHubAppResponse, error)
- func (client *Client) AddToken(ctx context.Context, request *gitdv1.AddTokenRequest) (*gitdv1.AddTokenResponse, error)
- func (client *Client) Adopt(ctx context.Context, request *gitdv1.AdoptRequest, progress Progress) (*gitdv1.AdoptResult, error)
- func (client *Client) Audit(ctx context.Context, request *gitdv1.AuditRequest) (*gitdv1.AuditResponse, error)
- func (client *Client) BeginGitHubApp(ctx context.Context, request *gitdv1.BeginGitHubAppRequest) (*gitdv1.BeginGitHubAppResponse, error)
- func (client *Client) Changes(ctx context.Context, request *gitdv1.ChangesRequest) (*gitdv1.ChangesResponse, error)
- func (client *Client) Checkout(ctx context.Context, request *gitdv1.CheckoutRequest, progress Progress) (*gitdv1.WorkspaceResult, error)
- func (client *Client) Compare(ctx context.Context, request *gitdv1.CompareRequest) (*gitdv1.CompareResponse, error)
- func (client *Client) CompleteGitHubApp(ctx context.Context, request *gitdv1.CompleteGitHubAppRequest) (*gitdv1.CompleteGitHubAppResponse, error)
- func (client *Client) Conflicts(ctx context.Context, request *gitdv1.ConflictsRequest) (*gitdv1.ConflictsResponse, error)
- func (client *Client) Describe(ctx context.Context, path string) (*gitdv1.DescribeResponse, error)
- func (client *Client) Diff(ctx context.Context, request *gitdv1.DiffRequest) (*gitdv1.DiffResponse, error)
- func (client *Client) FinishGitHubLogin(ctx context.Context, loginID string) (*gitdv1.FinishGitHubLoginResponse, error)
- func (client *Client) GetSettings(ctx context.Context) (*gitdv1.GetSettingsResponse, error)
- func (client *Client) Info(ctx context.Context) (*gitdv1.InfoResponse, error)
- func (client *Client) IssueToken(ctx context.Context, request *gitdv1.IssueTokenRequest) (*gitdv1.IssueTokenResponse, error)
- func (client *Client) List(ctx context.Context) (*gitdv1.ListResponse, error)
- func (client *Client) ListConnections(ctx context.Context) (*gitdv1.ListConnectionsResponse, error)
- func (client *Client) ListPresets(ctx context.Context) (*gitdv1.ListPresetsResponse, error)
- func (client *Client) ListTokens(ctx context.Context) (*gitdv1.ListTokensResponse, error)
- func (client *Client) ListWarm(ctx context.Context, request *gitdv1.ListWarmRequest) (*gitdv1.ListWarmResponse, error)
- func (client *Client) Prepare(ctx context.Context, request *gitdv1.PrepareRequest, progress Progress) (*gitdv1.WorkspaceResult, error)
- func (client *Client) Probe(ctx context.Context, request *gitdv1.ProbeRequest) (*gitdv1.ProbeResponse, error)
- func (client *Client) Publish(ctx context.Context, request *gitdv1.PublishRequest) (*gitdv1.PublishResponse, error)
- func (client *Client) Remove(ctx context.Context, path string) error
- func (client *Client) RemoveConnection(ctx context.Context, id string) error
- func (client *Client) RemovePreset(ctx context.Context, name string) error
- func (client *Client) RemoveSettings(ctx context.Context, prefix string) error
- func (client *Client) Retire(ctx context.Context, unusedForSeconds int64) (*gitdv1.RetireResponse, error)
- func (client *Client) RevokeToken(ctx context.Context, request *gitdv1.RevokeTokenRequest) (*gitdv1.RevokeTokenResponse, error)
- func (client *Client) Seal(ctx context.Context, request *gitdv1.SealRequest) (*gitdv1.SealResponse, error)
- func (client *Client) SetPreset(ctx context.Context, preset *gitdv1.Preset) (*gitdv1.SetPresetResponse, error)
- func (client *Client) SetSettings(ctx context.Context, settings *gitdv1.PublishSettings) (*gitdv1.SetSettingsResponse, error)
- func (client *Client) StartGitHubLogin(ctx context.Context, host string) (*gitdv1.StartGitHubLoginResponse, error)
- func (client *Client) SyncSubmodules(ctx context.Context, request *gitdv1.SyncSubmodulesRequest, progress Progress) (*gitdv1.SyncSubmodulesResult, error)
- func (client *Client) Update(ctx context.Context, request *gitdv1.UpdateRequest, progress Progress) (*gitdv1.WorkspaceResult, error)
- func (client *Client) Watch(ctx context.Context, paths []string, told func(*gitdv1.WatchResponse)) error
- type Options
- type Progress
Examples ¶
Constants ¶
const SocketVariable = "GITD_SOCKET"
SocketVariable names the environment variable that says where gitd's socket is.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Client ¶
type Client struct {
Workspaces gitdv1connect.WorkspaceServiceClient
Repositories gitdv1connect.RepositoryServiceClient
Server gitdv1connect.ServerServiceClient
Connections gitdv1connect.ConnectionServiceClient
Publishing gitdv1connect.PublishingServiceClient
Endpoint gitdv1connect.EndpointServiceClient
}
Client is a gitd on one socket.
func New ¶
New returns the gitd that answers on socket, with no key. Nothing is dialled until the first call.
func Open ¶
Open returns the gitd options name. Nothing is dialled until the first call.
Example (Network) ¶
A gitd on another machine, with the key naming the caller's tenant.
package main
import (
"context"
"github.com/dooservice/gitd/client"
)
func main() {
gitd, err := client.Open(client.Options{URL: "https://gitd.internal:9420", Key: "acme-key"})
if err != nil {
panic(err)
}
_, _ = gitd.Info(context.Background())
}
Output:
func (*Client) AddGitHubApp ¶
func (client *Client) AddGitHubApp(ctx context.Context, request *gitdv1.AddGitHubAppRequest) (*gitdv1.AddGitHubAppResponse, error)
AddGitHubApp keeps a GitHub App by its ID and private key.
func (*Client) AddToken ¶
func (client *Client) AddToken(ctx context.Context, request *gitdv1.AddTokenRequest) (*gitdv1.AddTokenResponse, error)
AddToken keeps a token for the repositories under a prefix.
func (*Client) Adopt ¶
func (client *Client) Adopt( ctx context.Context, request *gitdv1.AdoptRequest, progress Progress, ) (*gitdv1.AdoptResult, error)
Adopt takes an existing clone in.
func (*Client) Audit ¶
func (client *Client) Audit(ctx context.Context, request *gitdv1.AuditRequest) (*gitdv1.AuditResponse, error)
Audit reads the audit log: every publish, done or refused, newest first.
func (*Client) BeginGitHubApp ¶
func (client *Client) BeginGitHubApp(ctx context.Context, request *gitdv1.BeginGitHubAppRequest) (*gitdv1.BeginGitHubAppResponse, error)
BeginGitHubApp starts creating a GitHub App from a manifest.
func (*Client) Changes ¶
func (client *Client) Changes(ctx context.Context, request *gitdv1.ChangesRequest) (*gitdv1.ChangesResponse, error)
Changes says what was changed in a workspace since gitd last put it on a commit.
func (*Client) Checkout ¶
func (client *Client) Checkout( ctx context.Context, request *gitdv1.CheckoutRequest, progress Progress, ) (*gitdv1.WorkspaceResult, error)
Checkout moves a workspace to a commit.
func (*Client) Compare ¶
func (client *Client) Compare(ctx context.Context, request *gitdv1.CompareRequest) (*gitdv1.CompareResponse, error)
Compare says how two works differ.
func (*Client) CompleteGitHubApp ¶
func (client *Client) CompleteGitHubApp(ctx context.Context, request *gitdv1.CompleteGitHubAppRequest) (*gitdv1.CompleteGitHubAppResponse, error)
CompleteGitHubApp finishes creating a GitHub App with the code GitHub sent back.
func (*Client) Conflicts ¶
func (client *Client) Conflicts(ctx context.Context, request *gitdv1.ConflictsRequest) (*gitdv1.ConflictsResponse, error)
Conflicts says which pairs of works do not merge cleanly.
func (*Client) Diff ¶
func (client *Client) Diff(ctx context.Context, request *gitdv1.DiffRequest) (*gitdv1.DiffResponse, error)
Diff writes the unified diff of a workspace's changes.
func (*Client) FinishGitHubLogin ¶
func (client *Client) FinishGitHubLogin(ctx context.Context, loginID string) (*gitdv1.FinishGitHubLoginResponse, error)
FinishGitHubLogin waits until the person entered the code, and keeps the sign-in.
func (*Client) GetSettings ¶
GetSettings is every publishing setting.
func (*Client) IssueToken ¶
func (client *Client) IssueToken(ctx context.Context, request *gitdv1.IssueTokenRequest) (*gitdv1.IssueTokenResponse, error)
IssueToken issues a token of gitd's endpoint for a sandbox.
func (*Client) List ¶ added in v0.15.0
List is every workspace gitd made, with what Describe says of each and the branches published from it.
func (*Client) ListConnections ¶
ListConnections is the credentials gitd keeps, never a secret.
func (*Client) ListPresets ¶
ListPresets is every preset as it applies.
func (*Client) ListTokens ¶
ListTokens lists the endpoint's tokens alive.
func (*Client) ListWarm ¶
func (client *Client) ListWarm(ctx context.Context, request *gitdv1.ListWarmRequest) (*gitdv1.ListWarmResponse, error)
ListWarm lists the warm layers of a repository.
func (*Client) Prepare ¶
func (client *Client) Prepare( ctx context.Context, request *gitdv1.PrepareRequest, progress Progress, ) (*gitdv1.WorkspaceResult, error)
Prepare makes a workspace, or moves the one gitd already made there.
func (*Client) Probe ¶
func (client *Client) Probe(ctx context.Context, request *gitdv1.ProbeRequest) (*gitdv1.ProbeResponse, error)
Probe asks a repository whether it can be read, and for its branches.
func (*Client) Publish ¶
func (client *Client) Publish(ctx context.Context, request *gitdv1.PublishRequest) (*gitdv1.PublishResponse, error)
Publish pushes what was committed in a workspace to a new branch.
func (*Client) RemoveConnection ¶
RemoveConnection forgets a connection made through the API.
func (*Client) RemovePreset ¶
RemovePreset forgets a preset set through the API.
func (*Client) RemoveSettings ¶
RemoveSettings forgets the publishing settings of a prefix.
func (*Client) Retire ¶
func (client *Client) Retire(ctx context.Context, unusedForSeconds int64) (*gitdv1.RetireResponse, error)
Retire removes now the pools nobody used for a while.
func (*Client) RevokeToken ¶
func (client *Client) RevokeToken(ctx context.Context, request *gitdv1.RevokeTokenRequest) (*gitdv1.RevokeTokenResponse, error)
RevokeToken ends a token of gitd's endpoint.
func (*Client) Seal ¶
func (client *Client) Seal(ctx context.Context, request *gitdv1.SealRequest) (*gitdv1.SealResponse, error)
Seal makes an overlay workspace's own layer a warm layer of its repository.
func (*Client) SetPreset ¶
func (client *Client) SetPreset(ctx context.Context, preset *gitdv1.Preset) (*gitdv1.SetPresetResponse, error)
SetPreset keeps a preset.
func (*Client) SetSettings ¶
func (client *Client) SetSettings(ctx context.Context, settings *gitdv1.PublishSettings) (*gitdv1.SetSettingsResponse, error)
SetSettings keeps the publishing settings of a prefix.
func (*Client) StartGitHubLogin ¶
func (client *Client) StartGitHubLogin(ctx context.Context, host string) (*gitdv1.StartGitHubLoginResponse, error)
StartGitHubLogin asks for the code a person enters to sign in to GitHub.
func (*Client) SyncSubmodules ¶
func (client *Client) SyncSubmodules( ctx context.Context, request *gitdv1.SyncSubmodulesRequest, progress Progress, ) (*gitdv1.SyncSubmodulesResult, error)
SyncSubmodules checks out a workspace's submodules.
type Options ¶
Options say which gitd to call and how: on its Unix socket, or at URL on the network (https, or http on a private network), with Key naming the caller's tenant, and CAFile the certificate authority of a gitd whose certificate the system does not trust. With neither Socket nor URL, the socket is $GITD_SOCKET, then that of the gitd `gitd up` runs for the user when it is there, then the system's default.