lib

package
v0.0.0-...-0f8c8ae Latest Latest
Warning

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

Go to latest
Published: Feb 29, 2024 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const APIVersion = "v2"
View Source
const Host = "https://api.buildkite.com"
View Source
const Version = "0.13"

The buildkite-go version. Run "make release" to bump this number.

Variables

This section is empty.

Functions

func FindBuildFailure

func FindBuildFailure(log []byte, numOutputLines int) []byte

FindBuildFailure will attempt to find the most "interesting" part of the log, based on heuristics. At most numOutputLines will be displayed.

func GetToken

func GetToken(ctx context.Context, org string) (string, error)

Types

type Build

type Build struct {
	Number      int64          `json:"number"`
	State       BuildState     `json:"state"`
	Branch      string         `json:"branch"`
	Commit      string         `json:"commit"`
	Message     string         `json:"message"`
	WebURL      string         `json:"web_url"`
	CreatedAt   time.Time      `json:"created_at"`
	StartedAt   time.Time      `json:"started_at"`
	ScheduledAt types.NullTime `json:"scheduled_at"`
	FinishedAt  types.NullTime `json:"finished_at"`
	Jobs        []Job          `json:"jobs"`
	Pipeline    Pipeline       `json:"pipeline"`
}

func (Build) Empty

func (b Build) Empty() bool

type BuildService

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

func (*BuildService) Job

func (b *BuildService) Job(id string) *JobService

type BuildState

type BuildState string

type Client

type Client struct {
	*restclient.Client
	APIVersion string
}

func NewClient

func NewClient(token string) *Client

func (*Client) BuildSummary

func (c *Client) BuildSummary(ctx context.Context, org string, build Build, numOutputLines int) []byte

func (*Client) CreateResource

func (c *Client) CreateResource(ctx context.Context, pathPart string, data url.Values, v interface{}) error

CreateResource makes a POST request to the given resource.

func (*Client) DeleteResource

func (c *Client) DeleteResource(ctx context.Context, pathPart string, sid string) error

func (*Client) GetResource

func (c *Client) GetResource(ctx context.Context, pathPart string, sid string, v interface{}) error

GetResource retrieves an instance resource with the given path part (e.g. "/Messages") and sid (e.g. "MM123").

func (*Client) ListResource

func (c *Client) ListResource(ctx context.Context, pathPart string, data url.Values, v interface{}) error

func (*Client) MakeRequest

func (c *Client) MakeRequest(ctx context.Context, method string, pathPart string, data url.Values, v interface{}) error

func (*Client) Organization

func (c *Client) Organization(org string) *OrganizationService

func (*Client) UpdateResource

func (c *Client) UpdateResource(ctx context.Context, pathPart string, sid string, data url.Values, v interface{}) error

type FileConfig

type FileConfig struct {
	Default string
	// Map key is the Buildkite name
	Organizations map[string]Organization `toml:"organizations"`
}

func LoadConfig

func LoadConfig(ctx context.Context) (*FileConfig, error)

LoadConfig loads and marshals a config file from disk. LoadConfig will look in the following locations in order:

- $XDG_CONFIG_HOME/buildkite - $HOME/cfg/buildkite - $HOME/.buildkite

func (*FileConfig) OrgForRemote

func (f *FileConfig) OrgForRemote(gitRemote string) (Organization, bool)

func (*FileConfig) Token

func (f *FileConfig) Token(gitRemote string) (string, error)

Token finds the token for a given git remote.

type Job

type Job struct {
	ID          string         `json:"id"`
	Name        string         `json:"name"`
	Command     string         `json:"command"`
	State       JobState       `json:"state"`
	CreatedAt   time.Time      `json:"created_at"`
	StartedAt   time.Time      `json:"started_at"`
	ScheduledAt types.NullTime `json:"scheduled_at"`
	FinishedAt  types.NullTime `json:"finished_at"`
	LogURL      string         `json:"log_url"`
}

func (Job) Failed

func (j Job) Failed() bool

type JobService

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

func (*JobService) Log

func (j *JobService) Log(ctx context.Context) (Log, error)

func (*JobService) Path

func (j *JobService) Path() string

func (*JobService) RawLog

func (j *JobService) RawLog(ctx context.Context) ([]byte, error)

type JobState

type JobState string

type ListBuildResponse

type ListBuildResponse []Build

type Log

type Log struct {
	Size    int64  `json:"size"`
	URL     string `json:"url"`
	Content string `json:"content"`
}

type Organization

type Organization struct {
	// This is the map key, so it needs to be explicitly set.
	Name  string
	Token string
	// List of git remotes that map to this Buildkite organization
	GitRemotes []string `toml:"git_remotes"`
}

type OrganizationService

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

func (*OrganizationService) Pipeline

func (o *OrganizationService) Pipeline(pipeline string) *PipelineService

type Pipeline

type Pipeline struct {
	ID                   string    `json:"id"`
	Name                 string    `json:"name"`
	Slug                 string    `json:"slug"`
	CreatedAt            time.Time `json:"created_at"`
	RunningBuildsCount   int       `json:"running_builds_count"`
	ScheduledBuildsCount int       `json:"scheduled_builds_count"`
	RunningJobsCount     int       `json:"running_jobs_count"`
	WaitingJobsCount     int       `json:"waiting_jobs_count"`
}

type PipelineService

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

func (*PipelineService) Build

func (p *PipelineService) Build(number int64) *BuildService

func (*PipelineService) ListBuilds

func (p *PipelineService) ListBuilds(ctx context.Context, query url.Values) (ListBuildResponse, error)

Jump to

Keyboard shortcuts

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