hcl

package
v0.4.0-rc2 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2022 License: MPL-2.0 Imports: 10 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, 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 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 {
	Redactions []Redact `hcl:"redact,block" json:"redactions,omitempty"`
}

NOTE(dcohen) this is currently a separate config block, as opposed to a parent block of the others

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"`
}

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"`
}

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"`
}

type GET

type GET struct {
	Path       string   `hcl:"path" json:"path"`
	Redactions []Redact `hcl:"redact,block" json:"redactions,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 {
	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"`
	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 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"`
}

type Product

type Product struct {
	Name         string        `hcl:"name,label" json:"name"`
	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"`
	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 Shell

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

Jump to

Keyboard shortcuts

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