configuration

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2024 License: MIT Imports: 11 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

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://pkg.go.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
	DefaultFilter          model.Severity
	DefaultSort            model.StatusField
	DisplayTimeForStatuses bool
	Clocks                 []ClockConfig
}

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 InternalConfig

type InternalConfig struct {
	Controller  ControllerConfig
	View        ViewConfig
	ProbeRunner []ProbeRunnerConfig
}

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.
	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 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 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"`
	// 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 inteval attribute is a duration that define how often the probe will check for a system or resources conditions.
	Interval string `hcl:"interval,attr"`
	// 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
}

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

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"`
}

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

type Variables

type Variables map[string]cty.Value

Variables contains user defined runtime variables.

type ViewConfig

type ViewConfig struct {
	Title string
}

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