luci: go.chromium.org/luci/buildbucket/appengine/model Index | Files

package model

import "go.chromium.org/luci/buildbucket/appengine/model"

Package model contains datastore model implementation.

Index

Package Files

bucket.go build.go details.go doc.go legacy.go tagindex.go unused.go utils.go

Constants

const MaxTagIndexEntries = 1000

MaxTagIndexEntries is the maximum number of entries that may be associated with a single TagIndex entity.

const NoRole pb.Acl_Role = -1

NoRole indicates the user has no defined role in a bucket.

const TagIndexShardCount = 16

TagIndexShardCount is the number of shards used by the TagIndex.

Variables

var TagIndexIncomplete = errors.BoolTag{Key: errors.NewTagKey("tag index incomplete")}

TagIndexIncomplete means the tag index is incomplete and thus cannot be searched.

func GetBuildAndBucket Uses

func GetBuildAndBucket(ctx context.Context, id int64) (*Build, *Bucket, error)

GetBuildAndBucket returns the build with the given ID as well as the bucket it belongs to. Returns datastore.ErrNoSuchEntity if either is not found.

func GetIgnoreMissing Uses

func GetIgnoreMissing(ctx context.Context, dst ...interface{}) error

GetIgnoreMissing fetches the given entities from the datastore, ignoring datastore.ErrNoSuchEntity errors. All other errors are returned. For valid values of dst, see datastore.Get.

type Bucket Uses

type Bucket struct {

    // ID is the bucket in v2 format.
    // e.g. try (never luci.chromium.try).
    ID     string         `gae:"$id"`
    Parent *datastore.Key `gae:"$parent"`

    // Bucket is the bucket in v2 format.
    // e.g. try (never luci.chromium.try).
    Bucket string `gae:"bucket_name"`
    // Proto is the pb.Bucket proto representation of the bucket.
    //
    // acl_sets is zeroed by inlining acls. swarming.builders is
    // zeroed and stored in separate Builder datastore entities due to
    // potentially large size.
    //
    // noindex is not respected here, it's set in pb.Bucket.ToProperty.
    Proto pb.Bucket `gae:"config,noindex"`
    // Revision is the config revision this entity was created from.
    // TODO(crbug/1042991): Switch to noindex.
    Revision string `gae:"revision"`
    // Schema is this entity's schema version.
    // TODO(crbug/1042991): Switch to noindex.
    Schema int32 `gae:"entity_schema_version"`
    // contains filtered or unexported fields
}

Bucket is a representation of a bucket in the datastore.

func (*Bucket) GetRole Uses

func (b *Bucket) GetRole(ctx context.Context) (pb.Acl_Role, error)

GetRole returns the role of current identity in this bucket. Roles are numerically comparable and role n implies roles [0, n-1] as well. May return NoRole if the current identity has no defined role in this bucket. TODO(crbug/1042991): Move elsewhere as needed.

type Build Uses

type Build struct {
    ID  int64 `gae:"$id"`

    // LegacyProperties are properties set for v1 legacy builds.
    LegacyProperties
    // UnusedProperties are properties set previously but currently unused.
    UnusedProperties

    // Proto is the pb.Build proto representation of the build.
    //
    // infra, input.properties, output.properties, and steps
    // are zeroed and stored in separate datastore entities
    // due to their potentially large size (see details.go).
    // tags are given their own field so they can be indexed.
    //
    // noindex is not respected here, it's set in pb.Build.ToProperty.
    Proto pb.Build `gae:"proto,noindex"`

    Project string `gae:"project"`
    // <project>/<bucket>. Bucket is in v2 format.
    // e.g. chromium/try (never chromium/luci.chromium.try).
    BucketID string `gae:"bucket_id"`
    // <project>/<bucket>/<builder>. Bucket is in v2 format.
    // e.g. chromium/try/linux-rel.
    BuilderID string `gae:"builder_id"`

    Canary bool `gae:"canary"`
    // TODO(crbug/1042991): Create datastore.PropertyConverter in server/auth.
    CreatedBy []byte `gae:"created_by,noindex"`
    // TODO(nodir): Replace reliance on create_time indices with id.
    CreateTime time.Time `gae:"create_time"`
    // Experimental, if true, means to exclude from monitoring and search results
    // (unless specifically requested in search results).
    Experimental        bool      `gae:"experimental"`
    Incomplete          bool      `gae:"incomplete"`
    IsLuci              bool      `gae:"is_luci"`
    ResultDBUpdateToken string    `gae:"resultdb_update_token,noindex"`
    Status              pb.Status `gae:"status_v2"`
    StatusChangedTime   time.Time `gae:"status_changed_time"`
    // Tags is a slice of "<key>:<value>" strings taken from Proto.Tags.
    // Stored separately in order to index.
    Tags []string `gae:"tags"`

    // PubSubCallback, if set, creates notifications for build status changes.
    PubSubCallback PubSubCallback `gae:"pubsub_callback,noindex"`
    // contains filtered or unexported fields
}

Build is a representation of a build in the datastore.

func (*Build) ToProto Uses

func (b *Build) ToProto(ctx context.Context, m mask.Mask) (*pb.Build, error)

ToProto returns the *pb.Build representation of this build. TODO(crbug/1042991): Support field masks.

type BuildInfra Uses

type BuildInfra struct {

    // ID is always 1 because only one such entity exists.
    ID  int `gae:"$id"`
    // Build is the key for the build this entity belongs to.
    Build *datastore.Key `gae:"$parent"`
    // Proto is the pb.BuildInfra proto representation of the infra field.
    Proto pb.BuildInfra `gae:"infra,noindex"`
    // contains filtered or unexported fields
}

BuildInfra is a representation of a build proto's infra field in the datastore.

type BuildInputProperties Uses

type BuildInputProperties struct {

    // ID is always 1 because only one such entity exists.
    ID  int `gae:"$id"`
    // Build is the key for the build this entity belongs to.
    Build *datastore.Key `gae:"$parent"`
    // Proto is the struct.Struct representation of the properties field.
    Proto DSStruct `gae:"properties,noindex"`
    // contains filtered or unexported fields
}

BuildInputProperties is a representation of a build proto's input field's properties field in the datastore.

type BuildOutputProperties Uses

type BuildOutputProperties struct {

    // ID is always 1 because only one such entity exists.
    ID  int `gae:"$id"`
    // Build is the key for the build this entity belongs to.
    Build *datastore.Key `gae:"$parent"`
    // Proto is the struct.Struct representation of the properties field.
    Proto DSStruct `gae:"properties,noindex"`
    // contains filtered or unexported fields
}

BuildOutputProperties is a representation of a build proto's output field's properties field in the datastore.

type BuildSteps Uses

type BuildSteps struct {

    // ID is always 1 because only one such entity exists.
    ID  int `gae:"$id"`
    // Build is the key for the build this entity belongs to.
    Build *datastore.Key `gae:"$parent"`
    // IsZipped indicates whether or not Bytes must be zlib decompressed.
    IsZipped bool `gae:"step_container_bytes_zipped,noindex"`
    // Bytes is the pb.Build proto representation of the build proto where only steps is set.
    // IsZipped determines whether this value is compressed or not.
    Bytes []byte `gae:"steps,noindex"`
    // contains filtered or unexported fields
}

BuildSteps is a representation of a build proto's steps field in the datastore.

func (*BuildSteps) ToProto Uses

func (s *BuildSteps) ToProto(ctx context.Context) ([]*pb.Step, error)

ToProto returns the []*pb.Step representation of these steps.

type DSStruct Uses

type DSStruct struct {
    structpb.Struct
}

DSStruct is a wrapper around structpb.Struct. Implements datastore.PropertyConverter, allowing reads from and writes to the datastore.

func (*DSStruct) FromProperty Uses

func (s *DSStruct) FromProperty(p datastore.Property) error

FromProperty deserializes structpb.Struct protos from the datastore. Implements datastore.PropertyConverter.

func (*DSStruct) ToProperty Uses

func (s *DSStruct) ToProperty() (datastore.Property, error)

ToProperty serializes structpb.Struct protos to datastore format. Implements datastore.PropertyConverter.

type LeaseProperties Uses

type LeaseProperties struct {
    IsLeased bool `gae:"is_leased"`
    // TODO(crbug/1042991): Create datastore.PropertyConverter in server/auth.
    Leasee              []byte    `gae:"leasee"`
    LeaseExpirationDate time.Time `gae:"lease_expiration_date"`
    // LeaseKey is a random value used to verify the leaseholder's identity.
    LeaseKey    int  `gae:"lease_key"`
    NeverLeased bool `gae:"never_leased"`
}

LeaseProperties are properties associated with the legacy leasing API.

type LegacyCancelationReason Uses

type LegacyCancelationReason int

LegacyCancelationReason is the reason for a canceled legacy build.

const (

    // ExplicitlyCanceled means the build was canceled (likely via API call).
    ExplicitlyCanceled LegacyCancelationReason
    // TimeoutCanceled means Buildbucket timed the build out.
    TimeoutCanceled
)

type LegacyFailureReason Uses

type LegacyFailureReason int

LegacyFailureReason is the reason for a legacy build failure.

const (

    // BuildFailure means the build itself failed.
    BuildFailure LegacyFailureReason
    // BuildbucketFailure means something went wrong within Buildbucket.
    BuildbucketFailure
    // InfraFailure means something went wrong outside the build and Buildbucket.
    InfraFailure
    // InvalidBuildDefinition means the build system rejected the build definition.
    InvalidBuildDefinition
)

type LegacyProperties Uses

type LegacyProperties struct {
    LeaseProperties

    CancelationReason LegacyCancelationReason `gae:"cancelation_reason"`
    FailureReason     LegacyFailureReason     `gae:"failure_reason"`
    Parameters        []byte                  `gae:"parameters"`
    Result            LegacyResult            `gae:"result"`
    ResultDetails     []byte                  `gae:"result_details"`
    // ID of the Build this is a retry of.
    RetryOf int          `gae:"retry_of"`
    Status  LegacyStatus `gae:"status"`
    URL     string       `gae:"url,noindex"`
}

LegacyProperties are properties of legacy builds.

Parameters and ResultDetails are byte slices interpretable as JSON. TODO(crbug/1042991): Create datastore.PropertyConverter for JSON properties.

type LegacyResult Uses

type LegacyResult int

LegacyResult is the result of a completed legacy build.

const (

    // Success means the build completed successfully.
    Success LegacyResult
    // Failure means the build failed and has an associated LegacyFailureReason.
    Failure
    // Canceled means the build was canceled
    // and has an associated LegacyCancelationReason.
    Canceled
)

type LegacyStatus Uses

type LegacyStatus int

LegacyStatus is the status of a legacy build request.

const (

    // Scheduled builds may be leased and started.
    Scheduled LegacyStatus
    // Started builds are leased and marked as started.
    Started
    // Completed builds are finished and have an associated LegacyResult.
    Completed
)

type Project Uses

type Project struct {
    ID string `gae:"$id"`
}

Project is the parent entity of buckets in the datastore. Entities of this kind don't exist in the datastore.

type PubSubCallback Uses

type PubSubCallback struct {
    AuthToken string `gae:"auth_token,noindex"`
    Topic     string `gae:"topic,noindex"`
    UserData  string `gae:"user_data,noindex"`
}

PubSubCallback encapsulates parameters for a Pub/Sub callback.

type TagIndex Uses

type TagIndex struct {

    // ID is a "<key>:<value>" or ":<index>:<key>:<value>" string for index > 0.
    ID  string `gae:"$id"`
    // Incomplete means there are more than MaxTagIndexEntries entities
    // with the same ID, and therefore the index is incomplete and cannot be
    // searched.
    Incomplete bool `gae:"permanently_incomplete,noindex"`
    // Entries is a slice of TagIndexEntries matching this ID.
    Entries []TagIndexEntry `gae:"entries,noindex"`
    // contains filtered or unexported fields
}

TagIndex is an index used to search Build entities by tag.

type TagIndexEntry Uses

type TagIndexEntry struct {
    // BuildID is the ID of the Build entity this entry refers to.
    BuildID int64 `json:"build_id"`
    // <project>/<bucket>. Bucket is in v2 format.
    // e.g. chromium/try (never chromium/luci.chromium.try).
    BucketID string `json:"bucket_id"`
    // CreatedTime is the time this entry was created.
    CreatedTime time.Time `json:"created_time"`
}

TagIndexEntry refers to a particular Build entity.

func SearchTagIndex Uses

func SearchTagIndex(ctx context.Context, key, val string) ([]TagIndexEntry, error)

SearchTagIndex searches the tag index for the given tag. Returns an error tagged with TagIndexIncomplete if the tag index is incomplete and thus cannot be searched.

func (*TagIndexEntry) FromProperty Uses

func (e *TagIndexEntry) FromProperty(p datastore.Property) error

FromProperty deserializes TagIndexEntries from the datastore. Implements datastore.PropertyConverter.

func (*TagIndexEntry) ToProperty Uses

func (e *TagIndexEntry) ToProperty() (datastore.Property, error)

ToProperty serializes TagIndexEntries to datastore format. Implements datastore.PropertyConverter.

type UnusedProperties Uses

type UnusedProperties struct {
    // CanaryPreference was used to indicate if the build may use canary infrastructure.
    // Since replaced by the proto's canary field.
    CanaryPreference int32 `gae:"canary_preference,noindex"`
    // Infra was used to store the proto's infra field value in order to reduce
    // the size of the proto being unmarshalled in projection queries.
    // Since moved to its own entity (see details.go) and backfilled for all builds.
    Infra []byte `gae:"infra_bytes,noindex"`
    // InputProperties was used to store the proto's input.properties field value
    // in order to reduce the size of the proto being unmarshalled in projection queries.
    // Since moved to its own entity (see details.go) and backfilled for all builds.
    InputProperties []byte `gae:"input_properties_bytes,noindex"`
    // SwarmingTaskKey was used before Swarming task creation was made idempotent
    // in order to ensure only one task could call UpdateBuild.
    SwarmingTaskKey string `gae:"swarming_task_key,noindex"`
    // PubSubCallback is normally a struct (see build.go), which translates into datastore
    // fields pubsub_callback.auth_token, pubsub_callback.topic, pubsub_callback.user_data
    // with no actual field called pubsub_callback. However, nil values in the datastore
    // may exist for pubsub_callback (should instead be represented by having all three
    // pubsub_callback.* fields nil, but isn't). Capture such nil values here.
    // TODO(crbug/1042991): Support this case properly in gae datastore package.
    PubSubCallback []byte `gae:"pubsub_callback,noindex"`
}

UnusedProperties are properties previously set but currently unused.

Package model imports 15 packages (graph) and is imported by 1 packages. Updated 2020-05-30. Refresh now. Tools for package owners.