client

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2020 License: Apache-2.0, MIT Imports: 14 Imported by: 0

Documentation

Overview

Package client provides a type-safe client for the Testground server.

Testground uses a client-server architecture. The Testground client talks to the Testground daemon, which builds, and runs your test plans.

The Testground client and daemon can run on the same system, or you can connect a Testground client to a remote Testground daemon.

Currently all commands to Testground, but the `daemon` command, are client-side commands.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseDescribeResponse

func ParseDescribeResponse(r io.ReadCloser) error

ParseDescribeResponse parses a response from a `describe` call

func ParseListResponse

func ParseListResponse(r io.ReadCloser) error

ParseListResponse parses a response from a `list` call

func ParseTerminateRequest added in v0.2.0

func ParseTerminateRequest(r io.ReadCloser) error

ParseTerminateRequest parses a response from a 'terminate' call

Types

type BuildRequest

type BuildRequest struct {
	Composition api.Composition `json:"composition"`
}

BuildRequest is the request struct for the `build` function.

type BuildResponse

type BuildResponse = []api.BuildOutput

BuildResponse is the response struct for the `build` function.

func ParseBuildResponse

func ParseBuildResponse(r io.ReadCloser) (BuildResponse, error)

ParseBuildResponse parses a response from a `build` call

type Client

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

Client is the API client that performs all operations against a Testground server.

func New

func New(endpoint string) *Client

New initializes a new API client

func (*Client) Build

func (c *Client) Build(ctx context.Context, r *BuildRequest) (io.ReadCloser, error)

Build sends `build` request to the daemon. The Body in the response implement an io.ReadCloser and it's up to the caller to close it. The response is a stream of `Msg` protocol messages. See `ParseBuildResponse()` for specifics.

func (*Client) Close

func (c *Client) Close() error

Close the transport used by the client

func (*Client) CollectOutputs

func (c *Client) CollectOutputs(ctx context.Context, r *OutputsRequest) (io.ReadCloser, error)

CollectOutputs sends a `collectOutputs` request to the daemon.

The Body in the response implement an io.ReadCloser and it's up to the caller to close it.

func (*Client) Describe

func (c *Client) Describe(ctx context.Context, r *DescribeRequest) (io.ReadCloser, error)

Describe sends `describe` request to the daemon. The Body in the response implement an io.ReadCloser and it's up to the caller to close it. The response is a stream of `Msg` protocol messages. See `ParseDescribeResponse()` for specifics.

func (*Client) Healthcheck added in v0.2.0

func (c *Client) Healthcheck(ctx context.Context, r *HealthcheckRequest) (io.ReadCloser, error)

Healthcheck sends a `healthcheck` request to the daemon.

func (*Client) List

func (c *Client) List(ctx context.Context) (io.ReadCloser, error)

List sends `list` request to the daemon. The Body in the response implement an io.ReadCloser and it's up to the caller to close it.

func (*Client) Run

func (c *Client) Run(ctx context.Context, r *RunRequest) (io.ReadCloser, error)

Run sends `run` request to the daemon. The Body in the response implement an io.ReadCloser and it's up to the caller to close it. The response is a stream of `Msg` protocol messages.

func (*Client) Terminate added in v0.2.0

func (c *Client) Terminate(ctx context.Context, r *TerminateRequest) (io.ReadCloser, error)

Terminate sends a `terminate` request to the daemon.

type CollectResponse added in v0.4.0

type CollectResponse struct {
	File   bytes.Buffer
	Exists bool
}

func ParseCollectResponse added in v0.4.0

func ParseCollectResponse(r io.ReadCloser, file io.Writer) (CollectResponse, error)

ParseCollectResponse parses a response from a `collect` call

type DescribeRequest

type DescribeRequest struct {
	Term string `json:"term"`
}

DescribeRequest is the request struct for the `describe` function.

type HealthcheckRequest added in v0.2.0

type HealthcheckRequest struct {
	Runner string `json:"runner"`
	Fix    bool   `json:"fix"`
}

type HealthcheckResponse added in v0.2.0

type HealthcheckResponse = api.HealthcheckReport

func ParseHealthcheckResponse added in v0.2.0

func ParseHealthcheckResponse(r io.ReadCloser) (HealthcheckResponse, error)

ParseHealthcheckResponse parses a response from a 'healthcheck' call

type OutputsRequest

type OutputsRequest struct {
	Runner string `json:"runner"`
	RunID  string `json:"run_id"`
}

type RunRequest

type RunRequest struct {
	Composition api.Composition `json:"composition"`
}

RunRequest is the request struct for the `run` function.

type RunResponse

type RunResponse = api.RunOutput

func ParseRunResponse

func ParseRunResponse(r io.ReadCloser) (RunResponse, error)

ParseRunResponse parses a response from a `run` call

type TerminateRequest added in v0.2.0

type TerminateRequest struct {
	Runner string `json:"runner"`
}

Jump to

Keyboard shortcuts

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