Documentation ¶
Overview ¶
Package protoutil provides utility functions for protobuf messages in ../proto package.
Index ¶
- Constants
- Variables
- func AddBotDimensionsToTaskDetails(botDims []*pb.StringPair, details *structpb.Struct) (*structpb.Struct, error)
- func BotDimensions(b *pb.Build) ([]*pb.StringPair, error)
- func BotDimensionsFromBackend(b *pb.Build) ([]*pb.StringPair, error)
- func BuildSets(b *pb.Build) []string
- func CacheDir(b *pb.Build) string
- func ExePayloadPath(b *pb.Build) string
- func FormatBucketID(project, bucket string) string
- func FormatBuilderID(id *pb.BuilderID) string
- func GerritBuildSet(c *pb.GerritChange) string
- func GerritChangeURL(c *pb.GerritChange) string
- func GitilesBuildSet(c *pb.GitilesCommit) string
- func GitilesCommitURL(c *pb.GitilesCommit) string
- func GitilesRepoURL(c *pb.GitilesCommit) string
- func IsEnded(s pb.Status) bool
- func MergeSummary(b *pb.Build) string
- func MustBotDimensions(b *pb.Build) []*pb.StringPair
- func ParentStepName(stepName string) string
- func ParseBucketID(s string) (string, string, error)
- func ParseBuildSet(buildSet string) proto.Message
- func ParseBuilderID(s string) (*pb.BuilderID, error)
- func ParseGetBuildRequest(s string) (*pb.GetBuildRequest, error)
- func RunDuration(b *pb.Build) (duration time.Duration, ok bool)
- func SchedulingDuration(b *pb.Build) (duration time.Duration, ok bool)
- func Search(ctx context.Context, buildC chan<- *pb.Build, client pb.BuildsClient, ...) error
- func SetStatus(now time.Time, b *pb.Build, st pb.Status)
- func SortStringPairs(pairs []*pb.StringPair)
- func StringPairMap(pairs []*pb.StringPair) strpair.Map
- func StringPairs(m strpair.Map) []*pb.StringPair
- func Tags(b *pb.Build) strpair.Map
- func ToBuilderIDString(project, bucket, builder string) string
- func ValidateBuilderID(b *pb.BuilderID) error
- func ValidateRequiredBuilderID(b *pb.BuilderID) error
- func ValidateStepName(stepName string) error
- func WellKnownExperiments(globalCfg *pb.SettingsCfg) stringset.Set
Constants ¶
const BuildMediaType = "application/luci+proto; message=buildbucket.v2.Build"
BuildMediaType is a media type for a binary-encoded Build message.
const StepNameSep = "|"
StepNameSep is the separator between each node in step names.
const SummaryMarkdownMaxLength = 4 * 1000
SummaryMarkdownMaxLength is the maximum size of Build.summary_markdown field in bytes. Find more details at https://godoc.org/go.chromium.org/luci/buildbucket/proto#Build
Variables ¶
var ExperimentNameRE = regexp.MustCompile(`^[a-z][a-z0-9_]*(?:\.[a-z][a-z0-9_]*)*$`)
ExperimentNameRE is the regular expression that a valid Buildbucket experiment name must match.
Functions ¶
func AddBotDimensionsToTaskDetails ¶
func AddBotDimensionsToTaskDetails(botDims []*pb.StringPair, details *structpb.Struct) (*structpb.Struct, error)
AddBotDimensionsToTaskDetails converts bot_dimensions from a list of StringPairs to a field in task details struct.
If details is nil, construct a struct with bot_dimensions as the only field.
func BotDimensions ¶
func BotDimensions(b *pb.Build) ([]*pb.StringPair, error)
BotDimensions retrieves bot dimensions from the backend task running the build.
Supports both builds running on raw Swarming or backend.
func BotDimensionsFromBackend ¶
func BotDimensionsFromBackend(b *pb.Build) ([]*pb.StringPair, error)
BotDimensionsFromBackend retrieves bot dimensions from the backend task running the build.
Exclusively for builds running on backend.
func ExePayloadPath ¶
ExePayloadPath returns the payload path of the build.
func FormatBucketID ¶
FormatBucketID returns "{project}/{bucket}" string.
func FormatBuilderID ¶
FormatBuilderID converts BuilderID to a "{project}/{bucket}/{builder}" string.
func GerritBuildSet ¶
func GerritBuildSet(c *pb.GerritChange) string
GerritBuildSet returns a buildset representation of c, e.g. "patch/gerrit/chromium-review.googlesource.com/677784/5"
func GerritChangeURL ¶
func GerritChangeURL(c *pb.GerritChange) string
GerritChangeURL returns URL of the change.
func GitilesBuildSet ¶
func GitilesBuildSet(c *pb.GitilesCommit) string
GitilesBuildSet returns a buildset representation of c. e.g. "commit/gitiles/chromium.googlesource.com/infra/luci/luci-go/+/b7a757f457487cd5cfe2dae83f65c5bc10e288b7"
Returns an empty string if not all of {Host, Project, Id} are set.
func GitilesCommitURL ¶
func GitilesCommitURL(c *pb.GitilesCommit) string
GitilesCommitURL returns the URL for the gitiles commit. e.g. "https://chromium.googlesource.com/chromium/src/+/b7a757f457487cd5cfe2dae83f65c5bc10e288b7" or "https://chromium.googlesource.com/chromium/src/+/refs/heads/master" if id is not available.
func GitilesRepoURL ¶
func GitilesRepoURL(c *pb.GitilesCommit) string
GitilesRepoURL returns the URL for the gitiles repo. e.g. "https://chromium.googlesource.com/chromium/src"
func MergeSummary ¶
MergeSummary combines the contents of all summary fields.
func MustBotDimensions ¶
func MustBotDimensions(b *pb.Build) []*pb.StringPair
MustBotDimensions retrieves bot dimensions from the backend task running the build.
Supports both builds running on raw Swarming or backend.
panic on error.
func ParentStepName ¶
ParentStepName returns the name of the parent step.
If stepName is empty or doesn't have a parent, an empty string is returned.
func ParseBucketID ¶
ParseBucketID parses a "{project}/{bucket}" string. Opposite of FormatBucketID.
func ParseBuildSet ¶
ParseBuildSet tries to parse buildset as one of the known formats. May return *pb.GerritChange, *pb.GitilesCommit or nil.
func ParseBuilderID ¶
ParseBuilderID parses a "{project}/{bucket}/{builder}" string. Opposite of FormatBuilderID.
func ParseGetBuildRequest ¶
func ParseGetBuildRequest(s string) (*pb.GetBuildRequest, error)
ParseGetBuildRequest parses a GetBuild request. Supports two forms: - <build-id> - <project>/<bucket>/<builder>/<build-number>
func RunDuration ¶
RunDuration returns duration between build start and end.
func SchedulingDuration ¶
SchedulingDuration returns duration between build creation and start.
func Search ¶
func Search(ctx context.Context, buildC chan<- *pb.Build, client pb.BuildsClient, requests ...*pb.SearchBuildsRequest) error
Search searches for builds continuously, sending findings to `buildC` until the search is exhausted or context is canceled. The builds are ordered newest-to-oldest and deduplicated.
If len(requests) > 1, the builds represent a union of the search requests.
Search does not return a next page token because ctx can be canceled in the middle of a page and because Search supports multiple requests.
func SetStatus ¶
SetStatus sets the status field on `b`, and also correctly adjusts StartTime and EndTime.
Will set UpdateTime iff `st` is different than `b.Status`.
func SortStringPairs ¶
func SortStringPairs(pairs []*pb.StringPair)
SortStringPairs sorts string pairs.
func StringPairMap ¶
func StringPairMap(pairs []*pb.StringPair) strpair.Map
StringPairMap converts a slice of StringPair messages to a strpair.Map.
func StringPairs ¶
func StringPairs(m strpair.Map) []*pb.StringPair
StringPairs converts a strpair.Map to a slice of StringPair messages.
func ToBuilderIDString ¶
ToBuilderIDString returns "{project}/{bucket}/{builder}" string.
func ValidateBuilderID ¶
ValidateBuilderID validates the given builder ID. Bucket and Builder are optional and only validated if specified.
func ValidateRequiredBuilderID ¶
ValidateRequiredBuilderID validates the given builder ID, requiring Bucket and Builder.
func ValidateStepName ¶
ValidateStepName validates a given step name.
func WellKnownExperiments ¶
func WellKnownExperiments(globalCfg *pb.SettingsCfg) stringset.Set
WellKnownExperiments computes all known 'global' experiments from the global SettingsCfg.
Types ¶
This section is empty.