matchers

package
v1.2.3 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package matchers contains the functionality to match two Kubernetes runtime.Objects.

Index

Constants

This section is empty.

Variables

View Source
var (
	// IgnoreAutogeneratedMetadata contains the paths for all the metadata fields that are commonly set by the
	// client and APIServer. This is used as a MatchOption for situations when only user-provided metadata is relevant.
	IgnoreAutogeneratedMetadata = IgnorePaths{
		{"metadata", "uid"},
		{"metadata", "generation"},
		{"metadata", "creationTimestamp"},
		{"metadata", "resourceVersion"},
		{"metadata", "managedFields"},
		{"metadata", "deletionGracePeriodSeconds"},
		{"metadata", "deletionTimestamp"},
		{"metadata", "selfLink"},
		{"metadata", "generateName"},
	}
)

These package variables hold pre-created commonly used options that can be used to reduce the manual work involved in identifying the paths that need to be compared for testing equality between objects.

Functions

This section is empty.

Types

type AllowPaths

type AllowPaths [][]string

AllowPaths instructs the Matcher to restrict its diff to the given paths. If empty the Matcher will look at all paths.

func (AllowPaths) ApplyToMatcher

func (i AllowPaths) ApplyToMatcher(opts *MatchOptions)

ApplyToMatcher applies this configuration to the given MatchOptions.

type IgnorePaths

type IgnorePaths [][]string

IgnorePaths instructs the Matcher to ignore given paths when computing a diff.

func (IgnorePaths) ApplyToMatcher

func (i IgnorePaths) ApplyToMatcher(opts *MatchOptions)

ApplyToMatcher applies this configuration to the given MatchOptions.

type MatchOption

type MatchOption interface {
	// ApplyToMatcher applies this configuration to the given MatchOption.
	ApplyToMatcher(options *MatchOptions)
}

MatchOption describes an Option that can be applied to a Matcher.

type MatchOptions

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

MatchOptions holds the available types of MatchOptions that can be applied to a Matcher.

func (*MatchOptions) ApplyOptions

func (o *MatchOptions) ApplyOptions(opts []MatchOption) *MatchOptions

ApplyOptions adds the passed MatchOptions to the MatchOptions struct.

type Matcher

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

Matcher is a Gomega matcher used to establish equality between two Kubernetes runtime.Objects.

func EqualObject

func EqualObject(original runtime.Object, opts ...MatchOption) *Matcher

EqualObject returns a Matcher for the passed Kubernetes runtime.Object with the passed Options. This function can be used as a Gomega Matcher in Gomega Assertions.

func (*Matcher) FailureMessage

func (m *Matcher) FailureMessage(actual interface{}) (message string)

FailureMessage returns a message comparing the full objects after an unexpected failure to match has occurred.

func (*Matcher) Match

func (m *Matcher) Match(actual interface{}) (success bool, err error)

Match compares the current object to the passed object and returns true if the objects are the same according to the Matcher and MatchOptions.

func (*Matcher) NegatedFailureMessage

func (m *Matcher) NegatedFailureMessage(actual interface{}) (message string)

NegatedFailureMessage returns a string comparing the full objects after an unexpected match has occurred.

Jump to

Keyboard shortcuts

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