luci: Index | Files

package deprecated

import ""

Package deprecated is deprecated part of the buildbucket library. TODO(nodir): delete it when Buildbot is dead.


Package Files

build.go doc.go v1.go


var MalformedBuild = errors.BoolTag{Key: errors.NewTagKey("malformed buildbucket v1 build")}

MalformedBuild tag is present in an error if the build was malformed.

func BucketNameToV1 Uses

func BucketNameToV1(project, bucket string) string

BucketNameToV1 returns legacy (long) bucket name for a LUCI bucket.

func BucketNameToV2 Uses

func BucketNameToV2(v1Bucket string) (project string, bucket string)

BucketNameToV2 converts a v1 Bucket name to the v2 constituent parts. An error is returned if the bucketname does not match the expected format. The difference between the bucket name is that v2 uses short names, for example: v1: luci.chromium.try v2: try "luci" is dropped, "chromium" is recorded as the project, "try" is the name. If the bucket does not conform to this convention, or if it is not a luci bucket, then this return and empty string for both project and bucket.

func BuildToV2 Uses

func BuildToV2(msg *v1.LegacyApiCommonBuildMessage) (b *pb.Build, err error)

BuildToV2 converts a v1 build message to v2.

The returned build may be incomplete if msg is incomplete. For example, if msg is a partial response and does not have builder name, the returned build won't have it either.

The returned build does not include steps. Returns an error if msg is malformed.

func StatusToV2 Uses

func StatusToV2(build *v1.LegacyApiCommonBuildMessage) (pb.Status, error)

StatusToV2 converts v1 build's Status, Result, FailureReason and CancelationReason to v2 Status enum.

If build.Status is "", returns (Status_STATUS_UNSPECIFIED, nil). Useful with partial buildbucket responses.

type Build Uses

type Build struct {
    ID           int64
    CreationTime time.Time
    CreatedBy    identity.Identity
    Project      string
    Bucket       string
    Builder      string
    // Number identifies the build within the builder.
    // Build numbers are monotonically increasing, mostly contiguous.
    // The type is *int to prevent accidental confusion
    // of valid build number 0 with absence of the number (zero value).
    Number *int
    Tags   strpair.Map
    Input  Input

    Status           pb.Status
    StatusChangeTime time.Time
    URL              string
    StartTime        time.Time
    UpdateTime       time.Time
    Canary           bool
    Experimental     bool

    CompletionTime time.Time
    Output         Output

Build is a buildbucket build. It is a more type-safe version of buildbucket.LegacyApiCommonBuildMessage.

DEPRECATED: use BuildToV2.

func GetByAddress Uses

func GetByAddress(c context.Context, client *v1.Service, address string) (*Build, error)

GetByAddress fetches a build by its address. Returns (nil, nil) if build is not found.

func (*Build) Address Uses

func (b *Build) Address() string

Address returns an alternative identifier of the build. If b has a number, the address is "<bucket>/<builder>/<number>". Otherwise it is "<id>".

See also "".FormatBuildAddress.

func (*Build) BuilderID Uses

func (b *Build) BuilderID() *pb.BuilderID

BuilderID returns the builder ID of the build.

func (*Build) ParseMessage Uses

func (b *Build) ParseMessage(msg *v1.LegacyApiCommonBuildMessage) error

ParseMessage parses a build message to Build.

Numeric values in JSON-formatted fields, e.g. property values, are parsed as json.Number.

If an error is returned, the state of b is undefined.

DEPRECATED: use BuildToV2.

func (*Build) PutRequest Uses

func (b *Build) PutRequest() (*v1.LegacyApiPutRequestMessage, error)

PutRequest converts b to a build creation request.

If a buildset is present in both b.BuildSets and b.Map, it is deduped. Returned value has zero ClientOperationId. Returns an error if properties could not be marshaled to JSON.

func (*Build) RunDuration Uses

func (b *Build) RunDuration() (duration time.Duration, ok bool)

RunDuration returns duration between build start and completion.

func (*Build) SchedulingDuration Uses

func (b *Build) SchedulingDuration() (duration time.Duration, ok bool)

SchedulingDuration returns duration between build creation and start.

type Input Uses

type Input struct {
    // Properties is opaque data passed to the build.
    // For recipe-based builds, this is build properties.
    Properties Properties

Input is the input to the builder.

type Output Uses

type Output struct {
    Properties Properties

    // TODO(nodir, iannucci): replace type "error" with a new type that
    // represents a stack of errors emitted by different layers of the system,
    // where each error has
    // - domain string, e.g. "kitchen"
    // - reason string, e.g. kitchen-specific error code
    // - message string: human readable error
    // - meta: a proto.Struct with random data provided by the layer
    // The new type must implement error so that the change is
    // backward compatible.
    Err error // populated in builds with status StatusError

Output is build output.

type Properties Uses

type Properties interface{}

Properties is data provided by users, opaque to LUCI services. The value must be JSON marshalable/unmarshalable into/out from a JSON object.

When using an unmarshaling function, such as (*Build).ParseMessage, if the user knows the properties they need, they may set the value to a json-compatible struct. The unmarshaling function will try to unmarshal the properties into the struct. Otherwise, the unmarshaling function will use a generic type, e.g. map[string]interface{}.


var props struct {
  A string
var build buildbucket.Build
build.Input.Properties = &props
if err := build.ParseMessage(msg); err != nil {
  return err

Package deprecated imports 17 packages (graph) and is imported by 7 packages. Updated 2020-07-03. Refresh now. Tools for package owners.