Documentation
¶
Index ¶
- Constants
- func IsNotFoundError(err error) bool
- type App
- func (a *App) AddSecret(ctx context.Context, env, key, value string) (err error)
- func (a *App) ApproveMember(ctx context.Context, deviceID string) (err error)
- func (a *App) ChangeStorage(ctx context.Context, settings config.StorageConfig) (err error)
- func (a *App) CompactHistory(ctx context.Context, env string, keep int) (result *CompactResult, err error)
- func (a *App) CreateEnvironment(name string) (err error)
- func (a *App) CreateIdentity() (info identity.PublicInfo, warning string, err error)
- func (a *App) CurrentEnvironment() (name string, err error)
- func (a *App) DefaultStorageURL() (_ string, err error)
- func (a *App) DeleteEnvironment(ctx context.Context, name string, purge bool) (deletion EnvironmentDeletion, err error)
- func (a *App) DeleteSecret(ctx context.Context, env, key string) (err error)
- func (a *App) Diagnose(ctx context.Context) DoctorReport
- func (a *App) DiagnoseIdentity(ctx context.Context) identity.Diagnosis
- func (a *App) DiffHistory(ctx context.Context, env string, fromIdx, toIdx int) (diff *Diff, err error)
- func (a *App) EditSecret(ctx context.Context, env, key, value string) (err error)
- func (a *App) IdentityInfo() (info identity.PublicInfo, err error)
- func (a *App) ImportDotenv(ctx context.Context, env string, content []byte, overwrite bool) (result *ImportResult, err error)
- func (a *App) ImportSecrets(ctx context.Context, env string, secrets map[string]string, overwrite bool) (result *ImportResult, err error)
- func (a *App) InitializeRepository(ctx context.Context, opts InitOptions) (result *InitResult, err error)
- func (a *App) ListConflicts(ctx context.Context, env string) (set *ConflictSet, err error)
- func (a *App) ListEnvironments() (envs []EnvInfo, err error)
- func (a *App) ListHistory(ctx context.Context, env string) (history []HistoryEntry, err error)
- func (a *App) ListJoinRequests(ctx context.Context) (requests []JoinRequestInfo, err error)
- func (a *App) ListMembers(ctx context.Context) (members []MemberInfo, err error)
- func (a *App) ListSecrets(ctx context.Context, env string) (result map[string]string, err error)
- func (a *App) PullSecrets(ctx context.Context, env string) (data []byte, output string, count int, err error)
- func (a *App) PullSecretsData(ctx context.Context, env string) (result *PulledSecrets, err error)
- func (a *App) PullSecretsToFile(ctx context.Context, env string) (err error)
- func (a *App) PullSecretsToFileWith(ctx context.Context, env string, replace bool) (written *WrittenFile, err error)
- func (a *App) PurgeIncarnation(ctx context.Context, incarnation string) (deleted int, err error)
- func (a *App) ReadConfig() (content string, err error)
- func (a *App) RemoveMember(ctx context.Context, deviceID string) (err error)
- func (a *App) RenameEnvironment(oldName, newName string) (err error)
- func (a *App) ResolveSecrets(ctx context.Context, env string, seen []string, choices []SecretChoice) (err error)
- func (a *App) RestoreHistory(ctx context.Context, env string, idx int) (err error)
- func (a *App) SetAdmin(ctx context.Context, deviceID string, admin bool) (err error)
- func (a *App) SetRepositoryDir(dir string)
- func (a *App) SwitchEnvironment(name string) (err error)
- func (a *App) SwitchPrevious() (name string, err error)
- func (a *App) SyncSecrets(ctx context.Context, env string) (err error)
- func (a *App) WorkspaceID() (id string, err error)
- func (a *App) WriteConfig(content string) (err error)
- type CompactResult
- type ConflictCandidate
- type ConflictSet
- type DiagnosticCheck
- type Diff
- type DoctorReport
- type EnvInfo
- type EnvironmentDeletion
- type EventHandler
- type HistoryEntry
- type IdentityStore
- type ImportResult
- type InitOptions
- type InitResult
- type JoinRequestInfo
- type MemberInfo
- type ProgressStep
- type PulledSecrets
- type RepoDetector
- type ResolvedEnvironment
- type Runtime
- type SecretChoice
- type SecretConflict
- type TokenProvider
- type WrittenFile
Constants ¶
const DefaultEnvironment = "default"
Variables ¶
This section is empty.
Functions ¶
func IsNotFoundError ¶
Types ¶
type App ¶
type App struct {
// Runtime supplies per-instance external dependencies. Nil uses production defaults.
Runtime *Runtime
Storage storage.Store
StorageURL string
TokenProvider TokenProvider
Identities IdentityStore
RepoDetector RepoDetector
Git gitprovider.Client
Events EventHandler
RepositoryDir string
// CheckpointDir holds the local rollback checkpoints. Empty means the
// per-user data directory.
CheckpointDir string
// CacheDir holds what this device keeps to avoid fetching again: heads of
// stored revisions and the history index. Empty means the per-user data
// directory. Nothing in it is trusted or secret.
CacheDir string
}
func (*App) ApproveMember ¶ added in v0.9.0
ApproveMember adds a pending device to the workspace Control as a member, then re-encrypts every environment for the new recipient set. The caller is expected to have shown the device's fingerprint to the admin.
func (*App) ChangeStorage ¶ added in v0.10.1
ChangeStorage copies verified ciphertext and history before changing enbu.toml. The team must pause writes until every member has the new enbu.toml: immutable OCI objects provide no cross-registry lock or atomic redirect for old clients.
func (*App) CompactHistory ¶ added in v0.9.0
func (a *App) CompactHistory(ctx context.Context, env string, keep int) (result *CompactResult, err error)
CompactHistory deletes the revisions of env older than the latest keep, so storage and the time to read an environment stop growing with its history. Only a workspace admin may compact, on a backend that can delete.
The revision keep-1 steps behind the current one (following each revision's first parent) becomes the floor: it and every revision descending from it stay. Everything else is deleted, after a signed record listing it is published, so other devices accept that those revisions are gone instead of reporting a rollback. The environment must have one head; concurrent heads are merged with sync first.
func (*App) CreateEnvironment ¶
func (*App) CreateIdentity ¶ added in v0.9.0
func (a *App) CreateIdentity() (info identity.PublicInfo, warning string, err error)
func (*App) CurrentEnvironment ¶
func (*App) DefaultStorageURL ¶ added in v0.9.0
DefaultStorageURL is the storage a new workspace gets when none is given: a GHCR repository beside the GitHub origin, or under the signed-in account using the folder name when there is no usable GitHub origin. It is used once, when init writes enbu.toml, and never derived again.
func (*App) DeleteEnvironment ¶
func (a *App) DeleteEnvironment(ctx context.Context, name string, purge bool) (deletion EnvironmentDeletion, err error)
DeleteEnvironment removes an environment from enbu.toml. With purge its stored revisions are deleted too (admin only). Every check runs first, so a deletion that would be refused never deletes secrets: the revisions go only when the environment can really be removed, and the environment stays in enbu.toml until they are gone so a failure halfway can simply be repeated.
func (*App) DeleteSecret ¶
func (*App) Diagnose ¶ added in v0.10.0
func (a *App) Diagnose(ctx context.Context) DoctorReport
Diagnose checks all configured environments without publishing data, creating keys, promoting keys, or advancing trust pins and checkpoints. Successful execution produces a report even when individual checks fail. The caller controls the overall budget: retained histories have no fixed size.
func (*App) DiagnoseIdentity ¶ added in v0.9.0
func (*App) DiffHistory ¶
func (*App) EditSecret ¶
func (*App) IdentityInfo ¶ added in v0.9.0
func (a *App) IdentityInfo() (info identity.PublicInfo, err error)
func (*App) ImportDotenv ¶ added in v0.10.0
func (a *App) ImportDotenv(ctx context.Context, env string, content []byte, overwrite bool) (result *ImportResult, err error)
ImportDotenv adds every variable of a dotenv file's content to env, as ImportSecrets does.
func (*App) ImportSecrets ¶ added in v0.9.0
func (a *App) ImportSecrets(ctx context.Context, env string, secrets map[string]string, overwrite bool) (result *ImportResult, err error)
ImportSecrets adds every key of secrets to env in one signed state. A key that already exists with the same value is left alone; one with another value is refused unless overwrite is set, so an import never changes a secret nobody meant to change.
func (*App) InitializeRepository ¶
func (a *App) InitializeRepository(ctx context.Context, opts InitOptions) (result *InitResult, err error)
InitializeRepository sets this device up in the repository: it founds a workspace, or joins the one enbu.toml names, and keeps the files a pull writes out of Git.
func (*App) ListConflicts ¶ added in v0.9.0
ListConflicts returns the keys of env that are waiting for a decision.
func (*App) ListEnvironments ¶
func (*App) ListHistory ¶
ListHistory lists the retained revisions of env that changed its secrets, oldest first. It is a change log bounded by what storage still holds, not an audit log. Revisions that only re-encrypted the same content are left out, as are revisions this device cannot decrypt (written before it was a member).
Telling those apart needs each revision decrypted once. What was learned is kept in a local index (two flags per revision, never content), so later listings decrypt only revisions that are new since.
func (*App) ListJoinRequests ¶ added in v0.9.0
func (a *App) ListJoinRequests(ctx context.Context) (requests []JoinRequestInfo, err error)
ListJoinRequests returns verified requests from devices that are not yet principals, newest first. Invalid requests are skipped: they are only hints. Storage listing order says nothing about which request is newest, so a device that asked twice with different keys material appears once per distinct recipient and the admin chooses.
func (*App) ListMembers ¶ added in v0.9.0
func (a *App) ListMembers(ctx context.Context) (members []MemberInfo, err error)
ListMembers returns the principals of the verified Control.
func (*App) ListSecrets ¶
func (*App) PullSecrets ¶
func (*App) PullSecretsData ¶ added in v0.8.0
func (*App) PullSecretsToFile ¶
func (*App) PullSecretsToFileWith ¶ added in v0.9.0
func (a *App) PullSecretsToFileWith(ctx context.Context, env string, replace bool) (written *WrittenFile, err error)
PullSecretsToFileWith writes the environment's secrets to its output file, followed by a marker. Variables below the marker that enbu does not store are kept there and reported, unless replace is set; variables above it were written by an earlier pull and leave the file once the environment no longer has them. A file without a marker was written before enbu wrote one, or by hand: its variables that some retained revision of the environment held are enbu's own and leave the file too, and the rest are kept. A file that cannot be read as dotenv is not overwritten without replace.
func (*App) PurgeIncarnation ¶ added in v0.9.0
PurgeIncarnation deletes the stored revisions of an environment that was deleted without --purge, which only forgot where they are. The incarnation is the one switch --delete printed (it is also in enbu.toml's git history). An incarnation that a current environment still uses is refused.
func (*App) ReadConfig ¶
func (*App) RemoveMember ¶ added in v0.9.0
RemoveMember removes a principal and re-encrypts every environment without its recipient. Plaintext the member already obtained cannot be revoked.
func (*App) RenameEnvironment ¶
func (*App) ResolveSecrets ¶ added in v0.9.0
func (a *App) ResolveSecrets(ctx context.Context, env string, seen []string, choices []SecretChoice) (err error)
ResolveSecrets settles every conflicted key of env and publishes the result as a revision that merges all heads. Every conflict must be settled at once: a merge revision holds one value per key. seen is ConflictSet.Heads from the listing the choices were made from; if the heads are different now, nothing is published and the person looks again.
func (*App) RestoreHistory ¶
RestoreHistory publishes the content of a retained revision as a new revision.
func (*App) SetAdmin ¶ added in v0.9.0
SetAdmin grants or revokes the membership-admin flag. It does not change which secrets a member can read.
func (*App) SetRepositoryDir ¶
func (*App) SwitchEnvironment ¶
func (*App) SwitchPrevious ¶
func (*App) WorkspaceID ¶ added in v0.9.0
func (*App) WriteConfig ¶
type CompactResult ¶ added in v0.9.0
type CompactResult struct {
Kept int `json:"kept"` // revisions kept: the latest ones and what they merged
Removed int `json:"removed"` // revisions deleted from storage
}
CompactResult says what a compaction removed.
type ConflictCandidate ¶ added in v0.9.0
type ConflictSet ¶ added in v0.9.0
type ConflictSet struct {
Environment string `json:"environment"`
// ID is a short name for Heads, for a person to repeat back when deciding.
ID string `json:"id"`
Heads []string `json:"heads"`
Conflicts []SecretConflict `json:"conflicts"`
}
ConflictSet is what a person looked at when deciding: the conflicted keys and the heads they were computed from. ResolveSecrets must be given the same Heads, so a value that appeared since is shown to the person rather than swept away by a choice made without seeing it.
type DiagnosticCheck ¶ added in v0.10.0
type DiagnosticCheck struct {
Name string `json:"name"`
Environment string `json:"environment,omitempty"`
Status string `json:"status"`
Message string `json:"message"`
Code apperr.Code `json:"code,omitempty"`
}
DiagnosticCheck contains only safe descriptions and error codes, never provider response bodies, credentials, or decrypted secret names and values.
type DoctorReport ¶ added in v0.10.0
type DoctorReport struct {
identity.Diagnosis
Healthy bool `json:"healthy"`
Checks []DiagnosticCheck `json:"checks"`
}
type EnvironmentDeletion ¶ added in v0.10.0
type EnvironmentDeletion struct {
Purged int `json:"purged"`
// Incarnation is what `enbu switch --purge-incarnation` deletes the
// revisions by later; enbu.toml no longer names it.
Incarnation string `json:"incarnation,omitempty"`
}
EnvironmentDeletion is what deleting an environment did to its stored revisions: how many it purged, or the incarnation that still names them.
type EventHandler ¶
type EventHandler interface {
OnProgress(msg string)
OnStepProgress(step ProgressStep)
OnConflictRetry(attempt, maxAttempts int)
}
type HistoryEntry ¶
type IdentityStore ¶ added in v0.9.0
type IdentityStore interface {
Create(workspaceID string) (*identity.Device, identity.PublicInfo, string, error)
Load(workspaceID string) (*identity.Device, error)
Info(workspaceID string) (identity.PublicInfo, error)
Doctor(context.Context) identity.Diagnosis
}
IdentityStore keeps this device's keys, one set per workspace.
type ImportResult ¶ added in v0.9.0
type ImportResult struct {
Environment string `json:"environment"`
Added []string `json:"added"`
Updated []string `json:"updated"`
Unchanged []string `json:"unchanged"`
}
ImportResult names what one import did to an environment.
type InitOptions ¶ added in v0.10.0
type InitOptions struct {
// Storage is where to found the workspace, with the options enbu.toml
// keeps for it. Nil keeps enbu.toml's storage, or DefaultStorageURL's.
Storage *config.StorageConfig
// AcceptNewGenesis replaces the genesis this device pinned for the
// workspace with the one enbu.toml names. Only a person who confirmed the
// workspace was re-founded sets it.
AcceptNewGenesis bool
}
InitOptions are what `enbu init` takes besides the repository.
type InitResult ¶
type InitResult struct {
PublicKey string `json:"public_key"`
Username string `json:"username"`
Environment string `json:"environment"`
WorkspaceID string `json:"workspace_id"`
// ControlGenesis is the genesis this device trusts for the workspace.
ControlGenesis string `json:"control_genesis"`
Storage string `json:"storage"`
KeyCreated bool `json:"key_created"`
Mode string `json:"mode"`
HasSecrets bool `json:"has_secrets"`
CanDecrypt *bool `json:"can_decrypt"`
DeviceID string `json:"device_id"`
Fingerprint string `json:"fingerprint"`
// Founded is set when this init created the workspace's genesis Control.
Founded bool `json:"founded"`
// Pending is set when this device is not yet in the workspace Control; an
// admin must approve it.
Pending bool `json:"pending"`
// ReplacedGenesis is the genesis this device trusted before
// AcceptNewGenesis replaced it, or "".
ReplacedGenesis string `json:"replaced_genesis,omitempty"`
Warnings []string `json:"-"`
}
type JoinRequestInfo ¶ added in v0.9.0
type MemberInfo ¶ added in v0.9.0
type ProgressStep ¶ added in v0.7.4
type PulledSecrets ¶ added in v0.8.0
type RepoDetector ¶
type ResolvedEnvironment ¶
type Runtime ¶ added in v0.10.0
type Runtime struct {
Clock clock.Clock
NewID func() string
Encrypt func([]byte, []string) ([]byte, error)
LocalStateDir string
}
Runtime isolates clocks, identifiers, encryption and personal state without changing process globals. Unset dependencies retain production behavior. Encryption injection never bypasses decryption or protocol verification.
type SecretChoice ¶ added in v0.9.0
type SecretChoice struct {
Key string `json:"key"`
Value string `json:"value"`
Delete bool `json:"delete"`
}
SecretChoice settles one conflicted key with a value, or by deleting it.
type SecretConflict ¶ added in v0.9.0
type SecretConflict struct {
Key string `json:"key"`
Candidates []ConflictCandidate `json:"candidates"`
}
SecretConflict is a key that concurrent edits changed differently. Nothing is chosen for the user: they pick one candidate, or give a new value.
type TokenProvider ¶
type WrittenFile ¶ added in v0.9.0
type WrittenFile struct {
Output string `json:"output"` // the file, as configured for the environment
Count int `json:"count"` // secrets written
Kept []string `json:"kept"` // variables of the previous file that enbu does not store
// Removed are variables an earlier pull wrote that the environment no
// longer has; they are not kept, so a deleted secret leaves the file.
Removed []string `json:"removed"`
}
WrittenFile describes what a pull wrote.
func (*WrittenFile) Messages ¶ added in v0.9.0
func (w *WrittenFile) Messages() []string
Messages tells the user what the pull kept and removed besides the secrets.
Source Files
¶
- app.go
- compact.go
- config.go
- conflicts.go
- doctor.go
- environments.go
- gitignore.go
- helpers.go
- history.go
- history_index.go
- identity.go
- import.go
- init.go
- interfaces.go
- join_requests.go
- members.go
- output.go
- publish.go
- pull.go
- reencrypt.go
- resource.go
- runtime.go
- secrets.go
- session.go
- storage_local_disabled.go
- storage_migration.go
- write.go