config

package
v0.10.2 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2026 License: MIT Imports: 18 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DataDir

func DataDir() string

DataDir is enbu's per-user data directory. It is always absolute: a relative path would put identities and checkpoints under the working directory, which is usually a Git repository. XDG_DATA_HOME is used only when absolute, as the XDG Base Directory specification requires.

func DefaultDataDir added in v0.10.0

func DefaultDataDir() string

DefaultDataDir is the data directory DataDir names when XDG_DATA_HOME is not set.

func DefaultOutput

func DefaultOutput(name string) string

func LocalStatePath

func LocalStatePath(workspaceID string) string

LocalStatePath returns the XDG data dir path for per-project local state.

func MarshalProject

func MarshalProject(cfg *ProjectConfig) ([]byte, error)

MarshalProject emits the compact, canonical enbu.toml layout. Encoding the environment map directly would add a redundant [env] parent table and indent every [env.<name>] section.

func ParseGitHubRemote

func ParseGitHubRemote(remote string) (string, string, error)

ParseGitHubRemote returns the owner and repository of a github.com remote (git@github.com:owner/repo, https://github.com/owner/repo or ssh://git@github.com/owner/repo, each with or without .git). Other hosts are an error.

func ProjectConfigPathFrom

func ProjectConfigPathFrom(dir string) (string, error)

func SaveGUI

func SaveGUI(cfg *GUIConfig) error

func SaveLocalStateTo added in v0.10.0

func SaveLocalStateTo(dir, workspaceID string, cfg *LocalConfig) error

SaveLocalStateTo persists local state for one explicitly selected device.

func SaveProjectTo

func SaveProjectTo(dir string, cfg *ProjectConfig) error

SaveProjectTo honors an explicit destination. Only an implicit destination searches ancestors, so a fresh explicit workspace cannot overwrite a parent.

func ValidEnvironmentName

func ValidEnvironmentName(name string) bool

func ValidateProjectOutputs

func ValidateProjectOutputs(cfg *ProjectConfig) error

Types

type EnvironmentConfig

type EnvironmentConfig struct {
	Output string `toml:"output"`
	// Incarnation names this environment's lineage in storage. Creating an
	// environment draws a new one, so re-creating a deleted name never mixes
	// with the old revisions, and renaming keeps the lineage. An environment
	// written by hand without one is stored under its own name; renaming it
	// records that name here so the lineage stays the same.
	Incarnation string `toml:"incarnation,omitempty"`
}

type GUIConfig

type GUIConfig struct {
	SelectedRepo string   `toml:"selected_repo,omitempty"`
	RepoHistory  []string `toml:"repo_history,omitempty"`
}

func LoadGUI

func LoadGUI() (*GUIConfig, error)

type LocalConfig

type LocalConfig struct {
	Current  string `toml:"current,omitempty"`
	Previous string `toml:"previous,omitempty"`
}

LocalConfig is per-user state of one workspace, kept outside the repository.

func LoadLocalStateFrom added in v0.10.0

func LoadLocalStateFrom(dir, workspaceID string) (*LocalConfig, error)

LoadLocalStateFrom reads local state for one explicitly selected device.

type ProjectConfig

type ProjectConfig struct {
	WorkspaceID string `toml:"workspace_id"`
	// ControlGenesis is the trusted digest of the workspace's first signed
	// Control. It is the bootstrap anchor shared through the repository.
	ControlGenesis string        `toml:"control_genesis,omitempty"`
	Storage        StorageConfig `toml:"storage"`
	Version        string        `toml:"version"`
	// DefaultEnv is the team's default environment.
	DefaultEnv   string                       `toml:"default_env,omitempty"`
	Environments map[string]EnvironmentConfig `toml:"env,omitempty"`
	// Current is the environment this user switched to, from the local state.
	// It is personal, so it is never written to enbu.toml.
	Current string `toml:"-"`
}

func DecodeProject

func DecodeProject(content string) (*ProjectConfig, error)

DecodeProject reads enbu.toml content without checking its version, so the values it protects can be compared even in a file enbu would refuse to use.

func LoadProject

func LoadProject() (*ProjectConfig, error)

func LoadProjectFrom

func LoadProjectFrom(dir string) (*ProjectConfig, error)

func NewProjectWithEnvironment

func NewProjectWithEnvironment(name string) *ProjectConfig

func NewProjectWithIDs added in v0.10.0

func NewProjectWithIDs(name string, newID func() string) *ProjectConfig

NewProjectWithIDs creates a project using an instance-owned identifier source.

func ParseProject

func ParseProject(content string) (*ProjectConfig, error)

func (*ProjectConfig) AddEnvironment

func (cfg *ProjectConfig) AddEnvironment(name string) error

func (*ProjectConfig) AddEnvironmentWithID added in v0.10.0

func (cfg *ProjectConfig) AddEnvironmentWithID(name string, newID func() string) error

AddEnvironmentWithID uses an instance-owned incarnation source.

func (*ProjectConfig) CurrentEnvironment

func (cfg *ProjectConfig) CurrentEnvironment() string

CurrentEnvironment is the environment commands use without --env: the one this user switched to while it still exists, else the team default.

func (*ProjectConfig) Environment

func (cfg *ProjectConfig) Environment(name string) (EnvironmentConfig, error)

func (*ProjectConfig) EnvironmentNames

func (cfg *ProjectConfig) EnvironmentNames() []string

func (*ProjectConfig) HasEnvironment

func (cfg *ProjectConfig) HasEnvironment(name string) bool

func (*ProjectConfig) RemoveEnvironment

func (cfg *ProjectConfig) RemoveEnvironment(name string) error

func (*ProjectConfig) RenameEnvironment

func (cfg *ProjectConfig) RenameEnvironment(oldName, newName string) error

func (*ProjectConfig) Resource

func (cfg *ProjectConfig) Resource(env string) string

Resource names the storage lineage of an environment's secrets. An environment with an incarnation is named by it, so renaming keeps its history; one without (an implicit default, or an older enbu.toml) is named by its own name.

func (*ProjectConfig) SetDefault

func (cfg *ProjectConfig) SetDefault(name string)

type StorageConfig

type StorageConfig struct {
	URL       string `toml:"url" json:"url"`
	Region    string `toml:"region,omitempty" json:"region"`
	Endpoint  string `toml:"endpoint,omitempty" json:"endpoint"`
	PathStyle bool   `toml:"path_style,omitempty" json:"path_style"`
	PlainHTTP bool   `toml:"plain_http,omitempty" json:"plain_http"`
}

Jump to

Keyboard shortcuts

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