client

package
v0.8.8 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2022 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	WatchInterval = time.Second
)

Variables

This section is empty.

Functions

func MapExecutionOptionsToStartRequest

func MapExecutionOptionsToStartRequest(options ExecuteOptions) testkube.ExecutorStartRequest

Types

type ExecuteOptions

type ExecuteOptions struct {
	ID           string
	ScriptName   string
	ScriptSpec   scriptv2.ScriptSpec
	ExecutorName string
	ExecutorSpec executorv1.ExecutorSpec
	Request      testkube.ExecutionRequest
	Sync         bool
	HasSecrets   bool
}

func NewExecuteOptions

func NewExecuteOptions() ExecuteOptions

type Executor added in v0.6.4

type Executor interface {
	// Watch returns ExecuteEvents stream
	Watch(id string) (events chan ResultEvent)

	// Get synnchronous request to executor to get testkubeExecution
	Get(id string) (execution testkube.ExecutionResult, err error)

	// Execute starts new external script execution, reads data and returns ID
	// execution is started asynchronously client can check later for results
	Execute(execution testkube.Execution, options ExecuteOptions) (result testkube.ExecutionResult, err error)

	// Execute starts new external script execution, reads data and returns ID
	// execution is started synchronously client is blocked
	ExecuteSync(execution testkube.Execution, options ExecuteOptions) (result testkube.ExecutionResult, err error)

	// Abort aborts pending execution, do nothing when there is no pending execution
	Abort(id string) (err error)

	Logs(id string) (logs chan output.Output, err error)
}

Executor abstraction to implement new executors

type HTTPClient

type HTTPClient interface {
	Post(url, contentType string, body io.Reader) (resp *http.Response, err error)
	Get(url string) (resp *http.Response, err error)
}

HTTPClient interface for getting REST based requests

type JobExecutor added in v0.6.4

type JobExecutor struct {
	Client     *jobs.JobClient
	Repository result.Repository
	Log        *zap.SugaredLogger
}

func NewJobExecutor added in v0.6.4

func NewJobExecutor(repo result.Repository) (client JobExecutor, err error)

func (JobExecutor) Abort added in v0.6.4

func (c JobExecutor) Abort(id string) error

func (JobExecutor) Execute added in v0.6.4

func (c JobExecutor) Execute(execution testkube.Execution, options ExecuteOptions) (result testkube.ExecutionResult, err error)

Execute starts new external script execution, reads data and returns ID Execution is started asynchronously client can check later for results

func (JobExecutor) ExecuteSync added in v0.7.6

func (c JobExecutor) ExecuteSync(execution testkube.Execution, options ExecuteOptions) (result testkube.ExecutionResult, err error)

Execute starts new external script execution, reads data and returns ID Execution is started synchronously client will be blocked

func (JobExecutor) Get added in v0.6.4

func (c JobExecutor) Get(id string) (execution testkube.ExecutionResult, err error)

func (JobExecutor) Logs added in v0.6.4

func (c JobExecutor) Logs(id string) (out chan output.Output, err error)

Logs returns job logs using kubernetes api

func (JobExecutor) Watch added in v0.6.4

func (c JobExecutor) Watch(id string) (events chan ResultEvent)

Watch will get valid execution after async Execute, execution will be returned when success or error occurs Worker should set valid state for success or error after script completion TODO add timeout

type ResultEvent

type ResultEvent struct {
	Result testkube.ExecutionResult
	Error  error
}

ResultEvent event passed when watching execution changes

Jump to

Keyboard shortcuts

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