tasks

package
v0.0.0-...-56a9bdf Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2021 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TypeDeleteTestData = "DeleteTestData"
	TypeDownloadAsset  = "DownloadAsset"
	TypeKeyValue       = "KeyValue"
	TypeSetGroup       = "SetGroup"
	TypeInstallTestRun = "InstallTestRun"
	TypeExecuteTestRun = "ExecuteTestRun"
)

Task type constants

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseTask

type BaseTask struct {
	Type string `json:"type"`
}

BaseTask is a struct that is intended to be embedded by specific task structs. Both of these in conjunction are used primarily to house the JSON message for passing tasks over the comms package (i.e. message queue), but may also contain important dependencies of the task, such as an HTTP handler.

type DeleteTestData

type DeleteTestData struct {
	BaseTask
	TestUUID string `json:"key"`
}

DeleteTestData embeds BaseTask and adds the necessary fields to transport a DeleteTestData task through comms

func NewDeleteTestData

func NewDeleteTestData(uuid string) *DeleteTestData

NewDeleteTestData returns a new DeleteTestData tasks.

func (*DeleteTestData) Run

Run contains the logic necessary to perform this task on the agent.

type DownloadAsset

type DownloadAsset struct {
	BaseTask
	Assets []string `json:"assets"`
}

DownloadAsset defines this particular task. It contains definitions not only for the task message, but also HTTPClient, filesystem, and i/o system abstractions to be more conducive to unit testing.

func NewDownloadAsset

func NewDownloadAsset(assets []string) *DownloadAsset

NewDownloadAsset returns a new DownloadAsset task.

func (*DownloadAsset) Run

Run contains the logic necessary to perform this task on the agent. This particular task will download all required assets, copy them into the appropriate directory, and ensure that the execute permission is given to each collector file.

type ExecuteTestRun

type ExecuteTestRun struct {
	BaseTask
	TestUUID  string `json:"test_uuid"`
	TimeLimit int    `json:"time_limit"`
}

ExecuteTestRun defines this particular task.

func NewExecuteTestRun

func NewExecuteTestRun(testUUID string, timeLimit int) *ExecuteTestRun

NewExecuteTestRun returns a new ExecuteTestRun task.

func (*ExecuteTestRun) Run

func (t *ExecuteTestRun) Run(cfg *config.Config, ac *cache.AgentCache, responder Responder) (err error)

Run contains the logic necessary to perform this task on the agent. This particular task will execute a testrun that has already been installed into the local agent cache. In this context (single agent), a testrun will be executed once per target, all in parallel.

type InstallTestRun

type InstallTestRun struct {
	BaseTask
	TR defs.TestRun `json:"test_run"`
}

InstallTestRun defines this particular task.

func NewInstallTestRun

func NewInstallTestRun(tr defs.TestRun) *InstallTestRun

NewInstallTestRun returns a new InstallTestRun task.

func (*InstallTestRun) Run

func (t *InstallTestRun) Run(cfg *config.Config, ac *cache.AgentCache, responder Responder) (err error)

Run contains the logic necessary to perform this task on the agent. This particular task will install, but not execute a testrun on this agent. The installation procedure will first run the referenced testlet in check mode to help ensure that the actual testrun execution can take place. If that succeeds, the testrun is installed in the agent cache.

type KeyValue

type KeyValue struct {
	BaseTask
	Key   string `json:"key"`
	Value string `json:"value"`
}

KeyValue defines this particular task.

func NewKeyValue

func NewKeyValue(key, value string) *KeyValue

NewKeyValue returns a new KeyValue task.

func (*KeyValue) Run

func (t *KeyValue) Run(_ *config.Config, ac *cache.AgentCache, _ Responder) error

Run contains the logic necessary to perform this task on the agent. This particular task will simply pass a key/value pair to the agent cache to be set

type Responder

type Responder func(responses.Response) error

Responder is a function which a task can use to send a response.

type SetGroup

type SetGroup struct {
	BaseTask
	GroupName string `json:"groupName"`
}

SetGroup defines this particular task.

func NewSetGroup

func NewSetGroup(groupName string) *SetGroup

NewSetGroup returns a new SetGroup task.

func (*SetGroup) Run

func (t *SetGroup) Run(_ *config.Config, ac *cache.AgentCache, _ Responder) error

Run contains the logic necessary to perform this task on the agent.

type Task

type Task interface {

	// TODO(mierdin): This works but is a little "meh". Basically, each task has to have a "Run()" function, as enforced
	// by this interface. If the task needs some additional data, it gets these through struct properties. This works but
	// doesn't quite feel right. Come back to this and see if there's a better way.
	Run(*config.Config, *cache.AgentCache, Responder) error
}

Task is an interface to define task behavior This is used for functions like those in comms that need to work with all specific task types, not one specific task.

func Parse

func Parse(jsonData []byte) (Task, error)

Parse unmarshals JSON into a Task.

Jump to

Keyboard shortcuts

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