import "github.com/muesli/beehive/cfg"
aesbackend.go config.go filebackend.go membackend.go
const EncryptedHeaderPrefix = "beehiveconf+"
EncryptedHeaderPrefix is added to the encrypted configuration to make it possible to detect it's an encrypted configuration file
const PasswordEnvVar = "BEEHIVE_CONFIG_PASSWORD"
PasswordEnvVar defines the environment variable name that should contain the configuration password.
DefaultPath returns Beehive's default config path.
The path returned is OS dependant. If there's an error while trying to figure out the OS dependant path, "beehive.conf" in the current working dir is returned.
IsEncrypted returns true and no error if the configuration is encrypted
If the error returned is not nil, an error was returned while opening or reading the file.
Lookup tries to find the config file.
If a config file is found in the current working directory, that's returned. Otherwise we try to locate it following an OS dependant:
Unix:
- ~/.config/app/filename.conf
macOS:
- ~/Library/Preferences/app/filename.conf
Windows:
- %LOCALAPPDATA%/app/Config/filename.conf
If no valid config file is found, an empty string is returned.
type AESBackend struct{}
AESBackend symmetrically encrypts the configuration file using AES-GCM
func NewAESBackend(u *url.URL) (*AESBackend, error)
NewAESBackend creates the backend.
Given the password is required to encrypt/decrypt the configuration, if the URL passed doesn't have a password or PasswordEnvVar is not defined, it'll return an error.
Load configuration file from the given URL and decrypt it
func (b *AESBackend) Save(config *Config) error
Save encrypts then saves the configuration
type Config struct { Bees []bees.BeeConfig Actions []bees.Action Chains []bees.Chain // contains filtered or unexported fields }
Config contains an entire configuration set for Beehive
New returns a new Config struct.
The URL will be matched against all the supported backends and the first backend that can handle the URL scheme will be loaded.
A UNIX style path is also accepted, and will be handled by the default FileBackend.
func (c *Config) Backend() ConfigBackend
Backend currently being used.
Load the configuration.
The backend loaded will be responsible for loading it from the given URL.
Save the current configuration.
The backend loaded will be responsible for saving it to the given URL
SetURL updates the configuration URL.
Next time the config is loaded or saved the new URL will be used.
URL currently being used.
ConfigBackend is the interface implemented by the configuration backends.
Backends are responsible for loading and saving the Config struct to memory, the local filesystem, the network, etc.
type FileBackend struct {
// contains filtered or unexported fields
}
FileBackend implements a filesystem backend for the configuration
func NewFileBackend() *FileBackend
NewFileBackend returns a FileBackend that handles loading and saving files from the local filesytem.
Load loads chains from config
func (fs *FileBackend) Save(config *Config) error
Save saves chains to config
type MemBackend struct {
// contains filtered or unexported fields
}
MemBackend implements a dummy memory backend for the configuration
func NewMemBackend() *MemBackend
NewMemBackend returns a backend that handles loading and saving the configuration from memory
Load the config from memory
No need to do anything here, already loaded
func (m *MemBackend) Save(config *Config) error
Save the config to memory
No need to do anything special here, already in memory
Package cfg imports 16 packages (graph) and is imported by 4 packages. Updated 2021-01-26. Refresh now. Tools for package owners.