buildkite

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2016 License: BSD-2-Clause Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const BuildKiteDateFormat = time.RFC3339Nano

BuildKiteDateFormat is the format of the dates used throughout the api, note this odd string is used to parse/format dates in go

View Source
const Version = "1.0.0"

Version the library version number

Variables

This section is empty.

Functions

func Int

func Int(v int) *int

Int is a helper routine that allocates a new int value to store v and returns a pointer to it, but unlike Int its argument value is an int.

func SetHttpDebug

func SetHttpDebug(flag bool)

SetHttpDebug this enables global http request/response dumping for this API

func String

func String(v string) *string

String is a helper routine that allocates a new string value to store v and returns a pointer to it.

Types

type Agent

type Agent struct {
	ID             *string    `json:"id,omitempty"`
	URL            *string    `json:"url,omitempty"`
	Name           *string    `json:"name,omitempty"`
	ConnectedState *string    `json:"connection_state,omitempty"`
	AgentToken     *string    `json:"access_token,omitempty"`
	Hostname       *string    `json:"hostname,omitempty"`
	IPAddress      *string    `json:"ip_address,omitempty"`
	UserAgent      *string    `json:"user_agent,omitempty"`
	CreatedAt      *Timestamp `json:"created_at,omitempty"`

	// the user which created the agent
	Creator *User `json:"creator,omitempty"`
}

Agent represents a buildkite build agent.

type AgentListOptions

type AgentListOptions struct {
	ListOptions
}

AgentListOptions specifies the optional parameters to the AgentService.List method.

type AgentsService

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

AgentsService handles communication with the agent related methods of the buildkite API.

buildkite API docs: https://buildkite.com/docs/api/agents

func (*AgentsService) Create

func (as *AgentsService) Create(org string, agent *Agent) (*Agent, *Response, error)

Create a new buildkite agent.

buildkite API docs: https://buildkite.com/docs/api/agents#create-an-agent

func (*AgentsService) Delete

func (as *AgentsService) Delete(org string, id string) (*Response, error)

Delete an agent.

buildkite API docs: https://buildkite.com/docs/api/agents#delete-an-agent

func (*AgentsService) Get

func (as *AgentsService) Get(org string, id string) (*Agent, *Response, error)

Get fetches an agent.

buildkite API docs: https://buildkite.com/docs/api/agents#get-an-agent

func (*AgentsService) List

func (as *AgentsService) List(org string, opt *AgentListOptions) ([]Agent, *Response, error)

List the agents for a given orginisation.

buildkite API docs: https://buildkite.com/docs/api/agents#list-agents

type BasicAuthTransport

type BasicAuthTransport struct {
	Username string
	Password string
}

BasicAuthTransport manages injection of the authorization header

func NewBasicConfig

func NewBasicConfig(username string, password string) (*BasicAuthTransport, error)

NewBasicConfig configure authentication using the supplied credentials

func (*BasicAuthTransport) Client

func (bat *BasicAuthTransport) Client() *http.Client

Client builds a new http client.

func (BasicAuthTransport) RoundTrip

func (bat BasicAuthTransport) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip invoked each time a request is made

type Build

type Build struct {
	ID          *string           `json:"id,omitempty"`
	URL         *string           `json:"url,omitempty"`
	WebURL      *string           `json:"web_url,omitempty"`
	Number      *int              `json:"number,omitempty"`
	State       *string           `json:"state,omitempty"`
	Message     *string           `json:"message,omitempty"`
	Commit      *string           `json:"commit,omitempty"`
	Branch      *string           `json:"branch,omitempty"`
	Env         map[string]string `json:"env,omitempty"`
	CreatedAt   *Timestamp        `json:"created_at,omitempty"`
	ScheduledAt *Timestamp        `json:"scheduled_at,omitempty"`
	StartedAt   *Timestamp        `json:"started_at,omitempty"`
	FinishedAt  *Timestamp        `json:"finished_at,omitempty"`
	MetaData    interface{}       `json:"meta_data,omitempty"`

	// jobs run during the build
	Jobs []*Job `json:"jobs,omitempty"`

	// the project this build is associated with
	Project *Project `json:"project,omitempty"`
}

Build represents a build which has run in buildkite

type BuildsListOptions

type BuildsListOptions struct {

	// State of builds to list.  Possible values are: running, scheduled, passed,
	// failed, canceled, skipped and not_run. Default is "".
	State string `url:"state,omitempty"`

	// Branch filter by the name of the branch. Default is "".
	Branch string `url:"branch,omitempty"`

	ListOptions
}

BuildsListOptions specifies the optional parameters to the BuildsService.List method.

type BuildsService

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

BuildsService handles communication with the build related methods of the buildkite API.

buildkite API docs: https://buildkite.com/docs/api/builds

func (*BuildsService) Get

func (as *BuildsService) Get(org string, project string, id string) (*Build, *Response, error)

Get fetches a build.

buildkite API docs: https://buildkite.com/docs/api/builds#get-a-build

func (*BuildsService) List

func (bs *BuildsService) List(opt *BuildsListOptions) ([]Build, *Response, error)

List the builds for the current user.

buildkite API docs: https://buildkite.com/docs/api/builds#list-all-builds

func (*BuildsService) ListByOrg

func (bs *BuildsService) ListByOrg(org string, opt *BuildsListOptions) ([]Build, *Response, error)

ListByOrg lists the builds within the specified orginisation.

buildkite API docs: https://buildkite.com/docs/api/builds#list-builds-for-an-organization

func (*BuildsService) ListByProject

func (bs *BuildsService) ListByProject(org string, project string, opt *BuildsListOptions) ([]Build, *Response, error)

ListByProject lists the builds for a project within the specified originisation.

buildkite API docs: https://buildkite.com/docs/api/builds#list-builds-for-a-project

type Client

type Client struct {

	// Base URL for API requests.  Defaults to the public buildkite API. BaseURL should
	// always be specified with a trailing slash.
	BaseURL *url.URL

	// User agent used when communicating with the buildkite API.
	UserAgent string

	// Services used for talking to different parts of the buildkite API.
	Agents        *AgentsService
	Builds        *BuildsService
	Organizations *OrganizationsService
	Projects      *ProjectsService
	User          *UserService
	// contains filtered or unexported fields
}

A Client manages communication with the buildkite API.

func NewClient

func NewClient(httpClient *http.Client) *Client

NewClient returns a new buildkite API client. As API calls require authentication you MUST supply a client which provides the required API key.

func (*Client) Do

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

Do sends an API request and returns the API response. The API response is JSON decoded and stored in the value pointed to by v, or returned as an error if an API error has occurred. If v implements the io.Writer interface, the raw response body will be written to v, without attempting to first decode it.

func (*Client) ListEmojis

func (c *Client) ListEmojis(org string) ([]Emoji, *Response, error)

ListEmojis list all the emojis for a given account, including custom emojis and aliases.

buildkite API docs: https://buildkite.com/docs/api/emojis

func (*Client) NewRequest

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

NewRequest creates an API request. A relative URL can be provided in urlStr, in which case it is resolved relative to the BaseURL of the Client. Relative URLs should always be specified without a preceding slash. If specified, the value pointed to by body is JSON encoded and included as the request body.

type Emoji

type Emoji struct {
	Name *string `json:"name,omitempty"`
	URL  *string `json:"url,omitempty"`
}

Emoji emoji, what else can you say?

type ErrorResponse

type ErrorResponse struct {
	Response *http.Response // HTTP response that caused this error
	Message  string         `json:"message"` // error message
}

ErrorResponse provides a message.

func (*ErrorResponse) Error

func (r *ErrorResponse) Error() string

type Job

type Job struct {
	ID            *string    `json:"id,omitempty"`
	Type          *string    `json:"type,omitempty"`
	Name          *string    `json:"name,omitempty"`
	State         *string    `json:"state,omitempty"`
	LogsURL       *string    `json:"logs_url,omitempty"`
	RawLogsURL    *string    `json:"raw_log_url,omitempty"`
	Command       *string    `json:"command,omitempty"`
	ExitStatus    *int       `json:"exit_status,omitempty"`
	ArtifactPaths *string    `json:"artifact_paths,omitempty"`
	CreatedAt     *Timestamp `json:"created_at,omitempty"`
	ScheduledAt   *Timestamp `json:"scheduled_at,omitempty"`
	StartedAt     *Timestamp `json:"started_at,omitempty"`
	FinishedAt    *Timestamp `json:"finished_at,omitempty"`
}

Job represents a job run during a build in buildkite

type ListOptions

type ListOptions struct {
	// For paginated result sets, page of results to retrieve.
	Page int `url:"page,omitempty"`

	// For paginated result sets, the number of results to include per page.
	PerPage int `url:"per_page,omitempty"`
}

ListOptions specifies the optional parameters to various List methods that support pagination.

type Organization

type Organization struct {
	ID          *string    `json:"id,omitempty"`
	URL         *string    `json:"url,omitempty"`
	WebURL      *string    `json:"web_url,omitempty"`
	Name        *string    `json:"name,omitempty"`
	Slug        *string    `json:"slug,omitempty"`
	Repository  *string    `json:"repository,omitempty"`
	ProjectsURL *string    `json:"projects_url,omitempty"`
	AgentsURL   *string    `json:"agents_url,omitempty"`
	CreatedAt   *Timestamp `json:"created_at,omitempty"`
}

Organization represents a buildkite organization.

type OrganizationListOptions

type OrganizationListOptions struct {
	ListOptions
}

OrganizationListOptions specifies the optional parameters to the OrganizationsService.List method.

type OrganizationsService

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

OrganizationsService handles communication with the organization related methods of the buildkite API.

buildkite API docs: https://buildkite.com/docs/api/organizations

func (*OrganizationsService) Get

Get fetches an organization

buildkite API docs: https://buildkite.com/docs/api/organizations#get-an-organization

func (*OrganizationsService) List

List the organizations for the current user.

buildkite API docs: https://buildkite.com/docs/api/organizations#list-organizations

type Project

type Project struct {
	ID         *string    `json:"id,omitempty"`
	URL        *string    `json:"url,omitempty"`
	WebURL     *string    `json:"web_url,omitempty"`
	Name       *string    `json:"name,omitempty"`
	Slug       *string    `json:"slug,omitempty"`
	Repository *string    `json:"repository,omitempty"`
	BuildsURL  *string    `json:"builds_url,omitempty"`
	CreatedAt  *Timestamp `json:"created_at,omitempty"`

	ScheduledBuildsCount *int `json:"scheduled_builds_count,omitempty"`
	RunningBuildsCount   *int `json:"running_builds_count,omitempty"`
	ScheduledJobsCount   *int `json:"scheduled_jobs_count,omitempty"`
	RunningJobsCount     *int `json:"running_jobs_count,omitempty"`
	WaitingJobsCount     *int `json:"waiting_jobs_count,omitempty"`

	// the provider of sources
	Provider *Provider `json:"provider,omitempty"`

	// build featured when you view the project
	FeaturedBuild *Build `json:"featured_build,omitempty"`

	// build steps
	Steps []*Step `json:"steps,omitempty"`
}

Project represents a buildkite project.

type ProjectListOptions

type ProjectListOptions struct {
	ListOptions
}

ProjectListOptions specifies the optional parameters to the ProjectsService.List method.

type ProjectsService

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

ProjectsService handles communication with the project related methods of the buildkite API.

buildkite API docs: https://buildkite.com/docs/api/projects

func (*ProjectsService) List

func (ps *ProjectsService) List(org string, opt *ProjectListOptions) ([]Project, *Response, error)

List the projects for a given orginisation.

buildkite API docs: https://buildkite.com/docs/api/projects#list-projects

type Provider

type Provider struct {
	ID         *string `json:"id,omitempty"`
	WebhookURL *string `json:"webhook_url,omitempty"`
}

Provider represents a source code provider.

type Response

type Response struct {
	*http.Response

	NextPage  int
	PrevPage  int
	FirstPage int
	LastPage  int
}

Response is a buildkite API response. This wraps the standard http.Response returned from buildkite and provides convenient access to things like pagination links.

type Step

type Step struct {
	Type                *string           `json:"type,omitempty"`
	Name                *string           `json:"name,omitempty"`
	Command             *string           `json:"command,omitempty"`
	ArtifactPaths       *string           `json:"artifact_paths,omitempty"`
	BranchConfiguration *string           `json:"branch_configuration,omitempty"`
	Env                 map[string]string `json:"env,omitempty"`
	TimeoutInMinutes    interface{}       `json:"timeout_in_minutes,omitempty"` // *shrug*
	AgentQueryRules     interface{}       `json:"agent_query_rules,omitempty"`  // *shrug*
}

Step represents a build step in buildkites build pipeline

type Timestamp

type Timestamp struct {
	time.Time
}

Timestamp custom timestamp to support buildkite api timestamps

func NewTimestamp

func NewTimestamp(t time.Time) *Timestamp

NewTimestamp make a new timestamp using the time suplied.

func (Timestamp) Equal

func (ts Timestamp) Equal(u Timestamp) bool

Equal reports whether t and u are equal based on time.Equal

func (Timestamp) MarshalJSON

func (ts Timestamp) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface.

func (Timestamp) String

func (ts Timestamp) String() string

func (*Timestamp) UnmarshalJSON

func (ts *Timestamp) UnmarshalJSON(data []byte) (err error)

UnmarshalJSON implements the json.Unmarshaler interface.

type Token

type Token struct {
	AccessToken *string `json:"access_token,omitempty"`
	Type        *string `json:"token_type,omitempty"`
}

Token an oauth access token for the buildkite service

type TokenAuthTransport

type TokenAuthTransport struct {
	APIToken string
	Debug    bool
}

TokenAuthTransport manages injection of the API token for each request

func NewTokenConfig

func NewTokenConfig(apiToken string, debug bool) (*TokenAuthTransport, error)

NewTokenConfig configure authentication using an API token

func (*TokenAuthTransport) Client

func (t *TokenAuthTransport) Client() *http.Client

Client builds a new http client.

func (TokenAuthTransport) RoundTrip

func (t TokenAuthTransport) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip invoked each time a request is made

type User

type User struct {
	ID        *string    `json:"id,omitempty"`
	Name      *string    `json:"name,omitempty"`
	Email     *string    `json:"email,omitempty"`
	CreatedAt *Timestamp `json:"created_at,omitempty"`
}

User represents a buildkite user.

type UserService

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

UserService handles communication with the user related methods of the buildkite API.

buildkite API docs: https://buildkite.com/docs/api

func (*UserService) Get

func (os *UserService) Get() (*User, *Response, error)

Get the current user.

buildkite API docs: https://buildkite.com/docs/api

Jump to

Keyboard shortcuts

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