luci: Index | Files

package pbutil

import ""

Package pbutil implements utility functions for ResultDB protobuf messages.

TODO(nodir): many of these functions are not hardly useful for clients, e.g. ones involved in request validation. The request validation functions themselves are not in this package. Ideally all symbols in this package are useful for others. Otherwise pbutil should be in internal/.


Package Files

artifact.go common.go doc.go invocation.go invocation_processing.go predicate.go query.go strpair.go test_exoneration.go test_result.go variant.go

func FromStrpairMap Uses

func FromStrpairMap(m strpair.Map) []*pb.StringPair

FromStrpairMap converts a strpair.Map to []*pb.StringPair.

func InvocationArtifactName Uses

func InvocationArtifactName(invocationID, artifactID string) string

InvocationArtifactName synthesizes a name of an invocation-level artifact. Does not validate IDs, use ValidateInvocationID and ValidateArtifactID.

func InvocationName Uses

func InvocationName(id string) string

InvocationName synthesizes an invocation name from an id. Does not validate id, use ValidateInvocationID.

func MustDuration Uses

func MustDuration(du *durationpb.Duration) time.Duration

MustDuration converts a *durationpb.Duration to a time.Duration and panics on failure.

func MustTimestamp Uses

func MustTimestamp(ts *tspb.Timestamp) time.Time

MustTimestamp converts a *tspb.Timestamp to a time.Time and panics on failure.

func MustTimestampProto Uses

func MustTimestampProto(t time.Time) *tspb.Timestamp

MustTimestampProto converts a time.Time to a *tspb.Timestamp and panics on failure.

func NormalizeInvocation Uses

func NormalizeInvocation(inv *pb.Invocation)

NormalizeInvocation converts inv to the canonical form.

func NormalizeTestResult Uses

func NormalizeTestResult(tr *pb.TestResult)

NormalizeTestResult converts inv to the canonical form.

func NormalizeTestResultSlice Uses

func NormalizeTestResultSlice(trs []*pb.TestResult)

NormalizeTestResultSlice converts trs to the canonical form.

func ParseArtifactName Uses

func ParseArtifactName(name string) (invocationID, testID, resultID, artifactID string, err error)

ParseArtifactName extracts the invocation ID, unescaped test id, result ID and artifact ID. The testID and resultID are empty if this is an invocation-level artifact.

func ParseInvocationName Uses

func ParseInvocationName(name string) (id string, err error)

ParseInvocationName extracts the invocation id.

func ParseTestExonerationName Uses

func ParseTestExonerationName(name string) (invocationID, testID, exonerationID string, err error)

ParseTestExonerationName extracts invocation, test id and exoneration IDs from the name.

func ParseTestResultName Uses

func ParseTestResultName(name string) (invID, testID, resultID string, err error)

ParseTestResultName extracts the invocation ID, unescaped test id, and result ID.

func Query Uses

func Query(ctx context.Context, dest chan<- proto.Message, client pb.ResultDBClient, reqs ...proto.Message) error

Query queries for results continuously, sending individual items to dest channel until the paging query is exhausted or the context is canceled. A request must be *pb.QueryTestResultRequest, pb.QueryTestExonerationsRequest or *pb.QueryArtifactsRequest. Messages sent to dest are *pb.TestResult, *pb.TestExoneration or *pb.Artifact respectively.

Does not return the next page token because ctx can be canceled in the middle of a page.

If there are multiple requests in reqs, then runs them all concurrently and sends all of their results to dest. This is useful to query items of different types, e.g. test results and test exonerations. Does not limit concurrency.

func SortStringPairs Uses

func SortStringPairs(tags []*pb.StringPair)

SortStringPairs sorts in-place the tags slice lexicographically by key, then value.

func SortedVariantKeys Uses

func SortedVariantKeys(vr *pb.Variant) []string

SortedVariantKeys returns the keys in the variant as a sorted slice.

func StringPair Uses

func StringPair(k, v string) *pb.StringPair

StringPair creates a pb.StringPair with the given strings as key/value field values.

func StringPairFromString Uses

func StringPairFromString(s string) (*pb.StringPair, error)

StringPairFromString creates a pb.StringPair from the given key:val string.

func StringPairToString Uses

func StringPairToString(pair *pb.StringPair) string

StringPairToString converts a StringPair to a key:val string.

func StringPairs Uses

func StringPairs(pairs ...string) []*pb.StringPair

StringPairs creates a slice of pb.StringPair from a list of strings alternating key/value.

Panics if an odd number of tokens is passed.

func StringPairsContain Uses

func StringPairsContain(pairs []*pb.StringPair, item *pb.StringPair) bool

StringPairsContain checks if item is present in pairs.

func StringPairsToStrings Uses

func StringPairsToStrings(pairs ...*pb.StringPair) []string

StringPairsToStrings converts pairs to a slice of "{key}:{value}" strings in the same order.

func TestExonerationName Uses

func TestExonerationName(invocationID, testID, exonerationID string) string

TestExonerationName synthesizes a test exoneration name. Assumes invocation and exoneration IDs are valid.

func TestResultArtifactName Uses

func TestResultArtifactName(invocationID, testID, resulID, artifactID string) string

TestResultArtifactName synthesizes a name of an test-result-level artifact. Does not validate IDs, use ValidateInvocationID, ValidateTestID, ValidateResultID and ValidateArtifactID.

func TestResultName Uses

func TestResultName(invID, testID, resultID string) string

TestResultName synthesizes a test result name from its parts. Does not validate parts; use ValidateTestResultName.

func ValidateArtifactID Uses

func ValidateArtifactID(id string) error

ValidateArtifactID returns a non-nil error if id is invalid.

func ValidateArtifactName Uses

func ValidateArtifactName(name string) error

ValidateArtifactName returns a non-nil error if name is invalid.

func ValidateArtifactPredicate Uses

func ValidateArtifactPredicate(p *pb.ArtifactPredicate) error

ValidateArtifactPredicate returns a non-nil error if p is determined to be invalid.

func ValidateBatchRequestCount Uses

func ValidateBatchRequestCount(count int) error

ValidateBatchRequestCount validates the number of requests in a batch request.

func ValidateBigQueryExport Uses

func ValidateBigQueryExport(bqExport *pb.BigQueryExport) error

ValidateBigQueryExport returns a non-nil error if bqExport is determined to be invalid.

func ValidateEnum Uses

func ValidateEnum(value int32, validValues map[int32]string) error

ValidateEnum returns a non-nil error if the value is not among valid values.

func ValidateFilePath Uses

func ValidateFilePath(path string) error

ValidateFilePath returns a non-nil error if path is invalid.

func ValidateInvocationID Uses

func ValidateInvocationID(id string) error

ValidateInvocationID returns a non-nil error if id is invalid.

func ValidateInvocationName Uses

func ValidateInvocationName(name string) error

ValidateInvocationName returns a non-nil error if name is invalid.

func ValidateRequestID Uses

func ValidateRequestID(requestID string) error

ValidateRequestID returns a non-nil error if requestID is invalid. Returns nil if requestID is empty.

func ValidateResultID Uses

func ValidateResultID(resultID string) error

ValidateTestResultID returns a non-nil error if resultID is invalid.

func ValidateStartTimeWithDuration Uses

func ValidateStartTimeWithDuration(now time.Time, startTime *tspb.Timestamp, duration *dpb.Duration) error

ValidateStartTimeWithDuration returns a non-nil error if startTime and duration are invalid.

func ValidateStringPair Uses

func ValidateStringPair(p *pb.StringPair) error

ValidateStringPair returns an error if p is invalid.

func ValidateStringPairs Uses

func ValidateStringPairs(pairs []*pb.StringPair) error

ValidateStringPairs returns an error if any of the pairs is invalid.

func ValidateSummaryHTML Uses

func ValidateSummaryHTML(summary string) error

ValidateSummaryHTML returns a non-nil error if summary is invalid.

func ValidateTestExonerationName Uses

func ValidateTestExonerationName(name string) error

ValidateTestExonerationName returns a non-nil error if the test exoneration name is invalid.

func ValidateTestExonerationPredicate Uses

func ValidateTestExonerationPredicate(p *pb.TestExonerationPredicate) error

ValidateTestExonerationPredicate returns a non-nil error if p is determined to be invalid.

func ValidateTestID Uses

func ValidateTestID(testID string) error

ValidateTestID returns a non-nil error if testID is invalid.

func ValidateTestLocation Uses

func ValidateTestLocation(loc *pb.TestLocation, requireRepo bool) error

ValidateTestLocation returns a non-nil error if loc is invalid.

func ValidateTestMetadata Uses

func ValidateTestMetadata(tmd *pb.TestMetadata) error

ValidateTestMetadata returns a non-nil error if tmd is invalid.

func ValidateTestResult Uses

func ValidateTestResult(now time.Time, msg *pb.TestResult) (err error)

ValidateTestResult returns a non-nil error if msg is invalid.

func ValidateTestResultName Uses

func ValidateTestResultName(name string) error

ValidateTestResultName returns a non-nil error if name is invalid.

func ValidateTestResultPredicate Uses

func ValidateTestResultPredicate(p *pb.TestResultPredicate) error

ValidateTestResultPredicate returns a non-nil error if p is determined to be invalid.

func ValidateTestResultStatus Uses

func ValidateTestResultStatus(s pb.TestStatus) error

ValidateTestResultStatus returns a non-nil error if s is invalid for a test result.

func ValidateVariant Uses

func ValidateVariant(vr *pb.Variant) error

ValidateVariant returns an error if vr is invalid.

func ValidateVariantPredicate Uses

func ValidateVariantPredicate(p *pb.VariantPredicate) error

ValidateVariantPredicate returns a non-nil error if p is determined to be invalid.

func Variant Uses

func Variant(pairs ...string) *pb.Variant

Variant creates a pb.Variant from a list of strings alternating key/value. Does not validate pairs. See also VariantFromStrings.

Panics if an odd number of tokens is passed.

func VariantFromStrings Uses

func VariantFromStrings(pairs []string) (*pb.Variant, error)

VariantFromStrings returns a Variant proto given the key:val string slice of its contents.

If a key appears multiple times, the last pair wins.

func VariantHash Uses

func VariantHash(vr *pb.Variant) string

VariantHash returns a short hash of the variant.

func VariantToStringPairs Uses

func VariantToStringPairs(vr *pb.Variant) []*pb.StringPair

VariantToStringPairs returns a slice of StringPair derived from *pb.Variant.

func VariantToStrings Uses

func VariantToStrings(vr *pb.Variant) []string

VariantToStrings returns a key:val string slice representation of the Variant. Never returns nil.

Package pbutil imports 19 packages (graph) and is imported by 24 packages. Updated 2021-01-25. Refresh now. Tools for package owners.