buildbox

package
v0.0.0-...-7e1e83e Latest Latest
Warning

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

Go to latest
Published: May 20, 2014 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultAPIURL    = "https://agent.buildbox.io/v1"
	DefaultUserAgent = "buildbox-agent/" + Version + " (" + runtime.GOOS + "; " + runtime.GOARCH + ")"
)
View Source
const (
	Version = "0.2-beta.2"
)

Variables

This section is empty.

Functions

func Glob

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

func UploadArtifacts

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

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 hostname of the agent
	Hostname string `json:"hostname,omitempty"`

	// Whether to run the agent in Debug mode
	Debug bool

	// The boostrap script to run
	BootstrapScript string

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

func (*Agent) MonitorSignals

func (a *Agent) MonitorSignals()

func (*Agent) Run

func (a *Agent) Run(id string)

func (*Agent) Setup

func (a *Agent) Setup()

func (*Agent) Start

func (a *Agent) Start()

func (*Agent) String

func (a *Agent) 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(path 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/v1".
	URL string

	// The access token of the agent being used to make API requests
	AgentAccessToken string

	// Debug mode can be used to dump the full request and response to stdout.
	Debug bool

	// 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) AgentCrash

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

func (*Client) AgentUpdate

func (c *Client) AgentUpdate(agent *Agent) 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) JobFind

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

func (*Client) JobFindAndAssign

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

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 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 Process

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

func RunScript

func RunScript(dir string, script string, env []string, callback func(Process)) (*Process, error)

func (Process) Kill

func (p Process) Kill() 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