config

package
v0.4.10 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 11, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package config provides types and functions to collect, validate and apply user-provided settings.

Index

Constants

View Source
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

View Source
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

View Source
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)

View Source
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

func Version

func Version() string

Version emits application name, version and repo location.

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

func New() (*Config, error)

New is a factory function that produces a new Config object based on user provided flag and where applicable, default values.

func (Config) DBName

func (c Config) DBName() string

DBName returns the user-provided database name or the default value if not provided.

func (Config) DBQueryCountAllRecords

func (c Config) DBQueryCountAllRecords() string

DBQueryCountAllRecords returns the user-provided query for determining the count of all patron records or the default value if not provided.

func (Config) DBQueryCountInactiveRecords

func (c Config) DBQueryCountInactiveRecords() string

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

func (c Config) DBQueryRetrieveActivePatronRecords() string

DBQueryRetrieveActivePatronRecords returns the user-provided query for retrieving all active patron records or the default value if not provided.

func (Config) DBServerEncryptMode

func (c Config) DBServerEncryptMode() string

DBServerEncryptMode returns the user-provided encrypt mode or the default value if not provided.

func (Config) DBServerHost

func (c Config) DBServerHost() string

DBServerHost returns the user-provided database server host or the default value if not provided.

func (Config) DBServerInstance

func (c Config) DBServerInstance() string

DBServerInstance returns the user-provided database server instance or the default value if not provided.

func (Config) DBServerPassword

func (c Config) DBServerPassword() string

DBServerPassword returns the user-provided database server password or the default value if not provided.

func (Config) DBServerPort

func (c Config) DBServerPort() int

DBServerPort returns the user-provided database server port or the default value if not provided.

func (Config) DBServerTrustCert

func (c Config) DBServerTrustCert() bool

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

func (c Config) DBServerUsername() string

DBServerUsername returns the user-provided database server username or the default value if not provided.

func (Config) DBTable

func (c Config) DBTable() string

DBTable returns the user-provided database table name or the default value if not provided.

func (Config) Description

func (c Config) Description() string

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

func (c *Config) ImportConfigFile(fh io.Reader) error

ImportConfigFile reads from an io.Reader and unmarshals a configuration file in TOML format into the associated Config struct.

func (Config) LogLevel

func (c Config) LogLevel() string

LogLevel returns the user-provided logging level or the default value if not provided.

func (Config) String

func (c Config) String() string

String implements the Stringer interface in order to display all initialized (user-provided or default) values.

func (Config) Version

func (c Config) Version() string

Version reuses the package-level Version function to emit version information and associated branding details whenever the user specifies the `--version` flag. The application exits after displaying this information.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL