config

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2026 License: MIT Imports: 15 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 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 ProjectConfigPath

func ProjectConfigPath() (string, error)

ProjectConfigPath returns the path to enbu.toml by traversing up from cwd.

func ProjectConfigPathFrom

func ProjectConfigPathFrom(dir string) (string, error)

func SaveGUI

func SaveGUI(cfg *GUIConfig) error

func SaveLocalState

func SaveLocalState(workspaceID string, cfg *LocalConfig) error

SaveLocalState persists per-project state to the XDG data directory.

func SaveProject

func SaveProject(cfg *ProjectConfig) error

func SaveProjectTo

func SaveProjectTo(dir string, cfg *ProjectConfig) error

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 LoadLocalState

func LoadLocalState(workspaceID string) (*LocalConfig, error)

LoadLocalState loads per-project state from the XDG data directory.

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 ParseProject

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

func (*ProjectConfig) AddEnvironment

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

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"`
	Region    string `toml:"region,omitempty"`
	Endpoint  string `toml:"endpoint,omitempty"`
	PathStyle bool   `toml:"path_style,omitempty"`
	PlainHTTP bool   `toml:"plain_http,omitempty"`
}

Jump to

Keyboard shortcuts

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