gitconn

package
v0.5.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 19, 2026 License: Apache-2.0 Imports: 17 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
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 New

func New(st *store.Store, box *secrets.Box, dashboardURL func() string, log *slog.Logger) *Manager

func (*Manager) AddBuiltin

func (m *Manager) AddBuiltin(ctx context.Context, name, apiURL, webURL, token string) (View, error)

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) AddToken

func (m *Manager) AddToken(ctx context.Context, in TokenInput) (View, error)

AddToken verifies a token against the provider and saves it.

func (*Manager) AppWebhookSecret

func (m *Manager) AppWebhookSecret(ctx context.Context, id string) (string, error)

AppWebhookSecret is a GitHub App connection's webhook secret.

func (*Manager) CompleteManifest

func (m *Manager) CompleteManifest(ctx context.Context, userID, code, state string) (View, error)

CompleteManifest exchanges GitHub's code for the app's credentials and saves the connection. It returns where to install the app.

func (*Manager) Delete

func (m *Manager) Delete(ctx context.Context, idOrName string) error

Delete removes a connection no service builds from.

func (*Manager) Get

func (m *Manager) Get(ctx context.Context, idOrName string) (View, error)

func (*Manager) List

func (m *Manager) List(ctx context.Context) ([]View, error)

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).

func (*Manager) Provider

func (m *Manager) Provider(ctx context.Context, idOrName string) (store.GitConnection, gitprovider.Provider, error)

Provider returns a connection and its API client (cached, so GitHub App installation tokens are reused until they near expiry).

func (*Manager) SetWebURL

func (m *Manager) SetWebURL(ctx context.Context, id, webURL string) error

SetWebURL updates where browsers reach a connection's server.

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).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL