config

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2025 License: Apache-2.0 Imports: 12 Imported by: 3

Documentation

Overview

Package config contains configuration types for Korrel8r. These types can be loaded from YAML configuration files and/or used in a Kubernetes resource spec.

Index

Constants

View Source
const (
	StoreKeyDomain     = "domain"               // Required domain name
	StoreKeyError      = "error"                // Error message if store failed to load.
	StoreKeyErrorCount = "errorCount"           // Count of errors on a store.
	StoreKeyMock       = "mockData"             // Store loads mock data from a file or directory.
	StoreKeyCA         = "certificateAuthority" // Path to CA certificate.
)

Store keys that may be used by any stores.

Variables

This section is empty.

Functions

This section is empty.

Types

type Class added in v0.5.10

type Class struct {
	// Name is the short name for a group of classes.
	Name string `json:"name"`
	// Domain of the classes, all must be in the same domain.
	Domain string `json:"domain"`
	// Classes are the names of classes in this group.
	Classes []string `json:"classes"`
}

Class defines a shortcut name for a set of existing classes.

type ClassSpec

type ClassSpec struct {
	// Domain is the domain for selected classes.
	Domain string `json:"domain"`

	// Classes is a list of class names to be selected from the domain.
	// If absent, all classes in the domain are selected.
	Classes []string `json:"classes,omitempty"`
}

ClassSpec specifies one or more classes.

type Config

type Config struct {
	// Rules define the relationships that korrel8r will follow.
	Rules []Rule `json:"rules,omitempty"`

	// Aliases defines short names for groups of related classes.
	Aliases []Class `json:"aliases,omitempty"`

	// Stores is a list of store configurations.
	Stores []Store `json:"stores,omitempty"`

	// Include lists additional configuration files or URLs to include.
	Include []string `json:"include,omitempty"`

	// Tuning section has limits and optimizations.
	Tuning *Tuning `json:"tuning,omitempty"`

	// Soure of configuration, file or URL.
	Source string `json:"-"`
}

Config defines the configuration for an instance of korrel8r. Configuration files may be JSON or YAML.

type Configs

type Configs []Config

Configs is a list of configs from different sources.

func Load

func Load(fileOrURL string) (Configs, error)

Load loads all configurations from a file or URL.

If a configuration has an Include section, also loads all referenced configurations. Relative paths in Include are relative to the location of file containing them.

type Duration added in v0.7.5

type Duration struct {
	time.Duration
}

func (Duration) MarshalJSON added in v0.7.5

func (d Duration) MarshalJSON() ([]byte, error)

func (*Duration) UnmarshalJSON added in v0.7.5

func (d *Duration) UnmarshalJSON(b []byte) error

type ResultSpec

type ResultSpec struct {
	// Query template generates a query object suitable for the goal store.
	Query string `json:"query"`
}

ResultSpec contains templates to generate a result.

type Rule

type Rule struct {
	// Name is a short, descriptive name.
	// If omitted, a name is generated from Start and Goal.
	Name string `json:"name,omitempty"`

	// Start specifies the set of classes that this rule can apply to.
	Start ClassSpec `json:"start"`

	// Goal specifies the set of classes that this rule can produce.
	Goal ClassSpec `json:"goal"`

	// TemplateResult contains templates to generate the result of applying this rule.
	// Each template is applied to an object from one of the `start` classes.
	// If any template yields a blank string or an error, the rule does not apply.
	Result ResultSpec `json:"result"`
}

Rule configures a template rule.

The rule template is applied to a instance of the start object. It should generate one of the following: - a goal query string of the form DOAMAIN:CLASS:QUERY_DATA. - a blank (whitespace-only) string if the rule does not apply to the given object. - an error if something unexpected goes wrong.

If a rule returns an invalid query this will be logged as an error but will not prevent the progress on other rules. For expected conditions, returning blank generates less noise than an error.

type Store

type Store map[string]string

Store is a map of name:value attributes used to connect to a store. The names and values depend on the type of store.

type Tuning added in v0.7.5

type Tuning struct {
	// RequestTimeout cancel requests if they last longer than this timeout.
	// Cancelling a correlation operation may return an error or a partial result (HTTP 206).
	RequestTimeout Duration `json:"requestTimeout,omitempty"`
}

Tuning section for limits and optimizations.

Jump to

Keyboard shortcuts

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