Documentation
¶
Index ¶
- func DataDir() string
- func DefaultOutput(name string) string
- func LocalStatePath(workspaceID string) string
- func MarshalProject(cfg *ProjectConfig) ([]byte, error)
- func ParseGitHubRemote(remote string) (string, string, error)
- func ProjectConfigPath() (string, error)
- func ProjectConfigPathFrom(dir string) (string, error)
- func SaveGUI(cfg *GUIConfig) error
- func SaveLocalState(workspaceID string, cfg *LocalConfig) error
- func SaveProject(cfg *ProjectConfig) error
- func SaveProjectTo(dir string, cfg *ProjectConfig) error
- func ValidEnvironmentName(name string) bool
- func ValidateProjectOutputs(cfg *ProjectConfig) error
- type EnvironmentConfig
- type GUIConfig
- type LocalConfig
- type ProjectConfig
- func (cfg *ProjectConfig) AddEnvironment(name string) error
- func (cfg *ProjectConfig) CurrentEnvironment() string
- func (cfg *ProjectConfig) Environment(name string) (EnvironmentConfig, error)
- func (cfg *ProjectConfig) EnvironmentNames() []string
- func (cfg *ProjectConfig) HasEnvironment(name string) bool
- func (cfg *ProjectConfig) RemoveEnvironment(name string) error
- func (cfg *ProjectConfig) RenameEnvironment(oldName, newName string) error
- func (cfg *ProjectConfig) Resource(env string) string
- func (cfg *ProjectConfig) SetDefault(name string)
- type StorageConfig
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 LocalStatePath ¶
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 ¶
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 ¶
ProjectConfigPath returns the path to enbu.toml by traversing up from cwd.
func ProjectConfigPathFrom ¶
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 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 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)