Documentation
¶
Overview ¶
Package gitconnect binds the current project to a GitHub repository.
The CLI never creates push credentials and never pushes: it resolves a local remote to a repository the caller's GitHub connection can already see, and asks the platform to bind it. Pushing stays the user's own `git push`.
Index ¶
- Variables
- type ProjectRef
- type Service
- func (s Service) Connect(ctx context.Context, target Target, rootDirectory string, ...) (*apiclient.ProjectGitConnection, error)
- func (s Service) DeploySettings(ctx context.Context) (*apiclient.ProjectGitDeploySettings, error)
- func (s Service) Disconnect(ctx context.Context, expected *apiclient.ProjectGitConnection) error
- func (s Service) Project() (ProjectRef, error)
- func (s Service) Resolve(ctx context.Context, repository localgit.Repository) (*Target, error)
- func (s Service) Status(ctx context.Context) (*apiclient.ProjectGitConnection, error)
- func (s Service) WebURL() (string, error)
- type Target
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNoGitHubConnection indicates the caller has no usable GitHub // connection. The CLI cannot create one: the connect flow is a browser // redirect bound to an HttpOnly cookie, so it has to happen in the // dashboard. ErrNoGitHubConnection = errors.New("no GitHub account is connected") // ErrRepositoryNotAccessible indicates the repository is real as far as the // local remote is concerned, but the Volcano GitHub App cannot see it // through any of the caller's installations. ErrRepositoryNotAccessible = errors.New("repository is not accessible through your GitHub connection") // ErrProviderNotConfigured indicates the API has no GitHub App configured. // Local mode is the usual cause: those settings are first-party only. ErrProviderNotConfigured = errors.New("git provider integration is not configured on this API") // ErrNotConnected indicates the project has no repository bound. ErrNotConnected = errors.New("this project is not connected to a repository") // ErrBindingChanged indicates the project's binding was not what the command // read before it asked the user about it. ErrBindingChanged = errors.New("the project's repository connection changed while this command was running") // ErrProjectNotFound indicates the selected project does not exist. The // binding read answers 404 for this and for a project with no repository // connected, so the two are told apart before either is reported. ErrProjectNotFound = errors.New("the selected project does not exist") )
Functions ¶
This section is empty.
Types ¶
type ProjectRef ¶
type ProjectRef struct {
ID uuid.UUID
// Name is empty when the configuration cannot name the selected project,
// which is what VOLCANO_PROJECT_ID pointing somewhere else looks like.
Name string
}
ProjectRef identifies the project a command acts on. The repository comes from the working directory and the project comes from the CLI's own configuration, so the two are chosen independently and both have to be reported.
func (ProjectRef) Label ¶
func (p ProjectRef) Label() string
Label renders the project for output: its name where one is known, and always enough to identify it.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service performs project git-connection work for the current project.
func NewService ¶
func NewService(deps cliruntime.Deps) Service
NewService returns a git connection service.
func (Service) Connect ¶
func (s Service) Connect( ctx context.Context, target Target, rootDirectory string, expected *apiclient.ProjectGitConnection, ) (*apiclient.ProjectGitConnection, error)
Connect binds the current project to a resolved repository, provided its binding is still expected — nil for a project that had none.
The bind is a full replace and names no prior state, so it overwrites whatever is bound when it arrives. Everything the caller decided rests on a read taken before resolving the repository and before any prompt, so the window is wide: three provider round-trips plus however long the user takes to answer. Within it another actor can point the project somewhere the user was never shown. Re-reading narrows that; the API has no conditional write to close it.
func (Service) DeploySettings ¶
DeploySettings returns what a push to the production branch deploys. It is reported alongside a successful connect so the user learns straight away whether a push does anything.
func (Service) Disconnect ¶
Disconnect removes the project's repository binding, provided it is still the one in expected. The repository itself is untouched.
The delete names no repository, so it removes whatever is bound when it arrives. Re-reading first keeps the command from deleting a binding the user was never shown — the window between reading a binding and confirming it is as long as the user takes to answer. It narrows that window rather than closing it; the API has no conditional delete to close it with.
func (Service) Project ¶
func (s Service) Project() (ProjectRef, error)
Project returns the project these commands act on.
func (Service) Resolve ¶
Resolve finds the repository named by a local remote among the repos the caller's GitHub connection can reach, so the caller can confirm the binding before it is made.
type Target ¶
type Target struct {
ConnectionID uuid.UUID
ConnectionLogin string
InstallationID int64
InstallationAccount string
Repository apiclient.GitRepository
}
Target is a resolved repository, and the connection and installation it was reached through. It is everything the bind call needs.
ConnectionLogin and InstallationAccount are carried for reporting only. The connection decides whose stored GitHub token the platform reads the repository with on every future deploy, and more than one connection can reach the same repository, so which one was picked is not something to leave unsaid.