Documentation
¶
Overview ¶
Package config is the configuration of modctl: what it is when nothing has been said, what a config file says, and how the file is changed.
Nothing in it finds anything by itself. Where the directories of the user are, and which file is the config file, are given to it, and so it makes nothing that it was not asked to: reading a configuration does not make the directories that it names, or the one that the config file is in.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultPath ¶
DefaultPath is the config file that is read when there is not one that has been asked for, and the one that is made when there is not any.
func Keys ¶
func Keys() []string
Keys are the keys that there are, in the order that they are listed in. A key in the second level is named with a dot ("nexus.apikey"), which is how it is in the commands, and in the file it is a key of a table.
func Mask ¶
Mask is key (an API key) as it is shown: with all of it but the last four characters not there.
func Set ¶
Set makes the config file at path say that key is value. The file is made if it is not there (and so is the directory that it is in, which only the user can read), and what else it says is kept as it is, apart from how it is written: the comments and the formatting of a file that was written by hand are not.
Types ¶
type Config ¶
type Config struct {
// Bsdtar is the program that reads and extracts archives. It is found in
// the PATH if it is not a path.
Bsdtar string
// Database is the file of the database.
Database string
// ArchivesDir, BackupsDir and OverridesDir are where the blobs of each kind
// are kept.
ArchivesDir string
BackupsDir string
OverridesDir string
CacheDir string
LocksDir string
TmpDir string
// ScratchDir is where there is room for a copy of the data: the snapshots
// of the databases that an export makes, and the bundle that is extracted
// to import, verify or extract it. It is not TmpDir, which is for the
// staging of the archives that are applied, and which is by default on
// tmpfs.
ScratchDir string
NexusAPIKey string
File string // the config file that was read, if one was
// contains filtered or unexported fields
}
A Config is what modctl is configured to: the defaults, with what the config file says on top of them.
func Defaults ¶
Defaults is the configuration of a user whose directories are dirs, who has not said anything.
func Load ¶
Load is the configuration of a user whose directories are dirs. It is the defaults, and what the config file says over them: the file at path, which has to be there, or the default one (see DefaultPath) if path is empty, which does not have to be. A file that can't be read or is not a config file is an error, whichever one it is.
The file is read by an instance of viper of its own, which is what knows how a config file is read (the keys are not case sensitive, and a value is the text of what it is), and which nothing else in the program shares.
type Dirs ¶
type Dirs struct {
// ConfigHome is where the config file is ($XDG_CONFIG_HOME).
ConfigHome string
// DataHome is where what modctl keeps is ($XDG_DATA_HOME).
DataHome string
// CacheHome is where what can be made again is ($XDG_CACHE_HOME).
CacheHome string
// StateHome is where what is about what has been done is
// ($XDG_STATE_HOME).
StateHome string
// RuntimeDir is where what is only needed while modctl runs is
// ($XDG_RUNTIME_DIR).
RuntimeDir string
// TempDir is the temporary directory of the system ($TMPDIR, or /tmp).
TempDir string
}
Dirs are the directories of the user that the defaults are in, which are the XDG ones.
type UnknownKeyError ¶
type UnknownKeyError struct {
Key string
}
UnknownKeyError is a key that there is not.
func (UnknownKeyError) Error ¶
func (e UnknownKeyError) Error() string