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) RebindProject(projectID, backendID string) (Config, error)
- func (c Config) RemoveBackend(backendID string) (Config, int)
- func (c Config) RemoveProject(projectID string) (Config, []Workspace)
- func (c Config) UpsertBackend(apiBaseURL, deviceID string) (Config, Backend, error)
- func (c Config) WorkspacesForProject(projectID string) []Workspace
- 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) RebindProject ¶ added in v0.1.2
RebindProject moves one Project to a different backend, keeping the Project and the repositories registered to it exactly as they are.
This is what promoting a local Project to a shared one is made of. It is a change of address rather than a migration, and only because the Project keeps its identifier: that identifier is salted into every repository fingerprint and stamped on every event envelope, so a Project that changed identity on the way would not be recognisable as the same Project by any of the evidence the device already holds.
The backend it is leaving is deliberately left standing. It is shared with every other Project on this profile, and the loopback backend serves all of them.
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) RemoveProject ¶ added in v0.1.2
RemoveProject forgets one Project and every repository registered to it.
The backend it lived on stays. A profile holds several Projects on one backend after ADR-074, and the loopback backend is shared by all of them, so tearing it down here would strand the Projects beside this one - which is exactly the difference between this and RemoveBackend.
The cleared workspaces are returned rather than counted: the caller has to stop watching those roots and drop their stored rows, and it cannot ask the configuration for them once they are gone.
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.
func (Config) WorkspacesForProject ¶ added in v0.1.2
WorkspacesForProject lists the repositories registered to one Project.
type Paths ¶
type Paths struct{ Root, Config, DB, Lock, Socket string }
Paths are the per-profile locations the service and the CLI agree on.
Socket names the local IPC endpoint, and it is not always a filesystem path. On unix it is a Unix socket inside Root; on Windows there is no such thing, so endpointFor returns a named-pipe name instead. Callers pass it to the daemon package and never open it themselves, which is what lets the two forms share one field.
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"`
}