check

package module
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2023 License: MIT Imports: 19 Imported by: 36

README

Vulcan Check SDK

This SDK is used by Vulcan checks to track their progress, process targets, report results and communicate their status with the agent. It also provides some helper packages that may be used in multiple checks.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// VoidCheckerCleanUp defines a clean up function that does nothing this is usefull
	// for checks that don't need to do any cleanup when the check finalizes.
	VoidCheckerCleanUp = func(ctx context.Context, target, assetType, opts string) {}
)

Functions

func NewCheckLog

func NewCheckLog(name string) *log.Entry

NewCheckLog creates a log suitable to be used by a check

func WaitForFile

func WaitForFile(filepath string) (*os.File, error)

WaitForFile waits for a file to be created.

Types

type Check

type Check interface {
	RunAndServe()
	Shutdown() error
}

Check defines a check as seen by a checker, that is a concrete check implementor.

func NewCheck

func NewCheck(name string, checker Checker) Check

NewCheck creates a check given a Checker.

func NewCheckFromHandler

func NewCheckFromHandler(name string, run CheckerHandleRun) Check

NewCheckFromHandler creates a new check given a checker run handler.

func NewCheckFromHandlerWithCleanUp

func NewCheckFromHandlerWithCleanUp(name string, run CheckerHandleRun, cleanUp CheckerHandleCleanUp) Check

NewCheckFromHandlerWithCleanUp creates a new check given a checker run handler.

func NewCheckFromHandlerWithConfig

func NewCheckFromHandlerWithConfig(name string, conf *config.Config, run CheckerHandleRun) Check

NewCheckFromHandlerWithConfig creates a new check from run and abort handlers using provided config.

type Checker

type Checker interface {
	Run(ctx context.Context, target, assetType string, opts string, state state.State) error
	CleanUp(ctx context.Context, target, assetType, opts string)
}

Checker defines the shape a checker must have in order to be executed as vulcan-check.

type CheckerHandleCleanUp

type CheckerHandleCleanUp func(ctx context.Context, target, assetType, opts string)

CheckerHandleCleanUp func type to specify a CleanUp handler function for a checker.

func (CheckerHandleCleanUp) CleanUp

func (handler CheckerHandleCleanUp) CleanUp(ctx context.Context, target, assetType, opts string)

CleanUp is used as adapter to satisfy the method with same name in interface Checker.

type CheckerHandleRun

type CheckerHandleRun func(ctx context.Context, target, assetType string, opts string, state state.State) error

CheckerHandleRun func type to specify a Run handler function for a checker.

func (CheckerHandleRun) Run

func (handler CheckerHandleRun) Run(ctx context.Context, target, assetType string, opts string, state state.State) error

Run is used as adapter to satisfy the method with same name in interface Checker.

type ProcessCheck

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

ProcessCheck simplifies developing a check that runs a process.

func (*ProcessCheck) Run

func (p *ProcessCheck) Run(ctx context.Context) (pState *os.ProcessState, err error)

Run starts the execution of the process.

type ProcessCheckRunner

type ProcessCheckRunner interface {
	Run(ctx context.Context) (pState *os.ProcessState, err error)
}

ProcessCheckRunner defines interface a check must implement in order to use the process helper.

func NewProcessChecker

func NewProcessChecker(executable string, args []string, split bufio.SplitFunc, checker ProcessChecker) ProcessCheckRunner

NewProcessChecker creates a new ProcessChecker that launch a process and optionally process the standard output spliting it in chunks defined by a custom bufio.SplitFunc.

type ProcessChecker

type ProcessChecker interface {
	ProcessOutputChunk(chunk []byte) bool
}

ProcessChecker Declares the method a checker must implement in order to use processChecker.

type ProcessCheckerProcessOutputHandler

type ProcessCheckerProcessOutputHandler func([]byte) bool

ProcessCheckerProcessOutputHandler handy adapter to specify a ProcessFinished method deifined in the ProcessChecker interface using a function.

func (ProcessCheckerProcessOutputHandler) ProcessOutputChunk

func (h ProcessCheckerProcessOutputHandler) ProcessOutputChunk(chunk []byte) bool

ProcessOutputChunk handy adapter to specify a ProcessFinished method defined in the ProcessChecker interface using a function.

Directories

Path Synopsis
command
Package command provides helpers to execute process and parse the output.
Package command provides helpers to execute process and parse the output.
internal

Jump to

Keyboard shortcuts

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