Documentation ¶
Overview ¶
Package buildbucket provides a Buildbucket client with helper methods for interacting with builds.
Index ¶
- func FindDimValInFinalDims(dim string, build *buildbucketpb.Build) string
- func FindDimValInRequestedDims(dim string, build *buildbucketpb.Build) string
- func FindTagVal(tag string, build *buildbucketpb.Build) string
- type Client
- func (c *Client) AnyIncompleteBuildsWithTags(ctx context.Context, tags map[string]string) (bool, int64, error)
- func (c *Client) BuildURL(ID int64) string
- func (c *Client) CancelBuildsByUser(ctx context.Context, printer common.CLIPrinter, ...) error
- func (c *Client) GetAllBuildsByUser(ctx context.Context, user string, ...) ([]*buildbucketpb.Build, error)
- func (c *Client) GetAllBuildsWithTags(ctx context.Context, tags map[string]string, ...) ([]*buildbucketpb.Build, error)
- func (c *Client) GetBuild(ctx context.Context, ID int64, fields ...string) (*buildbucketpb.Build, error)
- func (c *Client) GetLatestGreenBuild(ctx context.Context) (*buildbucketpb.Build, error)
- func (c *Client) ScheduleBuild(ctx context.Context, props map[string]interface{}, dims map[string]string, ...) (*buildbucketpb.Build, error)
- func (c *Client) WaitForBuildStepStart(ctx context.Context, id int64, stepName string) (*buildbucketpb.Build, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FindDimValInFinalDims ¶
func FindDimValInFinalDims(dim string, build *buildbucketpb.Build) string
FindDimValInFinalDims finds the given dimension value in the build's requested dimensions.
func FindDimValInRequestedDims ¶
func FindDimValInRequestedDims(dim string, build *buildbucketpb.Build) string
FindDimValInRequestedDims finds the given dimension value in the build's requested dimensions, which are of type []*buildbucketpb.RequestedDimension.
Since the dimensions looped through are not of type []*buildbucketpb.StringPair, some duplicate code is unfortunately required.
func FindTagVal ¶
func FindTagVal(tag string, build *buildbucketpb.Build) string
FindTagVal finds the given tag value in the build's tags.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client provides helper methods to interact with Buildbucket builds.
func NewClient ¶
func NewClient(ctx context.Context, builder *buildbucketpb.BuilderID, bbService string, authFlags authcli.Flags) (*Client, error)
NewClient returns a new client to interact with Buildbucket builds from the given builder.
func NewClientForTesting ¶
func NewClientForTesting(builder *buildbucketpb.BuilderID) *Client
NewClientForTesting returns a new client with only the builderID configured.
func (*Client) AnyIncompleteBuildsWithTags ¶
func (c *Client) AnyIncompleteBuildsWithTags(ctx context.Context, tags map[string]string) (bool, int64, error)
AnyIncompleteBuildsWithTags returns a bool indicating whether there are any scheduled or started builds matching the given tags. If any builds are found, the first ID is returned.
func (*Client) BuildURL ¶
BuildURL constructs the URL for the LUCI page of the build (of the client's builder) with the given ID.
func (*Client) CancelBuildsByUser ¶
func (c *Client) CancelBuildsByUser(ctx context.Context, printer common.CLIPrinter, earliestCreateTime *timestamppb.Timestamp, user string, ids []string, reason string) error
CancelBuildsByUser cancels any pending or active build created after the given timestamp that was launched by the given user. An optional bot ID list can be given, which restricts cancellations to builds running on bots on the given list. The optional cancellation reason is used if not blank.
func (*Client) GetAllBuildsByUser ¶
func (c *Client) GetAllBuildsByUser(ctx context.Context, user string, searchBuildsRequest *buildbucketpb.SearchBuildsRequest) ([]*buildbucketpb.Build, error)
GetAllBuildsForUser finds returns all builds created by the given user matching the given SearchBuildsRequest. This function expects the field "builds.*.created_by" to be included in the field mask of the given SearchBuildRequest.
func (*Client) GetAllBuildsWithTags ¶
func (c *Client) GetAllBuildsWithTags(ctx context.Context, tags map[string]string, searchBuildsRequest *buildbucketpb.SearchBuildsRequest) ([]*buildbucketpb.Build, error)
GetAllBuildsWithTags returns all builds with the given tags matching the given SearchBuildsRequest. (Technically, the SearchBuildsRequest could include tags in the form []*buildbucketpb.StringPair; this function simply allows passing tags in the simpler map[string]string form.)
func (*Client) GetBuild ¶
func (c *Client) GetBuild(ctx context.Context, ID int64, fields ...string) (*buildbucketpb.Build, error)
GetBuild gets a Buildbucket build by ID, with the given build fields populated. If no fields are given, all fields will be populated.
func (*Client) GetLatestGreenBuild ¶
GetLatestGreenBuild gets the latest green build for the client's builder. To optimize runtime, this call is only configured to populate the build's ID and output properties. More fields can be added to the field mask if needed.
func (*Client) ScheduleBuild ¶
func (c *Client) ScheduleBuild(ctx context.Context, props map[string]interface{}, dims map[string]string, tags map[string]string, priority int32) (*buildbucketpb.Build, error)
ScheduleBuild schedules a new build (of the client's builder) with the given properties, tags, bot dimensions, and Buildbucket priority, and returns the scheduled build.
Buildbucket requests take properties of type *structpb.Struct. To simplify the conversion from other data structures to Structs, ScheduleBuild accepts properties of type map[string]interface{}, where interface{} can be any of Go's basic types (bool, string, number type, byte, or rune), a proto message (in the form protoreflect.ProtoMessage), or a nested map[string]interface{} that fulfils the same requirements recursively.
NOTE: Buildbucket priority is separate from internal swarming priority.
func (*Client) WaitForBuildStepStart ¶
func (c *Client) WaitForBuildStepStart(ctx context.Context, id int64, stepName string) (*buildbucketpb.Build, error)
WaitForBuildStart polls Buildbucket to check the status of the build with the given ID, and returns the build once it has started the given step. If the build has a status other than scheduled/started, both the build and a printable error message are returned.