buildbucket

package
v0.0.0-...-f4b31ea Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2025 License: BSD-3-Clause Imports: 28 Imported by: 0

Documentation

Overview

Copyright 2022 The Chromium Authors Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.

Copyright 2022 The ChromiumOS Authors. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.

Copyright 2022 The ChromiumOS Authors. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultPRPCOpts

func DefaultPRPCOpts() *prpc.Options

DefaultPRPCOpts returns a set of Options that work well with Buildbucket for most use cases.

func FakeAuthInfoRunner

func FakeAuthInfoRunner(tool string, exitCode int) cmd.FakeCommandRunner

FakeAuthInfoRunner creates a FakeCommandRunner for `{tool} auth-info` (like bb or led).

func FakeAuthInfoRunnerSuccessStdout

func FakeAuthInfoRunnerSuccessStdout(tool string, user string) cmd.FakeCommandRunner

FakeAuthInfoRunnerSuccessStdout is like FakeAuthInfoRunner with exitCode=0, plus stdout about the logged-in user. user should normally be an email address, such as "sundar@google.com". For now it doesn't mock OAuth token details.

func FakeBBAddRunner

func FakeBBAddRunner(args []string, bbid string) cmd.FakeCommandRunner

FakeBBAddRunner creates a FakeCommandRunner for `bb add`. args should be a list of command args, including ["bb", "add"].

func FakeWhichRunner

func FakeWhichRunner(tool string, exitCode int) cmd.FakeCommandRunner

FakeWhichRunner creates a FakeCommandRunner for `which {tool}` (like bb or led).

func GetProp

func GetProp(props map[string]interface{}, prop string) (interface{}, bool)

GetProp gets a property.

func HasProp

func HasProp(props map[string]interface{}, prop string, value interface{}) bool

HasProp checks if the given key value pair is in the dict. prop may be a nested field (. delmited).

func PollForOutputProp

func PollForOutputProp(
	ctx context.Context,
	client bbpb.BuildsClient,
	buildIds []int64,
	outputProp string,
	interval time.Duration,
) (map[int64]*bbpb.Build, error)

PollForOutputProp polls until all of buildIds are completed or have set outputProp. Between each call to Buildbucket, the fn. sleeps for interval. This functionality is similar to the `bb collect` command, but allows polling for an output prop being set, instead of only build completion; this is useful for things like polling until a builder has published images.

On completion, returns a map from build id -> Build for all of buildIds.

func ReadStructFromFile

func ReadStructFromFile(path string) (*structpb.Struct, error)

ReadStructFromFile reads a struct from the specified file.

func SeparateBucketFromBuilder

func SeparateBucketFromBuilder(fullBuilderName string) (bucket string, builder string, err error)

SeparateBucketFromBuilder takes a full builder name (like chromeos/release/release-main-orchestrator), and separates it into a bucket (chromeos/release) and a builder (release-main-orchestrator).

func SetProperty

func SetProperty(s *structpb.Struct, key string, value interface{}) error

SetProperty sets the specified property in the property struct.

func WriteStructToFile

func WriteStructToFile(s *structpb.Struct, file *os.File) error

WriteStructToFile creates a tempfile and writes the struct as JSON data.

Types

type Client

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

func NewClient

func NewClient(cmdRunner cmd.CommandRunner, stdoutLog *log.Logger, stderrLog *log.Logger) *Client

NewClient creates a new Buildbucket client.

func (*Client) BBAdd

func (c *Client) BBAdd(ctx context.Context, dryRun bool, args ...string) (string, error)

BBAdd runs a `bb add` command, and prints stdout to the user. Returns the bbid of the build and an error (if any).

func (*Client) BBBuilders

func (c *Client) BBBuilders(ctx context.Context, bucket string) ([]string, error)

getBuilders runs the `bb builders` command to get all builders in the given bucket. The bucket param should not include the project prefix (normally "chromeos/").

func (*Client) EnsureLUCIToolsAuthed

func (c *Client) EnsureLUCIToolsAuthed(ctx context.Context, tools ...string) error

EnsureLUCIToolsAuthed ensures that multiple LUCI CLI tools are logged in. If any tools are not authed, it will return an error instructing the user to log into each unauthed tool.

func (*Client) GetBuild

func (c *Client) GetBuild(ctx context.Context, bbid string) (*bbpb.Build, error)

GetBuild gets the specified build using `bb get`.

func (*Client) GetBuilderInputProps

func (c *Client) GetBuilderInputProps(ctx context.Context, fullBuilderName string) (*structpb.Struct, error)

func (*Client) GetBuilds

func (c *Client) GetBuilds(ctx context.Context, bbids []string) ([]*bbpb.Build, error)

GetBuild gets the specified build using `bb get`.

func (*Client) IsLUCIToolAuthed

func (c *Client) IsLUCIToolAuthed(ctx context.Context, tool string) (bool, error)

IsLUCIToolAuthed checks whether the named LUCI CLI tool is logged in.

func (*Client) ListBuildsWithPredicate

func (c *Client) ListBuildsWithPredicate(ctx context.Context, predicate string) ([]*bbpb.Build, error)

ListBuilds gets the specified build using `bb ls -predicate ...`.

func (*Client) LogErr

func (c *Client) LogErr(format string, a ...interface{})

LogErr logs to stderr.

func (*Client) LogOut

func (c *Client) LogOut(format string, a ...interface{})

LogOut logs to stdout.

func (*Client) ToolPath

func (c *Client) ToolPath(ctx context.Context, tool string) (string, error)

ToolPath uses `which` to return the path to the given tool.

Jump to

Keyboard shortcuts

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