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
- func AsTime(ts *timestamppb.Timestamp) (time.Time, error)
- func ChangelistFromResultDB(cl *rdbpb.GerritChange) *pb.GerritChange
- func ChangelistToResultDB(cl *pb.GerritChange) *rdbpb.GerritChange
- func ExonerationReasonFromResultDB(s rdbpb.ExonerationReason) pb.ExonerationReason
- func FailureReasonFromResultDB(fr *rdbpb.FailureReason) *pb.FailureReason
- func GitilesCommitFromResultDB(c *rdbpb.GitilesCommit) *pb.GitilesCommit
- func GitilesCommitToResultDB(c *pb.GitilesCommit) *rdbpb.GitilesCommit
- func MetricThresholdByID(id string, thresholds []*configpb.ImpactMetricThreshold) *configpb.MetricThreshold
- func MustTimestampProto(t time.Time) *timestamppb.Timestamp
- func PresubmitRunModeFromString(mode string) (pb.PresubmitRunMode, error)
- func PresubmitRunStatusFromLUCICV(status cvv0.Run_Status) (pb.PresubmitRunStatus, error)
- func SkipReasonFromResultDB(sr rdbpb.SkipReason) pb.SkipReason
- func SortedVariantKeys(vr *pb.Variant) []string
- func SourcePosition(sources *pb.Sources) int64
- func SourceRefFromSources(sources *pb.Sources) *pb.SourceRef
- func SourceRefHash(sourceRef *pb.SourceRef) []byte
- func SourceRefToResultDB(v *pb.SourceRef) *rdbpb.SourceRef
- func SourcesFromResultDB(s *rdbpb.Sources) *pb.Sources
- func SourcesToResultDB(s *pb.Sources) *rdbpb.Sources
- func StringPair(k, v string) *pb.StringPair
- func StringPairFromResultDB(v []*rdbpb.StringPair) []*pb.StringPair
- func StringPairFromString(s string) (*pb.StringPair, error)
- func StringPairToString(pair *pb.StringPair) string
- func StringPairs(pairs ...string) []*pb.StringPair
- func StringPairsToStrings(pairs ...*pb.StringPair) []string
- func TestMetadataFromResultDB(rdbTmd *rdbpb.TestMetadata) *pb.TestMetadata
- func TestResultIDFromResultDB(name string) *pb.TestResultId
- func TestResultStatusFromResultDB(s rdbpb.TestStatus) pb.TestResultStatus
- func TestVerdictStatusFromResultDB(s rdbpb.TestVariantStatus) pb.TestVerdictStatus
- func ValidateEnum(value int32, validValues map[int32]string) error
- func ValidateFailureReason(fr *pb.FailureReason) error
- func ValidateProject(project string) error
- func ValidateSourceRef(ref *pb.SourceRef) error
- func ValidateSources(sources *pb.Sources) error
- func ValidateStringPair(p *pb.StringPair) error
- func ValidateTestID(testID string) error
- func ValidateTestVerdictPredicate(predicate *pb.TestVerdictPredicate) error
- func ValidateTimeRange(ctx context.Context, tr *pb.TimeRange) error
- func ValidateVariant(vr *pb.Variant) error
- func ValidateVariantPredicate(p *pb.VariantPredicate) error
- func Variant(pairs ...string) *pb.Variant
- func VariantFromJSON(variant string) (*pb.Variant, error)
- func VariantFromResultDB(v *rdbpb.Variant) *pb.Variant
- func VariantFromStrings(pairs []string) (*pb.Variant, error)
- func VariantHash(v *pb.Variant) string
- func VariantToJSON(variant *pb.Variant) (string, error)
- func VariantToResultDB(v *pb.Variant) *rdbpb.Variant
- func VariantToStringPairs(vr *pb.Variant) []*pb.StringPair
- func VariantToStrings(vr *pb.Variant) []string
Constants ¶
const EmptyJSON = "{}"
EmptyJSON corresponds to a serialized, empty JSON object.
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 ¶
SortedVariantKeys returns the keys in the variant as a sorted slice.
func SourcePosition ¶
SourcePosition returns the position along the source ref tested by the given sources.
panics if the sources object is not valid.
func SourceRefFromSources ¶
SourceRefFromSources extracts a SourceRef from given sources.
panics if the sources object is not valid.
func SourceRefHash ¶
SourceRefHash returns a short hash of the source ref.
func SourceRefToResultDB ¶
SourceRefToResultDB returns a ResultDB SourceRef corresponding to the supplied LUCI Analysis SourceRef.
func SourcesFromResultDB ¶
SourcesFromResultDB returns the LUCI Analysis source description corresponding to a ResultDB source description.
func SourcesToResultDB ¶
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 ¶
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 ValidateSourceRef ¶
func ValidateSources ¶
ValidateSources validates a set of sources.
func ValidateStringPair ¶
func ValidateStringPair(p *pb.StringPair) error
ValidateStringPair returns an error if p is invalid.
func ValidateTestVerdictPredicate ¶
func ValidateTestVerdictPredicate(predicate *pb.TestVerdictPredicate) error
ValidateTestVerdictPredicate returns a non-nil error if p is determined to be invalid.
func ValidateTimeRange ¶
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 ¶
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 ¶
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 ¶
VariantFromJSON convert json string representation of the variant into protocol buffer.
func VariantFromResultDB ¶
VariantFromResultDB returns a LUCI Analysis Variant corresponding to the supplied ResultDB Variant.
func VariantFromStrings ¶
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 ¶
VariantHash returns a hash of the variant.
func VariantToJSON ¶
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 ¶
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 ¶
VariantToStrings returns a key:val string slice representation of the Variant. Never returns nil.
Types ¶
This section is empty.