Documentation
¶
Overview ¶
Package contract models notenv.toml, the committed contract declaring which env vars a project needs. It contains no values.
Index ¶
Constants ¶
const FileName = "notenv.toml"
Variables ¶
var ErrNotFound = errors.New("no " + FileName + " found (run `notenv init` in your project root)")
ErrNotFound is returned by Find when no notenv.toml exists between the start directory and the filesystem root.
var NamespaceName = regexp.MustCompile(`^[A-Za-z0-9_][A-Za-z0-9._-]*$`)
NamespaceName constrains namespaces: they become remote object names. Must start with an alphanumeric or underscore, which excludes the path-significant names "." and ".." (and any leading "-"), while still allowing dots/dashes internally.
Frozen at v1: a namespace names on-storage objects, so narrowing this set would orphan blobs built from now-illegal names, and widening it risks colliding with backend path semantics. The backend's blob-key recognizer is held to this exact set by TestNamespaceBlobKeyTracksContract.
Functions ¶
func Declare ¶
Declare appends a secret declaration to the contract file's [secrets] section (creating the section if absent). Textual insert, not a TOML rewrite, so the user's comments and layout survive.
func ValidEnvName ¶ added in v0.1.2
ValidEnvName reports whether s is a usable environment variable name (and thus a valid secret key): a letter or underscore followed by letters, digits, or underscores. Entry points that store a key (e.g. `notenv secret set`) should check this before doing any work, so a name that could never be injected never reaches storage. Frozen at v1: this is the secret-key charset, the shape every stored key and every .env round-trip relies on.
Types ¶
type File ¶
func Find ¶
Find walks up from start to the filesystem root looking for notenv.toml (like git does for .git) and parses the first one found. Returns the parsed file and the directory containing it.
func (*File) BuildEnv ¶
BuildEnv appends the contract's env vars (resolved from secrets) to base. Missing required secrets are an error; missing optional ones are skipped. os/exec deduplicates by key with last-wins, so appending overrides base.
func (*File) StorageKey ¶
StorageKey maps an env var name to the key it is stored under.