Documentation
¶
Index ¶
- func DataDir() string
- func DefaultDataDir() 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 ProjectConfigPathFrom(dir string) (string, error)
- func SaveGUI(cfg *GUIConfig) error
- func SaveLocalStateTo(dir, workspaceID string, cfg *LocalConfig) 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 DecodeProject(content string) (*ProjectConfig, error)
- func LoadProject() (*ProjectConfig, error)
- func LoadProjectFrom(dir string) (*ProjectConfig, error)
- func NewProjectWithEnvironment(name string) *ProjectConfig
- func NewProjectWithIDs(name string, newID func() string) *ProjectConfig
- func ParseProject(content string) (*ProjectConfig, error)
- func (cfg *ProjectConfig) AddEnvironment(name string) error
- func (cfg *ProjectConfig) AddEnvironmentWithID(name string, newID func() 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 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 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 ProjectConfigPathFrom ¶
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 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 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"`
}