pbutil

package
v0.0.0-...-45e446d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 28, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package pbutil contains methods for manipulating LUCI Analysis protos.

Package pbutil contains methods for manipulating LUCI Analysis protos.

Package pbutil contains methods for manipulating LUCI Analysis protos.

Package pbutil contains methods for manipulating LUCI Analysis protos.

Index

Constants

View Source
const EmptyJSON = "{}"

EmptyJSON corresponds to a serialized, empty JSON object.

View Source
const ProjectRePattern = `[a-z0-9\-]{1,40}`

ProjectRePattern is the regular expression pattern that matches validly formed LUCI Project names. From https://source.chromium.org/chromium/infra/infra/+/main:luci/appengine/components/components/config/common.py?q=PROJECT_ID_PATTERN

Variables

This section is empty.

Functions

func AsTime

func AsTime(ts *timestamppb.Timestamp) (time.Time, error)

AsTime converts a *timestamppb.Timestamp to a time.Time.

func ChangelistFromResultDB

func ChangelistFromResultDB(cl *rdbpb.GerritChange) *pb.GerritChange

ChangelistFromResultDB returns the LUCI Analysis gerrit changelist corresponding to a ResultDB gerrit changelist.

func ChangelistToResultDB

func ChangelistToResultDB(cl *pb.GerritChange) *rdbpb.GerritChange

ChangelistToResultDB returns the ResultDB gerrit changelist corresponding to a LUCI Analysis gerrit changelist.

func ExonerationReasonFromResultDB

func ExonerationReasonFromResultDB(s rdbpb.ExonerationReason) pb.ExonerationReason

ExonerationReasonFromResultDB converts a ResultDB ExonerationReason to a LUCI Analysis ExonerationReason.

func FailureReasonFromResultDB

func FailureReasonFromResultDB(fr *rdbpb.FailureReason) *pb.FailureReason

FailureReasonFromResultDB returns a LUCI Analysis FailureReason corresponding to the supplied ResultDB FailureReason.

func GitilesCommitFromResultDB

func GitilesCommitFromResultDB(c *rdbpb.GitilesCommit) *pb.GitilesCommit

GitilesCommitFromResultDB returns the LUCI Analysis gitiles commit corresponding to a ResultDB gitiles commit.

func GitilesCommitToResultDB

func GitilesCommitToResultDB(c *pb.GitilesCommit) *rdbpb.GitilesCommit

GitilesCommitToResultDB returns the ResultDB gitiles commit corresponding to a LUCI Analysis gitiles commit.

func MetricThresholdByID

func MetricThresholdByID(id string, thresholds []*configpb.ImpactMetricThreshold) *configpb.MetricThreshold

MetricThresholdByID returns the metricThreshold with the given id from a list of thresholds. It returns nil if the metric id doesn't exist in the thresholds list.

func MustTimestampProto

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

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

func PresubmitRunModeFromString

func PresubmitRunModeFromString(mode string) (pb.PresubmitRunMode, error)

PresubmitRunModeFromString returns a pb.PresubmitRunMode corresponding to a CV Run mode string.

func PresubmitRunStatusFromLUCICV

func PresubmitRunStatusFromLUCICV(status cvv0.Run_Status) (pb.PresubmitRunStatus, error)

PresubmitRunStatusFromLUCICV returns a pb.PresubmitRunStatus corresponding to a LUCI CV Run status. Only statuses corresponding to an ended run are supported.

func SkipReasonFromResultDB

func SkipReasonFromResultDB(sr rdbpb.SkipReason) pb.SkipReason

SkipReasonFromResultDB returns a LUCI Analysis SkipReason corresponding to the supplied ResultDB SkipReason.

func SortedVariantKeys

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

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

func SourcePosition

func SourcePosition(sources *pb.Sources) int64

SourcePosition returns the position along the source ref tested by the given sources.

panics if the sources object is not valid.

func SourceRefFromSources

func SourceRefFromSources(sources *pb.Sources) *pb.SourceRef

SourceRefFromSources extracts a SourceRef from given sources.

panics if the sources object is not valid.

func SourceRefHash

func SourceRefHash(sourceRef *pb.SourceRef) []byte

SourceRefHash returns a short hash of the source ref.

func SourceRefToResultDB

func SourceRefToResultDB(v *pb.SourceRef) *rdbpb.SourceRef

SourceRefToResultDB returns a ResultDB SourceRef corresponding to the supplied LUCI Analysis SourceRef.

func SourcesFromResultDB

func SourcesFromResultDB(s *rdbpb.Sources) *pb.Sources

SourcesFromResultDB returns the LUCI Analysis source description corresponding to a ResultDB source description.

func SourcesToResultDB

func SourcesToResultDB(s *pb.Sources) *rdbpb.Sources

SourcesToResultDB returns the ResultDB source description corresponding to a LUCI Analysis source description.

func StringPair

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

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

func StringPairFromResultDB

func StringPairFromResultDB(v []*rdbpb.StringPair) []*pb.StringPair

StringPairFromResultDB returns a LUCI Analysis StringPair corresponding to the supplied ResultDB StringPair.

func StringPairFromString

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

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

func StringPairToString

func StringPairToString(pair *pb.StringPair) string

StringPairToString converts a StringPair to a key:val string.

func StringPairs

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 StringPairsToStrings

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

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

func TestMetadataFromResultDB

func TestMetadataFromResultDB(rdbTmd *rdbpb.TestMetadata) *pb.TestMetadata

TestMetadataFromResultDB converts a ResultDB TestMetadata to a LUCI Analysis TestMetadata.

func TestResultIDFromResultDB

func TestResultIDFromResultDB(name string) *pb.TestResultId

TestResultIDFromResultDB returns a LUCI Analysis TestResultId corresponding to the supplied ResultDB test result name. The format of name should be: "invocations/{INVOCATION_ID}/tests/{URL_ESCAPED_TEST_ID}/results/{RESULT_ID}".

func TestResultStatusFromResultDB

func TestResultStatusFromResultDB(s rdbpb.TestStatus) pb.TestResultStatus

TestResultStatusFromResultDB returns the LUCI Analysis test result status corresponding to the given ResultDB test result status.

func TestVerdictStatusFromResultDB

func TestVerdictStatusFromResultDB(s rdbpb.TestVariantStatus) pb.TestVerdictStatus

TestVerdictStatusFromResultDB returns the LUCI Analysis test verdict status corresponding to the given ResultDB test variant status.

func ValidateEnum

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

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

func ValidateFailureReason

func ValidateFailureReason(fr *pb.FailureReason) error

ValidateFailureReason validates a failure reason.

func ValidateProject

func ValidateProject(project string) error

func ValidateSourceRef

func ValidateSourceRef(ref *pb.SourceRef) error

func ValidateSources

func ValidateSources(sources *pb.Sources) error

ValidateSources validates a set of sources.

func ValidateStringPair

func ValidateStringPair(p *pb.StringPair) error

ValidateStringPair returns an error if p is invalid.

func ValidateTestID

func ValidateTestID(testID string) error

ValidateTestID validates a test ID.

func ValidateTestVerdictPredicate

func ValidateTestVerdictPredicate(predicate *pb.TestVerdictPredicate) error

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

func ValidateTimeRange

func ValidateTimeRange(ctx context.Context, tr *pb.TimeRange) error

ValidateTimeRange returns a non-nil error if tr is determined to be invalid. To be valid, a TimeRange must have both Earliest and Latest fields specified, and the Earliest time must be chronologically before the Latest time.

func ValidateVariant

func ValidateVariant(vr *pb.Variant) error

ValidateVariant returns an error if vr is invalid.

func ValidateVariantPredicate

func ValidateVariantPredicate(p *pb.VariantPredicate) error

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

func Variant

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 VariantFromJSON

func VariantFromJSON(variant string) (*pb.Variant, error)

VariantFromJSON convert json string representation of the variant into protocol buffer.

func VariantFromResultDB

func VariantFromResultDB(v *rdbpb.Variant) *pb.Variant

VariantFromResultDB returns a LUCI Analysis Variant corresponding to the supplied ResultDB Variant.

func VariantFromStrings

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

func VariantHash(v *pb.Variant) string

VariantHash returns a hash of the variant.

func VariantToJSON

func VariantToJSON(variant *pb.Variant) (string, error)

VariantToJSON returns the JSON equivalent for a variant. Each key in the variant is mapped to a top-level key in the JSON object. e.g. `{"builder":"linux-rel","os":"Ubuntu-18.04"}`

func VariantToResultDB

func VariantToResultDB(v *pb.Variant) *rdbpb.Variant

VariantToResultDB returns a ResultDB Variant corresponding to the supplied LUCI Analysis Variant.

func VariantToStringPairs

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

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

func VariantToStrings

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

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

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL