Documentation ¶
Overview ¶
Package config provides types and functions to collect, validate and apply user-provided settings.
Index ¶
- Constants
- func Version() string
- type Config
- func (c Config) DBName() string
- func (c Config) DBQueryCountAllRecords() string
- func (c Config) DBQueryCountInactiveRecords() string
- func (c Config) DBQueryRetrieveActivePatronRecords() string
- func (c Config) DBServerEncryptMode() string
- func (c Config) DBServerHost() string
- func (c Config) DBServerInstance() string
- func (c Config) DBServerPassword() string
- func (c Config) DBServerPort() int
- func (c Config) DBServerTrustCert() bool
- func (c Config) DBServerUsername() string
- func (c Config) DBTable() string
- func (c Config) Description() string
- func (c *Config) ImportConfigFile(fh io.Reader) error
- func (c Config) LogLevel() string
- func (c Config) String() string
- func (c Config) Version() string
Constants ¶
const ( EncryptModeDisable string = "disable" EncryptModeTrue string = "true" EncryptModeFalse string = "false" )
These values directly map to the `encrypt` parameter settings used by the database driver. https://github.com/denisenkom/go-mssqldb#common-parameters
const ( MSSQLInstanceNameMaxChars int = 16 MSSQLUsernameMaxChars int = 128 MSSQLPasswordMaxChars int = 128 MSSQLDatabaseNameMaxChars int = 123 MSSQLDatabaseTableNameMaxChars int = 128 )
https://docs.microsoft.com/en-us/previous-versions/sql/sql-server-2008-r2/ms143531(v=sql.105) https://docs.microsoft.com/en-us/sql/relational-databases/system-stored-procedures/sp-server-info-transact-sql https://docs.microsoft.com/en-us/sql/t-sql/statements/create-database-transact-sql https://docs.microsoft.com/en-us/sql/t-sql/statements/create-table-transact-sql? https://docs.microsoft.com/en-us/sql/t-sql/statements/create-user-transact-sql
const ( TCPReservedPort int = 0 TCPSystemPortStart int = 1 TCPSystemPortEnd int = 1023 TCPUserPortStart int = 1024 TCPUserPortEnd int = 49151 TCPDynamicPrivatePortStart int = 49152 TCPDynamicPrivatePortEnd int = 65535 )
TCP port ranges http://www.iana.org/assignments/port-numbers Port numbers are assigned in various ways, based on three ranges: System Ports (0-1023), User Ports (1024-49151), and the Dynamic and/or Private Ports (49152-65535)
const ( // LogLevelDisabled maps to zerolog.Disabled logging level LogLevelDisabled string = "disabled" // LogLevelPanic maps to zerolog.PanicLevel logging level LogLevelPanic string = "panic" // LogLevelFatal maps to zerolog.FatalLevel logging level LogLevelFatal string = "fatal" // LogLevelError maps to zerolog.ErrorLevel logging level LogLevelError string = "error" // LogLevelWarn maps to zerolog.WarnLevel logging level LogLevelWarn string = "warn" // LogLevelInfo maps to zerolog.InfoLevel logging level LogLevelInfo string = "info" // LogLevelDebug maps to zerolog.DebugLevel logging level LogLevelDebug string = "debug" // LogLevelTrace maps to zerolog.TraceLevel logging level LogLevelTrace string = "trace" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct { // Log is an embedded zerolog Logger initialized via config.New(). Log zerolog.Logger `arg:"-"` // contains filtered or unexported fields }
Config is a unified set of configuration values for this application. This struct is configured via command-line flags or TOML configuration file provided by the user. The majority of values held by this object are intended to be retrieved via "Getter" methods.
func New ¶
New is a factory function that produces a new Config object based on user provided flag and where applicable, default values.
func (Config) DBName ¶
DBName returns the user-provided database name or the default value if not provided.
func (Config) DBQueryCountAllRecords ¶
DBQueryCountAllRecords returns the user-provided query for determining the count of all patron records or the default value if not provided.
func (Config) DBQueryCountInactiveRecords ¶
DBQueryCountInactiveRecords returns the user-provided query for determining the count of all inactive patron records or the default value if not provided.
func (Config) DBQueryRetrieveActivePatronRecords ¶
DBQueryRetrieveActivePatronRecords returns the user-provided query for retrieving all active patron records or the default value if not provided.
func (Config) DBServerEncryptMode ¶
DBServerEncryptMode returns the user-provided encrypt mode or the default value if not provided.
func (Config) DBServerHost ¶
DBServerHost returns the user-provided database server host or the default value if not provided.
func (Config) DBServerInstance ¶
DBServerInstance returns the user-provided database server instance or the default value if not provided.
func (Config) DBServerPassword ¶
DBServerPassword returns the user-provided database server password or the default value if not provided.
func (Config) DBServerPort ¶
DBServerPort returns the user-provided database server port or the default value if not provided.
func (Config) DBServerTrustCert ¶
DBServerTrustCert returns the user-provided choice of whether the database server certificate is trusted as-is or if validation is enforced, or the default value if not provided.
func (Config) DBServerUsername ¶
DBServerUsername returns the user-provided database server username or the default value if not provided.
func (Config) DBTable ¶
DBTable returns the user-provided database table name or the default value if not provided.
func (Config) Description ¶
Description emits branding information whenever the user specifies the `-h` flag. The application uses this as a header prior to displaying available CLI flag options.
func (*Config) ImportConfigFile ¶
ImportConfigFile reads from an io.Reader and unmarshals a configuration file in TOML format into the associated Config struct.
func (Config) LogLevel ¶
LogLevel returns the user-provided logging level or the default value if not provided.