Documentation
¶
Overview ¶
Package profile provides named configurations. Each non-default profile reads its values from its own file, so profiles do not share values. A Registry finds profiles by name.
Index ¶
Constants ¶
const DefaultName = "default"
DefaultName is the name of the default profile, whose configuration is the base configuration of the registry.
Variables ¶
var ErrCorrupt = errors.New("profile file is not valid")
ErrCorrupt is returned when a profile file exists but is not a valid configuration file.
var ErrInvalidName = errors.New("invalid profile name")
ErrInvalidName is returned when a profile name is not allowed.
var ErrNotFound = errors.New("profile not found")
ErrNotFound is returned when a profile does not exist.
Functions ¶
This section is empty.
Types ¶
type Profile ¶
type Profile interface {
// Name is the profile's name.
Name() string
// Configuration holds the profile's values. The same instance is returned on every call.
Configuration() configuration.Configuration
}
Profile is one named profile.
type Registry ¶
type Registry interface {
// Profile returns the profile with the given name, or ErrNotFound if it does not exist.
Profile(name string) (Profile, error)
}
Registry finds profiles by name.
func NewFileRegistry ¶
func NewFileRegistry(baseDir string, base configuration.Configuration) (Registry, error)
NewFileRegistry returns a registry that reads each profile from baseDir/profiles/<name>.json. The default profile is base itself, and every other profile is derived from base. baseDir must be absolute, otherwise a profile would fall back to the default storage.