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 ¶
LastNLines reads the last n lines from an artifact.
func LastNLinesChunked ¶
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 ResourceDirForLens ¶
ResourceDirForLens returns the path to a lens's public resource directory.
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.
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 |
Click to show internal directories.
Click to hide internal directories.