Documentation
¶
Overview ¶
Package environment manages environment variable collections and their origin tracking. It provides functionality for overlaying multiple environment sources and exporting them.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Change ¶
type Change struct {
// Key is the environment variable name.
Key string
// Old is the previous value of the variable.
Old string
// New is the current value of the variable.
New string
}
Change represents a single environment variable that has changed between two environments.
type Diff ¶
type Diff struct {
// Added contains variables present in B but not in A.
Added env.Env
// Removed contains variables present in A but not in B.
Removed env.Env
// Changed contains variables present in both with different values.
Changed []Change
}
Diff represents the differences between two environments.
type Environment ¶
type Environment struct {
// Name is the name of the profile.
Name string
// Output is the output file for the profile.
Output file.File
// Env is the environment variables for the profile.
Env env.Env
// Origin tracks the source of each environment variable.
Origin Origin
}
Environment represents the resolved environment variables for a named profile.
func New ¶
func New(name, output string) Environment
New returns a new environment for the given profile, with default values for the output file.
func (*Environment) OverlayDotEnv ¶
func (e *Environment) OverlayDotEnv(path, profile string) error
OverlayDotEnv overlays the environment variables from a .env file.
func (*Environment) OverlayOther ¶
func (e *Environment) OverlayOther(other Environment)
OverlayOther overlays the environment variables from another environment.
func (*Environment) UpdateOrigin ¶
func (e *Environment) UpdateOrigin(profile string, env env.Env)
UpdateOrigin updates the origin of the environment variables.
func (*Environment) Write ¶
func (e *Environment) Write() error
Write saves the environment variables to a dotenv file.
type Formatter ¶
type Formatter struct {
// WithOrigin indicates whether to include the origin of the variable.
WithOrigin bool
// WithKey indicates whether to include the key in the output.
WithKey bool
// Prefix is a string to prepend to the variable value.
Prefix string
// Padding is the width of the output field.
Padding int
}
Formatter holds the configuration for formatting environment variables.
func (Formatter) All ¶
func (f Formatter) All(environment Environment) string
All formats all environment variables for output.
type Heritage ¶
type Heritage []string
Heritage represents the inheritance chain of an environment variable.