Documentation
¶
Index ¶
- Constants
- func Glob(root string, pattern string) (matches []string, e error)
- func UploadArtifacts(client Client, job *Job, artifacts []*Artifact, destination string) error
- type Agent
- type Artifact
- type Client
- func (c *Client) APIReq(v interface{}, method string, path string, body interface{}) error
- func (c *Client) AgentCrash(agent *Agent) error
- func (c *Client) AgentUpdate(agent *Agent) error
- func (c *Client) ArtifactUpdate(job *Job, artifact Artifact) (*Artifact, error)
- func (c *Client) CreateArtifacts(job *Job, artifacts []*Artifact) ([]Artifact, error)
- func (c *Client) DataGet(job *Job, key string) (*Data, error)
- func (c *Client) DataSet(job *Job, key string, value string) (*Data, error)
- func (c *Client) DoReq(req *http.Request, v interface{}) error
- func (c *Client) Get(v interface{}, path string) error
- func (c *Client) JobFind(id string) (*Job, error)
- func (c *Client) JobFindAndAssign(id string) (*Job, error)
- func (c *Client) JobNext() (*Job, error)
- func (c *Client) JobUpdate(job *Job) (*Job, error)
- func (c *Client) NewRequest(method string, path string, body interface{}) (*http.Request, error)
- func (c *Client) Post(v interface{}, path string, body interface{}) error
- func (c *Client) Put(v interface{}, path string, body interface{}) error
- type Data
- type FormUploader
- type Job
- type Process
- type S3Uploader
- type Uploader
Constants ¶
const ( DefaultAPIURL = "https://agent.buildbox.io/v1" DefaultUserAgent = "buildbox-agent/" + Version + " (" + runtime.GOOS + "; " + runtime.GOARCH + ")" )
const (
Version = "0.2-beta.2"
)
Variables ¶
This section is empty.
Functions ¶
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()
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 CollectArtifacts ¶
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) AgentCrash ¶
func (*Client) AgentUpdate ¶
func (*Client) ArtifactUpdate ¶
func (*Client) CreateArtifacts ¶
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) DoReq ¶
Submits an HTTP request, checks its response, and deserializes the response into v.
func (*Client) NewRequest ¶
Generates an HTTP request for the Buildbox API, but does not perform the request.
type Data ¶
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.
type Process ¶
type Process struct {
Output string
Pid int
Running bool
ExitStatus int
// contains filtered or unexported fields
}
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