config

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2026 License: AGPL-3.0 Imports: 9 Imported by: 0

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

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

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

func Home() (string, error)

Home returns the beardrive home directory ($BDRIVE_HOME or ~/.bdrive).

func IsMount added in v0.4.0

func IsMount(folder string) bool

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

func LoadMounts() (map[string]MountInfo, error)

LoadMounts returns the mount-ID → mount registry.

func NewMountID

func NewMountID() string

NewMountID mints a stable mount identity.

func SaveMounts

func SaveMounts(m map[string]MountInfo) error

func SaveSettings

func SaveSettings(s Settings) error

SaveSettings persists the device settings.

func VolumeDir

func VolumeDir(mountID string) (string, error)

VolumeDir returns the local store dir of a mount, keyed by its stable mount ID (never the folder path — that's what makes renames/moves free).

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

func LoadDevice() (Device, error)

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

func LoadProject(folder string) (Project, bool, error)

LoadProject reads <folder>/.bdrive/config.json; ok is false if it does not exist.

func ResolveMount

func ResolveMount(folder string) (Project, bool, error)

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.

func SaveProject

func SaveProject(folder string, p Project) (Project, error)

SaveProject writes <folder>/.bdrive/config.json, assigning a mount ID on first save.

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

func LoadSettings() (Settings, error)

LoadSettings reads the device settings; a missing file is zero settings.

Jump to

Keyboard shortcuts

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