buildbox

package
v0.0.0-...-616e4d2 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2014 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Logger = initLogger()

Functions

func DownloadArtifacts

func DownloadArtifacts(artifacts []Artifact, destination string) error

func EC2InstanceTags

func EC2InstanceTags() (map[string]string, error)

func Glob

func Glob(root string, pattern string) (matches []string, e error)

func InDebugMode

func InDebugMode() bool

func LoggerInitDebug

func LoggerInitDebug()

func MachineHostname

func MachineHostname() string

func MachineIsWindows

func MachineIsWindows() bool

func StartDownload

func StartDownload(quit chan string, download Download)

func UploadArtifacts

func UploadArtifacts(client Client, job *Job, artifacts []*Artifact, destination string) error

func Version

func Version() string

Types

type Agent

type Agent struct {
	// The name of the agent
	Name string

	// The client the agent will use to communicate to
	// the API
	Client Client

	// The PID of the agent
	PID int `json:"pid,omitempty"`

	// The hostname of the agent
	Hostname string `json:"hostname,omitempty"`

	// The boostrap script to run
	BootstrapScript string

	// Run jobs in a PTY
	RunInPty bool

	// The currently running Job
	Job *Job
	// contains filtered or unexported fields
}

func (*Agent) MonitorSignals

func (a *Agent) MonitorSignals()

func (*Agent) Setup

func (a *Agent) Setup()

func (*Agent) Start

func (a *Agent) Start()

func (*Agent) Stop

func (a *Agent) Stop()

func (*Agent) String

func (a *Agent) String() string

type AgentRegistration

type AgentRegistration struct {
	// The access token for the agent
	AccessToken string `json:"access_token"`

	// Hostname of the machine
	Hostname string `json:"hostname"`

	// The priority of the agent
	Priority string `json:"priority,omitempty"`

	// The name of the new agent
	Name string `json:"name"`

	// Meta data for the agent
	MetaData []string `json:"meta_data"`
}

func (*AgentRegistration) String

func (a *AgentRegistration) String() string

type Artifact

type Artifact struct {
	// The ID of the artifact
	ID string `json:"id,omitempty"`

	// The current state of the artifact. Default is "new"
	State string `json:"state,omitempty"`

	// The relative path to the file
	Path string `json:"path"`

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

	// The glob path that was used to identify this file
	GlobPath string `json:"glob_path"`

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

	// Where we should upload the artifact to. If nil,
	// it will upload to Buildbox.
	URL string `json:"url,omitempty"`

	// When uploading artifacts to Buildbox, the API will return some
	// extra information on how/where to upload the file.
	Uploader struct {
		// Where/how to upload the file
		Action struct {
			// What the host to post to
			URL string `json:"url,omitempty"`

			// POST, PUT, GET, etc.
			Method string

			// What's the path at the URL we need to upload to
			Path string

			// What's the key of the file input named?
			FileInput string `json:"file_input"`
		}

		// Data that should be sent along with the upload
		Data map[string]string
	}
}

func BuildArtifact

func BuildArtifact(relativePath string, absolutePath string, globPath string) (*Artifact, error)

func CollectArtifacts

func CollectArtifacts(job *Job, artifactPaths string) (artifacts []*Artifact, err error)

func (Artifact) MimeType

func (a Artifact) MimeType() string

func (Artifact) String

func (a Artifact) String() string

type Client

type Client struct {
	// The URL of the Buildbox Agent API to communicate with. Defaults to
	// "https://agent.buildbox.io/v2".
	URL string

	// The authorization token agent being used to make API requests
	AuthorizationToken string

	// UserAgent to be provided in API requests. Set to DefaultUserAgent if not
	// specified.
	UserAgent string
}

func (*Client) APIReq

func (c *Client) APIReq(v interface{}, method string, path string, body interface{}) error

Sends a Buildbox API request and decodes the response into v.

func (*Client) AgentConnect

func (c *Client) AgentConnect(agent *Agent) error

func (*Client) AgentDisconnect

func (c *Client) AgentDisconnect(agent *Agent) error

func (*Client) AgentRegister

func (c *Client) AgentRegister(name string, priority string, metaData []string) (string, error)

func (*Client) ArtifactUpdate

func (c *Client) ArtifactUpdate(job *Job, artifact Artifact) (*Artifact, error)

func (*Client) CreateArtifacts

func (c *Client) CreateArtifacts(job *Job, artifacts []*Artifact) ([]Artifact, error)

Sends all the artifacts at once to the Buildbox Agent API. This will allow the UI to show what artifacts will be uploaded. Their state starts out as "new"

func (*Client) DataGet

func (c *Client) DataGet(job *Job, key string) (*Data, error)

func (*Client) DataSet

func (c *Client) DataSet(job *Job, key string, value string) (*Data, error)

func (*Client) DoReq

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

Submits an HTTP request, checks its response, and deserializes the response into v.

func (*Client) Get

func (c *Client) Get(v interface{}, path string) error

func (*Client) JobAccept

func (c *Client) JobAccept(job *Job) (*Job, error)

func (*Client) JobFind

func (c *Client) JobFind(id string) (*Job, error)

func (*Client) JobNext

func (c *Client) JobNext() (*Job, error)

func (*Client) JobUpdate

func (c *Client) JobUpdate(job *Job) (*Job, error)

func (*Client) NewRequest

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

Generates an HTTP request for the Buildbox API, but does not perform the request.

func (*Client) Post

func (c *Client) Post(v interface{}, path string, body interface{}) error

func (*Client) Put

func (c *Client) Put(v interface{}, path string, body interface{}) error

func (*Client) SearchArtifacts

func (c *Client) SearchArtifacts(buildId string, searchQuery string, jobQuery string, stateQuery string) ([]Artifact, error)

Searches for artifacts on the build

type Data

type Data struct {
	// The key of the data
	Key string `json:"key,omitempty"`

	// The value of the data
	Value string `json:"value,omitempty"`
}

func (Data) String

func (d Data) String() string

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
}

type FormUploader

type FormUploader struct {
}

func (*FormUploader) Setup

func (u *FormUploader) Setup(destination string) error

func (*FormUploader) URL

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

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

func (*FormUploader) Upload

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

type Job

type Job struct {
	ID string

	State string

	Env map[string]string

	Output string `json:"output,omitempty"`

	ExitStatus string `json:"exit_status,omitempty"`

	StartedAt string `json:"started_at,omitempty"`

	FinishedAt string `json:"finished_at,omitempty"`
	// contains filtered or unexported fields
}

The Job struct uses strings for StartedAt and FinishedAt because if they were actual date objects, then when this struct is initialized they would have a default value of: 00:00:00.000000000. This causes problems for the Buildbox Agent API because it looks for the presence of values in these properties to determine if the build has finished.

func (*Job) Kill

func (j *Job) Kill() error

func (*Job) Run

func (j *Job) Run(agent *Agent) error

func (Job) String

func (b Job) String() string

type LogFormatter

type LogFormatter struct {
}

func (*LogFormatter) Format

func (f *LogFormatter) Format(entry *logrus.Entry) ([]byte, error)

type LoggerFields

type LoggerFields logrus.Fields

type Process

type Process struct {
	Output     string
	Pid        int
	Running    bool
	RunInPty   bool
	ExitStatus string
	// contains filtered or unexported fields
}

func InitProcess

func InitProcess(scriptPath string, env []string, runInPty bool, callback func(*Process)) *Process

func (*Process) Kill

func (p *Process) Kill() error

func (*Process) Start

func (p *Process) Start() error

func (Process) String

func (p Process) String() string

Implement the Stringer thingy

type S3Uploader

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

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

func (*S3Uploader) Setup

func (u *S3Uploader) Setup(destination string) error

func (*S3Uploader) URL

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

func (*S3Uploader) Upload

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

type Uploader

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

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

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

Jump to

Keyboard shortcuts

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