utils

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2019 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ExampleClusterGitTrack = &farosv1alpha1.ClusterGitTrack{
	TypeMeta: metav1.TypeMeta{
		APIVersion: "faros.pusher.com/v1alpha1",
		Kind:       "ClusterGitTrack",
	},
	ObjectMeta: metav1.ObjectMeta{
		Name: "example",
	},
	Spec: farosv1alpha1.GitTrackSpec{},
}

ExampleClusterGitTrack is an example ClusterGitTrack object for use within test suites

View Source
var ExampleClusterGitTrackObject = &farosv1alpha1.ClusterGitTrackObject{
	TypeMeta: metav1.TypeMeta{
		APIVersion: "faros.pusher.com/v1alpha1",
		Kind:       "ClusterGitTrackObject",
	},
	ObjectMeta: metav1.ObjectMeta{
		Name: "example",
	},
	Spec: farosv1alpha1.GitTrackObjectSpec{
		Name: "clusterrolebinding-example",
		Kind: "ClusterRoleBinding",
		Data: []byte(`apiVersion: rbac.authorization.k8s.io/v1
		kind: ClusterRoleBinding
		metadata:
		  name: example
		  labels:
		    app: nginx
		roleRef:
		  apiGroup: rbac.authorization.k8s.io
		  kind: ClusterRole
		  name: nginx-ingress-controller
		subjects:
		- kind: ServiceAccount
		  name: nginx-ingress-controller
		  namespace: example
		`),
	},
}

ExampleClusterGitTrackObject is an example ClusterGitTrackObject object for use within test suites

View Source
var ExampleClusterRoleBinding = &rbacv1.ClusterRoleBinding{
	TypeMeta: metav1.TypeMeta{
		APIVersion: "rbac.authorization.k8s.io/v1",
		Kind:       "ClusterRoleBinding",
	},
	ObjectMeta: metav1.ObjectMeta{
		Name:   "example",
		Labels: appNginx,
	},
	RoleRef: rbacv1.RoleRef{
		APIGroup: "rbac.authorization.k8s.io",
		Kind:     "ClusterRole",
		Name:     "nginx-ingress-controller",
	},
	Subjects: []rbacv1.Subject{
		{
			Kind:      "ServiceAccount",
			Name:      "nginx-ingress-controller",
			Namespace: "example",
		},
	},
}

ExampleClusterRoleBinding is an example ClusterRoleBinding object for use within test suites

View Source
var ExampleDeployment = &appsv1.Deployment{
	TypeMeta: metav1.TypeMeta{
		APIVersion: "apps/v1",
		Kind:       "Deployment",
	},
	ObjectMeta: metav1.ObjectMeta{
		Name:      "example",
		Namespace: "default",
		Labels:    appNginx,
	},
	Spec: appsv1.DeploymentSpec{
		Selector: &metav1.LabelSelector{
			MatchLabels: appNginx,
		},
		Template: corev1.PodTemplateSpec{
			ObjectMeta: metav1.ObjectMeta{
				Labels: appNginx,
			},
			Spec: corev1.PodSpec{
				Containers: []corev1.Container{
					{
						Name:  "nginx",
						Image: "nginx",
					},
				},
			},
		},
	},
}

ExampleDeployment is an example Deployment object for use within test suites

View Source
var ExampleGitTrack = &farosv1alpha1.GitTrack{
	TypeMeta: metav1.TypeMeta{
		APIVersion: "faros.pusher.com/v1alpha1",
		Kind:       "GitTrack",
	},
	ObjectMeta: metav1.ObjectMeta{
		Name:      "example",
		Namespace: "default",
	},
	Spec: farosv1alpha1.GitTrackSpec{},
}

ExampleGitTrack is an example GitTrack object for use within test suites

View Source
var ExampleGitTrackObject = &farosv1alpha1.GitTrackObject{
	TypeMeta: metav1.TypeMeta{
		APIVersion: "faros.pusher.com/v1alpha1",
		Kind:       "GitTrackObject",
	},
	ObjectMeta: metav1.ObjectMeta{
		Name:      "example",
		Namespace: "default",
	},
	Spec: farosv1alpha1.GitTrackObjectSpec{
		Name: "deployment-example",
		Kind: "Deployment",
		Data: []byte(`apiVersion: apps/v1
		kind: Deployment
		metadata:
		  name: example
		  namespace: default
		  labels:
		    app: nginx
		spec:
		  selector:
		    matchLabels:
		      app: nginx
		  template:
		    metadata:
		     labels:
		       app: nginx
		    spec:
		      containers:
		      - name: nginx
		        image: nginx
		`),
	},
}

ExampleGitTrackObject is an example GitTrackObject 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 GetClusterGitTrackObjectOwnerRef added in v0.4.0

func GetClusterGitTrackObjectOwnerRef(gto *farosv1alpha1.ClusterGitTrackObject) metav1.OwnerReference

GetClusterGitTrackObjectOwnerRef constructs an owner reference for the given CGTO

func GetGitTrackInterfaceOwnerRef added in v0.7.0

func GetGitTrackInterfaceOwnerRef(gt farosv1alpha1.GitTrackInterface) metav1.OwnerReference

GetGitTrackInterfaceOwnerRef constructs an owner reference for the given GT

func GetGitTrackObjectOwnerRef added in v0.4.0

func GetGitTrackObjectOwnerRef(gto *farosv1alpha1.GitTrackObject) metav1.OwnerReference

GetGitTrackObjectOwnerRef constructs an owner reference for the given GTO

func SetGitTrackObjectInterfaceSpec added in v0.4.0

func SetGitTrackObjectInterfaceSpec(gto farosv1alpha1.GitTrackObjectInterface, obj Object) error

SetGitTrackObjectInterfaceSpec updates the spec of a GitTrackObjectInterface to match the given Object

func WithAnnotations added in v0.4.0

func WithAnnotations(matcher gtypes.GomegaMatcher) gtypes.GomegaMatcher

WithAnnotations returns the object's annotations

func WithContainers added in v0.4.0

func WithContainers(matcher gtypes.GomegaMatcher) gtypes.GomegaMatcher

WithContainers returns the deployment's containers

func WithEventType added in v0.4.0

func WithEventType(matcher gtypes.GomegaMatcher) gtypes.GomegaMatcher

WithEventType returns the event's type

func WithField added in v0.7.0

func WithField(field string, matcher gtypes.GomegaMatcher) gtypes.GomegaMatcher

WithField gets the value of the named field from the object

func WithFinalizers added in v0.4.0

func WithFinalizers(matcher gtypes.GomegaMatcher) gtypes.GomegaMatcher

WithFinalizers returns the object's annotations

func WithGitTrackObjectConditionMessage added in v0.4.0

func WithGitTrackObjectConditionMessage(matcher gtypes.GomegaMatcher) gtypes.GomegaMatcher

WithGitTrackObjectConditionMessage returns the GitTrackObjectCondition's message

func WithGitTrackObjectConditionReason added in v0.4.0

func WithGitTrackObjectConditionReason(matcher gtypes.GomegaMatcher) gtypes.GomegaMatcher

WithGitTrackObjectConditionReason returns the GitTrackObjectCondition's reason

func WithGitTrackObjectConditionStatus added in v0.4.0

func WithGitTrackObjectConditionStatus(matcher gtypes.GomegaMatcher) gtypes.GomegaMatcher

WithGitTrackObjectConditionStatus returns the GitTrackObjectCondition's status

func WithGitTrackObjectConditionType added in v0.4.0

func WithGitTrackObjectConditionType(matcher gtypes.GomegaMatcher) gtypes.GomegaMatcher

WithGitTrackObjectConditionType returns the GitTrackObjectCondition's type

func WithGitTrackObjectStatusConditions added in v0.4.0

func WithGitTrackObjectStatusConditions(matcher gtypes.GomegaMatcher) gtypes.GomegaMatcher

WithGitTrackObjectStatusConditions returns the GitTrackObject's status conditions

func WithImage added in v0.4.0

func WithImage(matcher gtypes.GomegaMatcher) gtypes.GomegaMatcher

WithImage returns the container's image

func WithInvolvedObjectKind added in v0.4.0

func WithInvolvedObjectKind(matcher gtypes.GomegaMatcher) gtypes.GomegaMatcher

WithInvolvedObjectKind returns the event's InvolvedObject's kind

func WithInvolvedObjectName added in v0.4.0

func WithInvolvedObjectName(matcher gtypes.GomegaMatcher) gtypes.GomegaMatcher

WithInvolvedObjectName returns the event's InvolvedObject's name

func WithInvolvedObjectNamespace added in v0.4.0

func WithInvolvedObjectNamespace(matcher gtypes.GomegaMatcher) gtypes.GomegaMatcher

WithInvolvedObjectNamespace returns the event's InvolvedObject's namespace

func WithItems added in v0.4.0

func WithItems(matcher gtypes.GomegaMatcher) gtypes.GomegaMatcher

WithItems returns the items of the list

func WithNamespaceFinalizers added in v0.4.0

func WithNamespaceFinalizers(matcher gtypes.GomegaMatcher) gtypes.GomegaMatcher

WithNamespaceFinalizers returns the namespace's finazliers

func WithOwnerReferences added in v0.4.0

func WithOwnerReferences(matcher gtypes.GomegaMatcher) gtypes.GomegaMatcher

WithOwnerReferences returns the object's owner references

func WithPodTemplateAnnotations added in v0.4.0

func WithPodTemplateAnnotations(matcher gtypes.GomegaMatcher) gtypes.GomegaMatcher

WithPodTemplateAnnotations returns the object's annotations

func WithPodTemplateLabels added in v0.4.0

func WithPodTemplateLabels(matcher gtypes.GomegaMatcher) gtypes.GomegaMatcher

WithPodTemplateLabels returns the object's labels

func WithReason added in v0.4.0

func WithReason(matcher gtypes.GomegaMatcher) gtypes.GomegaMatcher

WithReason returns the event's reason

func WithResourceVersion added in v0.4.0

func WithResourceVersion(matcher gtypes.GomegaMatcher) gtypes.GomegaMatcher

WithResourceVersion returns the object's resource version

func WithSubjects added in v0.4.0

func WithSubjects(matcher gtypes.GomegaMatcher) gtypes.GomegaMatcher

WithSubjects returns the ClusterRoleBinding's subjects

func WithUID added in v0.4.0

func WithUID(matcher gtypes.GomegaMatcher) gtypes.GomegaMatcher

WithUID returns the object's UID

func WithUnstructuredObject added in v0.4.0

func WithUnstructuredObject(matcher gtypes.GomegaMatcher) gtypes.GomegaMatcher

WithUnstructuredObject returns the object's inner object

Types

type Matcher added in v0.4.0

type Matcher struct {
	Client      client.Client
	FarosClient farosclient.Client
}

Matcher has Gomega Matchers that use the controller-runtime client

func (*Matcher) Apply added in v0.4.0

func (m *Matcher) Apply(obj Object, opts *farosclient.ApplyOptions, extras ...interface{}) gomega.GomegaAssertion

Apply creates or updates the object on the API server

func (*Matcher) Consistently added in v0.4.0

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

Consistently continually gets the object from the API for comparison

func (*Matcher) Create added in v0.4.0

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

Create creates the object on the API server

func (*Matcher) Delete added in v0.4.0

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

Delete deletes the object from the API server

func (*Matcher) Eventually added in v0.4.0

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

Eventually continually gets the object from the API for comparison

func (*Matcher) Get added in v0.4.0

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

Get gets the object from the API server

func (*Matcher) Update added in v0.4.0

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

Update udpates the object on the API server

func (*Matcher) UpdateWithFunc added in v0.7.0

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

UpdateWithFunc udpates the object on the API server by fetching the object and applying a mutating UpdateFunc before sending the update

type Object added in v0.4.0

type Object interface {
	runtime.Object
	metav1.Object
}

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

type UpdateFunc added in v0.7.0

type UpdateFunc func(Object) Object

UpdateFunc modifies the object fetched from the API server before sending the update

Jump to

Keyboard shortcuts

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