Documentation
¶
Overview ¶
Package config provides data structures and methods to read configuration files and validates the content of such files for sane values while setting default where applicable.
Index ¶
Constants ¶
View Source
const ( GroupTypeDeviceTag = "device_tag" GroupTypeInterfaceTag = "interface_tag" GroupTypeService = "service" InetFamilyAny = "any" InetFamilyInet = "inet" InetFamilyInet6 = "inet6" )
Variables ¶
View Source
var ( ErrorBadFilterLabel = errors.New("bad label for filter provided (must start with 'netbox_')") ErrorBadFilterMatch = errors.New("bad filter match provided") ErrorBadGroupType = errors.New("bad group type value") ErrorBadInetFamily = errors.New("bad inet_family value provided") ErrorBadPort = errors.New("bad port value") ErrorBadScanInterval = errors.New("failed to parse scan_interval") ErrorBaseURLMissingTLS = errors.New("netbox_base_url must start with https and support tls") ErrorDuplicateFile = errors.New("duplicate file name in configuration") ErrorMissingFile = errors.New("missing config file path") ErrorMissingRequired = errors.New("missing one or more required config values") ErrorParsingFile = errors.New("failed to parse config file") ErrorReadingFile = errors.New("failed to read config file") )
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
BaseURL string `yaml:"base_url"`
Token string `yaml:"api_token"`
AllowInsecure bool `yaml:"allow_insecure"`
ScanIntervalString string `yaml:"scan_interval"`
ScanInterval time.Duration `yaml:"-"`
Groups []*Group `yaml:"groups"`
}
Config is a generic config struct for netbox_sd
func ReadConfigFile ¶
ReadConfigFile reads and parses a given config file
type Filter ¶
type Filter struct {
Label string `yaml:"label"`
Match string `yaml:"match"`
Negate bool `yaml:"negate"`
// contains filtered or unexported fields
}
Filter defines a new filter where a the string index of the map is a label name and the value at that index represents a regular expression that must match.
type Flags ¶
type Flags struct {
// IncludeVMs will cause VMs to be checked for matches too.
IncludeVMs *bool `yaml:"include_vms"`
// InetFamily defines which inet address family is returned. If an address of a target doesn't match the family, the
// device is skipped in the resulting target group.
InetFamily *string `yaml:"inet_family"`
// AllAddresses causes all addresses of a service, device or interface to be returned when set to true. This still
// honors the InetFamily filter.
AllAddresses *bool `yaml:"all_addresses"`
}
Flags defines specific behavior that can be toggled on or off
type Group ¶
type Group struct {
File string `yaml:"file"`
Type string `yaml:"type"`
Match string `yaml:"match"`
ScanIntervalString string `yaml:"scan_interval"`
ScanInterval time.Duration `yaml:"-"`
Labels model.LabelSet `yaml:"labels"`
Port *int `yaml:"port"`
Flags Flags `yaml:"flags"`
Filters []*Filter `yaml:"filters"`
}
Group contains specific configuration for groups to get targets for
func (*Group) FiltersMatch ¶
func (group *Group) FiltersMatch(target *targetgroup.Group) bool
FiltersMatch returns true if all filters match with the target's labels.
Click to show internal directories.
Click to hide internal directories.