Skip to content
This repository was archived by the owner on Feb 15, 2024. It is now read-only.
This repository was 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

@atc0005

Description

@atc0005

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

Metadata

Metadata

Assignees

Labels

configquestionFurther information is requested

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions