Documentation ¶
Overview ¶
Package factory provides an API for managing application-level credential details.
Properties such as where credential files are stored, the name of the application, alternate username/password keys, and the credential file type are handled by factory.
Index ¶
- Constants
- type Factory
- func (thisFactory *Factory) GetAlternatePassword() string
- func (thisFactory *Factory) GetAlternateUsername() string
- func (thisFactory *Factory) GetAlternates() (string, string)
- func (thisFactory *Factory) Initialize() error
- func (thisFactory *Factory) ModifyLogger(logLevel string, pretty bool)
- func (thisFactory *Factory) SetAlternatePassword(alternatePassword string) error
- func (thisFactory *Factory) SetAlternateUsername(alternateUsername string) error
- func (thisFactory *Factory) SetAlternates(usernameKey string, passwordKey string) error
- func (thisFactory *Factory) SetOutputType(outputType string) error
Constants ¶
const ERR_ALTERNATE_PASSWORD_CANNOT_BE_BLANK = "the alternate password you provided is blank, please provide a string"
const ERR_ALTERNATE_USERNAME_CANNOT_BE_BLANK = "the alternate username you provided is blank, please provide a string"
const ERR_APPLICATION_NAME_BLANK = "sorry the application name must not be blank"
const ERR_FACTORY_INCONSISTENT_STATE = "the Factory is in an inconsistent state, please only use public methods to modify"
const ERR_FACTORY_NOT_INITIALIZED = "sorry the factory has not been initilalized please run f.Intialize() and try again"
const ERR_INVALID_OUTPUT_TYPE = "sorry the output type you have set is not valid and not supported"
const ERR_KEY_MUST_MATCH_REGEX = "sorry the key must only include letters and underscores [0-9A-Za-z_]"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Factory ¶
type Factory struct { ApplicationName string ParentDirectory string CredentialFile string ConfigDirectory string UseEnvironment bool Initialized bool OutputType string Log *zerolog.Logger // contains filtered or unexported fields }
Factory is the object that is used to store all of the application-level global configuration. All the settings for saving, setting, searching and finding credentials are in this object.
Application Name: this is the name of the application. ParentDirectory: automatically set to ~/.application_name CredentialFile: automatically set to configurationDirectory + "/credentials". UseEnvironment: can I load variables into the environment. Only set this if you intend on use LoadEnv. Initialized: has all of my configuration been initialized correctly? Output Type: the file type that the CredentialFile contents should be. Alternates: if username or password are set, those names are set
func (*Factory) GetAlternatePassword ¶
GetAlternatePassword sets a label to be used in lieu of password in environment variables.
func (*Factory) GetAlternateUsername ¶
GetAlternateUsername gets a label to be used in lieu of username in environment variables.
func (*Factory) GetAlternates ¶
GetAlternates returns the username and password.
func (*Factory) Initialize ¶
Initialize sets computed properties a Factory object. Specifically, it sets the value of ParentDirectory, ConfigDirectory and CredentialFile. If ParentDirectory does not exist, it will also create it. Alternates is also initialized as an empty map and the Initialized flag is set to true. The logger for the Factory is also initialized here.
func (*Factory) ModifyLogger ¶ added in v1.1.0
ModifyLogger is responsible for reconfiguring the log level and whether or not pretty output is used. Available log levels are panic, fatal, error, warn, info, debug, trace, and disabled. By default, all logging output is disabled.
func (*Factory) SetAlternatePassword ¶
SetAlternatePassword sets a label to be used in lieu of password in environment variables.
func (*Factory) SetAlternateUsername ¶
SetAlternateUsername sets a label to be used in lieu of username in environment variables.
func (*Factory) SetAlternates ¶ added in v1.2.0
SetAlternates is a function that sets the alternates for both username and password at the same time. This is the same as calling SetAlternateUsername, then calling SetAlternatePassword in a separate call. If you enter a blank value in either parameter, it won't be set and an error will be returned. However, the other variable will be set.
func (*Factory) SetOutputType ¶
SetOutputType determines which of the supported file types Credentials should be serialized to file as. The currently supported file types are ini with plans to implement json.