utils

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2018 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package utils contains a collection of utilities for the controller test suites

Index

Constants

This section is empty.

Variables

View Source
var ExampleConfigMap1 = &corev1.ConfigMap{
	ObjectMeta: metav1.ObjectMeta{
		Name:      "example1",
		Namespace: "default",
		Labels:    labels,
	},
	Data: map[string]string{
		"key1": "example1:key1",
		"key2": "example1:key2",
		"key3": "example1:key3",
	},
}

ExampleConfigMap1 is an example ConfigMap object for use within test suites

View Source
var ExampleConfigMap2 = &corev1.ConfigMap{
	ObjectMeta: metav1.ObjectMeta{
		Name:      "example2",
		Namespace: "default",
		Labels:    labels,
	},
	Data: map[string]string{
		"key1": "example2:key1",
		"key2": "example2:key2",
		"key3": "example2:key3",
	},
}

ExampleConfigMap2 is an example ConfigMap object for use within test suites

View Source
var ExampleDeployment = &appsv1.Deployment{
	ObjectMeta: metav1.ObjectMeta{
		Name:      "example",
		Namespace: "default",
		Labels:    labels,
	},
	Spec: appsv1.DeploymentSpec{
		Selector: &metav1.LabelSelector{
			MatchLabels: labels,
		},
		Template: corev1.PodTemplateSpec{
			ObjectMeta: metav1.ObjectMeta{
				Labels: labels,
			},
			Spec: corev1.PodSpec{
				Volumes: []corev1.Volume{
					{
						Name: "secret1",
						VolumeSource: corev1.VolumeSource{
							Secret: &corev1.SecretVolumeSource{
								SecretName: "example1",
							},
						},
					},
					{
						Name: "configmap1",
						VolumeSource: corev1.VolumeSource{
							ConfigMap: &corev1.ConfigMapVolumeSource{
								LocalObjectReference: corev1.LocalObjectReference{
									Name: "example1",
								},
							},
						},
					},
				},
				Containers: []corev1.Container{
					{
						Name:  "container1",
						Image: "container1",
						EnvFrom: []corev1.EnvFromSource{
							{
								ConfigMapRef: &corev1.ConfigMapEnvSource{
									LocalObjectReference: corev1.LocalObjectReference{
										Name: "example1",
									},
								},
							},
							{
								SecretRef: &corev1.SecretEnvSource{
									LocalObjectReference: corev1.LocalObjectReference{
										Name: "example1",
									},
								},
							},
						},
					},
					{
						Name:  "container2",
						Image: "container2",
						EnvFrom: []corev1.EnvFromSource{
							{
								ConfigMapRef: &corev1.ConfigMapEnvSource{
									LocalObjectReference: corev1.LocalObjectReference{
										Name: "example2",
									},
								},
							},
							{
								SecretRef: &corev1.SecretEnvSource{
									LocalObjectReference: corev1.LocalObjectReference{
										Name: "example2",
									},
								},
							},
						},
					},
				},
			},
		},
	},
}

ExampleDeployment is an example Deployment object for use within test suites

View Source
var ExampleSecret1 = &corev1.Secret{
	ObjectMeta: metav1.ObjectMeta{
		Name:      "example1",
		Namespace: "default",
		Labels:    labels,
	},
	StringData: map[string]string{
		"key1": "example1:key1",
		"key2": "example1:key2",
		"key3": "example1:key3",
	},
}

ExampleSecret1 is an example ConfigMap object for use within test suites

View Source
var ExampleSecret2 = &corev1.Secret{
	ObjectMeta: metav1.ObjectMeta{
		Name:      "example2",
		Namespace: "default",
		Labels:    labels,
	},
	StringData: map[string]string{
		"key1": "example2:key1",
		"key2": "example2:key2",
		"key3": "example2:key3",
	},
}

ExampleSecret2 is an example ConfigMap object for use within test suites

Functions

func DeleteAll

func DeleteAll(cfg *rest.Config, timeout time.Duration, objLists ...runtime.Object)

DeleteAll lists and deletes all resources

func GetOwnerRef

func GetOwnerRef(deployment *appsv1.Deployment) metav1.OwnerReference

GetOwnerRef constructs an owner reference for the Deployment given

func WithAnnotations

func WithAnnotations(matcher gtypes.GomegaMatcher) gtypes.GomegaMatcher

WithAnnotations returns the object's Annotations

func WithFinalizers

func WithFinalizers(matcher gtypes.GomegaMatcher) gtypes.GomegaMatcher

WithFinalizers returns the object's Finalizers

func WithItems

func WithItems(matcher gtypes.GomegaMatcher) gtypes.GomegaMatcher

WithItems returns the lists Finalizers

func WithOwnerReferences

func WithOwnerReferences(matcher gtypes.GomegaMatcher) gtypes.GomegaMatcher

WithOwnerReferences returns the object's OwnerReferences

func WithPodTemplateAnnotations

func WithPodTemplateAnnotations(matcher gtypes.GomegaMatcher) gtypes.GomegaMatcher

WithPodTemplateAnnotations returns the deployments PodTemplate's annotations

Types

type Matcher

type Matcher struct {
	Client client.Client
}

Matcher has Gomega Matchers that use the controller-runtime client

func (*Matcher) Consistently

func (m *Matcher) Consistently(obj Object, intervals ...interface{}) gomega.GomegaAsyncAssertion

Consistently continually gets the object from the API for comparison

func (*Matcher) Create

func (m *Matcher) Create(obj Object, extras ...interface{}) gomega.GomegaAssertion

Create creates the object on the API server

func (*Matcher) Delete

func (m *Matcher) Delete(obj Object, extras ...interface{}) gomega.GomegaAssertion

Delete deletes the object from the API server

func (*Matcher) Eventually

func (m *Matcher) Eventually(obj runtime.Object, intervals ...interface{}) gomega.GomegaAsyncAssertion

Eventually continually gets the object from the API for comparison

func (*Matcher) Get

func (m *Matcher) Get(obj Object, intervals ...interface{}) gomega.GomegaAsyncAssertion

Get gets the object from the API server

func (*Matcher) Update

func (m *Matcher) Update(obj Object, intervals ...interface{}) gomega.GomegaAsyncAssertion

Update udpates the object on the API server

type Object

type Object interface {
	runtime.Object
	metav1.Object
}

Object is the combination of two interfaces as a helper for passing Kubernetes objects between methods

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳