Skip to content
This repository has been archived by the owner on Feb 15, 2024. It is now read-only.

Review and update Getter methods (related logic/settings) to provide appropriate defaults #45

Open
atc0005 opened this issue Jun 11, 2020 · 0 comments
Assignees
Labels
config question Further information is requested
Milestone

Comments

@atc0005
Copy link
Owner

atc0005 commented Jun 11, 2020

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

@atc0005 atc0005 added question Further information is requested config labels Jun 11, 2020
@atc0005 atc0005 self-assigned this Jun 11, 2020
@atc0005 atc0005 added this to the Future milestone Jun 27, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
config question Further information is requested
Projects
None yet
Development

No branches or pull requests

1 participant