client

package
v0.6.4-beta004 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2021 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	WatchInterval = time.Second

	ExecutorTypeRest = "rest"
	ExecutorTypeJob  = "job"
)

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   scriptv1.ScriptSpec
	ExecutorName string
	ExecutorSpec executorv1.ExecutorSpec
	Request      testkube.ExecutionRequest
}

func NewExecuteOptions

func NewExecuteOptions() ExecuteOptions

type ExecutorClient

type ExecutorClient 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(options ExecuteOptions) (execution testkube.ExecutionResult, err error)

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

ExecutorClient abstraction to implement new executors

type Executors

type Executors struct {
	ExecutorsCRClient *executorscr.ExecutorsClient
	Namespace         string
	Clients           sync.Map
	Repository        result.Repository
}

Executors represents available HTTP clients for executors registered in Kubernetes API

func NewExecutors

func NewExecutors(client *executorscr.ExecutorsClient, repo result.Repository) Executors

func (*Executors) Get

func (p *Executors) Get(scriptType string) (client ExecutorClient, err error)

Get gets executor based on type with a basic map.Sync cache TODO there is no handling of CR change

func (*Executors) GetByType

func (e *Executors) GetByType(scriptType string, spec v1.ExecutorSpec) (executor ExecutorClient, err error)

func (*Executors) GetExecutorSpec

func (p *Executors) GetExecutorSpec(scriptType string) (spec v1.ExecutorSpec, err error)

func (*Executors) GetJobExecutor

func (p *Executors) GetJobExecutor() (executor ExecutorClient, err error)

func (*Executors) GetOpenAPIExecutor

func (p *Executors) GetOpenAPIExecutor(uri string) (executor RestExecutorClient, err error)

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 JobExecutorClient

type JobExecutorClient struct {
	Client     *jobs.JobClient
	Repository result.Repository
}

func NewJobExecutorClient

func NewJobExecutorClient(repo result.Repository) (client JobExecutorClient, err error)

func (JobExecutorClient) Abort

func (c JobExecutorClient) Abort(id string) error

func (JobExecutorClient) Execute

func (c JobExecutorClient) Execute(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 (JobExecutorClient) Get

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

func (JobExecutorClient) Watch

func (c JobExecutorClient) 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 RestExecutorClient

type RestExecutorClient struct {
	URI string
	// contains filtered or unexported fields
}

func NewRestExecutorClient

func NewRestExecutorClient(config RestExecutorConfig) RestExecutorClient

func (RestExecutorClient) Abort

func (c RestExecutorClient) Abort(id string) error

func (RestExecutorClient) Execute

func (c RestExecutorClient) Execute(options ExecuteOptions) (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 with Get

func (RestExecutorClient) Get

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

func (RestExecutorClient) Watch

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

Watch will get valid execution result 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 RestExecutorConfig

type RestExecutorConfig struct {
	URI string `default:"http://localhost:8082"`
}

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