Documentation
¶
Overview ¶
Package gitconn keeps the cluster's Git provider connections (§5.8): GitHub Apps created from a manifest in one click, and access tokens for GitHub, GitLab and Gitea/Forgejo. Services then pick a repository from a list; SynCloud mints clone tokens, creates the push webhook and reports commit statuses.
Index ¶
- Constants
- type ErrInvalid
- type Manager
- func (m *Manager) AddBuiltin(ctx context.Context, name, apiURL, webURL, token string) (View, error)
- func (m *Manager) AddToken(ctx context.Context, in TokenInput) (View, error)
- func (m *Manager) AppWebhookSecret(ctx context.Context, id string) (string, error)
- func (m *Manager) CompleteManifest(ctx context.Context, userID, code, state string) (View, error)
- func (m *Manager) Delete(ctx context.Context, idOrName string) error
- func (m *Manager) Get(ctx context.Context, idOrName string) (View, error)
- func (m *Manager) List(ctx context.Context) ([]View, error)
- func (m *Manager) Manifest(userID string, in ManifestInput) (Manifest, error)
- func (m *Manager) Provider(ctx context.Context, idOrName string) (store.GitConnection, gitprovider.Provider, error)
- func (m *Manager) SetWebURL(ctx context.Context, id, webURL string) error
- type Manifest
- type ManifestInput
- type TokenInput
- type View
Constants ¶
const HookPathGitHubApp = "/api/v1/hooks/github-app/"
HookPathGitHubApp receives a GitHub App's webhook: /api/v1/hooks/github-app/{id}.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ErrInvalid ¶
type ErrInvalid struct{ Err error }
ErrInvalid wraps validation errors.
func (ErrInvalid) Error ¶
func (e ErrInvalid) Error() string
type Manager ¶
type Manager struct {
// DashboardURL is where Git hosts send webhooks and users come back.
DashboardURL func() string
// contains filtered or unexported fields
}
func (*Manager) AddBuiltin ¶
AddBuiltin saves a connection to a Git server SynCloud runs itself: the API is reached at apiURL (loopback), browsers and clones use webURL.
func (*Manager) AppWebhookSecret ¶
AppWebhookSecret is a GitHub App connection's webhook secret.
func (*Manager) CompleteManifest ¶
CompleteManifest exchanges GitHub's code for the app's credentials and saves the connection. It returns where to install the app.
func (*Manager) Manifest ¶
func (m *Manager) Manifest(userID string, in ManifestInput) (Manifest, error)
Manifest prepares the GitHub App manifest flow: the dashboard posts the manifest to GitHub, the person confirms there, and GitHub redirects to the callback with a code (valid for an hour) and this state (10 minutes).
type Manifest ¶
type Manifest struct {
// PostURL is the form action; Manifest is the "manifest" field.
PostURL string `json:"postUrl"`
Manifest string `json:"manifest"`
State string `json:"state"`
}
Manifest is what the browser posts to GitHub.
type ManifestInput ¶
type ManifestInput struct {
Name string `json:"name"` // the connection name (default "github")
// Org creates the app under an organization ("" = the signed-in user).
Org string `json:"org"`
// GitHubURL is a GitHub Enterprise server ("" = github.com).
GitHubURL string `json:"githubUrl"`
}
ManifestInput starts creating a GitHub App.
type TokenInput ¶
type TokenInput struct {
Kind string `json:"kind"` // github | gitlab | gitea
Name string `json:"name"`
URL string `json:"url"` // the server ("" = github.com / gitlab.com)
Token string `json:"token"`
}
TokenInput connects GitHub, GitLab or Gitea with an access token.
type View ¶
type View struct {
ID string `json:"id"`
Kind string `json:"kind"`
Name string `json:"name"`
APIURL string `json:"apiUrl"`
WebURL string `json:"webUrl"`
Account string `json:"account"`
AppSlug string `json:"appSlug,omitempty"`
AppID int64 `json:"appId,omitempty"`
CreatedAt time.Time `json:"createdAt"`
// InstallURL adds the GitHub App to more accounts or repositories.
InstallURL string `json:"installUrl,omitempty"`
// Services built from this connection, as project/environment/service,
// and the repository each builds.
Services []string `json:"services"`
ServiceRepos map[string]string `json:"serviceRepos"`
}
View is a connection as the API shows it (no secrets).