# README

Kubernetes API Mocks

This folder contains all mocks and machinery to interact with a fake Kubernetes API.

Usage

1. Instantiate Fake

Inside a testing function, instantiate Fake by sharing the test context t and namespace name:

import "github.com/redhat-developer/service-binding-operator/test/mocks"

f := mocks.NewFake(t, "namespace")

2. Add Mocked Objects

Add mocked objects are you need.

f.AddMockedUnstructuredSecret("db-credentials")

3. Instantiate API Clients

Instantiate a fake API client, with:

fakeClient := f.FakeClient()
fakeDynamicClient := f.FakeDynClient()

Unstructured List vs. Typed Resource

As you may notice, in mocks.go we have methods returning typed Kubernetes objects, and sometimes returning unstructured.Unstructured. That happens because when using List with the dynamic client, it fails on parsing objects inside:

item[0]: can't assign or convert v1alpha1.ClusterServiceVersion into unstructured.Unstructured

However, using Unstructured it does not fail during testing.

# Functions

ClusterServiceVersionListMock returns a list with a single CSV object inside, reusing mock.
ClusterServiceVersionListVolumeMountMock returns a list with a single CSV object inside, reusing mock.
ClusterServiceVersionMock based on PostgreSQL operator having what's expected as defaults.
ClusterServiceVersionVolumeMountMock based on PostgreSQL operator.
ConfigMapMock returns a dummy config-map object.
CRDDescriptionMock based on PostgreSQL operator, returning a mock using default third party operator setup.
CRDDescriptionVolumeMountMock based on PostgreSQL operator, returns a mock having credentials in a volume.
DatabaseConfigMapMock returns a local ConfigMapDatabase object.
No description provided by the author
DeploymentMock creates a mocked Deployment object of busybox.
NestedDatabaseCRMock based on PostgreSQL operator, returning a instantiated object.
NewFake instantiate Fake type.
No description provided by the author
No description provided by the author
SecretMock returns a Secret based on PostgreSQL operator usage.
SecretMockRV returns a Secret with a resourceVersion.
ServiceBindingMock return a binding-request mock of informed name and match labels.
UnstructuredClusterServiceVersionMock unstructured object based on ClusterServiceVersionMock.
UnstructuredClusterServiceVersionVolumeMountMock returns ClusterServiceVersionVolumeMountMock as unstructured object.
UnstructuredDatabaseConfigMapMock returns a unstructured version of DatabaseConfigMapMock.
No description provided by the author
UnstructuredDatabaseCRMock returns a unstructured version of DatabaseCRMock.
UnstructuredDeploymentConfigMock converts the DeploymentMock to unstructured.
UnstructuredDeploymentMock converts the DeploymentMock to unstructured.
UnstructuredKnativeServiceMock converts the KnativeServiceMock to unstructured.
UnstructuredNestedDatabaseCRMock returns a unstructured object from NestedDatabaseCRMock.
No description provided by the author
No description provided by the author
No description provided by the author
UnstructuredServiceBindingMock returns a unstructured version of SBR.

# Constants

resource details employed in mocks.
Fixme(Akash): This values are tightly coupled with postgresql operator.
resource details employed in mocks.

# Variables

DBConfigMapSpecDesc spec descriptor to describe a operator that export username and password via config-map, instead of a usual secret.
DBNameSpecDesc default spec descriptor to inform the database name.
DBNameSpecDesc default spec descriptor to inform the database name.
DBPasswordCredentialsOnEnvStatusDesc status descriptor to describe a database operator that publishes username and password over a secret.
DBPasswordCredentialsOnVolumeMountStatusDesc status descriptor to describe a operator that informs credentials via a volume.
No description provided by the author

# Structs

ConfigMapDatabase ...
ConfigMapDatabaseSpec ...
Fake defines all the elements to fake a kubernetes api client.
NestedDatabase ...
NestedDatabaseSpec ...
NestedImage ...
No description provided by the author
No description provided by the author
ThirdLevel ...