Documentation ¶
Overview ¶
Package config handles the main config file.
Index ¶
Constants ¶
const ( DefaultFilePath = "/etc/tsp-controller/config" DefaultFilterPath = "/etc/tsp-controller/filter" )
Variables ¶
var ( FilePath = flag.String("f", DefaultFilePath, "configuration file") TestMode = flag.Bool("t", false, "configuration test") VerboseMode = flag.Bool("v", false, "verbose mode") ListenAddr = flag.String("l", ":8084", "listen address") VersionMode = flag.Bool("version", false, "echo version and exit") )
var Debug *log.Logger
Functions ¶
Types ¶
type Cluster ¶
type Cluster struct { ID string `xml:"id,attr"` Host []*Host `xml:"host"` Any *xml.Name `xml:",any"` }
Cluster represents a single <cluster> element.
type Config ¶
type Config struct { Hosts *Hosts `xml:"hostgroup"` Network *network.Config `xml:"network"` Filter *Filter `xml:"filter"` Extra []*Element `xml:",any"` }
Config represents controller's entire configuration, i.e. the <config> block.
var Loaded *Config
Loaded contains the loaded configuration.
func Decode ¶
Decode decodes from r the common configuration settings. It also validates that the extended settings are correct, but omits them from the returned config.
func (*Config) UpdateHost ¶
func (c *Config) UpdateHost(fn UpdateFunc) error
UpdateHost updates config to include extra Host-level elements.
type Element ¶
An Element is an extended configuration element. Such elements are stored in Config for processing by extension modules.
func (*Element) UnmarshalXML ¶
type Filter ¶
type Filter struct {
Path string `xml:"path,attr"`
}
Filter is a system command that acts as a hook, allowing operators to serve custom rewrite/block filter rules.
type Host ¶
type Host struct { ID string `xml:"id,attr"` ClusterID string `xml:"-"` Tags []string `xml:"-"` Extra []*Element `xml:",any"` }
Host represents a single <host> element.
type HostGroup ¶
type HostGroup struct { Sub []*HostGroup `xml:"hostgroup"` ID string `xml:"id,attr"` Cluster []*Cluster `xml:"cluster"` Any *xml.Name `xml:",any"` }
HostGroup represents a single <hostgroup> element.
type UpdateFunc ¶
UpdateFunc is registered by extension module to decode custom Host-level elements. It is passed the Host.ID and an Element to decode. The decoded information must be stored in Element.Value. Any error encountered should be returned.