Documentation
¶
Overview ¶
Secret stores API keys and other variables come from, such as Bitwarden Secrets Manager and 1Password, and the environment each profile reads through them: its own .env and what its stores supply over this process's environment
Index ¶
- Constants
- func Action(name, tokenEnv string, existing map[string]string, override bool) string
- func Encode(entry Entry) map[string]any
- func Expand(cfg *config.Config, text string) string
- func Fingerprint(material string) string
- func RemoveFile(path string)
- func Save(cfg *config.Config, settings ...Saved) error
- func Version(ctx context.Context, binary string, env map[string]string) string
- func Which(name, path string) string
- func WriteJSON(path string, payload any) error
- type Applied
- type Cache
- func (c *Cache) Clear(dir string)
- func (c *Cache) Lookup(dir, key string, ttl time.Duration, read func() (Entry, bool)) (Entry, bool, error)
- func (c *Cache) Path(dir string) string
- func (c *Cache) Read(dir, key string, ttl time.Duration) (Entry, bool, error)
- func (c *Cache) Remember(key string, entry Entry)
- func (c *Cache) Store(dir, key string, entry Entry, ttl time.Duration)
- func (c *Cache) Write(dir, key string, entry Entry, ttl time.Duration)
- type Configurable
- type Entry
- type Failure
- type Fetch
- type Forgetter
- type Live
- type Needer
- type Outcome
- type Output
- type Registrant
- type Registry
- type Report
- type Result
- type Rule
- type Saved
- type Secrets
- func (h *Secrets) Asked(cfg *config.Config) []Source
- func (h *Secrets) Bind(cfg *config.Config, name, variable, reference string) error
- func (h *Secrets) Bindings(cfg *config.Config, name string) map[string]string
- func (h *Secrets) Configured(cfg *config.Config, source Source) (bool, string)
- func (h *Secrets) Delete(profile string) error
- func (h *Secrets) Enabled(cfg *config.Config, name string) bool
- func (h *Secrets) Environ(c *config.Config) map[string]string
- func (h *Secrets) Existing(cfg *config.Config) map[string]string
- func (h *Secrets) Export(c *config.Config, source string, values map[string]string)
- func (h *Secrets) Fetch(ctx context.Context, cfg *config.Config, source Source, fresh bool) Result
- func (h *Secrets) Forget(cfg *config.Config, name string) (bool, error)
- func (h *Secrets) Lookup(c *config.Config, name string) (string, bool)
- func (h *Secrets) Ordered(cfg *config.Config) []Source
- func (h *Secrets) Origin(c *config.Config, name string) string
- func (h *Secrets) Overrides(cfg *config.Config, name string) bool
- func (h *Secrets) Preview(ctx context.Context, cfg *config.Config, name string, apply bool) ([]Outcome, []string, error)
- func (h *Secrets) Refresh(profile string)
- func (h *Secrets) Register(registrant Registrant)
- func (h *Secrets) Remedy(cfg *config.Config, spec Spec, kind Failure) string
- func (h *Secrets) Reorder(cfg *config.Config, names []string) error
- func (h *Secrets) Report(c *config.Config) Report
- func (h *Secrets) Reset(c *config.Config) Report
- func (h *Secrets) Serve(teller Teller)
- func (h *Secrets) Source(cfg *config.Config, name string) (Source, bool)
- func (h *Secrets) State(ctx context.Context, cfg *config.Config, source Source) State
- func (h *Secrets) States(ctx context.Context, cfg *config.Config, fresh bool, pass func() Report) ([]Source, []State, Report)
- func (h *Secrets) Stop(profile string) error
- func (h *Secrets) Switch(cfg *config.Config, name string, on bool) error
- func (h *Secrets) TokenEnv(cfg *config.Config, spec Spec) string
- func (h *Secrets) Unbind(cfg *config.Config, name, variable string) (bool, error)
- func (h *Secrets) WrittenBindings(cfg *config.Config, name string) map[string]string
- func (h *Secrets) WrittenTokenEnv(cfg *config.Config, spec Spec) string
- type Source
- type SourceReport
- type Sources
- type Spec
- type State
- type Teller
Constants ¶
const ( // Variables bound one by one to references in the store, such as op:// ones Mapped = "mapped" // Every secret of a project, each under its own name Bulk = "bulk" )
How a store hands its secrets over
const FetchTimeout = 120 * time.Second
Longest one fetch of a store may take unless its timeout_seconds says otherwise
Variables ¶
This section is empty.
Functions ¶
func Action ¶
What the next fetch would do with a variable a store hands over: skip_token for the store's own credential, skip_set for one set already that the store does not replace, override for one it does, export for the rest
func Expand ¶
Text a person gave a setting of a store as the store reads it, each ${NAME} standing for the variable it names among those the profile has without its stores, as a fetch reads its settings; a reference to a variable that is not set stays as it is written
func Fingerprint ¶
SHA-256 prefix of credential material a cache is keyed by, never shown
func RemoveFile ¶
func RemoveFile(path string)
Deletes a file, or a link where one stands, leaving a folder at the path alone
func Save ¶
Keeps the settings a store's own steps give, such as those its setup chose: each checked as a person's write of it is checked and found unlocked before any is written, so a refusal leaves the settings as they were, then each written in order. A setting given as the profile has it already, as a person wrote it, is not written at all, so the settings file keeps it as it holds it, references, comments and all; nor is a nil one the file holds nothing of. The caller fetches the stores again
func Version ¶
First line of what the program says of its version, "version unknown" when it says nothing or fails. A program run with the variables of this machine alone says the same of the same file, so what it said is kept until its file changes
Types ¶
type Applied ¶
type Applied struct {
Source string
// The store's value wins over one the .env gains later, the store overriding and the variable not kept local
Authoritative bool
}
Where one variable the stores set came from
type Cache ¶
type Cache struct {
// File name in the profile folder
Name string
// contains filtered or unexported fields
}
What a store fetched kept in this process and in a file of the profile folder, so a start within the ttl asks the store nothing
func (*Cache) Lookup ¶
func (c *Cache) Lookup(dir, key string, ttl time.Duration, read func() (Entry, bool)) (Entry, bool, error)
Fresh entry of the key from this process, else from the file, or from read when one is given, which this process keeps from then on
func (*Cache) Read ¶
Fresh entry of the key in the file, false when it is another key's, stale, or no entry; an error naming the file only for bytes that are not text
type Configurable ¶
Store that fetches with settings of its own beyond its credential, such as the project a bulk store pulls: the key of the first of them the profile leaves empty, empty once it is configured
type Entry ¶
Secrets fetched once, with when
type Failure ¶
type Failure string
Kind of failure of a fetch, which picks the fix a person is told
const ( NotConfigured Failure = "not_configured" BinaryMissing Failure = "binary_missing" AuthFailed Failure = "auth_failed" AuthExpired Failure = "auth_expired" RefInvalid Failure = "ref_invalid" Network Failure = "network" EmptyValue Failure = "empty_value" Timeout Failure = "timeout" Internal Failure = "internal" )
type Fetch ¶
type Fetch struct {
// Settings of the profile, read without the stores, so a fetch never waits on itself
Config *config.Config
// Variables the profile has without any store: its .env over this process's environment
Env map[string]string
// Nothing kept from an earlier ask stands in for asking: a fetch neither reads nor writes the caches of what the store holds, and a store
// asked what it lacks asks again what it keeps of how it stands, keeping the new answer
Fresh bool
}
One fetch of a store's secrets for a profile
type Forgetter ¶
type Forgetter interface {
Forget()
}
Store that keeps something of how it stands between the times it is asked what it lacks, such as what its program said of a sign-in, which it forgets as the profile turns it on or off or removes its token
type Live ¶
type Live interface {
Registrant
Live(profile string) []Source
}
Registrant whose stores come and go as it runs, such as those the extensions of a profile offer: its Sources has none, and the stores it offers a profile are listed again on every read, one whose name, shape or scheme can't be used left out rather than refused as a mistake of the code. Listing reads no setting or variable and starts nothing, since the stores are listed while a variable is being looked up
type Needer ¶
type Needer interface {
// What keeps it from working for the profile, in a few words and as a sentence; empty when nothing does. A slow question it asks, such as
// whether its program is signed in, may be answered as it was a moment ago, and is asked again when the fetch is fresh
Needs(ctx context.Context, fetch Fetch) (short, sentence string)
}
Store that says what it lacks to fill anything besides what the settings it fetches with hold, such as its program or a sign-in
type Outcome ¶
type Outcome struct{ Name, Action string }
What a fetch of a store does with one variable: export, override, skip_set, skip_token or unresolved; exported or overrode once set
type Output ¶
What a helper program printed and how it ended
func Run ¶
func Run(ctx context.Context, argv []string, env map[string]string, timeout time.Duration, label, timedOut string, stdin io.Reader) (Output, error)
Runs a helper program with exactly the variables given, those of this machine alone for none, its output as text; a timeout fails with the message given, a program that would not start with the label
type Registrant ¶
type Registrant interface {
Sources() []Source
}
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
func (*Registry) Host ¶
Host the registry is nested in, through which plugins fetch from other stores and read a profile's environment
func (*Registry) Live ¶
Stores the live registrants offer the profile now, those of the registries nested in this one among them
func (*Registry) Register ¶
func (r *Registry) Register(registrant Registrant)
type Report ¶
type Report struct {
Sources []SourceReport
// Values the stores set and where each came from, by variable
Values map[string]string
Applied map[string]Applied
// Variables two stores supplied, the first keeping it
Conflicts []string
}
What a pass over every enabled store did for a profile
type Result ¶
type Result struct {
// Values by variable
Secrets map[string]string
Warnings []string
// Why it failed, empty when it did not
Error string
Kind Failure
// Helper program it ran
Binary string
}
What one fetch got
type Saved ¶
One setting of a store that its own steps keep, such as the project Bitwarden loads, nil taking it out of the settings file
type Secrets ¶
type Secrets struct {
Registry
// contains filtered or unexported fields
}
The secret stores and the environment of every profile
func (*Secrets) Asked ¶
Every store in the order a fetch asks them: those that fill named variables first, so a variable bound to a reference wins over one a store holds among all its secrets, then the others, each kind in its place in Ordered
func (*Secrets) Bind ¶
Fills the variable from the reference in the store, the reference checked as it reads before it is kept as it is written, then fetches the stores again; a reference the variable is filled from already, as it is written, leaves the settings as they are
func (*Secrets) Bindings ¶
Variables a store that fills named ones binds to its references, each named as it is written and its reference as it is read, every ${NAME} in it standing for the variable it names: what a fetch asks the store for
func (*Secrets) Configured ¶
Whether the store has every setting it fetches with, its credential aside, and the key of the first one missing when it has not
func (*Secrets) Existing ¶
Variables the profile has without its stores, to judge what a store would replace
func (*Secrets) Export ¶
Sets the variables for the profile as the store supplied them, over the .env and what was there, until its stores are fetched again: what a sync exports
func (*Secrets) Fetch ¶
Fetches the store's secrets for the profile within its timeout, the variables it reads being the profile's without any store
func (*Secrets) Forget ¶
Removes the token the store signs in with from the profile's keys file, then fetches the stores again; false when the keys file held none
func (*Secrets) Lookup ¶
Value of the variable for the profile: what its stores set, else its .env, else the .env beside the icebath program when the profile has none, else this process's, else its .op.env and the .env beside the program
func (*Secrets) Ordered ¶
Every store: those secrets.sources names first, in its order, then the others in the order they are registered. The stores are listed once and found by name in that list, each name being one store's alone
func (*Secrets) Origin ¶
Store that supplied the variable the profile reads, by its short name, empty for one of the .env or this process
func (*Secrets) Overrides ¶
Whether the store's values replace those the shell or the .env set already
func (*Secrets) Preview ¶
func (h *Secrets) Preview(ctx context.Context, cfg *config.Config, name string, apply bool) ([]Outcome, []string, error)
Fetches the store now, neither reading nor writing its cache, and says what the next start does with each variable it holds and why a bound one could not be read. Apply sets those it would set for the profile until the stores are fetched again
func (*Secrets) Refresh ¶
Has the stores of a profile fetched again the next time a variable of it is read, for stores that came or went, such as those of an extension that started or stopped
func (*Secrets) Register ¶
func (h *Secrets) Register(registrant Registrant)
Adds a registrant; a registry nested in the host reaches it through Host
func (*Secrets) Remedy ¶
Fix of a failure of the store, empty when there is none to tell, the variable of its credential named as its setting is written
func (*Secrets) Reorder ¶
Asks the stores in the order named, those not named after them in the order they are registered, then fetches them again; the order as it is written already leaves the settings as they are
func (*Secrets) Report ¶
What the stores of the profile last did, fetched now when they have not been
func (*Secrets) Reset ¶
Fetches the stores of the profile again, the report of the fetch coming back
func (*Secrets) Serve ¶
Asks the stores of every profile from now on, for a process that serves its own profiles: each profile's are fetched the first time a variable of it is read, and the person on the profile is told through teller what went wrong in that first fetch. Serving again changes nothing
func (*Secrets) State ¶
How the store stands for the profile: on or off, what it lacks, how many variables it fills, and its credential
func (*Secrets) States ¶
func (h *Secrets) States(ctx context.Context, cfg *config.Config, fresh bool, pass func() Report) ([]Source, []State, Report)
Every store of the profile in the order they are asked with how each stands, and the report of the pass over them that pass makes, such as Report or Reset. The pass and what each store lacks are asked side by side, the variables the profile has without its stores read once for all of them; fresh has every store ask again what it would otherwise keep of how it stands
func (*Secrets) Stop ¶
Forgets what the stores supplied a profile before its folder moves to a new name, its stores read again under that one
func (*Secrets) Switch ¶
Turns the store on or off for the profile, then fetches the stores again so what it fills comes or goes at once
func (*Secrets) Unbind ¶
Stops filling the variable from the store, then fetches the stores again; false when the store did not fill it
func (*Secrets) WrittenBindings ¶
Variables a store that fills named ones binds to its references, each reference exactly as a person wrote it, every ${NAME} kept: what a person is shown of them and what a change of one starts from, so one sent back as it is shown is the one the settings file holds
type Source ¶
type Source interface {
Spec() Spec
// Resolves the store's secrets for the profile; a failure is a Result, never a panic
Fetch(ctx context.Context, fetch Fetch) Result
}
Store of secrets a plugin brings
type SourceReport ¶
type SourceReport struct {
Name, Label string
Result Result
Applied []string
// Variables it supplied that were kept: set already and not replaced, taken by an earlier store, the credential of a store, not names
Existing, Claimed, Protected, Invalid []string
}
What one store did in a pass
type Spec ¶
type Spec struct {
// Name of its section, secrets.<name>, and of its subcommand
Name string
// Name in status lines, and the short one variables are said to come from
Label, Short string
Shape string
// Scheme of the references it resolves, such as op for op://, owned by one store only, a reference of it a person reads as an example,
// and a sentence saying where a person finds one
Scheme, Example, Find string
// Setting of its section naming the variable that holds its own credential, and that variable unless the setting names another; no
// store may overwrite it
TokenSetting, TokenEnv string
// Fix of a kind of failure, {name} standing for the store and {token_env} for the variable of its credential
Hints map[Failure]string
}
What a store is, fixed for it
type State ¶
type State struct {
On bool
// What keeps it from filling anything, in the few words a row says, such as Needs a token, and as the sentence its page opens on; empty
// when nothing does
Needs, Lacks string
// Variables it fills: those bound to its references for a store that fills named ones, those its last fetch set for one that fills all
// it holds
Fills int
// Variable of the credential it signs in with as its setting is written, every ${NAME} kept, and whether the profile holds one, for a
// store that has one
TokenEnv string
TokenSet bool
}
How a store stands for a profile
Directories
¶
| Path | Synopsis |
|---|---|
|
Page of Secret stores in the settings menu: the stores with how each stands, the page of each with turning it on or off, setting it up, the variables it fills and its options, the order they are asked in, and the options every store shares
|
Page of Secret stores in the settings menu: the stores with how each stands, the page of each with turning it on or off, setting it up, the variables it fills and its options, the order they are asked in, and the options every store shares |
|
The secrets command: the subcommands of each secret store, which the stores register, and what every store shares: how each stands, turning one on or off, and the order they are asked in
|
The secrets command: the subcommands of each secret store, which the stores register, and what every store shares: how each stands, turning one on or off, and the order they are asked in |