api

package
v2.6.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2017 License: MIT Imports: 21 Imported by: 55

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsRetryableError

func IsRetryableError(err error) bool

Looks at a bunch of connection related errors, and returns true if the error matches one of them.

func NewUUID

func NewUUID() string

Types

type Agent

type Agent struct {
	Name              string   `json:"name"`
	AccessToken       string   `json:"access_token"`
	Hostname          string   `json:"hostname"`
	Endpoint          string   `json:"endpoint"`
	PingInterval      int      `json:"ping_interval"`
	HearbeatInterval  int      `json:"heartbeat_interval"`
	OS                string   `json:"os"`
	Arch              string   `json:"arch"`
	ScriptEvalEnabled bool     `json:"script_eval_enabled"`
	Priority          string   `json:"priority,omitempty"`
	Version           string   `json:"version"`
	Build             string   `json:"build"`
	MetaData          []string `json:"meta_data"`
	PID               int      `json:"pid,omitempty"`
}

Agent represents an agent on the Buildkite Agent API

type AgentsService

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

AgentsService handles communication with the agent related methods of the Buildkite Agent API.

func (*AgentsService) Connect

func (as *AgentsService) Connect() (*Response, error)

Connects the agent to the Buildkite Agent API

func (*AgentsService) Disconnect

func (as *AgentsService) Disconnect() (*Response, error)

Disconnects the agent to the Buildkite Agent API

func (*AgentsService) Register

func (as *AgentsService) Register(agent *Agent) (*Agent, *Response, error)

Registers the agent against the Buildktie Agent API. The client for this call must be authenticated using an Agent Registration Token

type Artifact

type Artifact struct {
	// The ID of the artifact. The ID is assigned to it after a successful
	// batch creation
	ID string `json:"-"`

	// The path to the artifact relative to the working directory
	Path string `json:"path"`

	// The absolute path to the artifact
	AbsolutePath string `json:"absolute_path"`

	// The glob path used to find this artifact
	GlobPath string `json:"glob_path"`

	// The size of the file in bytes
	FileSize int64 `json:"file_size"`

	// A Sha1Sum calculation of the file
	Sha1Sum string `json:"sha1sum"`

	// The HTTP url to this artifact once it's been uploaded
	URL string `json:"url,omitempty"`

	// The destination specified on the command line when this file was
	// uploaded
	UploadDestination string `json:"upload_destination,omitempty"`

	// Information on how to upload this artifact.
	UploadInstructions *ArtifactUploadInstructions `json:"-"`
}

Artifact represents an artifact on the Buildkite Agent API

type ArtifactBatch

type ArtifactBatch struct {
	ID                string      `json:"id"`
	Artifacts         []*Artifact `json:"artifacts"`
	UploadDestination string      `json:"upload_destination"`
}

type ArtifactBatchCreateResponse

type ArtifactBatchCreateResponse struct {
	ID                 string                      `json:"id"`
	ArtifactIDs        []string                    `json:"artifact_ids"`
	UploadInstructions *ArtifactUploadInstructions `json:"upload_instructions"`
}

type ArtifactBatchUpdateArtifact

type ArtifactBatchUpdateArtifact struct {
	ID    string `json:"id"`
	State string `json:"state"`
}

type ArtifactBatchUpdateRequest

type ArtifactBatchUpdateRequest struct {
	Artifacts []*ArtifactBatchUpdateArtifact `json:"artifacts"`
}

type ArtifactSearchOptions

type ArtifactSearchOptions struct {
	Query string `url:"query,omitempty"`
	Scope string `url:"scope,omitempty"`
}

ArtifactSearchOptions specifies the optional parameters to the ArtifactsService.Search method.

type ArtifactUploadInstructions

type ArtifactUploadInstructions struct {
	Data   map[string]string `json: "data"`
	Action struct {
		URL       string `json:"url,omitempty"`
		Method    string `json:"method"`
		Path      string `json:"path"`
		FileInput string `json:"file_input"`
	}
}

type ArtifactsService

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

ArtifactsService handles communication with the artifact related methods of the Buildkite Artifact API.

func (*ArtifactsService) Create

Accepts a slice of artifacts, and creates them on Buildkite as a batch.

func (*ArtifactsService) Search

func (as *ArtifactsService) Search(buildId string, opt *ArtifactSearchOptions) ([]*Artifact, *Response, error)

Searches Buildkite for a set of artifacts

func (*ArtifactsService) Update

func (as *ArtifactsService) Update(jobId string, artifactStates map[string]string) (*Response, error)

Updates a paticular artifact

type AuthenticatedTransport

type AuthenticatedTransport struct {
	// The Token used for authentication. This can either the be
	// organizations registration token, or the agents access token.
	Token string

	// Transport is the underlying HTTP transport to use when making
	// requests. It will default to http.DefaultTransport if nil.
	Transport http.RoundTripper
}

Transport manages injection of the API token

func (*AuthenticatedTransport) CancelRequest

func (t *AuthenticatedTransport) CancelRequest(req *http.Request)

CancelRequest cancels an in-flight request by closing its connection.

func (*AuthenticatedTransport) Client

func (t *AuthenticatedTransport) Client() *http.Client

Client builds a new http client.

func (AuthenticatedTransport) RoundTrip

func (t AuthenticatedTransport) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip invoked each time a request is made

type Chunk

type Chunk struct {
	Data     string
	Sequence int
	Offset   int
	Size     int
}

Chunk represents a Buildkite Agent API Chunk

type ChunksService

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

ChunksService handles communication with the chunk related methods of the Buildkite Agent API.

func (*ChunksService) Upload

func (cs *ChunksService) Upload(jobId string, chunk *Chunk) (*Response, error)

Uploads the chunk to the Buildkite Agent API. This request sends the compressed log directly as a request body.

type Client

type Client struct {

	// Base URL for API requests. Defaults to the public Buildkite Agent API.
	// The URL should always be specified with a trailing slash.
	BaseURL *url.URL

	// User agent used when communicating with the Buildkite Agent API.
	UserAgent string

	// If true, requests and responses will be dumped and set to the logger
	DebugHTTP bool

	// Services used for talking to different parts of the Buildkite Agent API.
	Agents      *AgentsService
	Pings       *PingsService
	Jobs        *JobsService
	Chunks      *ChunksService
	MetaData    *MetaDataService
	HeaderTimes *HeaderTimesService
	Artifacts   *ArtifactsService
	Pipelines   *PipelinesService
	Heartbeats  *HeartbeatsService
	// contains filtered or unexported fields
}

A Client manages communication with the Buildkite Agent API.

func NewClient

func NewClient(httpClient *http.Client) *Client

NewClient returns a new Buildkite Agent API Client.

func (*Client) Do

func (c *Client) Do(req *http.Request, v interface{}) (*Response, error)

Do sends an API request and returns the API response. The API response is JSON decoded and stored in the value pointed to by v, or returned as an error if an API error has occurred. If v implements the io.Writer interface, the raw response body will be written to v, without attempting to first decode it.

func (*Client) NewFormRequest

func (c *Client) NewFormRequest(method, urlStr string, body *bytes.Buffer) (*http.Request, error)

NewFormRequest creates an mutli-part form request. A relative URL can be provided in urlStr, in which case it is resolved relative to the UploadURL of the Client. Relative URLs should always be specified without a preceding slash.

func (*Client) NewRequest

func (c *Client) NewRequest(method, urlStr string, body interface{}) (*http.Request, error)

NewRequest creates an API request. A relative URL can be provided in urlStr, in which case it is resolved relative to the BaseURL of the Client. Relative URLs should always be specified without a preceding slash. If specified, the value pointed to by body is JSON encoded and included as the request body.

type ErrorResponse

type ErrorResponse struct {
	Response *http.Response // HTTP response that caused this error
	Message  string         `json:"message"` // error message
}

ErrorResponse provides a message.

func (*ErrorResponse) Error

func (r *ErrorResponse) Error() string

type HeaderTimes

type HeaderTimes struct {
	Times map[string]string `json:"header_times"`
}

HeaderTimes represents a set of header times that are associated with a job log.

type HeaderTimesService

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

HeaderTimesService handles communication with the meta data related methods of the Buildkite Agent API.

func (*HeaderTimesService) Save

func (hs *HeaderTimesService) Save(jobId string, headerTimes *HeaderTimes) (*Response, error)

Saves the header times to the job

type Heartbeat

type Heartbeat struct {
	SentAt     string `json:"sent_at"`
	ReceivedAt string `json:"received_at,omitempty"`
}

Heartbeat represents a Buildkite Agent API Heartbeat

type HeartbeatsService

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

HeartbeatsService handles communication with the ping related methods of the Buildkite Agent API.

func (*HeartbeatsService) Beat

func (hs *HeartbeatsService) Beat() (*Heartbeat, *Response, error)

Heartbeats the API which keeps the agent connected to Buildkite

type Job

type Job struct {
	ID                 string            `json:"id,omitempty"`
	Endpoint           string            `json:"endpoint"`
	State              string            `json:"state,omitempty"`
	Env                map[string]string `json:"env,omitempty"`
	ChunksMaxSizeBytes int               `json:"chunks_max_size_bytes,omitempty"`
	ExitStatus         string            `json:"exit_status,omitempty"`
	StartedAt          string            `json:"started_at,omitempty"`
	FinishedAt         string            `json:"finished_at,omitempty"`
	ChunksFailedCount  int               `json:"chunks_failed_count,omitempty"`
}

Job represents a Buildkite Agent API Job

type JobState

type JobState struct {
	State string `json:"state,omitempty"`
}

type JobsService

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

JobsService handles communication with the job related methods of the Buildkite Agent API.

func (*JobsService) Accept

func (js *JobsService) Accept(job *Job) (*Job, *Response, error)

Accepts the passed in job. Returns the job with it's finalized set of environment variables (when a job is accepted, the agents environment is applied to the job)

func (*JobsService) Finish

func (js *JobsService) Finish(job *Job) (*Response, error)

Finishes the passed in job

func (*JobsService) GetState

func (js *JobsService) GetState(id string) (*JobState, *Response, error)

Fetches a job

func (*JobsService) Start

func (js *JobsService) Start(job *Job) (*Response, error)

Starts the passed in job

type MetaData

type MetaData struct {
	Key   string `json:"key,omitempty"`
	Value string `json:"value,omitempty"`
}

MetaData represents a Buildkite Agent API MetaData

type MetaDataExists

type MetaDataExists struct {
	Exists bool `json:"exists"`
}

MetaDataExists represents a Buildkite Agent API MetaData Exists check response

type MetaDataService

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

MetaDataService handles communication with the meta data related methods of the Buildkite Agent API.

func (*MetaDataService) Exists

func (ps *MetaDataService) Exists(jobId string, key string) (*MetaDataExists, *Response, error)

Returns true if the meta data key has been set, false if it hasn't.

func (*MetaDataService) Get

func (ps *MetaDataService) Get(jobId string, key string) (*MetaData, *Response, error)

Gets the meta data value

func (*MetaDataService) Set

func (ps *MetaDataService) Set(jobId string, metaData *MetaData) (*Response, error)

Sets the meta data value

type Ping

type Ping struct {
	Action   string `json:"action,omitempty"`
	Message  string `json:"message,omitempty"`
	Job      *Job   `json:"job,omitempty"`
	Endpoint string `json:"endpoint,omitempty"`
}

Ping represents a Buildkite Agent API Ping

type PingsService

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

PingsService handles communication with the ping related methods of the Buildkite Agent API.

func (*PingsService) Get

func (ps *PingsService) Get() (*Ping, *Response, error)

Pings the API and returns any work the client needs to perform

type Pipeline

type Pipeline struct {
	UUID     string
	Data     []byte
	FileName string
	Replace  bool
}

Pipeline represents a Buildkite Agent API Pipeline

type PipelinesService

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

PipelinesService handles communication with the pipeline related methods of the Buildkite Agent API.

func (*PipelinesService) Upload

func (cs *PipelinesService) Upload(jobId string, pipeline *Pipeline) (*Response, error)

Uploads the pipeline to the Buildkite Agent API. This request doesn't use JSON, but a multi-part HTTP form upload

type Response

type Response struct {
	*http.Response
}

Response is a Buildkite Agent API response. This wraps the standard http.Response.

Jump to

Keyboard shortcuts

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