cli/config: Load(), LoadDefaultConfigFile(): improve GoDoc

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2024-05-16 14:19:09 +02:00
parent 57a1180c52
commit 426fb2fd81
No known key found for this signature in database
GPG Key ID: 76698F39D527CE8C
1 changed files with 14 additions and 3 deletions

View File

@ -84,8 +84,10 @@ func LoadFromReader(configData io.Reader) (*configfile.ConfigFile, error) {
return &configFile, err return &configFile, err
} }
// Load reads the configuration files in the given directory, and sets up // Load reads the configuration file ([ConfigFileName]) from the given directory.
// the auth config information and returns values. // If no directory is given, it uses the default [Dir]. A [*configfile.ConfigFile]
// is returned containing the contents of the configuration file, or a default
// struct if no configfile exists in the given location.
func Load(configDir string) (*configfile.ConfigFile, error) { func Load(configDir string) (*configfile.ConfigFile, error) {
if configDir == "" { if configDir == "" {
configDir = Dir() configDir = Dir()
@ -118,7 +120,16 @@ func load(configDir string) (*configfile.ConfigFile, error) {
} }
// LoadDefaultConfigFile attempts to load the default config file and returns // LoadDefaultConfigFile attempts to load the default config file and returns
// an initialized ConfigFile struct if none is found. // a reference to the ConfigFile struct. If none is found or when failing to load
// the configuration file, it initializes a default ConfigFile struct. If no
// credentials-store is set in the configuration file, it attempts to discover
// the default store to use for the current platform.
//
// Important: LoadDefaultConfigFile prints a warning to stderr when failing to
// load the configuration file, but otherwise ignores errors. Consumers should
// consider using [Load] (and [credentials.DetectDefaultStore]) to detect errors
// when updating the configuration file, to prevent discarding a (malformed)
// configuration file.
func LoadDefaultConfigFile(stderr io.Writer) *configfile.ConfigFile { func LoadDefaultConfigFile(stderr io.Writer) *configfile.ConfigFile {
configFile, err := load(Dir()) configFile, err := load(Dir())
if err != nil { if err != nil {