1fed2d910c
If you are using rclone a library you can decide to use the rclone config file system or not by calling configfile.LoadConfig(ctx) If you don't you will need to set `config.Data` to an implementation of `config.Storage`. Other changes - change interface of config.FileGet to remove unused default - remove MustValue from config.Storage interface - change GetValue to return string or bool like elsewhere in rclone - implement a default config file system which panics with helpful error - implement getWithDefault to replace the removed MustValue - don't embed goconfig.ConfigFile so we can change the methods
61 lines
1.6 KiB
Go
61 lines
1.6 KiB
Go
package config
|
|
|
|
// Default config.Storage which panics with a useful error when used
|
|
type defaultStorage struct{}
|
|
|
|
var noConfigStorage = "internal error: no config file system found. Did you call configfile.LoadConfig(ctx)?"
|
|
|
|
// GetSectionList returns a slice of strings with names for all the
|
|
// sections
|
|
func (defaultStorage) GetSectionList() []string {
|
|
panic(noConfigStorage)
|
|
}
|
|
|
|
// HasSection returns true if section exists in the config file
|
|
func (defaultStorage) HasSection(section string) bool {
|
|
panic(noConfigStorage)
|
|
}
|
|
|
|
// DeleteSection removes the named section and all config from the
|
|
// config file
|
|
func (defaultStorage) DeleteSection(section string) {
|
|
panic(noConfigStorage)
|
|
}
|
|
|
|
// GetKeyList returns the keys in this section
|
|
func (defaultStorage) GetKeyList(section string) []string {
|
|
panic(noConfigStorage)
|
|
}
|
|
|
|
// GetValue returns the key in section with a found flag
|
|
func (defaultStorage) GetValue(section string, key string) (value string, found bool) {
|
|
panic(noConfigStorage)
|
|
}
|
|
|
|
// SetValue sets the value under key in section
|
|
func (defaultStorage) SetValue(section string, key string, value string) {
|
|
panic(noConfigStorage)
|
|
}
|
|
|
|
// DeleteKey removes the key under section
|
|
func (defaultStorage) DeleteKey(section string, key string) bool {
|
|
panic(noConfigStorage)
|
|
}
|
|
|
|
// Load the config from permanent storage
|
|
func (defaultStorage) Load() error {
|
|
panic(noConfigStorage)
|
|
}
|
|
|
|
// Save the config to permanent storage
|
|
func (defaultStorage) Save() error {
|
|
panic(noConfigStorage)
|
|
}
|
|
|
|
// Serialize the config into a string
|
|
func (defaultStorage) Serialize() (string, error) {
|
|
panic(noConfigStorage)
|
|
}
|
|
|
|
// Check the interface is satisfied
|
|
var _ Storage = defaultStorage{}
|