Documentation ¶
Overview ¶
* knoxite * Copyright (c) 2020, Nicolas Martin <penguwin@penguwin.eu> * 2020, Sergio Rubio <sergio@rubio.im> * * For license see LICENSE
* knoxite * Copyright (c) 2020, Nicolas Martin <penguwin@penguwin.eu> * 2020, Sergio Rubio <sergio@rubio.im> * * For license see LICENSE
* knoxite * Copyright (c) 2020, Nicolas Martin <penguwin@penguwin.eu> * 2020, Sergio Rubio <sergio@rubio.im> * * For license see LICENSE
* knoxite * Copyright (c) 2020, Nicolas Martin <penguwin@penguwin.eu> * 2020, Sergio Rubio <sergio@rubio.im> * * For license see LICENSE
Index ¶
Constants ¶
const ( FileConf = iota CryptoConf MemoryConf )
Available configuration backends.
const EncryptedHeaderPrefix = "knoxiteconf+"
EncryptedHeaderPrefix is added to the encrypted configuration to make it possible to detect it's an encrypted configuration file.
Variables ¶
This section is empty.
Functions ¶
func DefaultPath ¶
func DefaultPath() string
DefaultPath returns Knoxite's default config path.
The path returned is OS dependant. If there's an error while trying to figure out the OS dependant path, "knoxite.conf" in the current working dir is returned.
func IsEncrypted ¶
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.
func Lookup ¶
func Lookup() string
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/knoxite/knoxite.conf
macOS:
- ~/Library/Preferences/knoxite/knoxite.conf
Windows:
- %LOCALAPPDATA%/knoxite/Config/knoxite.conf
If no valid config file is found, an empty string is returned.
Types ¶
type AESBackend ¶
type AESBackend struct{}
AESBackend symmetrically encrypts the configuration file using AES-GCM.
func NewAESBackend ¶
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.
func (*AESBackend) Load ¶
func (b *AESBackend) Load(u *url.URL) (*Config, error)
Load configuration file from the given URL and decrypt it.
func (*AESBackend) Save ¶
func (b *AESBackend) Save(config *Config) error
Save encrypts then saves the configuration.
func (*AESBackend) Type ¶
func (b *AESBackend) Type() int
type Config ¶
type Config struct { Repositories map[string]RepoConfig `toml:"repositories"` // contains filtered or unexported fields }
func New ¶
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.
func (*Config) Load ¶
Load the configuration.
The backend loaded will be responsible for loading it from the given URL.
func (*Config) SetURL ¶
SetURL updates the configuration URL.
Next time the config is loaded or saved the new URL will be used.
type ConfigBackend ¶
ConfigBackend is the interface implemented by the configuration backends.
Backends are responsible for loading and saving the Config struct to the local filesystem, the network, etc.
type FileBackend ¶
type FileBackend struct{}
FileBackend implements a filesystem backend for the configuration.
func NewFileBackend ¶
func NewFileBackend() *FileBackend
NewFileBackend returns a FileBackend that handles loading and saving files from the local filesytem.
func (*FileBackend) Load ¶
func (fs *FileBackend) Load(u *url.URL) (*Config, error)
Load a config from a URL.
func (*FileBackend) Type ¶
func (fs *FileBackend) Type() int
type MemBackend ¶
type MemBackend struct {
// contains filtered or unexported fields
}
MemBackend implements a dummy memory backend for the configuration.
func NewMemBackend ¶
func NewMemBackend() *MemBackend
NewMemBackend returns a backend that handles loading and saving the configuration from memory.
func (*MemBackend) Load ¶
func (m *MemBackend) Load(u *url.URL) (*Config, error)
Load the config from memory.
No need to do anything here, already loaded.
func (*MemBackend) Save ¶
func (m *MemBackend) Save(config *Config) error
Save the config to memory.
No need to do anything special here, already in memory.
func (*MemBackend) Type ¶
func (m *MemBackend) Type() int
type RepoConfig ¶
type RepoConfig struct { Url string `toml:"url" comment:"Repository directory to backup to/restore from"` Compression string `toml:"compression" comment:"Compression algo to use: none (default), flate, gzip, lzma, zlib, zstd"` Tolerance uint `toml:"tolerance" comment:"Failure tolerance against n backend failures"` Encryption string `toml:"encryption" comment:"Encryption algo to use: aes (default), none"` Pedantic bool `toml:"pedantic" comment:"Stop backup operation after the first error occurred"` StoreExcludes []string `toml:"store_excludes" comment:"Specify excludes for the store operation"` RestoreExcludes []string `toml:"restore_excludes" comment:"Specify excludes for the restore operation"` }
The RepoConfig struct contains all the default values for a a repository.