spyglass

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 3, 2023 License: Apache-2.0 Imports: 29 Imported by: 0

README

DOCUMENTATION DEPRECATION NOTICE: This file is deprecated. Please refer to the new migrated location. Please do not edit this file; instead, make changes to the new location!

The new location is served on the web at https://docs.prow.k8s.io/docs/.

This file will be deleted on 2023-02-28.

Documentation

Overview

Package spyglass creates views for Prow job artifacts.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrCannotParseSource is returned by newStorageJobSource when an incorrectly formatted source string is passed
	ErrCannotParseSource = errors.New("could not create job source from provided source")
)

Functions

This section is empty.

Types

type ExtraLink struct {
	Name        string
	Description string
	URL         string
}

ExtraLink represents an extra link to be added to the Spyglass page.

type LensConfig

type LensConfig interface {
	Config() lenses.LensConfig
}

type LensRequest

type LensRequest struct {
	Source    string   `json:"src"`
	Index     int      `json:"index"`
	Artifacts []string `json:"artifacts"`
}

LensRequest holds data sent by a view

type PodLogArtifact

type PodLogArtifact struct {
	// contains filtered or unexported fields
}

PodLogArtifact holds data for reading from a specific pod log

func NewPodLogArtifact

func NewPodLogArtifact(jobName string, buildID string, artifactName string, container string, sizeLimit int64, ja jobAgent) (*PodLogArtifact, error)

NewPodLogArtifact creates a new PodLogArtifact

func (a *PodLogArtifact) CanonicalLink() string

CanonicalLink returns a link to where pod logs are streamed

func (*PodLogArtifact) JobPath

func (a *PodLogArtifact) JobPath() string

JobPath gets the path within the job for the pod log. Always returns build-log.txt if we have only 1 test container in the ProwJob. Returns <containerName>-build-log.txt if we have multiple containers in the ProwJob. This is because the pod log becomes the build log after the job artifact uploads are complete, which should be used instead of the pod log.

func (*PodLogArtifact) Metadata

func (a *PodLogArtifact) Metadata() (map[string]string, error)

func (*PodLogArtifact) ReadAll

func (a *PodLogArtifact) ReadAll() ([]byte, error)

ReadAll reads all available pod logs, failing if they are too large

func (*PodLogArtifact) ReadAt

func (a *PodLogArtifact) ReadAt(p []byte, off int64) (n int, err error)

ReadAt implements reading a range of bytes from the pod logs endpoint

func (*PodLogArtifact) ReadAtMost

func (a *PodLogArtifact) ReadAtMost(n int64) ([]byte, error)

ReadAtMost reads at most n bytes

func (*PodLogArtifact) ReadTail

func (a *PodLogArtifact) ReadTail(n int64) ([]byte, error)

ReadTail reads the last n bytes of the pod log

func (*PodLogArtifact) Size

func (a *PodLogArtifact) Size() (int64, error)

Size gets the size of the pod log. Note: this function makes the same network call as reading the entire file.

func (*PodLogArtifact) UpdateMetadata

func (a *PodLogArtifact) UpdateMetadata(meta map[string]string) error

type PodLogArtifactFetcher

type PodLogArtifactFetcher struct {
	// contains filtered or unexported fields
}

PodLogArtifactFetcher is used to fetch artifacts from k8s apiserver

func NewPodLogArtifactFetcher

func NewPodLogArtifactFetcher(ja jobAgent) *PodLogArtifactFetcher

NewPodLogArtifactFetcher returns a PodLogArtifactFetcher using the given job agent as storage

func (*PodLogArtifactFetcher) Artifact

func (af *PodLogArtifactFetcher) Artifact(_ context.Context, key, artifactName string, sizeLimit int64) (api.Artifact, error)

artifact constructs an artifact handle for the given job build

type Spyglass

type Spyglass struct {
	// JobAgent contains information about the current jobs in deck
	JobAgent *jobs.JobAgent

	*StorageArtifactFetcher
	*PodLogArtifactFetcher
	// contains filtered or unexported fields
}

Spyglass records which sets of artifacts need views for a Prow job. The metaphor can be understood as follows: A spyglass receives light from a source through an eyepiece, which has a lens that ultimately presents a view of the light source to the observer. Spyglass receives light (artifacts) via a source (src) through the eyepiece (Eyepiece) and presents the view (what you see in your browser) via a lens (Lens).

func New

func New(ctx context.Context, ja *jobs.JobAgent, cfg config.Getter, opener pkgio.Opener, useCookieAuth bool) *Spyglass

New constructs a Spyglass object from a JobAgent, a config.Agent, and a storage Client.

func (sg *Spyglass) ExtraLinks(ctx context.Context, src string) ([]ExtraLink, error)

ExtraLinks fetches started.json and extracts links from metadata.links.

func (*Spyglass) FetchArtifacts

func (s *Spyglass) FetchArtifacts(ctx context.Context, src string, podName string, sizeLimit int64, artifactNames []string) ([]api.Artifact, error)

FetchArtifacts constructs and returns Artifact objects for each artifact name in the list. This includes getting any handles needed for read write operations, direct artifact links, etc.

func (*Spyglass) JobPath

func (sg *Spyglass) JobPath(src string) (string, error)

JobPath returns a link to the directory for the job specified in src

func (*Spyglass) Lenses

func (sg *Spyglass) Lenses(lensConfigIndexes []int) (orderedIndexes []int, lensMap map[int]LensConfig)

Lenses gets all views of all artifact files matching each regexp with a registered lens

func (*Spyglass) ListArtifacts

func (s *Spyglass) ListArtifacts(ctx context.Context, src string) ([]string, error)

ListArtifacts gets the names of all artifacts available from the given source

func (*Spyglass) ProwJob

func (sg *Spyglass) ProwJob(src string) (string, string, prowapi.ProwJobState, error)

ProwJob returns a link and state to the YAML for the job specified in src. If no job is found, it returns empty strings and nil error.

func (sg *Spyglass) ResolveSymlink(src string) (string, error)

func (*Spyglass) RunPath

func (sg *Spyglass) RunPath(src string) (string, error)

RunPath returns the path to the directory for the job run specified in src.

func (*Spyglass) RunToPR

func (sg *Spyglass) RunToPR(src string) (string, string, int, error)

RunToPR returns the (org, repo, pr#) tuple referenced by the provided src. Returns an error if src does not reference a job with an associated PR.

func (*Spyglass) Start

func (sg *Spyglass) Start()
func (sg *Spyglass) TestGridLink(src string) (string, error)

TestGridLink returns a link to a relevant TestGrid tab for the given source string. Because there is a one-to-many mapping from job names to TestGrid tabs, the returned tab link may not be deterministic.

type StorageArtifact

type StorageArtifact struct {
	// contains filtered or unexported fields
}

StorageArtifact represents some output of a prow job stored in GCS

func NewStorageArtifact

func NewStorageArtifact(ctx context.Context, handle artifactHandle, link string, path string, sizeLimit int64) *StorageArtifact

NewStorageArtifact returns a new StorageArtifact with a given handle, canonical link, and path within the job

func (a *StorageArtifact) CanonicalLink() string

CanonicalLink gets the GCS web address of the artifact

func (*StorageArtifact) JobPath

func (a *StorageArtifact) JobPath() string

JobPath gets the GCS path of the artifact within the current job

func (*StorageArtifact) Metadata

func (a *StorageArtifact) Metadata() (map[string]string, error)

func (*StorageArtifact) ReadAll

func (a *StorageArtifact) ReadAll() ([]byte, error)

ReadAll will either read the entire file or throw an error if file size is too big

func (*StorageArtifact) ReadAt

func (a *StorageArtifact) ReadAt(p []byte, off int64) (n int, err error)

ReadAt reads len(p) bytes from a file in GCS at offset off

func (*StorageArtifact) ReadAtMost

func (a *StorageArtifact) ReadAtMost(n int64) ([]byte, error)

ReadAtMost reads at most n bytes from a file in GCS. If the file is compressed (gzip) in GCS, n bytes of gzipped content will be downloaded and decompressed into potentially GREATER than n bytes of content.

func (*StorageArtifact) ReadTail

func (a *StorageArtifact) ReadTail(n int64) ([]byte, error)

ReadTail reads the last n bytes from a file in GCS

func (*StorageArtifact) Size

func (a *StorageArtifact) Size() (int64, error)

Size returns the size of the artifact in GCS

func (*StorageArtifact) UpdateMetadata

func (a *StorageArtifact) UpdateMetadata(meta map[string]string) error

type StorageArtifactFetcher

type StorageArtifactFetcher struct {
	// contains filtered or unexported fields
}

StorageArtifactFetcher contains information used for fetching artifacts from GCS

func NewStorageArtifactFetcher

func NewStorageArtifactFetcher(opener pkgio.Opener, cfg config.Getter, useCookieAuth bool) *StorageArtifactFetcher

NewStorageArtifactFetcher creates a new ArtifactFetcher with a real GCS Client

func (*StorageArtifactFetcher) Artifact

func (af *StorageArtifactFetcher) Artifact(ctx context.Context, key string, artifactName string, sizeLimit int64) (api.Artifact, error)

Artifact constructs a GCS artifact from the given GCS bucket and key. Uses the golang GCS library to get read handles. If the artifactName is not a valid key in the bucket a handle will still be constructed and returned, but all read operations will fail (dictated by behavior of golang GCS lib). If no scheme is given we assume GS, e.g.: * test-bucket/logs/sig-flexing/example-ci-run/403 or * gs://test-bucket/logs/sig-flexing/example-ci-run/403

type TestGrid

type TestGrid struct {
	// contains filtered or unexported fields
}

TestGrid manages a TestGrid configuration, and handles lookups of TestGrid configuration.

func (*TestGrid) FindQuery

func (tg *TestGrid) FindQuery(jobName string) (string, error)

FindPath returns a 'query' for a job name, e.g. 'sig-testing-misc#bazel' for ci-test-infra-bazel. This is based on the same logic Gubernator uses: find the dashboard with the fewest tabs, where our tab doesn't have any BaseOptions.

func (*TestGrid) Ready

func (tg *TestGrid) Ready() bool

Ready returns true if a usable TestGrid config is loaded, otherwise false.

func (*TestGrid) Start

func (tg *TestGrid) Start()

Start synchronously requests the testgrid config, then continues to update it periodically.

Directories

Path Synopsis
Package lenses provides interfaces and methods necessary for implementing custom artifact viewers
Package lenses provides interfaces and methods necessary for implementing custom artifact viewers
buildlog
Package buildlog provides a build log viewer for Spyglass
Package buildlog provides a build log viewer for Spyglass
coverage
Package coverage provides a coverage viewer for Spyglass
Package coverage provides a coverage viewer for Spyglass
junit
Package junit provides a junit viewer for Spyglass
Package junit provides a junit viewer for Spyglass
metadata
Package metadata provides a metadata viewer for Spyglass
Package metadata provides a metadata viewer for Spyglass
podinfo
Package podinfo provides a coverage viewer for Spyglass
Package podinfo provides a coverage viewer for Spyglass

Jump to

Keyboard shortcuts

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