As an example, here is how the Config.DisabledUsersFile() method is defined:
// DisabledUsersFile returns the user-provided path to the EZproxy include
// file where this application should write disabled user accounts or the
// default value if not provided. CLI flag values take precedence if provided.
func (c Config) DisabledUsersFile() string {
switch {
case c.cliConfig.DisabledUsers.File != nil:
return *c.cliConfig.DisabledUsers.File
case c.fileConfig.DisabledUsers.File != nil:
return *c.fileConfig.DisabledUsers.File
default:
// FIXME: During development the default is set to a fixed/temporary
// path. Before MVP deployment the defaults should be changed to empty
// strings?
return defaultDisabledUsersFile
}
}
and here is how the defaultDisabledUsersFile constant is defined (spacing tweaked):
defaultDisabledUsersFile string = "/var/cache/brick/users.brick-disabled.txt"
and here is how it is checked inside of Config.validate():
if c.DisabledUsersFile() == "" {
return fmt.Errorf("path to disabled users file not provided")
}
If the sysadmin provides no value for the configuration setting they will end up with /var/cache/brick/users.brick-disabled.txt as the default value, otherwise if they specify something that will be the value returned by the Getter method. Lastly, if they supply a blank response they'll either get "caught" by the flag or config-file handling packages or the Config.validate() method will catch it and complain.
Is this the desired behavior? If so, what about other defaultXYZ constants which supply values when omitted by the sysadmin?
Worth emphasizing: this is already the documented behavior as of v0.1.1 (https://github.com/atc0005/brick/blob/v0.1.1/docs/configure.md).