config

package
v0.6.8 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2022 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package config provides types and functions to collect, validate and apply user-provided settings.

Index

Constants

View Source
const (

	// LogLevelFatal is used for errors that should definitely be noted.
	// Commonly used for hooks to send errors to an error tracking service.
	LogLevelFatal string = "fatal"

	// LogLevelError is for errors that should definitely be noted.
	LogLevelError string = "error"

	// LogLevelWarn is for non-critical entries that deserve eyes.
	LogLevelWarn string = "warn"

	// LogLevelInfo is for general application operational entries.
	LogLevelInfo string = "info"

	// LogLevelDebug is for debug-level messages and is usually enabled
	// when debugging. Very verbose logging.
	LogLevelDebug string = "debug"
)

Log levels

View Source
const (
	RequestTypeA     string = "A"
	RequestTypeAAAA  string = "AAAA"
	RequestTypeCNAME string = "CNAME"
	RequestTypeMX    string = "MX"
	RequestTypeNS    string = "NS"
	RequestTypePTR   string = "PTR"
	RequestTypeSRV   string = "SRV"
)

Supported Request types TODO: Duplicated in dqrs package

View Source
const (
	SrvProtocolMSDCS      string = "msdcs"
	SrvProtocolKerberos   string = "kerberos"
	SrvProtocolXMPPServer string = "xmppsrv"
	SrvProtocolXMPPClient string = "xmppclient"
	SrvProtocolSIP        string = "sip"
)

Supported Service Location (SRV) Protocol keywords

View Source
const (
	// LogFormatCLI provides human-friendly CLI output
	LogFormatCLI string = "cli"

	// LogFormatJSON provides JSON output
	LogFormatJSON string = "json"

	// LogFormatLogFmt provides logfmt plain-text output
	LogFormatLogFmt string = "logfmt"

	// LogFormatText provides human-friendly colored output
	LogFormatText string = "text"

	// LogFormatDiscard discards all logs
	LogFormatDiscard string = "discard"
)

apex/log Handlers

--------------------------------------------------------- cli - human-friendly CLI output discard - discards all logs es - Elasticsearch handler graylog - Graylog handler json - JSON output handler kinesis - AWS Kinesis handler level - level filter handler logfmt - logfmt plain-text formatter memory - in-memory handler for tests multi - fan-out to multiple handlers papertrail - Papertrail handler text - human-friendly colored output delta - outputs the delta between log calls and spinner

View Source
const (
	ResultsOutputSingleLine string = "single-line"
	ResultsOutputMultiLine  string = "multi-line"
)

Results summary output display options TODO: Duplicated in dqrs package

Variables

View Source
var ErrVersionRequested = errors.New("version information requested")

ErrVersionRequested indicates that the user requested application version information.

Functions

func Branding

func Branding()

Branding is responsible for emitting application name, version and origin

func PathExists

func PathExists(path string) bool

PathExists confirms that the specified path exists

func SrvProtocolTmplLookup added in v0.5.0

func SrvProtocolTmplLookup(keyword string) (string, error)

SrvProtocolTmplLookup looks up the protocol record template associated with a given protocol keyword. An error is returned if support is not provided for a specific protocol keyword.

Types

type Config

type Config struct {
	// contains filtered or unexported fields
}

Config is a unified set of configuration values for this application. This struct is configured via command-line flags or TOML configuration file provided by the user. The majority of values held by this object are intended to be retrieved via "Getter" methods.

func NewConfig

func NewConfig() (*Config, error)

NewConfig is a factory function that produces a new Config object based on user provided flag and config file values.

func (Config) DNSErrorsFatal added in v0.3.0

func (c Config) DNSErrorsFatal() bool

DNSErrorsFatal returns the user-provided choice of whether DNS-related errors should be fatal or the default value for this choice.

func (*Config) ImportConfigFile

func (c *Config) ImportConfigFile(fh io.Reader) (bool, error)

ImportConfigFile reads from an io.Reader and unmarshals a configuration file in TOML format into the associated Config struct.

func (Config) LogFormat

func (c Config) LogFormat() string

LogFormat returns the user-provided logging format or empty string if not provided. CLI flag values take precedence if provided.

func (Config) LogLevel

func (c Config) LogLevel() string

LogLevel returns the user-provided logging level or the default value if not provided. CLI flag values take precedence if provided.

func (Config) OmitTimestamp added in v0.6.0

func (c Config) OmitTimestamp() bool

OmitTimestamp returns the user-provided choice of whether the date/time when results are generated should be omitted from the results output.

func (Config) Query

func (c Config) Query() string

Query returns the user-provided DNS server query or the default value if DNS server query was not provided. CLI flag values take precedence if provided.

func (Config) QueryTypes

func (c Config) QueryTypes() []string

QueryTypes returns the user-provided choice of which DNS record types to request when submitting queries. If not set, defaults to A record type.

func (Config) ResultsOutput added in v0.5.0

func (c Config) ResultsOutput() string

ResultsOutput specifies whether the results summary is composed of a single comma-separated line of records for a query, or whether the records are returned one per line.

func (Config) Servers

func (c Config) Servers() []string

Servers returns a slice of configured DNS server entries or nil if DNS server entries were not provided. CLI flag values take precedence if provided.

func (Config) ShowVersion

func (c Config) ShowVersion() bool

ShowVersion returns the user-provided choice of displaying the application version and exiting or the default value for this choice.

func (Config) SrvProtocols added in v0.5.0

func (c Config) SrvProtocols() []string

SrvProtocols returns the user-provided choice of which Service Location (SRV) record protocols should be used with a given query string. This is a "shortcut" of sorts that allows specifying one or more short strings instead of providing a much longer, unwieldy formatted string as the query value as separate queries.

For example, "msdcs" can be specified as a SRV record protocol along with "example.com" as the query string to search DNS for "_ldap._tcp.dc._msdcs.example.com".

func (Config) String

func (c Config) String() string

func (Config) Timeout added in v0.2.0

func (c Config) Timeout() time.Duration

Timeout returns the user-provided choice of what timeout value to use for DNS queries. If not set, returns the default value for our application.

func (Config) Validate

func (c Config) Validate() error

Validate verifies all struct fields have been provided acceptable values

Jump to

Keyboard shortcuts

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