client

package
v1.2.22 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2022 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const TestkubeInstallationNamespace = "testkube"

TestkubeInstallationNamespace where Testkube is installed

View Source
const Version = "v1"

Version is client version literal

Variables

This section is empty.

Functions

func GetClientSet

func GetClientSet(overrideHost string) (clientset kubernetes.Interface, err error)

GetClientSet configures Kube client set, can override host with local proxy

func GetHTTTPClient added in v1.1.16

func GetHTTTPClient(token *oauth2.Token) (*http.Client, error)

GetHTTPClient prepares http client

func StreamToLogsChannel added in v0.6.5

func StreamToLogsChannel(resp io.Reader, logs chan output.Output)

StreamToLogsChannel converts io.Reader with SSE data like `data: {"type": "event", "message":"something"}` to channel of output.Output objects, helps with logs streaming from SSE endpoint (passed from job executor)

Types

type APIClient added in v0.10.0

APIClient struct managing proxy API Client dependencies

func NewDirectAPIClient added in v0.9.5

func NewDirectAPIClient(httpClient *http.Client, apiURI string) APIClient

NewDirectAPIClient returns direct api client

func NewProxyAPIClient added in v0.9.5

func NewProxyAPIClient(client kubernetes.Interface, config APIConfig) APIClient

NewProxyAPIClient returns proxy api client

type APIConfig added in v0.10.2

type APIConfig struct {
	// Namespace where testkube is installed
	Namespace string
	// API Server service name
	ServiceName string
	// API Server service port
	ServicePort int
}

func NewAPIConfig added in v0.10.2

func NewAPIConfig(namespace string) APIConfig

type All added in v1.1.16

type All interface {
	Gettable | Executable
}

All is an interface of all objects

type Client

Client is the Testkube API client abstraction

func GetClient

func GetClient(clientType ClientType, options Options) (client Client, err error)

GetClient returns configured Testkube API client, can be one of direct and proxy - direct need additional proxy to be run (`make api-proxy`)

type ClientType

type ClientType string
const (
	ClientDirect ClientType = "direct"
	ClientProxy  ClientType = "proxy"
)

type CreateExecutorOptions added in v0.6.4

type CreateExecutorOptions testkube.ExecutorCreateRequest

CreateExecutorOptions - is mapping for now to OpenAPI schema for creating executor request

type CreateWebhookOptions added in v0.9.18

type CreateWebhookOptions testkube.WebhookCreateRequest

CreateWebhookOptions - is mapping for now to OpenAPI schema for creating/changing webhook

type DirectClient added in v1.1.16

type DirectClient[A All] struct {
	// contains filtered or unexported fields
}

DirectClient implements direct client

func NewDirectClient added in v1.1.16

func NewDirectClient[A All](httpClient *http.Client, apiURI string) DirectClient[A]

NewDirectClient returns new direct client

func (DirectClient[A]) Delete added in v1.1.16

func (t DirectClient[A]) Delete(uri, selector string, isContentExpected bool) error

Delete is a method to make delete api call

func (DirectClient[A]) Execute added in v1.1.16

func (t DirectClient[A]) Execute(method, uri string, body []byte, params map[string]string) (result A, err error)

Execute is a method to make an api call for a single object

func (DirectClient[A]) ExecuteMultiple added in v1.1.16

func (t DirectClient[A]) ExecuteMultiple(method, uri string, body []byte, params map[string]string) (result []A, err error)

ExecuteMultiple is a method to make an api call for multiple objects

func (DirectClient[A]) GetFile added in v1.1.16

func (t DirectClient[A]) GetFile(uri, fileName, destination string) (name string, err error)

GetFile returns file artifact

func (DirectClient[A]) GetLogs added in v1.1.16

func (t DirectClient[A]) GetLogs(uri string, logs chan output.Output) error

GetLogs returns logs stream from job pods, based on job pods logs

func (DirectClient[A]) GetURI added in v1.1.16

func (t DirectClient[A]) GetURI(pathTemplate string, params ...interface{}) string

GetURI returns uri for api method

type Executable added in v1.1.16

Executable is an interface of executable objects

type ExecuteTestOptions added in v1.0.23

type ExecuteTestOptions struct {
	ExecutionVariables            map[string]testkube.Variable
	ExecutionVariablesFileContent string
	Args                          []string
	Envs                          map[string]string
	SecretEnvs                    map[string]string
	HTTPProxy                     string
	HTTPSProxy                    string
}

TODO consider replacing it with testkube.ExecutionRequest - looks almost the samea and redundant ExecuteTestOptions contains test run options

type ExecuteTestSuiteOptions added in v1.1.2

type ExecuteTestSuiteOptions struct {
	ExecutionVariables map[string]testkube.Variable
	HTTPProxy          string
	HTTPSProxy         string
}

ExecuteTestSuiteOptions contains test suite run options

type ExecutionAPI added in v1.1.16

type ExecutionAPI interface {
	GetExecution(executionID string) (execution testkube.Execution, err error)
	ListExecutions(id string, limit int, selector string) (executions testkube.ExecutionsResult, err error)
	AbortExecution(test string, id string) error
	GetExecutionArtifacts(executionID string) (artifacts testkube.Artifacts, err error)
	DownloadFile(executionID, fileName, destination string) (artifact string, err error)
}

ExecutionAPI describes execution api methods

type ExecutorAPI added in v1.1.16

type ExecutorAPI interface {
	CreateExecutor(options CreateExecutorOptions) (executor testkube.ExecutorDetails, err error)
	GetExecutor(name string) (executor testkube.ExecutorDetails, err error)
	ListExecutors(selector string) (executors testkube.ExecutorsDetails, err error)
	DeleteExecutor(name string) (err error)
	DeleteExecutors(selector string) (err error)
}

ExecutorAPI describes executor api methods

type ExecutorClient added in v1.1.16

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

ExecutorClient is a client for executors

func NewExecutorClient added in v1.1.16

func NewExecutorClient(executorTransport Transport[testkube.ExecutorDetails]) ExecutorClient

NewExecutorClient creates new Executor client

func (ExecutorClient) CreateExecutor added in v1.1.16

func (c ExecutorClient) CreateExecutor(options CreateExecutorOptions) (executor testkube.ExecutorDetails, err error)

CreateExecutor creates new Executor Custom Resource

func (ExecutorClient) DeleteExecutor added in v1.1.16

func (c ExecutorClient) DeleteExecutor(name string) (err error)

DeleteExecutor deletes single executor by name

func (ExecutorClient) DeleteExecutors added in v1.1.16

func (c ExecutorClient) DeleteExecutors(selector string) (err error)

DeleteExecutors deletes all executors

func (ExecutorClient) GetExecutor added in v1.1.16

func (c ExecutorClient) GetExecutor(name string) (executor testkube.ExecutorDetails, err error)

GetExecutor gets executor by name

func (ExecutorClient) ListExecutors added in v1.1.16

func (c ExecutorClient) ListExecutors(selector string) (executors testkube.ExecutorsDetails, err error)

ListExecutors list all executors

type Gettable added in v1.1.16

Gettable is an interface of gettable objects

type Options added in v1.1.16

type Options struct {
	Namespace    string
	APIURI       string
	Token        *oauth2.Token
	Provider     oauth.ProviderType
	ClientID     string
	ClientSecret string
	Scopes       []string
}

Options contains client options

type ProxyClient added in v1.1.16

type ProxyClient[A All] struct {
	// contains filtered or unexported fields
}

ProxyClient implements proxy client

func NewProxyClient added in v1.1.16

func NewProxyClient[A All](client kubernetes.Interface, config APIConfig) ProxyClient[A]

NewProxyClient returns new proxy client

func (ProxyClient[A]) Delete added in v1.1.16

func (t ProxyClient[A]) Delete(uri, selector string, isContentExpected bool) error

Delete is a method to make delete api call

func (ProxyClient[A]) Execute added in v1.1.16

func (t ProxyClient[A]) Execute(method, uri string, body []byte, params map[string]string) (result A, err error)

Execute is a method to make an api call for a single object

func (ProxyClient[A]) ExecuteMultiple added in v1.1.16

func (t ProxyClient[A]) ExecuteMultiple(method, uri string, body []byte, params map[string]string) (result []A, err error)

ExecuteMultiple is a method to make an api call for multiple objects

func (ProxyClient[A]) GetFile added in v1.1.16

func (t ProxyClient[A]) GetFile(uri, fileName, destination string) (name string, err error)

GetFile returns file artifact

func (ProxyClient[A]) GetLogs added in v1.1.16

func (t ProxyClient[A]) GetLogs(uri string, logs chan output.Output) error

GetLogs returns logs stream from job pods, based on job pods logs

func (ProxyClient[A]) GetURI added in v1.1.16

func (t ProxyClient[A]) GetURI(pathTemplate string, params ...interface{}) string

GetURI returns uri for api method

type ServiceAPI added in v1.1.16

type ServiceAPI interface {
	GetServerInfo() (info testkube.ServerInfo, err error)
}

ServiceAPI describes service api methods

type TestAPI added in v1.1.16

type TestAPI interface {
	GetTest(id string) (test testkube.Test, err error)
	GetTestWithExecution(id string) (test testkube.TestWithExecution, err error)
	CreateTest(options UpsertTestOptions) (test testkube.Test, err error)
	UpdateTest(options UpsertTestOptions) (test testkube.Test, err error)
	DeleteTest(name string) error
	DeleteTests(selector string) error
	ListTests(selector string) (tests testkube.Tests, err error)
	ListTestWithExecutions(selector string) (tests testkube.TestWithExecutions, err error)
	ExecuteTest(id, executionName string, options ExecuteTestOptions) (executions testkube.Execution, err error)
	ExecuteTests(selector string, concurrencyLevel int, options ExecuteTestOptions) (executions []testkube.Execution, err error)
	Logs(id string) (logs chan output.Output, err error)
}

TestAPI describes test api methods

type TestClient added in v1.1.16

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

TestClient is a client for tests

func NewTestClient added in v1.1.16

func NewTestClient(
	testTransport Transport[testkube.Test],
	executionTransport Transport[testkube.Execution],
	testWithExecutionTransport Transport[testkube.TestWithExecution],
	executionsResultTransport Transport[testkube.ExecutionsResult],
	artifactTransport Transport[testkube.Artifact],
	serverInfoTransport Transport[testkube.ServerInfo],
) TestClient

NewTestClient creates new Test client

func (TestClient) AbortExecution added in v1.1.16

func (c TestClient) AbortExecution(testID, id string) error

AbortExecution aborts execution by testId and id

func (TestClient) CreateTest added in v1.1.16

func (c TestClient) CreateTest(options UpsertTestOptions) (test testkube.Test, err error)

CreateTest creates new Test Custom Resource

func (TestClient) DeleteTest added in v1.1.16

func (c TestClient) DeleteTest(name string) error

DeleteTest deletes single test by name

func (TestClient) DeleteTests added in v1.1.16

func (c TestClient) DeleteTests(selector string) error

DeleteTests deletes all tests

func (TestClient) DownloadFile added in v1.1.16

func (c TestClient) DownloadFile(executionID, fileName, destination string) (artifact string, err error)

DownloadFile downloads file

func (TestClient) ExecuteTest added in v1.1.16

func (c TestClient) ExecuteTest(id, executionName string, options ExecuteTestOptions) (execution testkube.Execution, err error)

ExecuteTest starts test execution, reads data and returns ID execution is started asynchronously client can check later for results

func (TestClient) ExecuteTests added in v1.1.16

func (c TestClient) ExecuteTests(selector string, concurrencyLevel int, options ExecuteTestOptions) (executions []testkube.Execution, err error)

ExecuteTests starts test executions, reads data and returns IDs executions are started asynchronously client can check later for results

func (TestClient) GetExecution added in v1.1.16

func (c TestClient) GetExecution(executionID string) (execution testkube.Execution, err error)

GetExecution returns test execution by excution id

func (TestClient) GetExecutionArtifacts added in v1.1.16

func (c TestClient) GetExecutionArtifacts(executionID string) (artifacts testkube.Artifacts, err error)

GetExecutionArtifacts returns execution artifacts

func (TestClient) GetServerInfo added in v1.1.16

func (c TestClient) GetServerInfo() (info testkube.ServerInfo, err error)

GetServerInfo returns server info

func (TestClient) GetTest added in v1.1.16

func (c TestClient) GetTest(id string) (test testkube.Test, err error)

GetTest returns single test by id

func (TestClient) GetTestWithExecution added in v1.1.16

func (c TestClient) GetTestWithExecution(id string) (test testkube.TestWithExecution, err error)

GetTestWithExecution returns single test by id with execution

func (TestClient) ListExecutions added in v1.1.16

func (c TestClient) ListExecutions(id string, limit int, selector string) (executions testkube.ExecutionsResult, err error)

ListExecutions list all executions for given test name

func (TestClient) ListTestWithExecutions added in v1.1.16

func (c TestClient) ListTestWithExecutions(selector string) (testWithExecutions testkube.TestWithExecutions, err error)

ListTestWithExecutions list all test with executions

func (TestClient) ListTests added in v1.1.16

func (c TestClient) ListTests(selector string) (tests testkube.Tests, err error)

ListTests list all tests

func (TestClient) Logs added in v1.1.16

func (c TestClient) Logs(id string) (logs chan output.Output, err error)

Logs returns logs stream from job pods, based on job pods logs

func (TestClient) UpdateTest added in v1.1.16

func (c TestClient) UpdateTest(options UpsertTestOptions) (test testkube.Test, err error)

UpdateTest updates Test Custom Resource

type TestSuiteAPI added in v1.1.16

type TestSuiteAPI interface {
	CreateTestSuite(options UpsertTestSuiteOptions) (testSuite testkube.TestSuite, err error)
	UpdateTestSuite(options UpsertTestSuiteOptions) (testSuite testkube.TestSuite, err error)
	GetTestSuite(id string) (testSuite testkube.TestSuite, err error)
	GetTestSuiteWithExecution(id string) (testSuite testkube.TestSuiteWithExecution, err error)
	ListTestSuites(selector string) (testSuites testkube.TestSuites, err error)
	ListTestSuiteWithExecutions(selector string) (testSuitesWithExecutions testkube.TestSuiteWithExecutions, err error)
	DeleteTestSuite(name string) error
	DeleteTestSuites(selector string) error
	ExecuteTestSuite(id, executionName string, options ExecuteTestSuiteOptions) (executions testkube.TestSuiteExecution, err error)
	ExecuteTestSuites(selector string, concurrencyLevel int, options ExecuteTestSuiteOptions) (executions []testkube.TestSuiteExecution, err error)
}

TestSuiteAPI describes test suite api methods

type TestSuiteClient added in v1.1.16

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

TestSuiteClient is a client for test suites

func NewTestSuiteClient added in v1.1.16

func NewTestSuiteClient(
	testSuiteTransport Transport[testkube.TestSuite],
	testSuiteExecutionTransport Transport[testkube.TestSuiteExecution],
	testSuiteWithExecutionTransport Transport[testkube.TestSuiteWithExecution],
	testSuiteExecutionsResultTransport Transport[testkube.TestSuiteExecutionsResult],
) TestSuiteClient

NewTestSuiteClient creates new TestSuite client

func (TestSuiteClient) CreateTestSuite added in v1.1.16

func (c TestSuiteClient) CreateTestSuite(options UpsertTestSuiteOptions) (testSuite testkube.TestSuite, err error)

CreateTestSuite creates new TestSuite Custom Resource

func (TestSuiteClient) DeleteTestSuite added in v1.1.16

func (c TestSuiteClient) DeleteTestSuite(name string) error

DeleteTestSuite deletes single test suite by name

func (TestSuiteClient) DeleteTestSuites added in v1.1.16

func (c TestSuiteClient) DeleteTestSuites(selector string) error

DeleteTestSuites deletes all test suites

func (TestSuiteClient) ExecuteTestSuite added in v1.1.16

func (c TestSuiteClient) ExecuteTestSuite(id, executionName string, options ExecuteTestSuiteOptions) (execution testkube.TestSuiteExecution, err error)

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

func (TestSuiteClient) ExecuteTestSuites added in v1.1.16

func (c TestSuiteClient) ExecuteTestSuites(selector string, concurrencyLevel int, options ExecuteTestSuiteOptions) (executions []testkube.TestSuiteExecution, err error)

ExecuteTestSuites starts new external test suite executions, reads data and returns IDs Executions are started asynchronously client can check later for results

func (TestSuiteClient) GetTestSuite added in v1.1.16

func (c TestSuiteClient) GetTestSuite(id string) (testSuite testkube.TestSuite, err error)

GetTestSuite returns single test suite by id

func (TestSuiteClient) GetTestSuiteExecution added in v1.1.16

func (c TestSuiteClient) GetTestSuiteExecution(executionID string) (execution testkube.TestSuiteExecution, err error)

GetTestSuiteExecution returns test suite execution by excution id

func (TestSuiteClient) GetTestSuiteWithExecution added in v1.1.16

func (c TestSuiteClient) GetTestSuiteWithExecution(id string) (test testkube.TestSuiteWithExecution, err error)

GetTestSuitWithExecution returns single test suite by id with execution

func (TestSuiteClient) ListTestSuiteExecutions added in v1.1.16

func (c TestSuiteClient) ListTestSuiteExecutions(testID string, limit int, selector string) (executions testkube.TestSuiteExecutionsResult, err error)

ListTestSuiteExecutions list all executions for given test suite

func (TestSuiteClient) ListTestSuiteWithExecutions added in v1.1.16

func (c TestSuiteClient) ListTestSuiteWithExecutions(selector string) (
	testSuiteWithExecutions testkube.TestSuiteWithExecutions, err error)

ListTestSuiteWithExecutions list all test suite with executions

func (TestSuiteClient) ListTestSuites added in v1.1.16

func (c TestSuiteClient) ListTestSuites(selector string) (testSuites testkube.TestSuites, err error)

ListTestSuites list all test suites

func (TestSuiteClient) UpdateTestSuite added in v1.1.16

func (c TestSuiteClient) UpdateTestSuite(options UpsertTestSuiteOptions) (testSuite testkube.TestSuite, err error)

UpdateTestSuite updates TestSuite Custom Resource

func (TestSuiteClient) WatchTestSuiteExecution added in v1.1.16

func (c TestSuiteClient) WatchTestSuiteExecution(executionID string) (executionCh chan testkube.TestSuiteExecution, err error)

WatchTestSuiteExecution watches for changes in channels of test suite executions steps

type TestSuiteExecutionAPI added in v1.1.16

type TestSuiteExecutionAPI interface {
	GetTestSuiteExecution(executionID string) (execution testkube.TestSuiteExecution, err error)
	ListTestSuiteExecutions(test string, limit int, selector string) (executions testkube.TestSuiteExecutionsResult, err error)
	WatchTestSuiteExecution(executionID string) (execution chan testkube.TestSuiteExecution, err error)
}

TestSuiteExecutionAPI describes test suite execution api methods

type Transport added in v1.1.16

type Transport[A All] interface {
	Execute(method, uri string, body []byte, params map[string]string) (result A, err error)
	ExecuteMultiple(method, uri string, body []byte, params map[string]string) (result []A, err error)
	Delete(uri, selector string, isContentExpected bool) error
	GetURI(pathTemplate string, params ...interface{}) string
	GetLogs(uri string, logs chan output.Output) error
	GetFile(uri, fileName, destination string) (name string, err error)
}

Transport provides methods to execute api calls

type UpsertTestOptions added in v0.7.6

type UpsertTestOptions testkube.TestUpsertRequest

UpsertTestOptions - is mapping for now to OpenAPI schema for creating/changing test if needed can beextended to custom struct

type UpsertTestSuiteOptions added in v0.9.5

type UpsertTestSuiteOptions testkube.TestSuiteUpsertRequest

UpsertTestSuiteOptions - mapping to OpenAPI schema for creating/changing testsuite

type WebhookAPI added in v1.1.16

type WebhookAPI interface {
	CreateWebhook(options CreateWebhookOptions) (webhook testkube.Webhook, err error)
	GetWebhook(name string) (webhook testkube.Webhook, err error)
	ListWebhooks(selector string) (executors testkube.Webhooks, err error)
	DeleteWebhook(name string) (err error)
	DeleteWebhooks(selector string) (err error)
}

WebhookAPI describes webhook api methods

type WebhookClient added in v1.1.16

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

WebhookClient is a client for webhooks

func NewWebhookClient added in v1.1.16

func NewWebhookClient(webhookTransport Transport[testkube.Webhook]) WebhookClient

NewWebhookClient creates new Webhook client

func (WebhookClient) CreateWebhook added in v1.1.16

func (c WebhookClient) CreateWebhook(options CreateWebhookOptions) (webhook testkube.Webhook, err error)

CreateWebhook creates new Webhook Custom Resource

func (WebhookClient) DeleteWebhook added in v1.1.16

func (c WebhookClient) DeleteWebhook(name string) (err error)

DeleteWebhook deletes single webhook by name

func (WebhookClient) DeleteWebhooks added in v1.1.16

func (c WebhookClient) DeleteWebhooks(selector string) (err error)

DeleteWebhooks deletes all webhooks

func (WebhookClient) GetWebhook added in v1.1.16

func (c WebhookClient) GetWebhook(name string) (webhook testkube.Webhook, err error)

GetWebhook gets webhook by name

func (WebhookClient) ListWebhooks added in v1.1.16

func (c WebhookClient) ListWebhooks(selector string) (webhooks testkube.Webhooks, err error)

ListWebhooks list all webhooks

Jump to

Keyboard shortcuts

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