configuration

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package configuration defines the HCL and internal types the configuration file is mapped to, and useful consts and functions that can be used using HCL. It also reads variable files and variable arguments.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewToSetFn

func NewToSetFn() function.Function

NewToSetFn turns an HCL list of strings into a cty.Set

func NewTodayFn added in v1.1.0

func NewTodayFn() function.Function

NewTodayFn creates a function that returns the current day in YYYY-MM-DD format.

Types

type Clock

type Clock struct {
	// The first label of the clock is a human readable label for the clock. For example, use "UTC" for a clock that displays the UTC time.
	Label string `hcl:"label,label"`
	// The location attribute is a name corresponding to a well known location on earth, for example "Europe/Paris".
	// You can also use the special values "UTC" and "Local" for the UTC timezone and the configured local one respectively.
	// See [time.LoadLocation].
	//
	// [time.LoadLocation]: https://pkgo.dev/time#LoadLocation
	Location string `hcl:"location"`
	// The format attribute is the display format of the clock. Use the [time.Format] reference time to describe the expected format, ie "2006-01-02 15:04:05"
	Format string `hcl:"format,optional"`
	// The status_format attribute is the display format for the Update and Change columns of a status row when the display_time_for_statuses attribute of the preferences block is set to true.
	StatusFormat string `hcl:"status_format,optional"`
	// The status_day_format attribute is the same as above, but used when the change or update happened a different day than today.
	StatusDayFormat string `hcl:"status_day_format,optional"`
}

Clock ("clock" block) configures a timezone location and display format for the clock in the header and for the Update and Change columns when display_time_for_statuses is set to true.

type ClockConfig

type ClockConfig struct {
	Label           string
	Location        *time.Location
	Format          string
	StatusFormat    string
	StatusDayFormat string
}

ClockConfig contains a clock configuration, including the loaded time location.

type ControllerConfig

type ControllerConfig struct {
	Refresh                time.Duration
	RefreshOnUpdate        bool
	Expiration             time.Duration
	DefaultSeverityFilter  model.Severity
	DefaultLayerFilter     model.Layer
	DefaultSort            model.StatusField
	MinimumErrorSeverity   model.Severity
	DisplayTimeForStatuses bool
	Clocks                 []ClockConfig
	LogFile                string
}

ControllerConfig contains the controller configuration as decoded and mapped to model types.

type File

type File struct {
	// A preferences block sets general preferences such as default severity filter, ordering and user interface refresh interval.
	// Only one preferences block is allowed per configuration.
	Preferences []Preferences `hcl:"preferences,block"`
	// A theme block customizes Kee's appearence.
	// Only one theme block is allowed per configuration.
	Theme []Theme `hcl:"theme,block"`
	// A probe block configures a probe provider to watch a system or resource and reports its status(es)/conditions.
	// The first label of the block is the provider type; the second is a human readable label for it.
	// The tuple (provider type, label) must be unique within the configuration.
	// You can define multiple probe blocks per configuration.
	Probes []Probe `hcl:"probe,block"`
}

File represents a complete Kee configuration file Within the configuration file, duration or time intervals are defined using strings such as "1s" or "3m". See the time.ParseDuration function. Severities are integers, but you should use predefined constants to set them explicitly: use severity.ok, severity.notice, severity.warning or severity.critical. Fields are integers, but you should use predefined constants to set them explicitly: use field.severity, field.label, field.change.

type HeaderConfig added in v1.1.0

type HeaderConfig struct {
	BgColor          tcell.Color
	FgColor          tcell.Color
	StatusCountRules []ThemeRuleConfig
	ErrorCountRules  []ThemeRuleConfig
	BorderColor      tcell.Color
	LayerMenu        ThemeMenuConfig
	SeverityMenu     ThemeMenuConfig
	SortMenu         ThemeMenuConfig
}

HeaderConfig configures the appearance the top part of the interface

type HeaderTheme added in v1.1.0

type HeaderTheme struct {
	BgColor         string      `hcl:"bg_color,optional"`
	FgColor         string      `hcl:"fg_color,optional"`
	StatusCountRule []ThemeRule `hcl:"status_count_rule,block"`
	ErrorCountRule  []ThemeRule `hcl:"error_count_rule,block"`
	BorderColor     string      `hcl:"border_color,optional"`
	LayerMenu       []ThemeMenu `hcl:"layer_menu,block"`
	SeverityMenu    []ThemeMenu `hcl:"severity_menu,block"`
	SortMenu        []ThemeMenu `hcl:"sort_menu,block"`
}

HeaderTheme ("header" block) configures the appearance the top part of the interface

type InternalConfig

type InternalConfig struct {
	Controller  *ControllerConfig
	View        *ViewConfig
	ProbeRunner ProbeRunnerConfigs
}

InternalConfig contains the Kee configuration as decoded and mapped to model types.

func Configure

func Configure(filename string, varFile string, varArgs map[string]string) (*InternalConfig, error)

Configure will decode the file at the provided path as an HCL File configuring Kee.

type Preferences

type Preferences struct {
	// The refresh_interval attribute sets how often the interface will be refreshed. Use duration values.
	// It defaults to 1 second.
	RefreshInterval string `hcl:"refresh_interval,optional"`
	// The refresh_on_update attribute will refresh the interface everytime new information is gathered by a probe, in addition to the refresh_interval, when set to true.
	RefreshOnUpdate bool `hcl:"refresh_on_update,optional"`
	// The expiration attribute will hide statuses that haven't been updated within the specified duration.
	// This is useful to clear some errors due to loosing network, or to "forget" statuses about resources that were deleted while kee is running, such as pods or CloudWatch alarms.
	Expiration string `hcl:"expiration,optional"`
	// The default_filter attribute is a severity that will filter status rows on launch. This is merely a convenience and you can always update the filter while the app is running.
	DefaultFilter int `hcl:"default_filter,optional"`
	// The default_sort attribute is a field that will sort status rows on launch. Only fields currently accepted are severity, label and change. You can change ordering while the app is running.
	DefaultSort int `hcl:"default_sort,optional"`
	// The minimum_error_severity attribute determines which severities count as errors (in summaries, like the count presented in the interface header or the JSON output from -t mode)
	MinErrorSeverity int `hcl:"minimum_error_severity,optional"`
	// The display_time_for_statuses attribute, when set to true, display the time and (if needed) the date of changes and updates rather than a duration.
	DisplayTimeForStatuses bool `hcl:"display_time_for_statuses,optional"`
	// The log_file attributes will enable a JSON log file reporting all changes. This is intended for incident post-mortems.
	LogFile string `hcl:"log_file,optional"`
	// A clock block configures a timezone location and display format for the clock in the header and for the Update and Change columns when display_time_for_statuses is set to true.
	Clocks []Clock `hcl:"clock,block"`
}

Preferences ("preferences" block) sets general preferences such as default severity filter, ordering and user interface refresh interval.

type Probe

type Probe struct {
	// The first label is the type of probe to use.
	Type string `hcl:"type,label"`
	// The second label is the human-readable label for the probe.
	Label string `hcl:"label,label"`
	// The minimum_severity attribute is a severity that will replace the probe's reported severity when the condition reported is not OK.
	// Use this if a probe doesn't present a condition as severe enough for critical resources in your system.
	MinSeverity int `hcl:"minimum_severity,optional"`
	// The interval attribute is a duration that define how often the probe will check for a system or resources conditions.
	// It defaults to 1 minute.
	Interval string `hcl:"interval,optional"`
	// The layer attribute assigns a static system layer to all Statuses returned by this probe.
	Layer int `hcl:"layer,optional"`
	// The remainder of the probe block depends on the type of the probe selected with the first label.
	ProbeConfig hcl.Body `hcl:"probe_configuration,remain"`
}

Probe ("probe" block) configures a probe provider to watch a system or resource and reports its status(es)/conditions.

type ProbeRunnerConfig

type ProbeRunnerConfig struct {
	ID          string
	Probe       model.Prober
	MinSeverity model.Severity
	Label       string
	Interval    time.Duration
	Layer       model.Layer
}

ProbeRunnerConfig contains a probe configuration as decoded and mapped to model types, including a configured instance of Prober.

type ProbeRunnerConfigs added in v1.1.0

type ProbeRunnerConfigs []ProbeRunnerConfig

ProbeRunnerConfigs is a slice of ProbeRunnerConfig

func (ProbeRunnerConfigs) MaxInterval added in v1.1.0

func (prcs ProbeRunnerConfigs) MaxInterval(min time.Duration) time.Duration

MaxInterval returns the maximum time.Duration of configured refresh interval for the ProbeRunnerConfigs

type StatusTableConfig added in v1.1.0

type StatusTableConfig struct {
	BgColor       tcell.Color
	BorderColor   tcell.Color
	HeaderBgColor tcell.Color
	HeaderFgColor tcell.Color
	Columns       []model.StatusField
	Rules         []ThemeRuleConfig
}

StatusTableConfig configures the looks of the status table.

type StatusTableTheme added in v1.1.0

type StatusTableTheme struct {
	BgColor       string      `hcl:"bg_color,optional"`
	BorderColor   string      `hcl:"border_color,optional"`
	HeaderBgColor string      `hcl:"header_bg_color,optional"`
	HeaderFgColor string      `hcl:"header_fg_color,optional"`
	Columns       []int       `hcl:"columns,optional"`
	Rules         []ThemeRule `hcl:"rule,block"`
}

StatusTableTheme configures the looks of the status table.

type Theme

type Theme struct {
	// The title attribute sets what is display on top of the header of the interface.
	// You may use it to distinguish between a prod and a dev Kee configuration for example, or to indicate which system or app is being monitored by the configuration.
	Title       string             `hcl:"title,optional"`
	Header      []HeaderTheme      `hcl:"header,block"`
	StatusTable []StatusTableTheme `hcl:"status_table,block"`
}

Theme ("theme" block) customizes Kee's appearence.

type ThemeMenu added in v1.1.0

type ThemeMenu struct {
	FgColor         string `hcl:"fg_color,optional"`
	SelectedFgColor string `hcl:"selected_fg_color,optional"`
	TitleFgColor    string `hcl:"title_fg_color,optional"`
}

ThemeMenu configures a menu's appearance.

type ThemeMenuConfig added in v1.1.0

type ThemeMenuConfig struct {
	FgColor         tcell.Color
	SelectedFgColor tcell.Color
	TitleFgColor    tcell.Color
}

ThemeMenuConfig configures a menu's appearance.

type ThemeRule added in v1.1.0

type ThemeRule struct {
	Condition hcl.Expression `hcl:"condition,optional"`
	BgColor   string         `hcl:"bg_color,optional"`
	FgColor   string         `hcl:"fg_color,optional"`
}

ThemeRule configures a dynamic coloring rule for an interface element. For a given element, the first rule in lexical order for which condition evaluates to true will determine the element's looks.

type ThemeRuleConfig added in v1.1.0

type ThemeRuleConfig struct {
	Condition hcl.Expression
	BgColor   tcell.Color
	FgColor   tcell.Color
}

ThemeRuleConfig configures a dynamic coloring rule for an interface element.

type Variables

type Variables map[string]cty.Value

Variables contains user defined runtime variables.

type ViewConfig

type ViewConfig struct {
	Title       string
	Header      HeaderConfig
	StatusTable StatusTableConfig
	Context     *hcl.EvalContext
}

ViewConfig contains the view configuration as decoded from HCL.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳