agent

package
v3.5.3+incompatible Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2018 License: MIT Imports: 57 Imported by: 53

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 APIProxy

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

APIProxy provides either a unix socket or a tcp socket listener with a proxy that will authenticate to the Buildkite Agent API

func NewAPIProxy

func NewAPIProxy(endpoint string, token string) *APIProxy

func (*APIProxy) AccessToken

func (p *APIProxy) AccessToken() string

func (*APIProxy) Close

func (p *APIProxy) Close() error

Close any listeners or internal files

func (*APIProxy) Endpoint

func (p *APIProxy) Endpoint() string

func (*APIProxy) Listen

func (p *APIProxy) Listen() error

Listen on either a tcp socket (for windows) or a unix socket

func (*APIProxy) Wait

func (p *APIProxy) Wait()

Wait blocks until the listener is ready

type AgentConfiguration

type AgentConfiguration struct {
	ConfigPath                string
	BootstrapScript           string
	BuildPath                 string
	HooksPath                 string
	PluginsPath               string
	GitCloneFlags             string
	GitCleanFlags             string
	GitSubmodules             bool
	SSHKeyscan                bool
	CommandEval               bool
	PluginsEnabled            bool
	PluginValidation          bool
	LocalHooksEnabled         bool
	RunInPty                  bool
	TimestampLines            bool
	DisconnectAfterJob        bool
	DisconnectAfterJobTimeout int
	Shell                     string
}

type AgentPool

type AgentPool struct {
	APIClient             *api.Client
	Token                 string
	ConfigFilePath        string
	Name                  string
	Priority              string
	Tags                  []string
	TagsFromEC2           bool
	TagsFromEC2Tags       bool
	TagsFromGCP           bool
	TagsFromHost          bool
	WaitForEC2TagsTimeout time.Duration
	Endpoint              string
	AgentConfiguration    *AgentConfiguration
	// contains filtered or unexported fields
}

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

func (*AgentWorker) UpdateProcTitle

func (a *AgentWorker) UpdateProcTitle(action string)

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 HTTP client to use for downloading
	Client http.Client

	// 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 GSDownloader

type GSDownloader 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 (GSDownloader) BucketFileLocation

func (d GSDownloader) BucketFileLocation() string

func (GSDownloader) BucketName

func (d GSDownloader) BucketName() string

func (GSDownloader) BucketPath

func (d GSDownloader) BucketPath() string

func (GSDownloader) Start

func (d GSDownloader) Start() error

type GSUploader

type GSUploader struct {
	// The destination which includes the GS bucket name and the path.
	// gs://my-bucket-name/foo/bar
	Destination string

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

	// The GS service
	Service *storage.Service
}

func (*GSUploader) BucketName

func (u *GSUploader) BucketName() string

func (*GSUploader) BucketPath

func (u *GSUploader) BucketPath() string

func (*GSUploader) Setup

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

func (*GSUploader) URL

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

func (*GSUploader) Upload

func (u *GSUploader) Upload(artifact *api.Artifact) 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 APIProxy that will be exposed to the job bootstrap
	APIProxy *APIProxy

	// 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 PipelineParser

type PipelineParser struct {
	Env             *env.Environment
	Filename        string
	Pipeline        []byte
	NoInterpolation bool
}

func (PipelineParser) Parse

type PipelineParserResult

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

PipelineParserResult is the ordered parse tree of a Pipeline document

func (*PipelineParserResult) MarshalJSON

func (p *PipelineParserResult) MarshalJSON() ([]byte, error)

type S3Downloader

type S3Downloader struct {
	// The S3 bucket name and the path, e.g s3://my-bucket-name/foo/bar
	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) BucketFileLocation

func (d S3Downloader) BucketFileLocation() string

func (S3Downloader) BucketName

func (d S3Downloader) BucketName() string

func (S3Downloader) BucketPath

func (d S3Downloader) BucketPath() string

func (S3Downloader) Start

func (d S3Downloader) Start() error

type S3Uploader

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

	// Whether or not HTTP calls should be debugged
	DebugHTTP bool
	// contains filtered or unexported fields
}

func (*S3Uploader) BucketName

func (u *S3Uploader) BucketName() string

func (*S3Uploader) BucketPath

func (u *S3Uploader) BucketPath() string

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
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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