client

package
v1.4.15 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2022 License: MIT Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// GitUsernameSecretName is git username secret name
	GitUsernameSecretName = "git-username"
	// GitUsernameEnvVarName is git username environment var name
	GitUsernameEnvVarName = "RUNNER_GITUSERNAME"
	// GitTokenSecretName is git token secret name
	GitTokenSecretName = "git-token"
	// GitTokenEnvVarName is git token environment var name
	GitTokenEnvVarName = "RUNNER_GITTOKEN"
)
View Source
const (
	WatchInterval = time.Second
)

Variables

This section is empty.

Functions

func IsPodReady added in v1.3.1

func IsPodReady(c *kubernetes.Clientset, podName, namespace string) wait.ConditionFunc

IsPodReady defines if pod is ready or failed for logs scrapping

func NewJobSpec added in v1.3.1

func NewJobSpec(log *zap.SugaredLogger, options JobOptions) (*batchv1.Job, error)

NewJobSpec is a method to create new job spec

Types

type ExecuteOptions

type ExecuteOptions struct {
	ID           string
	TestName     string
	Namespace    string
	TestSpec     testsv3.TestSpec
	ExecutorName string
	ExecutorSpec executorv1.ExecutorSpec
	Request      testkube.ExecutionRequest
	Sync         bool
	HasSecrets   bool
	Labels       map[string]string
}

type ExecutionCounter added in v1.3.1

type ExecutionCounter interface {
	IncExecuteTest(execution testkube.Execution)
}

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 test 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 test 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) (execution *testkube.ExecutionResult)

	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 {
	Repository result.Repository
	Log        *zap.SugaredLogger
	ClientSet  *kubernetes.Clientset
	Namespace  string
	Cmd        string

	Emitter *webhook.Emitter
	// contains filtered or unexported fields
}

JobExecutor is container for managing job executor dependencies

func NewJobExecutor added in v0.6.4

func NewJobExecutor(repo result.Repository, namespace, initImage, jobTemplate string, metrics ExecutionCounter, emiter *webhook.Emitter) (client *JobExecutor, err error)

NewJobExecutor creates new job executor

func (*JobExecutor) Abort added in v0.6.4

func (c *JobExecutor) Abort(jobName string) *testkube.ExecutionResult

AbortK8sJob aborts K8S by job name

func (JobExecutor) CreateJob added in v1.3.1

func (c JobExecutor) CreateJob(ctx context.Context, execution testkube.Execution, options ExecuteOptions) error

CreateJob creates new Kubernetes job based on execution and execute options

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 test 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 test 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)

Get returns execution result by execution id

func (*JobExecutor) GetJobPods added in v1.3.1

func (c *JobExecutor) GetJobPods(podsClient tcorev1.PodInterface, jobName string, retryNr, retryCount int) (*corev1.PodList, error)

GetJobPods returns job pods

func (*JobExecutor) GetLastLogLineError added in v1.3.1

func (c *JobExecutor) GetLastLogLineError(ctx context.Context, pod corev1.Pod) error

GetLastLogLineError return error if last line is failed

func (*JobExecutor) GetPodLogError added in v1.3.1

func (c *JobExecutor) GetPodLogError(ctx context.Context, pod corev1.Pod) (logsBytes []byte, err error)

GetPodLogError returns last line as error

func (*JobExecutor) GetPodLogs added in v1.3.1

func (c *JobExecutor) GetPodLogs(pod corev1.Pod, logLinesCount ...int64) (logs []byte, err error)

GetPodLogs returns pod logs bytes

func (JobExecutor) Logs added in v0.6.4

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

Logs returns job logs stream channel using kubernetes api

func (*JobExecutor) TailJobLogs added in v1.3.1

func (c *JobExecutor) TailJobLogs(id string, logs chan []byte) (err error)

TailJobLogs - locates logs for job pod(s)

func (*JobExecutor) TailPodLogs added in v1.3.1

func (c *JobExecutor) TailPodLogs(ctx context.Context, pod corev1.Pod, logs chan []byte) (err error)

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 test completion TODO add timeout - pass context with timeout

type JobOptions added in v1.3.1

type JobOptions struct {
	Name        string
	Namespace   string
	Image       string
	Jsn         string
	TestName    string
	InitImage   string
	JobTemplate string
	HasSecrets  bool
	SecretEnvs  map[string]string
	HTTPProxy   string
	HTTPSProxy  string
}

func NewJobOptions added in v1.3.1

func NewJobOptions(initImage, jobTemplate string, execution testkube.Execution, options ExecuteOptions) (jobOptions JobOptions, err error)

func NewJobOptionsFromExecutionOptions added in v1.3.1

func NewJobOptionsFromExecutionOptions(options ExecuteOptions) JobOptions

NewJobOptionsFromExecutionOptions compose JobOptions based on ExecuteOptions

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