Documentation ¶
Index ¶
- Constants
- Variables
- func FixInvalidLocales(cfg *model.Config) bool
- func GenerateClientConfig(c *model.Config, diagnosticID string, license *model.License) map[string]string
- func GenerateLimitedClientConfig(c *model.Config, diagnosticID string, license *model.License) map[string]string
- func Merge(cfg *model.Config, patch *model.Config, mergeConfig *utils.MergeConfig) (*model.Config, error)
- func Migrate(from, to string) error
- type DatabaseStore
- func (ds *DatabaseStore) Close() error
- func (cs *DatabaseStore) Get() *model.Config
- func (cs *DatabaseStore) GetEnvironmentOverrides() map[string]interface{}
- func (ds *DatabaseStore) GetFile(name string) ([]byte, error)
- func (ds *DatabaseStore) HasFile(name string) (bool, error)
- func (ds *DatabaseStore) Load() (err error)
- func (cs *DatabaseStore) RemoveEnvironmentOverrides(cfg *model.Config) *model.Config
- func (ds *DatabaseStore) RemoveFile(name string) error
- func (ds *DatabaseStore) Set(newCfg *model.Config) (*model.Config, error)
- func (ds *DatabaseStore) SetFile(name string, data []byte) error
- func (ds *DatabaseStore) String() string
- type FileStore
- func (fs *FileStore) Close() error
- func (cs *FileStore) Get() *model.Config
- func (cs *FileStore) GetEnvironmentOverrides() map[string]interface{}
- func (fs *FileStore) GetFile(name string) ([]byte, error)
- func (fs *FileStore) HasFile(name string) (bool, error)
- func (fs *FileStore) Load() (err error)
- func (cs *FileStore) RemoveEnvironmentOverrides(cfg *model.Config) *model.Config
- func (fs *FileStore) RemoveFile(name string) error
- func (fs *FileStore) Set(newCfg *model.Config) (*model.Config, error)
- func (fs *FileStore) SetFile(name string, data []byte) error
- func (fs *FileStore) String() string
- type Listener
- type MemoryStore
- func (ms *MemoryStore) Close() error
- func (cs *MemoryStore) Get() *model.Config
- func (cs *MemoryStore) GetEnvironmentOverrides() map[string]interface{}
- func (ms *MemoryStore) GetFile(name string) ([]byte, error)
- func (ms *MemoryStore) HasFile(name string) (bool, error)
- func (ms *MemoryStore) Load() (err error)
- func (cs *MemoryStore) RemoveEnvironmentOverrides(cfg *model.Config) *model.Config
- func (ms *MemoryStore) RemoveFile(name string) error
- func (ms *MemoryStore) Set(newCfg *model.Config) (*model.Config, error)
- func (ms *MemoryStore) SetFile(name string, data []byte) error
- func (ms *MemoryStore) String() string
- type MemoryStoreOptions
- type Store
Constants ¶
const MaxWriteLength = 4 * 1024 * 1024
MaxWriteLength defines the maximum length accepted for write to the Configurations or ConfigurationFiles table.
It is imposed by MySQL's default max_allowed_packet value of 4Mb.
Variables ¶
var ( // ErrReadOnlyConfiguration is returned when an attempt to modify a read-only configuration is made. ErrReadOnlyConfiguration = errors.New("configuration is read-only") )
Functions ¶
func FixInvalidLocales ¶
FixInvalidLocales checks and corrects the given config for invalid locale-related settings.
Ideally, this function would be completely internal, but it's currently exposed to allow the cli to test the config change before allowing the save.
func GenerateClientConfig ¶
func GenerateClientConfig(c *model.Config, diagnosticID string, license *model.License) map[string]string
GenerateClientConfig renders the given configuration for a client.
func GenerateLimitedClientConfig ¶
func GenerateLimitedClientConfig(c *model.Config, diagnosticID string, license *model.License) map[string]string
GenerateLimitedClientConfig renders the given configuration for an untrusted client.
Types ¶
type DatabaseStore ¶
type DatabaseStore struct {
// contains filtered or unexported fields
}
DatabaseStore is a config store backed by a database.
func NewDatabaseStore ¶
func NewDatabaseStore(dsn string) (ds *DatabaseStore, err error)
NewDatabaseStore creates a new instance of a config store backed by the given database.
func (*DatabaseStore) Close ¶
func (ds *DatabaseStore) Close() error
Close cleans up resources associated with the store.
func (*DatabaseStore) GetEnvironmentOverrides ¶
func (cs *DatabaseStore) GetEnvironmentOverrides() map[string]interface{}
GetEnvironmentOverrides fetches the configuration fields overridden by environment variables.
func (*DatabaseStore) GetFile ¶
func (ds *DatabaseStore) GetFile(name string) ([]byte, error)
GetFile fetches the contents of a previously persisted configuration file.
func (*DatabaseStore) HasFile ¶
func (ds *DatabaseStore) HasFile(name string) (bool, error)
HasFile returns true if the given file was previously persisted.
func (*DatabaseStore) Load ¶
func (ds *DatabaseStore) Load() (err error)
Load updates the current configuration from the backing store.
func (*DatabaseStore) RemoveEnvironmentOverrides ¶ added in v5.20.0
RemoveEnvironmentOverrides returns a new config without the given environment overrides.
func (*DatabaseStore) RemoveFile ¶
func (ds *DatabaseStore) RemoveFile(name string) error
RemoveFile remoevs a previously persisted configuration file.
func (*DatabaseStore) Set ¶
Set replaces the current configuration in its entirety and updates the backing store.
func (*DatabaseStore) SetFile ¶
func (ds *DatabaseStore) SetFile(name string, data []byte) error
SetFile sets or replaces the contents of a configuration file.
func (*DatabaseStore) String ¶
func (ds *DatabaseStore) String() string
String returns the path to the database backing the config, masking the password.
type FileStore ¶
type FileStore struct {
// contains filtered or unexported fields
}
FileStore is a config store backed by a file such as config/config.json.
It also uses the folder containing the configuration file for storing other configuration files.
func NewFileStore ¶
NewFileStore creates a new instance of a config store backed by the given file path.
If watch is true, any external changes to the file will force a reload.
func (*FileStore) GetEnvironmentOverrides ¶
func (cs *FileStore) GetEnvironmentOverrides() map[string]interface{}
GetEnvironmentOverrides fetches the configuration fields overridden by environment variables.
func (*FileStore) GetFile ¶
GetFile fetches the contents of a previously persisted configuration file.
func (*FileStore) RemoveEnvironmentOverrides ¶ added in v5.20.0
RemoveEnvironmentOverrides returns a new config without the given environment overrides.
func (*FileStore) RemoveFile ¶
RemoveFile removes a previously persisted configuration file.
func (*FileStore) Set ¶
Set replaces the current configuration in its entirety and updates the backing store.
type MemoryStore ¶ added in v5.20.0
type MemoryStore struct {
// contains filtered or unexported fields
}
MemoryStore implements the Store interface. It is meant primarily for testing.
func NewMemoryStore ¶
func NewMemoryStore() (*MemoryStore, error)
NewMemoryStore creates a new MemoryStore instance with default options.
func NewMemoryStoreWithOptions ¶
func NewMemoryStoreWithOptions(options *MemoryStoreOptions) (*MemoryStore, error)
NewMemoryStoreWithOptions creates a new MemoryStore instance.
func (*MemoryStore) Close ¶ added in v5.20.0
func (ms *MemoryStore) Close() error
Close does nothing for a memory store.
func (*MemoryStore) GetEnvironmentOverrides ¶ added in v5.20.0
func (cs *MemoryStore) GetEnvironmentOverrides() map[string]interface{}
GetEnvironmentOverrides fetches the configuration fields overridden by environment variables.
func (*MemoryStore) GetFile ¶ added in v5.20.0
func (ms *MemoryStore) GetFile(name string) ([]byte, error)
GetFile fetches the contents of a previously persisted configuration file.
func (*MemoryStore) HasFile ¶ added in v5.20.0
func (ms *MemoryStore) HasFile(name string) (bool, error)
HasFile returns true if the given file was previously persisted.
func (*MemoryStore) Load ¶ added in v5.20.0
func (ms *MemoryStore) Load() (err error)
Load applies environment overrides to the default config as if a re-load had occurred.
func (*MemoryStore) RemoveEnvironmentOverrides ¶ added in v5.20.0
RemoveEnvironmentOverrides returns a new config without the given environment overrides.
func (*MemoryStore) RemoveFile ¶ added in v5.20.0
func (ms *MemoryStore) RemoveFile(name string) error
RemoveFile removes a previously persisted configuration file.
func (*MemoryStore) SetFile ¶ added in v5.20.0
func (ms *MemoryStore) SetFile(name string, data []byte) error
SetFile sets or replaces the contents of a configuration file.
func (*MemoryStore) String ¶ added in v5.20.0
func (ms *MemoryStore) String() string
String returns a hard-coded description, as there is no backing store.
type MemoryStoreOptions ¶
type MemoryStoreOptions struct { IgnoreEnvironmentOverrides bool SkipValidation bool InitialConfig *model.Config InitialFiles map[string][]byte }
MemoryStoreOptions makes configuration of the memory store explicit.
type Store ¶
type Store interface { // Get fetches the current, cached configuration. Get() *model.Config // GetEnvironmentOverrides fetches the configuration fields overridden by environment variables. GetEnvironmentOverrides() map[string]interface{} // RemoveEnvironmentOverrides returns a new config without the environment // overrides RemoveEnvironmentOverrides(cfg *model.Config) *model.Config // Set replaces the current configuration in its entirety and updates the backing store. Set(*model.Config) (*model.Config, error) // Load updates the current configuration from the backing store, possibly initializing. Load() (err error) // AddListener adds a callback function to invoke when the configuration is modified. AddListener(listener Listener) string // RemoveListener removes a callback function using an id returned from AddListener. RemoveListener(id string) // GetFile fetches the contents of a previously persisted configuration file. // If no such file exists, an empty byte array will be returned without error. GetFile(name string) ([]byte, error) // SetFile sets or replaces the contents of a configuration file. SetFile(name string, data []byte) error // HasFile returns true if the given file was previously persisted. HasFile(name string) (bool, error) // RemoveFile removes a previously persisted configuration file. RemoveFile(name string) error // String describes the backing store for the config. String() string // Close cleans up resources associated with the store. Close() error }
Store abstracts the act of getting and setting the configuration.