agent

package
v2.6.6+incompatible Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2017 License: MIT Imports: 36 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ArtifactPathDelimiter = ";"
)

Variables

View Source
var ANSIColorRegex = regexp.MustCompile(`\x1b\[([;\d]+)?[mK]`)
View Source
var ArtifactPathVariableRegex = regexp.MustCompile("\\$\\{artifact\\:path\\}")
View Source
var HeaderRegex = regexp.MustCompile("^(?:---|\\+\\+\\+|~~~)\\s(.+)?$")

Functions

func APIClientEnableHTTPDebug

func APIClientEnableHTTPDebug()

func BuildVersion

func BuildVersion() string

func Version

func Version() string

func Worker

func Worker(id int, ls *LogStreamer)

The actual log streamer worker

Types

type APIClient

type APIClient struct {
	Endpoint string
	Token    string
}

func (APIClient) Create

func (a APIClient) Create() *api.Client

func (APIClient) UserAgent

func (a APIClient) UserAgent() string

type AgentConfiguration

type AgentConfiguration struct {
	BootstrapScript                string
	BuildPath                      string
	HooksPath                      string
	AutoSSHFingerprintVerification bool
	CommandEval                    bool
	RunInPty                       bool
	TimestampLines                 bool
	GitCleanFlags                  string
	GitCloneFlags                  string
}

type AgentPool

type AgentPool struct {
	APIClient          *api.Client
	Token              string
	ConfigFilePath     string
	Name               string
	Priority           string
	MetaData           []string
	MetaDataEC2        bool
	MetaDataEC2Tags    bool
	MetaDataGCP        bool
	Endpoint           string
	AgentConfiguration *AgentConfiguration
}

func (*AgentPool) CreateAgentTemplate

func (r *AgentPool) CreateAgentTemplate() *api.Agent

Takes the options passed to the CLI, and creates an api.Agent record that will be sent to the Buildkite Agent API for registration.

func (*AgentPool) RegisterAgent

func (r *AgentPool) RegisterAgent(agent *api.Agent) (*api.Agent, error)

Takes the agent template and returns a registered agent. The registered agent includes the Access Token used to communicate with the Buildkite Agent API

func (*AgentPool) ShowBanner

func (r *AgentPool) ShowBanner()

Shows the welcome banner and the configuration options used when starting this agent.

func (*AgentPool) Start

func (r *AgentPool) Start() error

type AgentWorker

type AgentWorker struct {
	// The API Client used when this agent is communicating with the API
	APIClient *api.Client

	// The endpoint that should be used when communicating with the API
	Endpoint string

	// The registred agent API record
	Agent *api.Agent

	// The configuration of the agent from the CLI
	AgentConfiguration *AgentConfiguration
	// contains filtered or unexported fields
}

func (*AgentWorker) Connect

func (a *AgentWorker) Connect() error

Connects the agent to the Buildkite Agent API, retrying up to 30 times if it fails.

func (AgentWorker) Create

func (a AgentWorker) Create() AgentWorker

Creates the agent worker and initializes it's API Client

func (*AgentWorker) Disconnect

func (a *AgentWorker) Disconnect() error

Disconnects the agent from the Buildkite Agent API, doesn't bother retrying because we want to disconnect as fast as possible.

func (*AgentWorker) Heartbeat

func (a *AgentWorker) Heartbeat() error

Performs a heatbeat

func (*AgentWorker) Ping

func (a *AgentWorker) Ping()

Performs a ping, which returns what action the agent should take next.

func (*AgentWorker) Start

func (a *AgentWorker) Start() error

Starts the agent worker

func (*AgentWorker) Stop

func (a *AgentWorker) Stop(graceful bool)

Stops the agent from accepting new work and cancels any current work it's running

type ArtifactBatchCreator

type ArtifactBatchCreator struct {
	// The APIClient that will be used when uploading jobs
	APIClient *api.Client

	// The ID of the Job that these artifacts belong to
	JobID string

	// All the artifacts that need to be created
	Artifacts []*api.Artifact

	// Where the artifacts are being uploaded to on the command line
	UploadDestination string
}

func (*ArtifactBatchCreator) Create

func (a *ArtifactBatchCreator) Create() ([]*api.Artifact, error)

type ArtifactDownloader

type ArtifactDownloader struct {
	// The APIClient that will be used when uploading jobs
	APIClient *api.Client

	// The ID of the Build
	BuildID string

	// The query used to find the artifacts
	Query string

	// Which step should we look at for the jobs
	Step string

	// Where we'll be downloading artifacts to
	Destination string
}

func (*ArtifactDownloader) Download

func (a *ArtifactDownloader) Download() error

type ArtifactSearcher

type ArtifactSearcher struct {
	// The APIClient that will be used when uploading jobs
	APIClient *api.Client

	// The ID of the Build that these artifacts belong to
	BuildID string
}

func (*ArtifactSearcher) Search

func (a *ArtifactSearcher) Search(query string, scope string) ([]*api.Artifact, error)

type ArtifactUploader

type ArtifactUploader struct {
	// The APIClient that will be used when uploading jobs
	APIClient *api.Client

	// The ID of the Job
	JobID string

	// The path of the uploads
	Paths string

	// Where we'll be uploading artifacts
	Destination string
}

func (*ArtifactUploader) Collect

func (a *ArtifactUploader) Collect() (artifacts []*api.Artifact, err error)

func (*ArtifactUploader) Upload

func (a *ArtifactUploader) Upload() error

type Download

type Download struct {
	// The actual URL to get the file from
	URL string

	// The root directory of the download
	Destination string

	// The relative path that should be preserved in the download folder
	Path string

	// How many times should it retry the download before giving up
	Retries int

	// If failed responses should be dumped to the log
	DebugHTTP bool
}

func (Download) Start

func (d Download) Start() error

type EC2MetaData

type EC2MetaData struct {
}

func (EC2MetaData) Get

func (e EC2MetaData) Get() (map[string]string, error)

type EC2Tags

type EC2Tags struct {
}

func (EC2Tags) Get

func (e EC2Tags) Get() (map[string]string, error)

type FormUploader

type FormUploader struct {
	// Whether or not HTTP calls shoud be debugged
	DebugHTTP bool
}

func (*FormUploader) Setup

func (u *FormUploader) Setup(destination string, debugHTTP bool) error

func (*FormUploader) URL

func (u *FormUploader) URL(artifact *api.Artifact) string

The FormUploader doens't specify a URL, as one is provided by Buildkite after uploading

func (*FormUploader) Upload

func (u *FormUploader) Upload(artifact *api.Artifact) error

type GCPMetaData

type GCPMetaData struct {
}

func (GCPMetaData) Get

func (e GCPMetaData) Get() (map[string]string, error)

type HeaderTimesStreamer

type HeaderTimesStreamer struct {
	// The callback that will be called when a header time is ready for
	// upload
	UploadCallback func(int, int, map[string]string)
	// contains filtered or unexported fields
}

func (*HeaderTimesStreamer) LineIsHeader

func (h *HeaderTimesStreamer) LineIsHeader(line string) bool

func (*HeaderTimesStreamer) LinePreProcessor

func (h *HeaderTimesStreamer) LinePreProcessor(line string) string

func (*HeaderTimesStreamer) Scan

func (h *HeaderTimesStreamer) Scan(line string)

func (*HeaderTimesStreamer) Start

func (h *HeaderTimesStreamer) Start() error

func (*HeaderTimesStreamer) Stop

func (h *HeaderTimesStreamer) Stop()

func (*HeaderTimesStreamer) Upload

func (h *HeaderTimesStreamer) Upload()

type JobRunner

type JobRunner struct {
	// The job being run
	Job *api.Job

	// The APIClient that will be used when updating the job
	APIClient *api.Client

	// The endpoint that should be used when communicating with the API
	Endpoint string

	// The registred agent API record running this job
	Agent *api.Agent

	// The configuration of the agent from the CLI
	AgentConfiguration *AgentConfiguration
	// contains filtered or unexported fields
}

func (JobRunner) Create

func (r JobRunner) Create() (runner *JobRunner, err error)

Initializes the job runner

func (*JobRunner) Kill

func (r *JobRunner) Kill() error

func (*JobRunner) Run

func (r *JobRunner) Run() error

Runs the job

type LogStreamer

type LogStreamer struct {
	// How many log streamer workers are running at any one time
	Concurrency int

	// The maximum size of chunks
	MaxChunkSizeBytes int

	// A counter of how many chunks failed to upload
	ChunksFailedCount int32

	// The callback called when a chunk is ready for upload
	Callback func(chunk *LogStreamerChunk) error
	// contains filtered or unexported fields
}

func (LogStreamer) New

func (ls LogStreamer) New() *LogStreamer

Creates a new instance of the log streamer

func (*LogStreamer) Process

func (ls *LogStreamer) Process(output string) error

Takes the full process output, grabs the portion we don't have, and adds it to the stream queue

func (*LogStreamer) Start

func (ls *LogStreamer) Start() error

Spins up x number of log streamer workers

func (*LogStreamer) Stop

func (ls *LogStreamer) Stop() error

Waits for all the chunks to be uploaded, then shuts down all the workers

type LogStreamerChunk

type LogStreamerChunk struct {
	// The contents of the chunk
	Data string

	// The sequence number of this chunk
	Order int

	// The byte offset of this chunk
	Offset int

	// The byte size of this chunk
	Size int
}

type S3Downloader

type S3Downloader struct {
	// The name of the bucket
	Bucket string

	// The root directory of the download
	Destination string

	// The relative path that should be preserved in the download folder,
	// also it's location in the bucket
	Path string

	// How many times should it retry the download before giving up
	Retries int

	// If failed responses should be dumped to the log
	DebugHTTP bool
}

func (S3Downloader) Start

func (d S3Downloader) Start() error

type S3Uploader

type S3Uploader struct {
	// The destination which includes the S3 bucket name
	// and the path.
	// s3://my-bucket-name/foo/bar
	Destination string

	// Whether or not HTTP calls shoud be debugged
	DebugHTTP bool

	// The S3 Bucket we're uploading these files to
	Bucket *s3.Bucket
}

func (*S3Uploader) Setup

func (u *S3Uploader) Setup(destination string, debugHTTP bool) error

func (*S3Uploader) URL

func (u *S3Uploader) URL(artifact *api.Artifact) string

func (*S3Uploader) Upload

func (u *S3Uploader) Upload(artifact *api.Artifact) error

type Uploader

type Uploader interface {
	// Called before anything happens.
	Setup(string, bool) error

	// The Artifact.URL property is populated with what ever is returned
	// from this method prior to uploading.
	URL(*api.Artifact) string

	// The actual uploading of the file
	Upload(*api.Artifact) error
}

Jump to

Keyboard shortcuts

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