Documentation
¶
Overview ¶
Package config manages beardrive's global state under the beardrive home directory (default ~/.bdrive, overridable with $BDRIVE_HOME): the device identity and the registry of mounted folders.
Index ¶
- Constants
- func Home() (string, error)
- func IsMount(folder string) bool
- func LoadMounts() (map[string]MountInfo, error)
- func NewMountID() string
- func SaveMounts(m map[string]MountInfo) error
- func SaveSettings(s Settings) error
- func VolumeDir(mountID string) (string, error)
- type Device
- type MountInfo
- type Project
- type Settings
Constants ¶
const DefaultServer = "https://beardrive.ai"
DefaultServer is used wherever a server is needed and none is configured: bare `bdrive login`, and `bdrive init` on a never-logged-in device.
const ProjectDir = ".bdrive"
ProjectDir is the per-folder settings directory at the mount root. It carries the mount's stable identity, so a project keeps syncing after the folder is renamed or moved — nothing is keyed by the path. It travels with the folder (copy the folder to a new machine and `bdrive init` resumes the same project) but is never synced, and it holds no session credentials — those stay in the bdrive home.
Variables ¶
This section is empty.
Functions ¶
func IsMount ¶ added in v0.4.0
IsMount reports whether folder is a BearDrive mount root, i.e. has a .bdrive/config.json — even an unparseable one, so callers that must not treat a mount as plain files (e.g. a parent mount's scanner) stay safe.
func LoadMounts ¶
LoadMounts returns the mount-ID → mount registry.
func SaveMounts ¶
Types ¶
type Device ¶
type Device struct {
ID string `json:"id"`
Name string `json:"name"`
Author string `json:"author"`
}
Device identifies this machine and its operator in journals.
func LoadDevice ¶
LoadDevice loads the device identity, creating one on first use.
type MountInfo ¶
type MountInfo struct {
Path string `json:"path"`
Volume string `json:"volume,omitempty"`
Remote string `json:"remote,omitempty"`
}
MountInfo is the registry's view of one mount: where the folder currently lives. The source of truth for identity/settings is the folder's own .bdrive/config.json; the registry only remembers the last-known path (for `bdrive status` and the daemon) and self-heals when the folder moves.
type Project ¶
type Project struct {
// ID is the stable mount identity (m-xxxxxxxx). The volume store, the
// daemon, and the registry are keyed by it, never by the folder path.
ID string `json:"id"`
Volume string `json:"volume,omitempty"`
Remote string `json:"remote,omitempty"`
// Include optionally narrows what syncs: when non-empty, only paths
// matching one of these patterns (gitignore-style, same syntax as
// .bdriveignore) are scanned and materialized.
Include []string `json:"include,omitempty"`
}
Project holds the settings stored in <folder>/.bdrive/config.json.
func LoadProject ¶
LoadProject reads <folder>/.bdrive/config.json; ok is false if it does not exist.
func ResolveMount ¶
ResolveMount loads a folder's project settings and self-heals the registry: if the folder was renamed or moved, the registry entry is updated to the new path so `bdrive status` and the daemon find it again.
type Settings ¶
type Settings struct {
// Server is the default bdrive web server for `bdrive init`.
Server string `json:"server,omitempty"`
// Token authenticates this device to Server (minted by `bdrive login`).
// Sent as a Bearer header.
Token string `json:"token,omitempty"`
// Email and Name identify the signed-in account; journal ops carry them
// so history shows who changed what.
Email string `json:"email,omitempty"`
Name string `json:"name,omitempty"`
}
Settings are device-wide defaults, stored at $BDRIVE_HOME/settings.json.
func LoadSettings ¶
LoadSettings reads the device settings; a missing file is zero settings.