config

package
v0.0.0-...-a200beb Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 28, 2019 License: AGPL-3.0, Apache-2.0 Imports: 24 Imported by: 0

README

config.json

This is the system configuration file for your Mattermost server. Settings are specific to different editions of Mattermost. Please read the documentation before making changes: https://about.mattermost.com/default-config-docs/

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrReadOnlyConfiguration = errors.New("configuration is read-only")
)

Functions

func FixInvalidLocales

func FixInvalidLocales(cfg *model.Config) bool

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.

func Merge

func Merge(cfg *model.Config, patch *model.Config, mergeConfig *utils.MergeConfig) (*model.Config, error)

Merge merges two configs together. The receiver's values are overwritten with the patch's values except when the patch's values are nil.

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.

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) Get

func (cs *DatabaseStore) Get() *model.Config

Get fetches the current, cached configuration.

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) RemoveFile

func (ds *DatabaseStore) RemoveFile(name string) error

RemoveFile remoevs a previously persisted configuration file.

func (*DatabaseStore) Set

func (ds *DatabaseStore) Set(newCfg *model.Config) (*model.Config, error)

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

func NewFileStore(path string, watch bool) (fs *FileStore, err error)

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) Close

func (fs *FileStore) Close() error

Close cleans up resources associated with the store.

func (*FileStore) Get

func (cs *FileStore) Get() *model.Config

Get fetches the current, cached configuration.

func (*FileStore) GetEnvironmentOverrides

func (cs *FileStore) GetEnvironmentOverrides() map[string]interface{}

GetEnvironmentOverrides fetches the configuration fields overridden by environment variables.

func (*FileStore) GetFile

func (fs *FileStore) GetFile(name string) ([]byte, error)

GetFile fetches the contents of a previously persisted configuration file.

func (*FileStore) HasFile

func (fs *FileStore) HasFile(name string) (bool, error)

HasFile returns true if the given file was previously persisted.

func (*FileStore) Load

func (fs *FileStore) Load() (err error)

Load updates the current configuration from the backing store.

func (*FileStore) RemoveFile

func (fs *FileStore) RemoveFile(name string) error

RemoveFile removes a previously persisted configuration file.

func (*FileStore) Set

func (fs *FileStore) Set(newCfg *model.Config) (*model.Config, error)

Set replaces the current configuration in its entirety and updates the backing store.

func (*FileStore) SetFile

func (fs *FileStore) SetFile(name string, data []byte) error

SetFile sets or replaces the contents of a configuration file.

func (*FileStore) String

func (fs *FileStore) String() string

String returns the path to the file backing the config.

type Listener

type Listener func(oldConfig *model.Config, newConfig *model.Config)

Listener is a callback function invoked when the configuration changes.

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{}

	// 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.

func NewStore

func NewStore(dsn string, watch bool) (Store, error)

NewStore creates a database or file store given a data source name by which to connect.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL