Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ValidationErrorsToErrorSlice ¶
func ValidationErrorsToErrorSlice(verrs goValidator.ValidationErrors) []error
ValidationErrorsToErrorSlice converts a goValidator.ValidationErrors to an array of standard Go errors, for easy use with external libraries that support arrays of stdlib errors.
Types ¶
type Disabled ¶
type Disabled struct {
Disabled bool `toml:"disabled"`
}
Disabled is an struct that must be embedded in any other application config struct. Doing so ensures there's a consistent, easy way to allow apps to be individually disabled via config file.
func (Disabled) IsDisabled ¶
IsDisabled returns true if the relevant app config struct was disabled via config file, otherwise it returns false.
type Status ¶
type Status int
Status is the general result of config health checking.
const ( // StatusOk is returned when the provided app config is healthy, and that // the relevant app can be switched. StatusOk Status = iota // StatusNotInstalled is returned when the application isn't installed. // User interaction is required to install the application, but will be // silently ignored otherwise. StatusNotInstalled // StatusMissingConfig is returned when no app config was provided for an // app that doesn't (or cannot) have a valid default configuration. User // interaction is required. StatusMissingConfig // StatusDisabled is returned when an app config was provided, but the // disabled field was set to 'true'. Valalidation errors -- if any -- are // available via the 'error' return value. StatusDisabled // StatusNotOk is returned when an app is not disabled and has validation // errors. The app's theme should not be switched. StatusNotOk // StatusInternalError is returned when something goes wrong in the // implementation of thcon -- typically when a non-nil config struct // doesn't embed health.Disabled. StatusInternalError )
func HasDefaults ¶
HasDefaults allows a nil config for apps that have a valid default configuration, and otherwise performs config health checking, including: * does the config struct embed health.Disabled? * are there any validation errors (via go-playground/validator)? * is the app disabled via config?
func RequiresConfig ¶
RequiresConfig rejects a nil config for apps that don't (or cannot) have a valid default configuration, and otherwise performs config health checking, including: * does the config struct embed health.Disabled? * are there any validation errors (via go-playground/validator)? * is the app disabled via config?