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

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

func FromStrpairMap Uses

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

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

func InvocationName Uses

func InvocationName(id string) string

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

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 NormalizeArtifactSlice Uses

func NormalizeArtifactSlice(arts []*pb.Artifact)

NormalizeArtifactSlice converts arts to the canonical form.

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 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 SortedVariantKeys Uses

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

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

func StringPair Uses

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

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

func StringPairFromString Uses

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

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

func StringPairToString Uses

func StringPairToString(pair *typepb.StringPair) string

StringPairToString converts a StringPair to a key:val string.

func StringPairs Uses

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

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

Panics if an odd number of tokens is passed.

func StringPairsContain Uses

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

StringPairsContain checks if item is present in pairs.

func StringPairsToStrings Uses

func StringPairsToStrings(pairs ...*typepb.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 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 ValidateBigQueryExport Uses

func ValidateBigQueryExport(bq_export *pb.BigQueryExport) error

ValidateBigQueryExport returns a non-nil error if bq_export 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 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 ValidateMaxStaleness Uses

func ValidateMaxStaleness(maxStaleness *durationpb.Duration) error

ValidateMaxStaleness returns a non-nil error if maxStaleness 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 ValidateStringPair Uses

func ValidateStringPair(p *typepb.StringPair) error

ValidateStringPair returns an error if p is invalid.

func ValidateStringPairs Uses

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

ValidateStringPairs returns an error if any of the pairs 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 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 ValidateVariant Uses

func ValidateVariant(vr *typepb.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) *typepb.Variant

Variant creates a typepb.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) (*typepb.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 *typepb.Variant) string

VariantHash returns a short hash of the variant.

func VariantToStrings Uses

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

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

Package pbutil imports 16 packages (graph) and is imported by 9 packages. Updated 2020-01-06. Refresh now. Tools for package owners.