Documentation
¶
Index ¶
- func ConvertUnstructured(in runtime.Object) (runtime.Object, error)
- func CreateOrUpdate(ctx context.Context, client client.Client, obj runtime.Object, ...) error
- func FakeDiscoveryClient() discovery.DiscoveryInterface
- func GetAPIResource(dClient discovery.DiscoveryInterface, gvk schema.GroupVersionKind) (metav1.APIResource, error)
- func InstallManifests(ctx context.Context, client client.Client, ...) ([]runtime.Object, error)
- func IsSubset(expected, actual interface{}) error
- func LoadYAML(path string) ([]runtime.Object, error)
- func MarshalObject(o runtime.Object, w io.Writer) error
- func Namespaced(dClient discovery.DiscoveryInterface, obj runtime.Object, namespace string) (string, string, error)
- func NewPod(name, namespace string) runtime.Object
- func NewResource(apiVersion, kind, name, namespace string) runtime.Object
- func ObjectKey(obj runtime.Object) client.ObjectKey
- func PatchObject(actual, expected runtime.Object) error
- func PrettyDiff(expected runtime.Object, actual runtime.Object) (string, error)
- func ResourceID(obj runtime.Object) string
- func Retry(ctx context.Context, fn func(context.Context) error, ...) error
- func RunTests(testName string, testFunc func(*testing.T))
- func Scheme() *runtime.Scheme
- func SetAnnotation(obj runtime.Object, key, value string) runtime.Object
- func ValidateErrors(err error, errValidationFuncs ...func(error) bool) error
- func WaitForCRDs(dClient discovery.DiscoveryInterface, crds []runtime.Object) error
- func WithAnnotations(obj runtime.Object, annotations map[string]string) runtime.Object
- func WithKeyValue(obj runtime.Object, key string, value map[string]interface{}) runtime.Object
- func WithLabels(obj runtime.Object, labels map[string]string) runtime.Object
- func WithNamespace(obj runtime.Object, namespace string) runtime.Object
- func WithSpec(obj runtime.Object, spec map[string]interface{}) runtime.Object
- func WithStatus(obj runtime.Object, status map[string]interface{}) runtime.Object
- type Logger
- type SubsetError
- type TestLogger
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConvertUnstructured ¶
ConvertUnstructured converts an unstructured object to the known struct. If the type is not known, then the unstructured object is returned unmodified.
func CreateOrUpdate ¶
func CreateOrUpdate(ctx context.Context, client client.Client, obj runtime.Object, retryOnError bool) error
CreateOrUpdate will create obj if it does not exist and update if it it does.
func FakeDiscoveryClient ¶
func FakeDiscoveryClient() discovery.DiscoveryInterface
FakeDiscoveryClient returns a fake discovery client that is populated with some types for use in unit tests.
func GetAPIResource ¶
func GetAPIResource(dClient discovery.DiscoveryInterface, gvk schema.GroupVersionKind) (metav1.APIResource, error)
GetAPIResource returns the APIResource object for a specific GroupVersionKind.
func InstallManifests ¶
func InstallManifests(ctx context.Context, client client.Client, dClient discovery.DiscoveryInterface, manifestsDir string) ([]runtime.Object, error)
InstallManifests recurses over ManifestsDir to install all resources defined in YAML manifests.
func IsSubset ¶
func IsSubset(expected, actual interface{}) error
IsSubset checks to see if `expected` is a subset of `actual`. A "subset" is an object that is equivalent to the other object, but where map keys found in actual that are not defined in expected are ignored.
func MarshalObject ¶
MarshalObject marshals a Kubernetes object to a YAML string.
func Namespaced ¶
func Namespaced(dClient discovery.DiscoveryInterface, obj runtime.Object, namespace string) (string, string, error)
Namespaced sets the namespace on an object to namespace, if it is a namespace scoped resource. If the resource is cluster scoped, then it is ignored and the namespace is not set.
func NewResource ¶
NewResource generates a Kubernetes object using the provided apiVersion, kind, name, and namespace.
func PatchObject ¶
PatchObject updates expected with the Resource Version from actual. In the future, PatchObject may perform a strategic merge of actual into expected.
func PrettyDiff ¶
PrettyDiff creates a unified diff highlighting the differences between two Kubernetes resources
func ResourceID ¶
ResourceID returns a human readable identifier indicating the object kind, name, and namespace.
func Retry ¶
func Retry(ctx context.Context, fn func(context.Context) error, errValidationFuncs ...func(error) bool) error
Retry retries a method until the context expires or the method returns an unvalidated error.
func RunTests ¶
RunTests runs a Go test method without requiring the Go compiler. This does not currently support test caching.
func SetAnnotation ¶
SetAnnotation sets the given key and value in the object's annotations, returning a copy.
func ValidateErrors ¶
ValidateErrors accepts an error as its first argument and passes it to each function in the errValidationFuncs slice, if any of the methods returns true, the method returns nil, otherwise it returns the original error.
func WaitForCRDs ¶
func WaitForCRDs(dClient discovery.DiscoveryInterface, crds []runtime.Object) error
WaitForCRDs waits for the provided CRD types to be available in the Kubernetes API.
func WithAnnotations ¶
WithAnnotations sets the annotations on an object.
func WithKeyValue ¶
WithKeyValue sets key in the provided object to value.
func WithLabels ¶
WithLabels sets the labels on an object.
func WithNamespace ¶
WithNamespace naively applies the namespace to the object. Used mainly in tests, otherwise use Namespaced.
Types ¶
type Logger ¶
type Logger interface {
Log(args ...interface{})
Logf(format string, args ...interface{})
WithPrefix(string) Logger
}
Logger is an interface used by the KUDO test operator to provide logging of tests.
type SubsetError ¶
type SubsetError struct {
// contains filtered or unexported fields
}
SubsetError is an error type used by IsSubset for tracking the path in the struct.
func (*SubsetError) AppendPath ¶
func (e *SubsetError) AppendPath(key string)
AppendPath appends key to the existing struct path. For example, in struct member `a.Key1.Key2`, the path would be ["Key1", "Key2"]
func (*SubsetError) Error ¶
func (e *SubsetError) Error() string
Error implements the error interface.
type TestLogger ¶
type TestLogger struct {
// contains filtered or unexported fields
}
TestLogger implements the Logger interface to be compatible with the go test operator's output buffering (without this, the use of Parallel tests combined with subtests causes test output to be mixed).
func NewTestLogger ¶
func NewTestLogger(test *testing.T, prefix string) *TestLogger
NewTestLogger creates a new test logger.
func (*TestLogger) Log ¶
func (t *TestLogger) Log(args ...interface{})
Log logs the provided arguments with the logger's prefix. See testing.Log for more details.
func (*TestLogger) Logf ¶
func (t *TestLogger) Logf(format string, args ...interface{})
Logf logs the provided arguments with the logger's prefix. See testing.Logf for more details.
func (*TestLogger) WithPrefix ¶
func (t *TestLogger) WithPrefix(prefix string) Logger
WithPrefix returns a new TestLogger with the provided prefix appended to the current prefix.