config

package
v0.2.11 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
)

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-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 (
	// ILLiadDatabase is the default database name for ILLiad software.
	ILLiadDatabase string = "ILLData"

	// ILLiadDatabaseEMailTable is the name of the database table which holds
	// metadata for email notifications.
	ILLiadDatabaseEMailTable string = "EMailCopies"
)
View Source
const (
	QueryILLiadEMailCancelledCount       string = "SELECT COUNT(*) As [CancelledEmails] FROM [ILLData].[dbo].[EMailCopies] WHERE [Status] = 'Cancelled';"
	QueryILLiadEMailNULLCount            string = "SELECT COUNT(*) As [NULLEmails] FROM [ILLData].[dbo].[EMailCopies] WHERE [Status] IS NULL;"
	QueryILLiadEMailSentCount            string = "SELECT COUNT(*) As [SentEmails] FROM [ILLData].[dbo].[EMailCopies] WHERE [Status] = 'Sent';"
	QueryILLiadEMailPendingCount         string = "SELECT COUNT(*) As [PendingEmails] FROM [ILLData].[dbo].[EMailCopies] WHERE [Status] = 'Pending';"
	QueryILLiadEMailStatusSummary        string = "SELECT [Status], COUNT(*) AS [Count] FROM [ILLData].[dbo].[EMailCopies] GROUP BY [Status];"
	QueryILLiadEMailCancelledEmailValues string = "SELECT [TransactionNumber], [EMailDate], [Status], [Note] FROM [ILLData].[dbo].[EMailCopies] WHERE [Status] = 'Cancelled';"
	QueryILLiadEMailPendingEmailValues   string = "SELECT [TransactionNumber], [EMailDate], [Status], [Note] FROM [ILLData].[dbo].[EMailCopies] WHERE [Status] = 'Pending';"
)

Queries used to interact with the ILLiad database that this plugin is responsible for checking.

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 Branding

func Branding(msg string) func() string

Branding accepts a message and returns a function that concatenates that message with version information. This returned function implements nagios.ExitCallBackFunc in order to optionally supply branding details with the service check output.

func Version

func Version() string

Version emits application name, version and repo location.

Types

type Config

type Config struct {
	Logging
	DBServer
	Database
	Thresholds
	Filters

	// 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 (maybe in the future) TOML configuration file provided by the user. 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) 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) 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) EmailAgeThresholds

func (c Config) EmailAgeThresholds() EmailAgeThresholds

EmailAgeThresholds returns the user-provided WARNING and CRITICAL threshold values for the age of email notifications in a pending state, or the default threshold values if not provided.

func (Config) EmailCountThresholds

func (c Config) EmailCountThresholds() EmailCountThresholds

EmailCountThresholds returns the user-provided WARNING and CRITICAL threshold values for the number of email notifications in a pending state, or the default threshold values if not provided.

func (Config) EmitBranding

func (c Config) EmitBranding() bool

EmitBranding returns the user-provided choice of whether branded output is emitted with check results or the default value if not provided.

func (Config) IgnoreMissingEmails

func (c Config) IgnoreMissingEmails() bool

IgnoreMissingEmails returns the user-provided choice of whether missing email notification entries in the database should be treated as an OK state or the default value if not provided.

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.

type DBServer

type DBServer struct {
	Host        *string `` /* 256-byte string literal not displayed */
	Port        *int    `` /* 152-byte string literal not displayed */
	Instance    *string `arg:"--instance,env:CHECK_ILLIAD_DBSERVER_INSTANCE" help:"The database server instance name. This may be blank."`
	Username    *string `` /* 203-byte string literal not displayed */
	Password    *string `` /* 213-byte string literal not displayed */
	EncryptMode *string `` /* 197-byte string literal not displayed */
	TrustCert   *bool   `` /* 203-byte string literal not displayed */
}

DBServer is the user-specified settings for creating a database server connection.

type Database

type Database struct {
	Name *string `` /* 144-byte string literal not displayed */
}

Database is the user-specified settings for the database used by the ILLiad software.

type EmailAgeThresholds

type EmailAgeThresholds struct {
	Critical time.Duration `arg:"-"`
	Warning  time.Duration `arg:"-"`
	Set      bool          `arg:"-"`
}

EmailAgeThresholds represents the user-specified email notification age thresholds.

type EmailCountThresholds

type EmailCountThresholds struct {
	Critical int  `arg:"-"`
	Warning  int  `arg:"-"`
	Set      bool `arg:"-"`
}

EmailCountThresholds represents the user-specified email notification count thresholds.

type Filters

type Filters struct {
	IgnoreMissingEmails *bool `` /* 283-byte string literal not displayed */
}

Filters represents options which lets the sysadmin filter in/out specific values or scenarios.

type Logging

type Logging struct {
	Level        *string `` /* 156-byte string literal not displayed */
	EmitBranding *bool   `` /* 342-byte string literal not displayed */
}

Logging represents options specific to how this application handles logging.

type TableEMailCopies

type TableEMailCopies struct {
	TransactionNumber int            `arg:"-"`
	EMailDate         time.Time      `arg:"-"`
	Status            sql.NullString `arg:"-"`
	Note              sql.NullString `arg:"-"`
}

TableEMailCopies reflects fields from the `EMailCopies` table from the `ILLData` database.

type Thresholds

type Thresholds struct {
	CountWarning  *int `` /* 176-byte string literal not displayed */
	CountCritical *int `` /* 179-byte string literal not displayed */
	AgeWarning    *int `` /* 203-byte string literal not displayed */
	AgeCritical   *int `` /* 206-byte string literal not displayed */
}

Thresholds represents the values which determine WARNING and CRITICAL thresholds.

Jump to

Keyboard shortcuts

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