api

package
v3.0.0-...-c194909 Latest Latest
Warning

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

Go to latest
Published: May 8, 2020 License: MIT Imports: 19 Imported by: 0

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 AgentRegisterRequest

type AgentRegisterRequest struct {
	Name               string   `json:"name"`
	Hostname           string   `json:"hostname"`
	OS                 string   `json:"os"`
	Arch               string   `json:"arch"`
	ScriptEvalEnabled  bool     `json:"script_eval_enabled"`
	IgnoreInDispatches bool     `json:"ignore_in_dispatches"`
	Priority           string   `json:"priority,omitempty"`
	Version            string   `json:"version"`
	Build              string   `json:"build"`
	Tags               []string `json:"meta_data"`
	PID                int      `json:"pid,omitempty"`
	MachineID          string   `json:"machine_id,omitempty"`
}

AgentRegisterRequest is a call to register on the Buildkite Agent API

type AgentRegisterResponse

type AgentRegisterResponse struct {
	UUID              string   `json:"id"`
	Name              string   `json:"name"`
	AccessToken       string   `json:"access_token"`
	Endpoint          string   `json:"endpoint"`
	PingInterval      int      `json:"ping_interval"`
	JobStatusInterval int      `json:"job_status_interval"`
	HeartbeatInterval int      `json:"heartbeat_interval"`
	Tags              []string `json:"meta_data"`
}

AgentRegisterResponse is the response from the Buildkite Agent API

type Annotation

type Annotation struct {
	Body    string `json:"body,omitempty"`
	Context string `json:"context,omitempty"`
	Style   string `json:"style,omitempty"`
	Append  bool   `json:"append,omitempty"`
}

Annotation represents a Buildkite Agent API Annotation

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:"-"`

	// A specific Content-Type to use on upload
	ContentType string `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"`
	IncludeRetriedJobs bool   `url:"include_retried_jobs,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 Chunk

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

Chunk represents a Buildkite Agent API Chunk

type Client

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

A Client manages communication with the Buildkite Agent API.

func NewClient

func NewClient(l logger.Logger, conf Config) *Client

NewClient returns a new Buildkite Agent API Client.

func (*Client) AcceptJob

func (c *Client) AcceptJob(job *Job) (*Job, *Response, error)

AcceptJob accepts the passed in job. Returns the job with its finalized set of environment variables (when a job is accepted, the agents environment is applied to the job)

func (*Client) AcquireJob

func (c *Client) AcquireJob(id string) (*Job, *Response, error)

Acquires a job using its ID

func (*Client) Annotate

func (c *Client) Annotate(jobId string, annotation *Annotation) (*Response, error)

Annotate a build in the Buildkite UI

func (*Client) Config

func (c *Client) Config() Config

Config returns the internal configuration for the Client

func (*Client) Connect

func (c *Client) Connect() (*Response, error)

Connects the agent to the Buildkite Agent API

func (*Client) CreateArtifacts

func (c *Client) CreateArtifacts(jobId string, batch *ArtifactBatch) (*ArtifactBatchCreateResponse, *Response, error)

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

func (*Client) Disconnect

func (c *Client) Disconnect() (*Response, error)

Disconnects the agent to the Buildkite Agent API

func (*Client) ExistsMetaData

func (c *Client) ExistsMetaData(jobId string, key string) (*MetaDataExists, *Response, error)

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

func (*Client) FinishJob

func (c *Client) FinishJob(job *Job) (*Response, error)

FinishJob finishes the passed in job

func (*Client) FromAgentRegisterResponse

func (c *Client) FromAgentRegisterResponse(resp *AgentRegisterResponse) *Client

FromAgentRegisterResponse returns a new instance using the access token and endpoint from the registration response

func (*Client) FromPing

func (c *Client) FromPing(resp *Ping) *Client

FromPing returns a new instance using a new endpoint from a ping response

func (*Client) GetJobState

func (c *Client) GetJobState(id string) (*JobState, *Response, error)

GetJobState returns the state of a given job

func (*Client) GetMetaData

func (c *Client) GetMetaData(jobId string, key string) (*MetaData, *Response, error)

Gets the meta data value

func (*Client) Heartbeat

func (c *Client) Heartbeat() (*Heartbeat, *Response, error)

Heartbeat notifies Buildkite that an agent is still connected

func (*Client) MetaDataKeys

func (c *Client) MetaDataKeys(jobId string) ([]string, *Response, error)

func (*Client) Ping

func (c *Client) Ping() (*Ping, *Response, error)

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

func (*Client) Register

func (c *Client) Register(regReq *AgentRegisterRequest) (*AgentRegisterResponse, *Response, error)

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

func (*Client) SaveHeaderTimes

func (c *Client) SaveHeaderTimes(jobId string, headerTimes *HeaderTimes) (*Response, error)

SaveHeaderTimes saves the header times to the job

func (*Client) SearchArtifacts

func (c *Client) SearchArtifacts(buildId string, opt *ArtifactSearchOptions) ([]*Artifact, *Response, error)

SearchArtifacts searches Buildkite for a set of artifacts

func (*Client) SetMetaData

func (c *Client) SetMetaData(jobId string, metaData *MetaData) (*Response, error)

Sets the meta data value

func (*Client) StartJob

func (c *Client) StartJob(job *Job) (*Response, error)

StartJob starts the passed in job

func (*Client) StepExport

func (c *Client) StepExport(stepIdOrKey string, stepGetRequest *StepExportRequest) (*StepExportResponse, *Response, error)

StepExport gets an attribute from step

func (*Client) StepUpdate

func (c *Client) StepUpdate(stepIdOrKey string, stepUpdate *StepUpdate) (*Response, error)

StepUpdate updates a step

func (*Client) UpdateArtifacts

func (c *Client) UpdateArtifacts(jobId string, artifactStates map[string]string) (*Response, error)

Updates a particular artifact

func (*Client) UploadChunk

func (c *Client) UploadChunk(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.

func (*Client) UploadPipeline

func (c *Client) UploadPipeline(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 Config

type Config struct {
	// Endpoint for API requests. Defaults to the public Buildkite Agent API.
	// The URL should always be specified with a trailing slash.
	Endpoint string

	// The authentication token to use, either a registration or access token
	Token string

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

	// If true, only HTTP2 is disabled
	DisableHTTP2 bool

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

	// The http client used, leave nil for the default
	HTTPClient *http.Client
}

Config is configuration for the API Client

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 Heartbeat

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

Heartbeat represents a Buildkite Agent API Heartbeat

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"`
	Signal             string            `json:"signal,omitempty"`
	SignalReason       string            `json:"signal_reason,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 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 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 Pipeline

type Pipeline struct {
	UUID     string      `json:"uuid"`
	Pipeline interface{} `json:"pipeline"`
	Replace  bool        `json:"replace,omitempty"`
}

Pipeline represents a Buildkite Agent API Pipeline

type Response

type Response struct {
	*http.Response
}

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

type StepExportRequest

type StepExportRequest struct {
	Attribute string `json:"attribute,omitempty"`
	Build     string `json:"build_id,omitempty"`
	Format    string `json:"format,omitempty"`
}

StepExportRequest represents a request for information about a step

type StepExportResponse

type StepExportResponse struct {
	Output string `json:"output"`
}

type StepUpdate

type StepUpdate struct {
	IdempotencyUUID string `json:"idempotency_uuid,omitempty"`
	Build           string `json:"build_id,omitempty"`
	Attribute       string `json:"attribute,omitempty"`
	Value           string `json:"value,omitempty"`
	Append          bool   `json:"append,omitempty"`
}

StepUpdate represents a change request to a step

Jump to

Keyboard shortcuts

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