Documentation
¶
Overview ¶
Package github is the source adapter for GitHub (R-091): github.com and GitHub Enterprise Server, reached with a GitHub App installation, an OAuth application, a personal access token or a deploy key.
A GitHub App is not entered by hand: authorizing the connection creates one from a manifest, owned by the person's account or organization, and then installs it (manifest.go). Each installation of Pando has its own App, so no private key is shared between installations.
Stateless like every adapter (R-027): an App installation token is minted on every call rather than cached, and an OAuth token refreshed here goes back to core in GitCredential.Rotated for core to store.
Index ¶
- Constants
- func Info() api.KindInfo
- type Adapter
- func (a *Adapter) BeginAuthorization(ctx context.Context, req api.AuthorizationRequest) (api.Authorization, error)
- func (a *Adapter) Category() api.Category
- func (a *Adapter) CompleteAuthorization(ctx context.Context, req api.AuthorizationCompletion) (api.AuthorizationResult, error)
- func (a *Adapter) Configure(_ context.Context, raw json.RawMessage) error
- func (a *Adapter) Covers(repoURL string) int
- func (a *Adapter) GitCredential(ctx context.Context, repoURL string) (api.GitCredential, error)
- func (a *Adapter) HealthCheck(context.Context) error
- func (a *Adapter) Kind() string
- func (a *Adapter) ListBranches(ctx context.Context, repoURL string) ([]string, error)
- func (a *Adapter) ListRepositories(ctx context.Context, req api.ListRepositoriesRequest) ([]api.Repository, error)
- func (a *Adapter) Refresh(ctx context.Context) (map[string]secret.Value, error)
- func (a *Adapter) SourceCapabilities() api.SourceCapabilities
Constants ¶
const ( // The credential fields a GitHub App connection holds, all written by // Pando when it creates and installs the App: its private key, the // secret its webhook is signed with, and its ID, URL name and // installation, which are not secret but arrive with the key. FieldAppPrivateKey = "app_private_key" FieldWebhookSecret = api.CredentialWebhookSecret FieldAppID = "app_id" FieldAppSlug = "app_slug" FieldAppOwner = "app_owner" FieldAppOwnerType = "app_owner_type" FieldInstallationID = "installation_id" )
const Kind = "github"
Kind is the adapter's kind string.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Adapter ¶
type Adapter struct {
// contains filtered or unexported fields
}
Adapter is one connection to GitHub.
func (*Adapter) BeginAuthorization ¶
func (a *Adapter) BeginAuthorization(ctx context.Context, req api.AuthorizationRequest) (api.Authorization, error)
BeginAuthorization starts a device or browser authorization, or the creation or installation of a GitHub App.
func (*Adapter) CompleteAuthorization ¶
func (a *Adapter) CompleteAuthorization(ctx context.Context, req api.AuthorizationCompletion) (api.AuthorizationResult, error)
CompleteAuthorization polls the device code or exchanges the browser's code, or finishes a GitHub App's creation or installation.
func (*Adapter) GitCredential ¶
GitCredential is the installation token, the OAuth token, the personal access token or the deploy key.
func (*Adapter) HealthCheck ¶
HealthCheck succeeds once configured. Whether the credential still works is learned at the next clone or listing, which reports it (R-146).
func (*Adapter) ListBranches ¶
ListBranches lists the repository's branches.
func (*Adapter) ListRepositories ¶
func (a *Adapter) ListRepositories(ctx context.Context, req api.ListRepositoriesRequest) ([]api.Repository, error)
ListRepositories lists what the installation, user or token can read, limited to the connection's owner when it has one.
func (*Adapter) Refresh ¶
Refresh renews an expired OAuth token and returns what to store. Nil for every other method, and for an OAuth token still good.
func (*Adapter) SourceCapabilities ¶
func (a *Adapter) SourceCapabilities() api.SourceCapabilities