results

package
v0.11.0-rc.1 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2018 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package results provides a low level API to extract data from a Sonobuoy result archive.

Index

Examples

Constants

View Source
const (
	// UnknownVersion lets the consumer know if this client can detect the archive version or not.
	UnknownVersion = "v?.?"
	VersionEight   = "v0.8"
	VersionNine    = "v0.9"
	VersionTen     = "v0.10"
)
View Source
const (
	// PluginsDir defines where in the archive the plugin results are.
	PluginsDir = "plugins/"
)

Variables

This section is empty.

Functions

func ConfigFile

func ConfigFile(version string) string

ConfigFile returns the path to the sonobuoy config file. This is not a method as it is used to determine the version of the archive.

func DiscoverVersion

func DiscoverVersion(reader io.Reader) (string, error)

DiscoverVersion takes a Sonobuoy archive stream and extracts just the version of the archive.

func ExtractBytes

func ExtractBytes(file string, path string, info os.FileInfo, buf *bytes.Buffer) error

ExtractBytes pulls out bytes into a buffer for any path matching file.

func ExtractConfig

func ExtractConfig(path string, info os.FileInfo, conf *config.Config) error

ExtractConfig populates the config object regardless of version.

func ExtractFileIntoStruct

func ExtractFileIntoStruct(file, path string, info os.FileInfo, object interface{}) error

ExtractFileIntoStruct is a helper for a common use case of extracting the contents of one file into the object.

func ExtractIntoStruct

func ExtractIntoStruct(predicate func(string) bool, path string, info os.FileInfo, object interface{}) error

ExtractIntoStruct takes a predicate function and some file information and decodes the contents of the file that matches the predicate into the interface passed in (generally a pointer to a struct/slice).

func Failed

func Failed(testCase reporters.JUnitTestCase) bool

Failed returns true if the test failed.

func Filter

func Filter(predicate func(testCase reporters.JUnitTestCase) bool, testSuite reporters.JUnitTestSuite) []reporters.JUnitTestCase

Filter keeps only the tests that match the predicate function.

func Passed

func Passed(testCase reporters.JUnitTestCase) bool

Passed returns true if the test passed.

func Skipped

func Skipped(testCase reporters.JUnitTestCase) bool

Skipped returns true if the test was skipped.

Types

type AlphabetizedTestCases

type AlphabetizedTestCases []reporters.JUnitTestCase

AlphabetizedTestCases implements Sort over the list of testCases.

func (AlphabetizedTestCases) Len

func (a AlphabetizedTestCases) Len() int

func (AlphabetizedTestCases) Less

func (a AlphabetizedTestCases) Less(i, j int) bool

func (AlphabetizedTestCases) Swap

func (a AlphabetizedTestCases) Swap(i, j int)

type Metadata

type Metadata struct {
	// Config is the config used during this Sonobuoy run.
	Config config.Config

	// QueryMetadata shows information about each query Sonobuoy ran in the
	// cluster.
	QueryData []discovery.QueryData
}

Metadata is the data about the Sonobuoy run and how long it took to query the system.

type Reader

type Reader struct {
	io.Reader
	Version string
}

Reader holds a reader and a version. It uses the version to know where to find files within the archive.

func NewReaderFromBytes

func NewReaderFromBytes(data []byte) (*Reader, error)

NewReaderFromBytes is a helper constructor that will discover the version of the archive and return a new Reader with the correct version already populated.

Example
package main

import (
	"fmt"
	"io/ioutil"

	"github.com/heptio/sonobuoy/pkg/client/results"
)

func main() {
	path := "testdata/results-0.8.tar.gz"
	data, err := ioutil.ReadFile(path)
	if err != nil {
		panic(err)
	}
	results, err := results.NewReaderFromBytes(data)
	if err != nil {
		panic(err)
	}
	fmt.Println(results.Version)
}
Output:

v0.8

func NewReaderWithVersion

func NewReaderWithVersion(reader io.Reader, version string) *Reader

NewReaderWithVersion creates a results.Reader that interprets a results archive of the version passed in. Useful if the reader can be read only once and if the version of the data to read is known.

Example
package main

import (
	"compress/gzip"
	"fmt"
	"os"

	"github.com/heptio/sonobuoy/pkg/client/results"
)

func main() {
	path := "testdata/results-0.9.tar.gz"
	f, err := os.Open(path)
	if err != nil {
		panic(err)
	}
	reader, err := gzip.NewReader(f)
	if err != nil {
		panic(err)
	}
	r := results.NewReaderWithVersion(reader, results.VersionNine)
	fmt.Println(r.Version)
}
Output:

v0.9

func (*Reader) Metadata

func (r *Reader) Metadata() string

Metadata is the location of the metadata directory in the results archive.

func (*Reader) NamespacedResources

func (r *Reader) NamespacedResources() string

NamespacedResources returns the path to the directory that contains information about namespaced Kubernetes resources.

func (*Reader) NodesFile

func (r *Reader) NodesFile() string

NodesFile returns the path to the file that lists the nodes of the Kubernetes cluster.

func (*Reader) NonNamespacedResources

func (r *Reader) NonNamespacedResources() string

NonNamespacedResources returns the path to the non-namespaced directory.

func (*Reader) ServerGroupsFile

func (r *Reader) ServerGroupsFile() string

ServerGroupsFile returns the path to the groups the Kubernetes API supported at the time of the run.

func (*Reader) ServerVersionFile

func (r *Reader) ServerVersionFile() string

ServerVersionFile is the location of the file that contains the Kubernetes version Sonobuoy ran on.

func (*Reader) WalkFiles

func (r *Reader) WalkFiles(walkfn filepath.WalkFunc) error

WalkFiles walks all of the files in the archive.

Directories

Path Synopsis
package e2e defines files and directories found in the e2e plugin results.
package e2e defines files and directories found in the e2e plugin results.

Jump to

Keyboard shortcuts

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