run

package
v0.0.0-...-d95c679 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2024 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewBytesFileAccessor

func NewBytesFileAccessor(name string, content []byte) *memFileAccessor

NewBytesFileAccessor creates a FileAccessor that has a byte buf as its content

func NewLocalFileAccessor

func NewLocalFileAccessor(name, path string) *localFileAccessor

NewLocalFileAccessor creates a FileAccessor of which content is the content of a file in the local filesystem

func NewStringFileAccessor

func NewStringFileAccessor(name, content string) *memFileAccessor

NewStringFileAccessor creates a FileAccessor that has a string as its content

func WorkDir

func WorkDir(f func(string)) error

WorkDir creates a temporary work directory, runs an action, and removes the directory afterwards. Returns a non-nil error in case of issues.

Types

type DockerRunnerOptions

type DockerRunnerOptions struct {
	Privileged bool
	Binds      []string
}

type ExitCodeError

type ExitCodeError struct {
	Code int
}

ExitCodeError is an error representing the exit code of Falco

func (*ExitCodeError) Error

func (c *ExitCodeError) Error() string

type FileAccessor

type FileAccessor interface {
	Name() string
	Content() ([]byte, error)
}

FileAccessor is an interface defining a file with given name and content to be used within a Runner, and that abstracts the logic with which content is retrieved.

type Runner

type Runner interface {
	// Run runs Falco with the given options and returns when it finishes its
	// execution or when the context deadline is exceeded.
	// Returns a non-nil error in case of failure.
	Run(ctx context.Context, options ...RunnerOption) error
	// WorkDir return the absolute path to the working directory assigned
	// to the runner.
	WorkDir() string
}

Runner runs Falco with a given set of options

func NewDockerRunner

func NewDockerRunner(image, entrypoint string, options *DockerRunnerOptions) (Runner, error)

NewDockerRunner returns a runner that runs a container image with Docker

func NewExecutableRunner

func NewExecutableRunner(executable string) (Runner, error)

NewExecutableRunner returns a runner that runs a local executable binary

type RunnerOption

type RunnerOption func(*runOpts)

RunnerOption is an option for running Falco

func WithArgs

func WithArgs(args ...string) RunnerOption

WithArgs is an option for running Falco with a given set of CLI arguments

func WithEnvVars

func WithEnvVars(vars map[string]string) RunnerOption

WithEnvVars is an option for running Falco with a given set of environment varibles

func WithFiles

func WithFiles(files ...FileAccessor) RunnerOption

WithFiles is an option for running Falco with some files to be used during execution and/or referenced in the CLI args (e.g. rules files, config files, capture files, etc...). For example, if you run Falco with `-c` (through WithArgs), you should add the referenced config file with WithFiles.

func WithStderr

func WithStderr(writer io.Writer) RunnerOption

WithStderr is an option for running Falco by writing stderr on a given writer

func WithStdout

func WithStdout(writer io.Writer) RunnerOption

WithStdout is an option for running Falco by writing stdout on a given writer

Jump to

Keyboard shortcuts

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