Documentation ¶
Index ¶
- Constants
- Variables
- func ValidLabel(s Label) bool
- type Baseline
- type Classifier
- type Expectations
- func (e *Expectations) AsBaseline() Baseline
- func (e *Expectations) Classification(test types.TestName, digest types.Digest) Label
- func (e *Expectations) DeepCopy() *Expectations
- func (e *Expectations) Empty() bool
- func (e *Expectations) ForAll(fn func(types.TestName, types.Digest, Label) error) error
- func (e *Expectations) Len() int
- func (e *Expectations) MergeExpectations(other *Expectations)
- func (e *Expectations) NumTests() int
- func (e *Expectations) Set(testName types.TestName, digest types.Digest, label Label)
- func (e *Expectations) String() string
- type JoinedExp
- type Label
- type ReadOnly
Constants ¶
const ( // Untriaged represents a previously unseen digest. Untriaged = Label("untriaged") // Positive represents a known good digest Positive = Label("positive") // Negative represents a known bad digest. Negative = Label("negative") )
Variables ¶
var AllLabel = []Label{Untriaged, Positive, Negative}
AllLabel is a list of all possible Label values. The index of each element in this list must match its LabelInt value (Untriaged = 0, etc.).
Functions ¶
func ValidLabel ¶
ValidLabel returns true if the given Label is valid.
Types ¶
type Baseline ¶
Baseline is a simplified view of the Expectations, suitable for JSON encoding. A Baseline only has entries with positive and negative labels (i.e. no untriaged entries).
type Classifier ¶
type Classifier interface { // Classification returns the label for the given test/digest pair. By definition, // this will return Untriaged if there isn't already a classification set. Classification(test types.TestName, digest types.Digest) Label }
Classifier is a simple interface for querying expectations.
func EmptyClassifier ¶
func EmptyClassifier() Classifier
EmptyClassifier returns a Classifier which returns Untriaged for given input. Mostly used for testing.
type Expectations ¶
type Expectations struct {
// contains filtered or unexported fields
}
Expectations captures the expectations for a set of tests and digests as labels (Positive/Negative/Untriaged). Put another way, this data structure keeps track if a digest (image) is drawn correctly, incorrectly, or newly-seen for a given test. Expectations is thread safe.
func (*Expectations) AsBaseline ¶
func (e *Expectations) AsBaseline() Baseline
AsBaseline returns a copy that has all untriaged digests removed.
func (*Expectations) Classification ¶
Classification implements the ReadOnly interface.
func (*Expectations) DeepCopy ¶
func (e *Expectations) DeepCopy() *Expectations
DeepCopy makes a deep copy of the current expectations/baseline.
func (*Expectations) Empty ¶
func (e *Expectations) Empty() bool
Empty implements the ReadOnly interface.
func (*Expectations) MergeExpectations ¶
func (e *Expectations) MergeExpectations(other *Expectations)
MergeExpectations adds the given expectations to the current expectations, letting the ones provided by the passed in parameter overwrite any existing data. Trying to merge two expectations into each other simultaneously may result in a dead-lock.
func (*Expectations) NumTests ¶
func (e *Expectations) NumTests() int
NumTests implements the ReadOnly interface.
func (*Expectations) Set ¶
Set sets the label for a test_name/digest pair. If the pair already exists, it will be over written.
func (*Expectations) String ¶
func (e *Expectations) String() string
String returns an alphabetically sorted string representation of this object.
type JoinedExp ¶
type JoinedExp []ReadOnly
JoinedExp represents a chain of ReadOnly that could contain Labels. The Expectations at the beginning of the list override those that follow.
type ReadOnly ¶
type ReadOnly interface { Classifier // ForAll will iterate through all entries in Expectations and call the callback with them. // Iteration will stop if a non-nil error is returned (and will be forwarded to the caller). ForAll(fn func(types.TestName, types.Digest, Label) error) error // Empty returns true iff NumTests() == 0 Empty() bool // NumTests returns the number of tests that Expectations knows about. NumTests() int // Len returns the number of test/digest pairs stored. Len() int }
ReadOnly is an interface with the non-mutating functions of Expectations. By using this instead of Expectations, we can make fewer copies, helping performance.