Documentation
¶
Index ¶
- Constants
- func BackendID(origin string) string
- func BackendKind(origin string) string
- func DefaultRoot() (string, error)
- func IsLoopbackOrigin(origin string) bool
- func Save(paths Paths, c Config) error
- type Backend
- type Config
- func (c Config) BackendByID(id string) (Backend, bool)
- func (c Config) BackendForOrigin(origin string) (Backend, bool)
- func (c Config) BackendForProject(projectID string) (Backend, bool)
- func (c Config) BackendForWorkspace(workspace Workspace) (Backend, bool)
- func (c Config) BackendTarget(apiBaseURL string) Backend
- func (c Config) BindProject(projectID, backendID string) Config
- func (c Config) ProjectsForBackend(backendID string) []string
- func (c Config) RemoveBackend(backendID string) (Config, int)
- func (c Config) UpsertBackend(apiBaseURL, deviceID string) (Config, Backend, error)
- type Paths
- type Project
- type Workspace
Constants ¶
const ( KindLocal = "local" KindTeam = "team" )
Backend kinds. A Project's kind follows from the origin it lives on, and is stored so the desktop and CLI can name it without re-deriving the rule.
const Version = 2
Version is the configuration version this build writes. Load migrates version 1 in memory and Save always writes this one.
Variables ¶
This section is empty.
Functions ¶
func BackendID ¶
BackendID is the opaque, stable identifier for a backend origin. It is derived from the origin alone, so re-enrolling against the same server - with a new device identity - updates that backend rather than growing a second entry for the same server.
func BackendKind ¶
BackendKind is the kind stored on a Backend record, derived once at write time from the origin.
func DefaultRoot ¶
func IsLoopbackOrigin ¶
IsLoopbackOrigin reports whether this origin is served by a backend running on this Mac. It is the single loopback rule: localbackend.IsLoopbackOrigin delegates here so the service, the CLI, and the desktop cannot disagree about which Projects are local.
Types ¶
type Backend ¶
type Backend struct {
ID string `json:"id"`
APIBaseURL string `json:"apiBaseUrl"`
DeviceID string `json:"deviceId"`
Kind string `json:"kind"`
}
Backend is one server implementing the /v1 contract, together with the device identity this profile uses with it. One Mac has one device identity per backend (ADR-069), so the two travel together.
type Config ¶
type Config struct {
Version int `json:"version"`
Backends []Backend `json:"backends"`
Projects []Project `json:"projects"`
Workspaces []Workspace `json:"workspaces"`
}
func Single ¶
Single is the version 2 configuration a single backend can express: one backend, and every Project in workspaces bound to it. It is what Load's migration of a version 1 profile produces.
func (Config) BackendByID ¶
BackendByID returns the backend with this identifier.
func (Config) BackendForOrigin ¶
BackendForOrigin returns the backend this profile already uses for a server.
func (Config) BackendForProject ¶
BackendForProject resolves the backend one Project lives on.
func (Config) BackendForWorkspace ¶
BackendForWorkspace resolves the backend one registered repository publishes to, through the Project it belongs to. A workspace whose Project has no backend is an orphan: the caller reports it and carries on with the rest.
func (Config) BackendTarget ¶
BackendTarget is the backend record this profile would use for a server: the one it already has, or an unenrolled record for a server it has never used. It is what an onboarding flow is pointed at, so the flow can tell "mint a device identity here" from "reuse the one this profile has".
func (Config) BindProject ¶
BindProject records which backend holds a Project. Re-binding an existing Project to the same backend is a no-op; nothing here moves a Project between backends.
func (Config) ProjectsForBackend ¶
ProjectsForBackend lists the Projects bound to one backend.
func (Config) RemoveBackend ¶
RemoveBackend forgets one backend, the Projects on it, and the repositories registered to those Projects. It returns the workspaces it cleared, which is what a reset reports.
func (Config) UpsertBackend ¶
UpsertBackend records the backend at this origin, or updates the device identity of the one already there.
A second device identity for a backend the profile already knows is refused rather than merged: the Projects on that backend belong to the identity that is already stored, and quietly replacing it would strand every one of them.
type Project ¶
Project binds one Project to the backend that holds it (ADR-074). Workspaces keep naming a Project, and resolve their backend through it.
type Workspace ¶
type Workspace struct {
ID string `json:"id"`
ProjectID string `json:"projectId"`
WorkstreamID string `json:"workstreamId"`
Root string `json:"root"`
Baseline string `json:"baseline"`
Fingerprint string `json:"repositoryFingerprint"`
MemberID string `json:"memberId"`
SessionID string `json:"sessionId"`
}