Documentation ¶
Overview ¶
Package config provides types and functions to collect, validate and apply user-provided settings.
Index ¶
- Constants
- Variables
- func Branding(msg string) func() string
- func Version() string
- type Config
- func (c Config) Age() FileAgeThresholds
- func (c Config) Description() string
- func (c Config) EmitBranding() bool
- func (c Config) FailFast() bool
- func (c Config) GroupName() string
- func (c Config) GroupNameCritical() bool
- func (c Config) GroupNameWarning() bool
- func (c Config) LogLevel() string
- func (c Config) MissingOK() bool
- func (c Config) PathExistsCritical() bool
- func (c Config) PathExistsWarning() bool
- func (c Config) PathsExclude() []string
- func (c Config) PathsInclude() []string
- func (c Config) Recursive() bool
- func (c Config) ResolveIDs() ResolveIDs
- func (c Config) SizeMax() FileSizeThresholds
- func (c Config) SizeMin() FileSizeThresholds
- func (c Config) String() string
- func (c Config) Username() string
- func (c Config) UsernameCritical() bool
- func (c Config) UsernameWarning() bool
- func (c Config) Version() string
- type FileAgeThresholds
- type FileSizeThresholds
- type FileSizeThresholdsMinMax
- type IDs
- type Logging
- type ResolveIDs
- type Search
Constants ¶
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 ¶
var ErrGroupNameHasSpaces = errors.New("group name contains spaces")
ErrGroupNameHasSpaces is returned by validation checks if a group name contains spaces.
var ErrGroupNameIsEmpty = errors.New("group name is empty string")
ErrGroupNameIsEmpty is returned by validation checks if a group name is an empty string.
var ErrUserNameHasSpaces = errors.New("username contains spaces")
ErrUserNameHasSpaces is returned by validation checks if a username contains spaces.
var ErrUsernameIsEmpty = errors.New("username is empty string")
ErrUsernameIsEmpty is returned by validation checks if a username is an empty string.
Functions ¶
Types ¶
type Config ¶
type Config struct { Logging Search // 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 ¶
New is a factory function that produces a new Config object based on user provided flag and where applicable, default values.
func (Config) Age ¶
func (c Config) Age() FileAgeThresholds
Age returns the user-provided CRITICAL and WARNING thresholds in days for the specified paths.
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) EmitBranding ¶
EmitBranding returns the user-provided choice of whether branded output is emitted with check results or the default value if not provided.
func (Config) FailFast ¶ added in v0.1.1
FailFast returns the user-provided choice of whether paths are processed in a way that prioritizes a first-fail result over a strict order of CRITICAL results before WARNING results. The default value is returned if not provided.
func (Config) GroupName ¶
GroupName returns the user-provided group name set via the group-name-missing-critical or group-name-missing-warning flags or the default value if not provided.
func (Config) GroupNameCritical ¶
GroupNameCritical indicates whether user opted to check for group name mismatches. Failing results indicate a CRITICAL state.
func (Config) GroupNameWarning ¶
GroupNameWarning indicates whether user opted to check for group name mismatches. Failing results indicate a WARNING state.
func (Config) LogLevel ¶
LogLevel returns the user-provided logging level or the default value if not provided.
func (Config) MissingOK ¶
MissingOK returns the user-provided choice of whether missing paths are considered OK or the default value if not provided.
func (Config) PathExistsCritical ¶
PathExistsCritical indicates whether the existence of specified paths is considered a CRITICAL state.
func (Config) PathExistsWarning ¶
PathExistsWarning indicates whether the existence of specified paths is considered a WARNING state.
func (Config) PathsExclude ¶ added in v0.1.2
PathsExclude returns the user-provided list of paths to ignore or an empty list if a user-specified list of paths was not provided. Each path in the list is processed by filepath.Clean. This allows for more reliable comparison against PathsInclude values to determine if a path should be ignored.
func (Config) PathsInclude ¶ added in v0.1.2
PathsInclude returns the user-provided list of paths to check or an empty list if a user-specified list of paths was not provided. Each path in the list is processed by filepath.Clean. This allows for more reliable comparison against PathsExclude values to determine if a path should be ignored.
func (Config) Recursive ¶
Recursive returns the user-provided choice of whether paths are checked recursively or the default value if not provided.
func (Config) ResolveIDs ¶ added in v0.1.2
func (c Config) ResolveIDs() ResolveIDs
ResolveIDs returns a ResolveIDs type which indicates whether user opted to resolve user and group id values to name values and if so, at which exit state values.
func (Config) SizeMax ¶ added in v0.1.2
func (c Config) SizeMax() FileSizeThresholds
SizeMax returns the user-provided CRITICAL and WARNING thresholds for maximum size in bytes for the specified paths.
func (Config) SizeMin ¶ added in v0.1.2
func (c Config) SizeMin() FileSizeThresholds
SizeMin returns the user-provided CRITICAL and WARNING thresholds for minimum size in bytes for the specified paths.
func (Config) String ¶
String implements the Stringer interface in order to display all initialized (user-provided or default) values.
func (Config) Username ¶
Username returns the user-provided username set via the username-missing-critical or username-missing-warning flags or the default value if not provided.
func (Config) UsernameCritical ¶
UsernameCritical indicates whether user opted to check for username mismatches. Failing results indicate a CRITICAL state.
func (Config) UsernameWarning ¶
UsernameWarning indicates whether user opted to check for group name mismatches. Failing results indicate a WARNING state.
type FileAgeThresholds ¶
FileAgeThresholds represents the user-specified file age thresholds for specified paths.
type FileSizeThresholds ¶
FileSizeThresholds represents the user-specified file size thresholds for specified paths.
type FileSizeThresholdsMinMax ¶ added in v0.1.2
type FileSizeThresholdsMinMax struct { SizeMin FileSizeThresholds SizeMax FileSizeThresholds }
FileSizeThresholdsMinMax represents the combined minimum and maximum user-specified file size thresholds for specified paths.
type Logging ¶
type Logging struct { Level *string `` /* 154-byte string literal not displayed */ EmitBranding *bool `` /* 340-byte string literal not displayed */ }
Logging represents options specific to how this application handles logging.
type ResolveIDs ¶ added in v0.1.2
type ResolveIDs struct { UsernameCheck bool UsernameCritical bool UsernameWarning bool GroupNameCheck bool GroupNameCritical bool GroupNameWarning bool IDs }
ResolveIDs is a helper struct to record whether user opted to resolve user and group id values to name values and if so, at which exit state values.
type Search ¶
type Search struct { PathsInclude []string `arg:"--paths,env:CHECK_PATH_PATHS_INCLUDE" help:"List of comma or space-separated paths to check."` PathsExclude []string `` /* 135-byte string literal not displayed */ Recursive *bool `arg:"--recurse,env:CHECK_PATH_RECURSE" help:"Perform recursive search into subdirectories per provided path."` MissingOK *bool `` /* 153-byte string literal not displayed */ FailFast *bool `` /* 238-byte string literal not displayed */ AgeCritical *int `` /* 184-byte string literal not displayed */ AgeWarning *int `` /* 181-byte string literal not displayed */ SizeMinCritical *int64 `` /* 186-byte string literal not displayed */ SizeMinWarning *int64 `` /* 183-byte string literal not displayed */ SizeMaxCritical *int64 `` /* 183-byte string literal not displayed */ SizeMaxWarning *int64 `` /* 181-byte string literal not displayed */ ExistsCritical *bool `` /* 143-byte string literal not displayed */ ExistsWarning *bool `` /* 140-byte string literal not displayed */ UsernameMissingCritical *string `` /* 205-byte string literal not displayed */ UsernameMissingWarning *string `` /* 202-byte string literal not displayed */ GroupNameMissingCritical *string `` /* 205-byte string literal not displayed */ GroupNameMissingWarning *string `` /* 202-byte string literal not displayed */ }
Search represents options specific to controlling how this application performs searches in the filesystem.