lenses

package
v0.0.0-...-d7867ec Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2018 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package lenses provides interfaces and methods necessary for implementing custom artifact viewers

Index

Constants

This section is empty.

Variables

View Source
var (

	// ErrGzipOffsetRead will be thrown when an offset read is attempted on a gzip-compressed object
	ErrGzipOffsetRead = errors.New("offset read on gzipped files unsupported")
	// ErrInvalidLensName will be thrown when a viewer method is called on a view name that has not
	// been registered. Ensure your viewer is registered using RegisterViewer and that you are
	// providing the correct viewer name.
	ErrInvalidLensName = errors.New("invalid lens name")
	// ErrFileTooLarge will be thrown when a size-limited operation (ex. ReadAll) is called on an
	// artifact whose size exceeds the configured limit.
	ErrFileTooLarge = errors.New("file size over specified limit")
	// ErrContextUnsupported is thrown when attempting to use a context with an artifact that
	// does not support context operations (cancel, withtimeout, etc.)
	ErrContextUnsupported = errors.New("artifact does not support context operations")
)

Functions

func LastNLines

func LastNLines(a Artifact, n int64) ([]string, error)

LastNLines reads the last n lines from an artifact.

func LastNLinesChunked

func LastNLinesChunked(a Artifact, n, chunkSize int64) ([]string, error)

LastNLinesChunked reads the last n lines from an artifact by reading chunks of size chunkSize from the end of the artifact. Best performance is achieved by: argmin 0<chunkSize<INTMAX, f(chunkSize) = chunkSize - n * avgLineLength

func RegisterLens

func RegisterLens(lens Lens) error

RegisterLens registers new viewers

func ResourceDirForLens

func ResourceDirForLens(baseDir, name string) string

ResourceDirForLens returns the path to a lens's public resource directory.

func UnregisterLens

func UnregisterLens(viewerName string)

UnregisterLens unregisters lenses

Types

type Artifact

type Artifact interface {
	// ReadAt reads len(p) bytes of the artifact at offset off. (unsupported on some compressed files)
	ReadAt(p []byte, off int64) (n int, err error)
	// ReadAtMost reads at most n bytes from the beginning of the artifact
	ReadAtMost(n int64) ([]byte, error)
	// CanonicalLink gets a link to viewing this artifact in storage
	CanonicalLink() string
	// JobPath is the path to the artifact within the job (i.e. without the job prefix)
	JobPath() string
	// ReadAll reads all bytes from the artifact up to a limit specified by the artifact
	ReadAll() ([]byte, error)
	// ReadTail reads the last n bytes from the artifact (unsupported on some compressed files)
	ReadTail(n int64) ([]byte, error)
	// Size gets the size of the artifact in bytes, may make a network call
	Size() (int64, error)
}

Artifact represents some output of a prow job

type Lens

type Lens interface {
	// Name returns the name of the lens. It must match the package name.
	Name() string
	// Title returns a human-readable title for the lens.
	Title() string
	// Priority returns a number used to sort viewers. Lower is more important.
	Priority() int
	// Header returns a a string that is injected into the rendered lens's <head>
	Header(artifacts []Artifact, resourceDir string) string
	// Body returns a string that is initially injected into the rendered lens's <body>.
	// The lens's front-end code may call back to Body again, passing in some data string of its choosing.
	Body(artifacts []Artifact, resourceDir string, data string) string
	// Callback receives a string sent by the lens's front-end code and returns another string to be returned
	// to that frontend code.
	Callback(artifacts []Artifact, resourceDir string, data string) string
}

Lens defines the interface that lenses are required to implement in order to be used by Spyglass.

func GetLens

func GetLens(name string) (Lens, error)

GetLens returns a Lens by name, if it exists; otherwise it returns an error.

Directories

Path Synopsis
Package buildlog provides a build log viewer for Spyglass
Package buildlog provides a build log viewer for Spyglass
Package junit provides a junit viewer for Spyglass
Package junit provides a junit viewer for Spyglass
Package metadata provides a metadata viewer for Spyglass
Package metadata provides a metadata viewer for Spyglass

Jump to

Keyboard shortcuts

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