hcl

package
v0.5.3 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2024 License: MPL-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildRunners

func BuildRunners[T Blocks](config T, tmpDir string, debugDuration time.Duration, debugInterval time.Duration, c *client.APIClient, since, until time.Time, redactions []*redact.Redact) ([]runner.Runner, error)

BuildRunners steps through the HCLConfig structs and maps each runner config type to the corresponding New<Runner> function. All custom runners are reduced into a linear slice of runners and served back up to the product. No runners are returned if any config is invalid.

func BuildRunnersWithContext added in v0.5.0

func BuildRunnersWithContext[T Blocks](ctx context.Context, config T, tmpDir string, debugDuration time.Duration, debugInterval time.Duration, c *client.APIClient, since, until time.Time, redactions []*redact.Redact) ([]runner.Runner, error)

BuildRunnersWithContext is similar to BuildRunners but accepts a context.Context that will be passed into the runners.

func MapRedacts

func MapRedacts(redactions []Redact) ([]*redact.Redact, error)

MapRedacts maps HCL redactions to "real" `redact.Redact`s

func ProductsMap

func ProductsMap(products []*Product) map[string]*Product

ProductsMap takes the collection of products and returns a map that keys each product to its Name.

func ValidateRedactions

func ValidateRedactions(redactions []Redact) error

ValidateRedactions takes a slice of redactions and ensures they match valid names.

Types

type Agent

type Agent struct {
	// NOTE(dcohen) this is currently a separate config block, as opposed to a parent block of the others
	Redactions []Redact `hcl:"redact,block" json:"redactions,omitempty"`
}

type Blocks

type Blocks interface {
	*Host | *Product | *Agent
}

type Command

type Command struct {
	Run        string   `hcl:"run" json:"run"`
	Format     string   `hcl:"format" json:"format"`
	Redactions []Redact `hcl:"redact,block" json:"redactions,omitempty"`
	Timeout    string   `hcl:"timeout,optional" json:"timeout,omitempty"`
}

type ConsulDebug added in v0.5.0

type ConsulDebug struct {
	Archive    string   `hcl:"archive" json:"archive"`
	Duration   string   `hcl:"duration,optional" json:"duration"`
	Interval   string   `hcl:"interval,optional" json:"interval"`
	Captures   []string `hcl:"captures,optional" json:"captures"`
	Redactions []Redact `hcl:"redact,block" json:"redactions"`
}

type Copy

type Copy struct {
	Path       string   `hcl:"path" json:"path"`
	Since      string   `hcl:"since,optional" json:"since"`
	Redactions []Redact `hcl:"redact,block" json:"redactions,omitempty"`
	Timeout    string   `hcl:"timeout,optional" json:"timeout,omitempty"`
}

type Do added in v0.5.0

type Do struct {
	Label       string `hcl:"name,label" json:"label"`
	Description string `hcl:"description,optional" json:"since"`

	Do  []Do  `hcl:"do,block" json:"do,omitempty"`
	Seq []Seq `hcl:"seq,block" json:"seq,omitempty"`

	// Runners
	Commands     []Command     `hcl:"command,block" json:"commands,omitempty"`
	Shells       []Shell       `hcl:"shell,block" json:"shells,omitempty"`
	GETs         []GET         `hcl:"GET,block" json:"gets,omitempty"`
	Copies       []Copy        `hcl:"copy,block" json:"copies,omitempty"`
	DockerLogs   []DockerLog   `hcl:"docker-log,block" json:"docker_log,omitempty"`
	JournaldLogs []JournaldLog `hcl:"journald-log,block" json:"journald_log,omitempty"`
	VaultDebugs  []VaultDebug  `hcl:"vault-debug,block" json:"vault_debug,omitempty"`
	ConsulDebugs []ConsulDebug `hcl:"consul-debug,block" json:"consul_debug,omitempty"`
	NomadDebugs  []NomadDebug  `hcl:"nomad-debug,block" json:"nomad_debug,omitempty"`
}

type DockerLog

type DockerLog struct {
	Container  string   `hcl:"container" json:"container"`
	Since      string   `hcl:"since,optional" json:"since"`
	Redactions []Redact `hcl:"redact,block" json:"redactions,omitempty"`
	Timeout    string   `hcl:"timeout,optional" json:"timeout,omitempty"`
}

type GET

type GET struct {
	Path       string   `hcl:"path" json:"path"`
	Redactions []Redact `hcl:"redact,block" json:"redactions,omitempty"`
	Timeout    string   `hcl:"timeout,optional" json:"timeout,omitempty"`
}

type HCL

type HCL struct {
	Host     *Host      `hcl:"host,block" json:"host,omitempty"`
	Products []*Product `hcl:"product,block" json:"products,omitempty"`
	Agent    *Agent     `hcl:"agent,block" json:"agent,omitempty"`
}

func Parse

func Parse(path string) (HCL, error)

Parse takes a file path and decodes the file from disk into HCL types.

type Host

type Host struct {
	// Do
	Do  []Do  `hcl:"do,block" json:"do,omitempty"`
	Seq []Seq `hcl:"seq,block" json:"seq,omitempty"`

	// Runners
	Commands     []Command     `hcl:"command,block" json:"commands,omitempty"`
	Shells       []Shell       `hcl:"shell,block" json:"shells,omitempty"`
	GETs         []GET         `hcl:"GET,block" json:"gets,omitempty"`
	Copies       []Copy        `hcl:"copy,block" json:"copies,omitempty"`
	DockerLogs   []DockerLog   `hcl:"docker-log,block" json:"docker_log,omitempty"`
	JournaldLogs []JournaldLog `hcl:"journald-log,block" json:"journald_log,omitempty"`

	// Filters
	Excludes []string `hcl:"excludes,optional" json:"excludes,omitempty"`
	Selects  []string `hcl:"selects,optional" json:"selects,omitempty"`

	// Params
	Redactions []Redact `hcl:"redact,block" json:"redactions,omitempty"`
}

type JournaldLog

type JournaldLog struct {
	Service    string   `hcl:"service" json:"service"`
	Since      string   `hcl:"since,optional" json:"since"`
	Redactions []Redact `hcl:"redact,block" json:"redactions,omitempty"`
	Timeout    string   `hcl:"timeout,optional" json:"timeout,omitempty"`
}

type NomadDebug added in v0.5.0

type NomadDebug struct {
	Duration      string `hcl:"duration,optional" json:"duration"`
	Interval      string `hcl:"interval,optional" json:"interval"`
	LogLevel      string `hcl:"log-level,optional" json:"log_level"`
	MaxNodes      int    `hcl:"max-nodes,optional" json:"max_nodes"`
	NodeClass     string `hcl:"node-class,optional" json:"node_class"`
	NodeID        string `hcl:"node-id,optional" json:"node_id"`
	PprofDuration string `hcl:"pprof-duration,optional" json:"pprof_duration"`
	PprofInterval string `hcl:"pprof-interval,optional" json:"pprof_interval"`
	ServerID      string `hcl:"server-id,optional" json:"server_id"`
	Stale         bool   `hcl:"stale,optional" json:"stale"`
	Verbose       bool   `hcl:"verbose,optional" json:"verbose"`

	EventTopic []string `hcl:"targets,optional" json:"targets"`
	Redactions []Redact `hcl:"redact,block" json:"redactions"`
}

type Product

type Product struct {
	Name string `hcl:"name,label" json:"name"`

	// Do
	Do  []Do  `hcl:"do,block" json:"do,omitempty"`
	Seq []Seq `hcl:"seq,block" json:"seq,omitempty"`

	// Runners
	Commands     []Command     `hcl:"command,block" json:"commands,omitempty"`
	Shells       []Shell       `hcl:"shell,block" json:"shells,omitempty"`
	GETs         []GET         `hcl:"GET,block" json:"gets,omitempty"`
	Copies       []Copy        `hcl:"copy,block" json:"copies,omitempty"`
	DockerLogs   []DockerLog   `hcl:"docker-log,block" json:"docker_log,omitempty"`
	JournaldLogs []JournaldLog `hcl:"journald-log,block" json:"journald_log,omitempty"`
	VaultDebugs  []VaultDebug  `hcl:"vault-debug,block" json:"vault_debug,omitempty"`
	ConsulDebugs []ConsulDebug `hcl:"consul-debug,block" json:"consul_debug,omitempty"`
	NomadDebugs  []NomadDebug  `hcl:"nomad-debug,block" json:"nomad_debug,omitempty"`
	Excludes     []string      `hcl:"excludes,optional" json:"excludes,omitempty"`
	Selects      []string      `hcl:"selects,optional" json:"selects,omitempty"`
	Redactions   []Redact      `hcl:"redact,block" json:"redactions,omitempty"`
}

type Redact

type Redact struct {
	Label   string `hcl:"name,label" json:"label"`
	ID      string `hcl:"id,optional" json:"id"`
	Match   string `hcl:"match" json:"-"`
	Replace string `hcl:"replace,optional" json:"replace"`
}

type Seq added in v0.5.0

type Seq struct {
	Label       string `hcl:"name,label" json:"label"`
	Description string `hcl:"description,optional" json:"since"`
	Timeout     string `hcl:"timeout,optional" json:"timeout,omitempty"`

	// Do
	Do  []Do  `hcl:"do,block" json:"do,omitempty"`
	Seq []Seq `hcl:"seq,block" json:"seq,omitempty"`

	// Runners
	Commands     []Command     `hcl:"command,block" json:"commands,omitempty"`
	Shells       []Shell       `hcl:"shell,block" json:"shells,omitempty"`
	GETs         []GET         `hcl:"GET,block" json:"gets,omitempty"`
	Copies       []Copy        `hcl:"copy,block" json:"copies,omitempty"`
	DockerLogs   []DockerLog   `hcl:"docker-log,block" json:"docker_log,omitempty"`
	JournaldLogs []JournaldLog `hcl:"journald-log,block" json:"journald_log,omitempty"`
	VaultDebugs  []VaultDebug  `hcl:"vault-debug,block" json:"vault_debug,omitempty"`
	ConsulDebugs []ConsulDebug `hcl:"consul-debug,block" json:"consul_debug,omitempty"`
	NomadDebugs  []NomadDebug  `hcl:"nomad-debug,block" json:"nomad_debug,omitempty"`
}

type Shell

type Shell struct {
	Run        string   `hcl:"run" json:"run"`
	Timeout    string   `hcl:"timeout,optional" json:"timeout,omitempty"`
	Redactions []Redact `hcl:"redact,block" json:"redactions,omitempty"`
}

type VaultDebug added in v0.5.0

type VaultDebug struct {
	Compress        string   `hcl:"compress" json:"compress"`
	Duration        string   `hcl:"duration,optional" json:"duration"`
	Interval        string   `hcl:"interval,optional" json:"interval"`
	LogFormat       string   `hcl:"log-format,optional" json:"log_format"`
	MetricsInterval string   `hcl:"metrics-interval,optional" json:"metrics_interval"`
	Targets         []string `hcl:"targets,optional" json:"targets"`
	Redactions      []Redact `hcl:"redact,block" json:"redactions"`
}

Jump to

Keyboard shortcuts

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