Documentation ¶
Overview ¶
Package config holds CLI configuration.
Index ¶
Constants ¶
View Source
const ( // EnvarLogPath is the log file path. EnvarLogPath = "SQ_LOG_FILE" // EnvarLogLevel is the log level. It maps to a slog.Level. EnvarLogLevel = "SQ_LOG_LEVEL" // EnvarLogFormat is the log format. It maps to a slog.Level. EnvarLogFormat = "SQ_LOG_FORMAT" // EnvarLogEnabled turns logging on or off. EnvarLogEnabled = "SQ_LOG" // EnvarConfigDir is the legacy envar for config location. // Instead use EnvarConfig. EnvarConfigDir = "SQ_CONFIGDIR" // EnvarConfig is the envar for config location. EnvarConfig = "SQ_CONFIG" )
Variables ¶
View Source
var OptConfigLockTimeout = options.NewDuration( "config.lock.timeout", "", 0, time.Second*5, "Wait timeout to acquire config lock", `Wait timeout to acquire the config lock (which prevents multiple sq instances stepping on each other's config changes). During this period, retry will occur if the lock is already held by another process. If zero, no retry occurs.`, )
OptConfigLockTimeout is the time allowed to acquire the config lock.
Functions ¶
Types ¶
type Config ¶
type Config struct { // Version is the config version. This will allow sq to // upgrade config files if needed. It must be a valid semver. Version string `yaml:"config.version" json:"config_version"` // Options contains default settings, such as output format. Options options.Options `yaml:"options" json:"options"` // Collection is the set of data sources. Collection *source.Collection `yaml:"collection" json:"collection"` // Ext holds sq config extensions, such as user driver config. Ext Ext `yaml:"-" json:"-"` }
Config holds application config/session data.
type DiscardStore ¶
type DiscardStore struct{}
DiscardStore implements Store but its Save method is no-op and Load always returns a new empty Config. Useful for testing.
func (DiscardStore) Load ¶
func (DiscardStore) Load(context.Context) (*Config, error)
Load returns a new empty Config.
type Ext ¶
type Ext struct {
UserDrivers []*userdriver.DriverDef `yaml:"user_drivers" json:"user_drivers"`
}
Ext holds additional config (extensions) loaded from other config files, e.g. ~/.config/sq/ext/*.sq.yml.
type Store ¶
type Store interface { // Save writes config to the store. Save(ctx context.Context, cfg *Config) error // Load reads config from the store. Load(ctx context.Context) (*Config, error) // Location returns the location of the store, typically // a file path. Location() string // Lockfile returns the lockfile used by the store, but does not acquire // the lock, which is the caller's responsibility. The lock should always // be acquired before mutating config. It is also the caller's responsibility // to release the acquired lock when done. Lockfile() (lockfile.Lockfile, error) }
Store saves and loads config.
Directories ¶
Path | Synopsis |
---|---|
Package yamlstore contains an implementation of config.Store that uses YAML files for persistence.
|
Package yamlstore contains an implementation of config.Store that uses YAML files for persistence. |
upgrades/v0.34.0
Package v0_34_0 upgrades YAML config to v0.34.0.
|
Package v0_34_0 upgrades YAML config to v0.34.0. |
Click to show internal directories.
Click to hide internal directories.