artifacts

package
v0.0.0-...-c1dffae Latest Latest
Warning

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

Go to latest
Published: May 23, 2024 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Overview

Package artifacts contains tools for reading and processing artifacts.

Index

Constants

View Source
const (
	RFC3339FullDate = "2006-01-02"
	PstTimeZone     = "America/Los_Angeles"
	UtcTimeZone     = "UTC"
)

Variables

View Source
var ContentHashRe = regexp.MustCompile(fmt.Sprintf(`^%s:%s$`, hashFunc, sha256Pattern))
View Source
var SupportedContentTypes = map[string]bool{
	"application/octet-stream": true,
	"application/x-gzip":       true,
}

Functions

func AddHashPrefix

func AddHashPrefix(hash string) string

AddHashPrefix adds HashFunc to a given hash string.

func MustParseName

func MustParseName(name string) (invID invocations.ID, testID, resultID, artifactID string)

MustParseName extracts invocation, test, result and artifactIDs. Test and result IDs are "" if this is a invocation-level artifact. Panics on failure.

func ParentID

func ParentID(testID, resultID string) string

ParentID returns a value for Artifacts.ParentId Spanner column.

func ParseParentID

func ParseParentID(parentID string) (testID, resultID string, err error)

ParseParentID parses parentID into testID and resultID. If the artifact's parent is invocation, then testID and resultID are "".

func ToLogLines

func ToLogLines(artifactID string, contentType string, content []byte, year, maxLines, maxBytes int) ([]*pb.ArtifactLine, error)

ToLogLines retrieves and processes an artifact and returns its content as a set of log lines. It executes best effort extraction of the timestamp and the severity of each log line. The `year` is used as a fallback if the year was absent from the log line's timestamp. The max specified the maximum number of results to return, if the max <= 0 it will return all lines.

func TrimHashPrefix

func TrimHashPrefix(hash string) string

TrimHashPrefix removes HashFunc from a given hash string.

func VerifyReadArtifactPermission

func VerifyReadArtifactPermission(ctx context.Context, name string) error

VerifyReadArtifactPermission verifies if the caller has enough permissions to read the artifact.

Types

type Artifact

type Artifact struct {
	*pb.Artifact
	RBECASHash string
}

Artifact contains pb.Artifact and its RBECAS hash.

func Read

func Read(ctx context.Context, name string) (*Artifact, error)

Read reads an artifact and returns and Artifact row from the database. It contains the following fields: * ContentType * Size * GcsURI * RBECASHash

type Query

type Query struct {
	InvocationIDs       invocations.IDSet
	ParentIDRegexp      string
	FollowEdges         *pb.ArtifactPredicate_EdgeTypeSet
	TestResultPredicate *pb.TestResultPredicate
	ContentTypeRegexp   string
	ArtifactIDRegexp    string
	PageSize            int // must be positive
	PageToken           string
	WithRBECASHash      bool
	WithGcsURI          bool
}

Query specifies artifacts to fetch.

func (*Query) FetchProtos

func (q *Query) FetchProtos(ctx context.Context) (arts []*pb.Artifact, nextPageToken string, err error)

FetchProtos returns a page of artifact protos matching q.

Returned artifacts are ordered by level (invocation or test result). Test result artifacts are sorted by parent invocation ID, test ID and artifact ID.

func (*Query) Run

func (q *Query) Run(ctx context.Context, f func(*Artifact) error) error

Run calls f for artifacts matching the query.

Refer to Fetch() for the ordering of returned artifacts.

Jump to

Keyboard shortcuts

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