Repository: redhat-developer/service-binding-operator
Pull request #268 (2019-12-05 01:36:03)

Update RDS example to match 4.3 Deployments and SBO use of resourceRefs
### Motivation
The goals of this pull request are to get the RDS example up to date with OpenShift's use of Deployments, and up to date with the Service Binding Operator's use of reeeesrouceRef for Application selectors. 

### Changes
The README, Makefile. and ServiceBindingRequest definitions are updated. 

### Testing
The example was verified by following the steps in the README.

For further more details refer the CONTRIBUTING.md

openshift-ci-robot: [APPROVALNOTIFIER] This PR is **NOT APPROVED**

This pull-request has been approved by:
To complete the [pull request process](https://git.k8s.io/community/contributors/guide/owners.md#the-code-review-process), please assign **baijum**
You can assign the PR to them by writing `/assign @baijum` in a comment when ready.

The full list of commands accepted by this bot can be found [here](https://go.k8s.io/bot-commands?repo=redhat-developer%2Fservice-binding-operator).

<details open>
Needs approval from an approver in each of these files:

- **[OWNERS](https://github.com/redhat-developer/service-binding-operator/blob/master/OWNERS)**

Approvers can indicate their approval by writing `/approve` in a comment
Approvers can cancel approval by writing `/approve cancel` in a comment
</details>
<!-- META={"approvers":["baijum"]} -->
sbose78: /lgtm
/approve
openshift-ci-robot: [APPROVALNOTIFIER] This PR is **APPROVED**

This pull-request has been approved by: *<a href="https://github.com/redhat-developer/service-binding-operator/pull/268#issuecomment-561926600" title="Approved">sbose78</a>*

The full list of commands accepted by this bot can be found [here](https://go.k8s.io/bot-commands?repo=redhat-developer%2Fservice-binding-operator).

The pull request process is described [here](https://git.k8s.io/community/contributors/guide/owners.md#the-code-review-process)

<details >
Needs approval from an approver in each of these files:

- ~~[OWNERS](https://github.com/redhat-developer/service-binding-operator/blob/master/OWNERS)~~ [sbose78]

Approvers can indicate their approval by writing `/approve` in a comment
Approvers can cancel approval by writing `/approve cancel` in a comment
</details>
<!-- META={"approvers":[]} -->
sbose78: /hold
codecov[bot]: # [Codecov](https://codecov.io/gh/redhat-developer/service-binding-operator/pull/268?src=pr&el=h1) Report
> Merging [#268](https://codecov.io/gh/redhat-developer/service-binding-operator/pull/268?src=pr&el=desc) into [master](https://codecov.io/gh/redhat-developer/service-binding-operator/commit/ba129432e43bf26455edeebf88bcaf92184586c3?src=pr&el=desc) will **not change** coverage.
> The diff coverage is `n/a`.

[![Impacted file tree graph](https://codecov.io/gh/redhat-developer/service-binding-operator/pull/268/graphs/tree.svg?width=650&token=CICBeVWlrC&height=150&src=pr)](https://codecov.io/gh/redhat-developer/service-binding-operator/pull/268?src=pr&el=tree)

```diff
@@           Coverage Diff           @@
##           master     #268   +/-   ##
=======================================
  Coverage   58.71%   58.71%           
=======================================
  Files          16       16           
  Lines        1279     1279           
=======================================
  Hits          751      751           
  Misses        393      393           
  Partials      135      135
```



------

[Continue to review full report at Codecov](https://codecov.io/gh/redhat-developer/service-binding-operator/pull/268?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/redhat-developer/service-binding-operator/pull/268?src=pr&el=footer). Last update [ba12943...7688c41](https://codecov.io/gh/redhat-developer/service-binding-operator/pull/268?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).


Patch:
diff --git a/OWNERS b/OWNERS
index bfbfd110..07a69d3f 100644
--- a/OWNERS
+++ b/OWNERS
@@ -7,6 +7,7 @@ approvers:
 - akashshinde
 - DhritiShikhar
 - Avni-Sharma
+- isutton
 
 reviewers:
 - sbose78
@@ -18,3 +19,4 @@ reviewers:
 - pmacik
 - ldimaggi
 - pratikjagrut
+- isutton
diff --git a/examples/nodejs_awsrds_varprefix/README.md b/examples/nodejs_awsrds_varprefix/README.md
index 952b69bf..19bca63a 100644
--- a/examples/nodejs_awsrds_varprefix/README.md
+++ b/examples/nodejs_awsrds_varprefix/README.md
@@ -24,13 +24,7 @@ manage off-cluster RDS database instances on AWS.
 
 #### Install the Service Binding Operator using an `OperatorSource`
 
-Apply the [Service Binding Operator Source](./operator-source.service-binding-operator.yaml):
-
-```shell
-make install-service-binding-operator-source
-```
-
-Then navigate to the `Operators`->`OperatorHub` in the OpenShift console under the `openshift-marketplace` project and in the `Other` category select the `Service Bidning Operator` operator
+Navigate to the `Operators`->`OperatorHub` in the OpenShift console under the `openshift-marketplace` project and in the `Other` category select the `Service Bidning Operator` operator
 
 ![Service Binding Operator as shown in OperatorHub](../../assets/operator-hub-sbo-screenshot.png)
 
@@ -45,7 +39,7 @@ This makes the `ServiceBindingRequest` custom resource available, that we as the
 The AWS RDS operator requires AWS credentials to be able to work with AWS. Follow the [instructions](https://github.com/operator-backing-service-samples/aws-rds#set-up-and-config) to install the proper secret.
 
 ``` shell
- install-aws-rds-operator-secrets
+ make install-aws-rds-operator-secrets
 ```
 
 ##### Install the operator source
@@ -84,6 +78,12 @@ The application and the DB needs a namespace to live in so let's create one for
 oc new-project service-binding-demo
 ```
 
+Alternatively, you can perform the same task with this make command:
+
+``` shell
+make create-project
+```
+
 #### Deploy Shell application
 
 To illustrate and verify that the binding works we will use a simple shell application that lists all environment variables that start with the `MYDB_` prefix and then goes to sleep for an hour.
@@ -194,9 +194,7 @@ spec:
     kind: RDSDatabase
     resourceRef: mydb
   applicationSelector:
-    matchLabels:
-      connects-to: postgres
-      environment: shell
+    resourceRef: shell-app
     group: apps.openshift.io
     version: v1
     resource: deploymentconfigs
@@ -206,7 +204,7 @@ There are 3 interesting parts in the request:
 
 * `envVarPrefix` - specifies the prefix for all the environment variables injected to the bound application
 * `backingServiceSelector` - used to find the backing service - our operator-backed DB instance called `mydb`
-* `applicationSelector` - used to search for the application based on the labels (check the [labels on the Shell application](./deployment-config.shell-app.yaml#L7)) and the `resourceKind` of the application to be a `DeploymentConfig`
+* `applicationSelector` - used to search for the application based on the resourceRef and the `resourceKind` of the application to be a `DeploymentConfig`
 
 We can use `create-service-binding-request-shell-app` make target to create the binding request for us:
 
@@ -243,26 +241,9 @@ The Node.js application should be already up and running after we [imported it b
 
 Let's check by navigating to the application's route to verify that it is up. Notice that in the header it says `(DB: N/A)`. That means that the application is not connected to DB and so it should not work properly. Try the application's UI to add a fruit - it causes an error proving that the DB is not connected.
 
-Now we ask the Service Binding Operator to bind the DB to the Node.js application in the following steps:
-
-* [Set labels on the application](#set-labels-on-the-nodejs-application) for the Service Binding Operator to find it
+Now we ask the Service Binding Operator to bind the DB to the Node.js application in the following step:
 * [Create `ServiceBindingRequest`](#create-servicebindingrequest-for-the-nodejs-application)
 
-##### Set labels on the Node.js application
-
-Similarly as with the Shell application we need to have arbitrary labels on the application's `DeploymentConfig` in order for the Service Binding Operator to be able to find the application.
-
-The labels we use are:
-
-* `connects-to=postgres` - indicates that the application needs to connect to a PostgreSQL DB
-* `environment=nodejs` - indicates the `nodejs` environment - it narrows the search and exclude the Shell application which has a different label (`environment=shell` instead).
-
-To set our labels we can use the `set-labels-on-nodejs-app` make target:
-
-```shell
-make set-labels-on-nodejs-app
-```
-
 #### Create `ServiceBindingRequest` for the Node.js application
 
 Now the only thing that remains is to connect the DB and the application. We let the Service Binding Operator to do the connection for us.
@@ -284,15 +265,13 @@ spec:
     kind: RDSDatabase
     resourceRef: mydb
   applicationSelector:
-    matchLabels:
-      connects-to: postgres
-      environment: nodejs
-    group: apps.openshift.io
+    resourceRef: nodejs-app
+    group: apps
     version: v1
-    resource: deploymentconfigs
+    resource: deployments
 ```
 
-The request is basically the same as the one we used for the Shell application. The only difference (appart from name) is the label `environment: nodejs` used in the `appicationSelector`.
+The request is basically the same as the one we used for the Shell application. The only difference is the application name used in resourceRef used in the `applicationSelector`.
 
 We can use the `create-service-binding-request-nodejs-app` make target to create the request for us:
 
diff --git a/examples/nodejs_awsrds_varprefix/namespace.yaml b/examples/nodejs_awsrds_varprefix/namespace.yaml
new file mode 100644
index 00000000..58b96261
--- /dev/null
+++ b/examples/nodejs_awsrds_varprefix/namespace.yaml
@@ -0,0 +1,5 @@
+---
+kind: Namespace
+apiVersion: v1
+metadata:
+  name: service-binding-demo
diff --git a/examples/nodejs_awsrds_varprefix/service-binding-request.nodejs-app.yaml b/examples/nodejs_awsrds_varprefix/service-binding-request.nodejs-app.yaml
index dc58ec3b..b3494e92 100644
--- a/examples/nodejs_awsrds_varprefix/service-binding-request.nodejs-app.yaml
+++ b/examples/nodejs_awsrds_varprefix/service-binding-request.nodejs-app.yaml
@@ -12,9 +12,7 @@ spec:
     kind: RDSDatabase
     resourceRef: mydb
   applicationSelector:
-    matchLabels:
-      connects-to: postgres
-      environment: nodejs
-    group: apps.openshift.io
+    resourceRef: nodejs-app
+    group: apps
     version: v1
-    resource: deploymentconfigs
+    resource: deployments
diff --git a/examples/nodejs_awsrds_varprefix/service-binding-request.shell-app.yaml b/examples/nodejs_awsrds_varprefix/service-binding-request.shell-app.yaml
index b5c191e5..8cf07c69 100644
--- a/examples/nodejs_awsrds_varprefix/service-binding-request.shell-app.yaml
+++ b/examples/nodejs_awsrds_varprefix/service-binding-request.shell-app.yaml
@@ -12,9 +12,7 @@ spec:
     kind: RDSDatabase
     resourceRef: mydb
   applicationSelector:
-    matchLabels:
-      connects-to: postgres
-      environment: shell
+    resourceRef: shell-app
     group: apps.openshift.io
     version: v1
     resource: deploymentconfigs
diff --git a/pkg/controller/servicebindingrequest/bind_custom_resources.go b/pkg/controller/servicebindingrequest/bind_custom_resources.go
index fb721084..19469e99 100644
--- a/pkg/controller/servicebindingrequest/bind_custom_resources.go
+++ b/pkg/controller/servicebindingrequest/bind_custom_resources.go
@@ -41,7 +41,7 @@ func NewDetectBindableResources(
 	return b
 }
 
-// GetBindableVariables returns list of subresources owned by operator backed CR
+// GetOwnedResources returns list of subresources owned by operator backed CR
 func (b DetectBindableResources) GetOwnedResources() ([]unstructured.Unstructured, error) {
 	var subResources []unstructured.Unstructured
 	for _, resource := range b.resourcesToCheck {
diff --git a/pkg/controller/servicebindingrequest/retriever.go b/pkg/controller/servicebindingrequest/retriever.go
index c2c01f02..ae897b80 100644
--- a/pkg/controller/servicebindingrequest/retriever.go
+++ b/pkg/controller/servicebindingrequest/retriever.go
@@ -199,7 +199,7 @@ func (r *Retriever) readSecret(
 		log.Debug("Inspecting secret key...")
 		r.markVisitedPaths(path, k, fromPath)
 		// update cache after reading configmap/secret in cache
-		r.cache[fromPath].(map[string]interface{})[path].(map[string]interface{})[k] = string(value)
+		r.cache[fromPath].(map[string]interface{})[path].(map[string]interface{})[k] = string(data)
 		// making sure key name has a secret reference
 		r.store(fmt.Sprintf("configMap_%s", k), data)
 		r.store(fmt.Sprintf("secret_%s", k), data)


Test patch:
diff --git a/pkg/controller/servicebindingrequest/binder_test.go b/pkg/controller/servicebindingrequest/binder_test.go
index c67a88b4..69c04b16 100644
--- a/pkg/controller/servicebindingrequest/binder_test.go
+++ b/pkg/controller/servicebindingrequest/binder_test.go
@@ -5,6 +5,7 @@ import (
 	"testing"
 	"time"
 
+	"github.com/stretchr/testify/assert"
 	"github.com/stretchr/testify/require"
 	corev1 "k8s.io/api/core/v1"
 	"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
@@ -35,9 +36,8 @@ func TestBinderNew(t *testing.T) {
 		"connects-to": "database",
 		"environment": "binder",
 	}
-
 	f := mocks.NewFake(t, ns)
-	sbr := f.AddMockedServiceBindingRequest(name, "ref", "", matchLabels)
+	sbr := f.AddMockedServiceBindingRequest(name, "ref", "", deploymentsGVR, matchLabels)
 	f.AddMockedUnstructuredDeployment("ref", matchLabels)
 
 	binder := NewBinder(
@@ -54,6 +54,7 @@ func TestBinderNew(t *testing.T) {
 		"service-binding-request-with-ref",
 		"ref",
 		"ref",
+		deploymentsGVR,
 		map[string]string{},
 	)
 
@@ -181,9 +182,8 @@ func TestBinderAppendEnvVar(t *testing.T) {
 func TestBinderApplicationName(t *testing.T) {
 	ns := "binder"
 	name := "service-binding-request"
-
 	f := mocks.NewFake(t, ns)
-	sbr := f.AddMockedServiceBindingRequest(name, "backingServiceResourceRef", "applicationResourceRef", nil)
+	sbr := f.AddMockedServiceBindingRequest(name, "backingServiceResourceRef", "applicationResourceRef", deploymentsGVR, nil)
 	f.AddMockedUnstructuredDeployment("ref", nil)
 
 	binder := NewBinder(
@@ -202,3 +202,76 @@ func TestBinderApplicationName(t *testing.T) {
 		require.Equal(t, 1, len(list.Items))
 	})
 }
+
+func TestBindingWithDeploymentConfig(t *testing.T) {
+	ns := "service-binding-demo-with-deploymentconfig"
+	name := "service-binding-request"
+	f := mocks.NewFake(t, ns)
+	sbr := f.AddMockedServiceBindingRequest(name, "backingServiceResourceRef", "applicationResourceRef", deploymentConfigsGVR, nil)
+	f.AddMockedUnstructuredDeploymentConfig("ref", nil)
+
+	binder := NewBinder(
+		context.TODO(),
+		f.FakeClient(),
+		f.FakeDynClient(),
+		sbr,
+		[]string{},
+	)
+
+	require.NotNil(t, binder)
+
+	t.Run("deploymentconfig", func(t *testing.T) {
+		list, err := binder.search()
+		require.NoError(t, err)
+		require.Equal(t, 1, len(list.Items))
+		require.Equal(t, "DeploymentConfig", list.Items[0].Object["kind"])
+	})
+
+}
+
+func TestBindTwoApplications(t *testing.T) {
+	ns := "binder"
+	f := mocks.NewFake(t, ns)
+
+	name1 := "service-binding-request-1"
+	matchLabels1 := map[string]string{
+		"connects-to": "database",
+		"environment": "binder",
+	}
+	f.AddMockedUnstructuredDeployment("applicationResourceRef1", matchLabels1)
+	sbr1 := f.AddMockedServiceBindingRequest(name1, "backingServiceResourceRef", "", deploymentsGVR, matchLabels1)
+	binder1 := NewBinder(
+		context.TODO(),
+		f.FakeClient(),
+		f.FakeDynClient(),
+		sbr1,
+		[]string{},
+	)
+	require.NotNil(t, binder1)
+
+	name2 := "service-binding-request-2"
+	matchLabels2 := map[string]string{
+		"connects-to": "database",
+		"environment": "demo",
+	}
+	f.AddMockedUnstructuredDeployment("applicationResourceRef2", matchLabels2)
+	sbr2 := f.AddMockedServiceBindingRequest(name2, "backingServiceResourceRef", "", deploymentsGVR, matchLabels2)
+	binder2 := NewBinder(
+		context.TODO(),
+		f.FakeClient(),
+		f.FakeDynClient(),
+		sbr2,
+		[]string{},
+	)
+	require.NotNil(t, binder2)
+
+	t.Run("two applications with one backing service", func(t *testing.T) {
+		list1, err := binder1.search()
+		assert.Nil(t, err)
+		assert.Equal(t, 1, len(list1.Items))
+
+		list2, err := binder2.search()
+		assert.Nil(t, err)
+		assert.Equal(t, 1, len(list2.Items))
+	})
+}
diff --git a/pkg/controller/servicebindingrequest/planner_test.go b/pkg/controller/servicebindingrequest/planner_test.go
index 19923635..cdc0c21f 100644
--- a/pkg/controller/servicebindingrequest/planner_test.go
+++ b/pkg/controller/servicebindingrequest/planner_test.go
@@ -24,9 +24,8 @@ func TestPlannerNew(t *testing.T) {
 		"connects-to": "database",
 		"environment": "planner",
 	}
-
 	f := mocks.NewFake(t, ns)
-	sbr := f.AddMockedServiceBindingRequest(name, resourceRef, "", matchLabels)
+	sbr := f.AddMockedServiceBindingRequest(name, resourceRef, "", deploymentsGVR, matchLabels)
 	f.AddMockedUnstructuredCSV("cluster-service-version")
 	f.AddMockedDatabaseCR(resourceRef)
 	f.AddMockedUnstructuredDatabaseCRD()
@@ -61,9 +60,8 @@ func TestPlannerAnnotation(t *testing.T) {
 		"connects-to": "database",
 		"environment": "planner",
 	}
-
 	f := mocks.NewFake(t, ns)
-	sbr := f.AddMockedServiceBindingRequest(name, resourceRef, "", matchLabels)
+	sbr := f.AddMockedServiceBindingRequest(name, resourceRef, "", deploymentsGVR, matchLabels)
 	f.AddMockedUnstructuredDatabaseCRD()
 
 	planner = NewPlanner(context.TODO(), f.FakeDynClient(), sbr)
diff --git a/pkg/controller/servicebindingrequest/reconciler_test.go b/pkg/controller/servicebindingrequest/reconciler_test.go
index fbb976ee..dc52b138 100644
--- a/pkg/controller/servicebindingrequest/reconciler_test.go
+++ b/pkg/controller/servicebindingrequest/reconciler_test.go
@@ -7,6 +7,7 @@ import (
 
 	"github.com/stretchr/testify/require"
 	appsv1 "k8s.io/api/apps/v1"
+	"k8s.io/apimachinery/pkg/runtime/schema"
 	"k8s.io/apimachinery/pkg/types"
 	"sigs.k8s.io/controller-runtime/pkg/reconcile"
 	logf "sigs.k8s.io/controller-runtime/pkg/runtime/log"
@@ -19,6 +20,11 @@ const (
 	reconcilerName = "binding-request"
 )
 
+var (
+	deploymentsGVR       = schema.GroupVersionResource{Group: "apps", Version: "v1", Resource: "deployments"}
+	deploymentConfigsGVR = schema.GroupVersionResource{Group: "apps", Version: "v1", Resource: "deploymentconfigs"}
+)
+
 func init() {
 	logf.SetLogger(logf.ZapLogger(true))
 }
@@ -39,9 +45,8 @@ func TestReconcilerReconcileError(t *testing.T) {
 		"connects-to": "database",
 		"environment": "reconciler",
 	}
-
 	f := mocks.NewFake(t, reconcilerNs)
-	f.AddMockedUnstructuredServiceBindingRequest(reconcilerName, backingServiceResourceRef, "", matchLabels)
+	f.AddMockedUnstructuredServiceBindingRequest(reconcilerName, backingServiceResourceRef, "", deploymentsGVR, matchLabels)
 
 	fakeClient := f.FakeClient()
 	fakeDynClient := f.FakeDynClient()
@@ -66,7 +71,7 @@ func TestApplicationSelectorByName(t *testing.T) {
 	backingServiceResourceRef := "backingServiceRef"
 	applicationResourceRef := "applicationRef"
 	f := mocks.NewFake(t, reconcilerNs)
-	f.AddMockedUnstructuredServiceBindingRequest(reconcilerName, backingServiceResourceRef, applicationResourceRef, nil)
+	f.AddMockedUnstructuredServiceBindingRequest(reconcilerName, backingServiceResourceRef, applicationResourceRef, deploymentsGVR, nil)
 	f.AddMockedUnstructuredCSV("cluster-service-version-list")
 	f.AddMockedUnstructuredDatabaseCRD()
 	f.AddMockedUnstructuredDatabaseCR(backingServiceResourceRef)
@@ -103,9 +108,8 @@ func TestReconcilerReconcileUsingSecret(t *testing.T) {
 		"connects-to": "database",
 		"environment": "reconciler",
 	}
-
 	f := mocks.NewFake(t, reconcilerNs)
-	f.AddMockedUnstructuredServiceBindingRequest(reconcilerName, backingServiceResourceRef, "", matchLabels)
+	f.AddMockedUnstructuredServiceBindingRequest(reconcilerName, backingServiceResourceRef, "", deploymentsGVR, matchLabels)
 	f.AddMockedUnstructuredCSV("cluster-service-version-list")
 	f.AddMockedUnstructuredDatabaseCRD()
 	f.AddMockedUnstructuredDatabaseCR(backingServiceResourceRef)
@@ -151,9 +155,8 @@ func TestReconcilerReconcileUsingVolumes(t *testing.T) {
 		"connects-to": "database",
 		"environment": "reconciler",
 	}
-
 	f := mocks.NewFake(t, reconcilerNs)
-	f.AddMockedUnstructuredServiceBindingRequest(reconcilerName, backingServiceResourceRef, "", matchLabels)
+	f.AddMockedUnstructuredServiceBindingRequest(reconcilerName, backingServiceResourceRef, "", deploymentsGVR, matchLabels)
 	f.AddMockedUnstructuredCSVWithVolumeMount("cluster-service-version-list")
 	f.AddMockedUnstructuredDatabaseCRD()
 	f.AddMockedUnstructuredDatabaseCR(backingServiceResourceRef)
diff --git a/pkg/controller/servicebindingrequest/retriever_test.go b/pkg/controller/servicebindingrequest/retriever_test.go
index 4503c0b2..f11f6076 100644
--- a/pkg/controller/servicebindingrequest/retriever_test.go
+++ b/pkg/controller/servicebindingrequest/retriever_test.go
@@ -243,7 +243,7 @@ func TestCustomEnvParser(t *testing.T) {
 		if err != nil {
 			t.Error(err)
 		}
-		require.Equal(t, "dXNlcg==_cGFzc3dvcmQ=", values["ANOTHER_STRING"], "Custom env values are not matching")
-		require.Equal(t, "postgres@cGFzc3dvcmQ=", values["JDBC_CONNECTION_STRING"], "Custom env values are not matching")
+		require.Equal(t, "user_password", values["ANOTHER_STRING"], "Custom env values are not matching")
+		require.Equal(t, "postgres@password", values["JDBC_CONNECTION_STRING"], "Custom env values are not matching")
 	})
 }
diff --git a/pkg/controller/servicebindingrequest/secret_test.go b/pkg/controller/servicebindingrequest/secret_test.go
index b5906fa3..f3f89880 100644
--- a/pkg/controller/servicebindingrequest/secret_test.go
+++ b/pkg/controller/servicebindingrequest/secret_test.go
@@ -21,7 +21,7 @@ func TestSecretNew(t *testing.T) {
 	f := mocks.NewFake(t, ns)
 
 	matchLabels := map[string]string{}
-	sbr := mocks.ServiceBindingRequestMock(ns, name, "", "", matchLabels, true)
+	sbr := mocks.ServiceBindingRequestMock(ns, name, "", "", deploymentsGVR, matchLabels, true)
 
 	plan := &Plan{Ns: ns, Name: name, CRDDescription: nil, SBR: *sbr}
 	data := map[string][]byte{"key": []byte("value")}
diff --git a/test/e2e/servicebindingrequest_test.go b/test/e2e/servicebindingrequest_test.go
index 6e63f63b..0fc45bd1 100644
--- a/test/e2e/servicebindingrequest_test.go
+++ b/test/e2e/servicebindingrequest_test.go
@@ -17,6 +17,7 @@ import (
 	appsv1 "k8s.io/api/apps/v1"
 	corev1 "k8s.io/api/core/v1"
 	"k8s.io/apimachinery/pkg/api/errors"
+	"k8s.io/apimachinery/pkg/runtime/schema"
 	"k8s.io/apimachinery/pkg/types"
 	logf "sigs.k8s.io/controller-runtime/pkg/runtime/log"
 
@@ -39,6 +40,7 @@ var (
 	retryInterval  = time.Second * 5
 	timeout        = time.Second * 120
 	cleanupTimeout = time.Second * 5
+	deploymentsGVR = schema.GroupVersionResource{Group: "apps", Version: "v1", Resource: "deployments"}
 )
 
 // TestAddSchemesToFramework starting point of the test, it declare the CRDs that will be using
@@ -331,11 +333,12 @@ func CreateSBR(
 	cleanupOpts *framework.CleanupOptions,
 	namespacedName types.NamespacedName,
 	resourceRef string,
+	applicationGVR schema.GroupVersionResource,
 	matchLabels map[string]string,
 ) *v1alpha1.ServiceBindingRequest {
 	t.Logf("Creating ServiceBindingRequest mock object '%#v'...", namespacedName)
 	sbr := mocks.ServiceBindingRequestMock(
-		namespacedName.Namespace, namespacedName.Name, resourceRef, "", matchLabels, false)
+		namespacedName.Namespace, namespacedName.Name, resourceRef, "", applicationGVR, matchLabels, false)
 	require.NoError(t, f.Client.Create(ctx, sbr, cleanupOpts))
 	return sbr
 }
@@ -458,7 +461,6 @@ func serviceBindingRequestTest(
 	csvNamespacedName := types.NamespacedName{Namespace: ns, Name: csvName}
 
 	cleanupOpts := cleanupOptions(ctx)
-	noCleanupOpts := &framework.CleanupOptions{TestContext: ctx}
 
 	todoCtx := context.TODO()
 
@@ -472,7 +474,7 @@ func serviceBindingRequestTest(
 		case AppStep:
 			CreateApp(todoCtx, t, f, cleanupOpts, deploymentNamespacedName, matchLabels)
 		case SBRStep:
-			sbr = CreateSBR(todoCtx, t, f, noCleanupOpts, sbrNamespacedName, resourceRef, matchLabels)
+			sbr = CreateSBR(todoCtx, t, f, cleanupOpts, sbrNamespacedName, resourceRef, deploymentsGVR, matchLabels)
 		}
 	}
 
diff --git a/test/mocks/fake.go b/test/mocks/fake.go
index cfad5f70..9754bf92 100644
--- a/test/mocks/fake.go
+++ b/test/mocks/fake.go
@@ -11,12 +11,14 @@ import (
 	apiextensionv1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1"
 	"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
 	"k8s.io/apimachinery/pkg/runtime"
+	"k8s.io/apimachinery/pkg/runtime/schema"
 	"k8s.io/client-go/dynamic"
 	fakedynamic "k8s.io/client-go/dynamic/fake"
 	"k8s.io/client-go/kubernetes/scheme"
 	"sigs.k8s.io/controller-runtime/pkg/client"
 	"sigs.k8s.io/controller-runtime/pkg/client/fake"
 
+	ocav1 "github.com/openshift/api/apps/v1"
 	v1alpha1 "github.com/redhat-developer/service-binding-operator/pkg/apis/apps/v1alpha1"
 )
 
@@ -33,10 +35,11 @@ func (f *Fake) AddMockedServiceBindingRequest(
 	name string,
 	backingServiceResourceRef string,
 	applicationResourceRef string,
+	applicationGVR schema.GroupVersionResource,
 	matchLabels map[string]string,
 ) *v1alpha1.ServiceBindingRequest {
 	f.S.AddKnownTypes(v1alpha1.SchemeGroupVersion, &v1alpha1.ServiceBindingRequest{})
-	sbr := ServiceBindingRequestMock(f.ns, name, backingServiceResourceRef, applicationResourceRef, matchLabels, false)
+	sbr := ServiceBindingRequestMock(f.ns, name, backingServiceResourceRef, applicationResourceRef, applicationGVR, matchLabels, false)
 	f.objs = append(f.objs, sbr)
 	return sbr
 }
@@ -46,10 +49,11 @@ func (f *Fake) AddMockedServiceBindingRequestWithUnannotated(
 	name string,
 	backingServiceResourceRef string,
 	applicationResourceRef string,
+	applicationGVR schema.GroupVersionResource,
 	matchLabels map[string]string,
 ) *v1alpha1.ServiceBindingRequest {
 	f.S.AddKnownTypes(v1alpha1.SchemeGroupVersion, &v1alpha1.ServiceBindingRequest{})
-	sbr := ServiceBindingRequestMock(f.ns, name, backingServiceResourceRef, applicationResourceRef, matchLabels, true)
+	sbr := ServiceBindingRequestMock(f.ns, name, backingServiceResourceRef, applicationResourceRef, applicationGVR, matchLabels, true)
 	f.objs = append(f.objs, sbr)
 	return sbr
 }
@@ -58,10 +62,11 @@ func (f *Fake) AddMockedUnstructuredServiceBindingRequest(
 	name string,
 	backingServiceResourceRef string,
 	applicationResourceRef string,
+	applicationGVR schema.GroupVersionResource,
 	matchLabels map[string]string,
 ) *unstructured.Unstructured {
 	f.S.AddKnownTypes(v1alpha1.SchemeGroupVersion, &v1alpha1.ServiceBindingRequest{})
-	sbr, err := UnstructuredServiceBindingRequestMock(f.ns, name, backingServiceResourceRef, applicationResourceRef, matchLabels)
+	sbr, err := UnstructuredServiceBindingRequestMock(f.ns, name, backingServiceResourceRef, applicationResourceRef, applicationGVR, matchLabels)
 	require.NoError(f.t, err)
 	f.objs = append(f.objs, sbr)
 	return sbr
@@ -114,6 +119,15 @@ func (f *Fake) AddMockedUnstructuredDatabaseCR(ref string) {
 	f.objs = append(f.objs, d)
 }
 
+// AddMockedUnstructuredDeploymentConfig adds mocked object from UnstructuredDeploymentConfigMock.
+func (f *Fake) AddMockedUnstructuredDeploymentConfig(name string, matchLabels map[string]string) {
+	require.Nil(f.t, ocav1.AddToScheme(f.S))
+	d, err := UnstructuredDeploymentConfigMock(f.ns, name, matchLabels)
+	require.Nil(f.t, err)
+	f.S.AddKnownTypes(ocav1.SchemeGroupVersion, &ocav1.DeploymentConfig{})
+	f.objs = append(f.objs, d)
+}
+
 // AddMockedUnstructuredDeployment add mocked object from UnstructuredDeploymentMock.
 func (f *Fake) AddMockedUnstructuredDeployment(name string, matchLabels map[string]string) {
 	require.NoError(f.t, appsv1.AddToScheme(f.S))
diff --git a/test/mocks/mocks.go b/test/mocks/mocks.go
index 8200e3d8..06252498 100644
--- a/test/mocks/mocks.go
+++ b/test/mocks/mocks.go
@@ -5,18 +5,21 @@ import (
 	"fmt"
 	"strings"
 
+	ocav1 "github.com/openshift/api/apps/v1"
 	ocv1 "github.com/openshift/api/route/v1"
 	pgv1alpha1 "github.com/operator-backing-service-samples/postgresql-operator/pkg/apis/postgresql/v1alpha1"
 	olmv1alpha1 "github.com/operator-framework/operator-lifecycle-manager/pkg/api/apis/operators/v1alpha1"
 	olminstall "github.com/operator-framework/operator-lifecycle-manager/pkg/controller/install"
+	v1alpha1 "github.com/redhat-developer/service-binding-operator/pkg/apis/apps/v1alpha1"
+	"github.com/redhat-developer/service-binding-operator/pkg/converter"
 	appsv1 "k8s.io/api/apps/v1"
 	corev1 "k8s.io/api/core/v1"
 	apiextensionv1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1"
 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
 	"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
-
-	v1alpha1 "github.com/redhat-developer/service-binding-operator/pkg/apis/apps/v1alpha1"
-	"github.com/redhat-developer/service-binding-operator/pkg/converter"
+	ustrv1 "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
+	"k8s.io/apimachinery/pkg/runtime"
+	"k8s.io/apimachinery/pkg/runtime/schema"
 )
 
 // resource details employed in mocks
@@ -371,6 +374,7 @@ func ServiceBindingRequestMock(
 	name string,
 	backingServiceResourceRef string,
 	applicationResourceRef string,
+	applicationGVR schema.GroupVersionResource,
 	matchLabels map[string]string,
 	bindUnannotated bool,
 ) *v1alpha1.ServiceBindingRequest {
@@ -394,9 +398,9 @@ func ServiceBindingRequestMock(
 				ResourceRef: backingServiceResourceRef,
 			},
 			ApplicationSelector: v1alpha1.ApplicationSelector{
-				Group:       "apps",
-				Version:     "v1",
-				Resource:    "deployments",
+				Group:       applicationGVR.Group,
+				Version:     applicationGVR.Version,
+				Resource:    applicationGVR.Resource,
 				ResourceRef: applicationResourceRef,
 				MatchLabels: matchLabels,
 			},
@@ -411,13 +415,68 @@ func UnstructuredServiceBindingRequestMock(
 	name string,
 	backingServiceResourceRef string,
 	applicationResourceRef string,
+	applicationGVR schema.GroupVersionResource,
 	matchLabels map[string]string,
 ) (*unstructured.Unstructured, error) {
 	sbr := ServiceBindingRequestMock(
-		ns, name, backingServiceResourceRef, applicationResourceRef, matchLabels, false)
+		ns, name, backingServiceResourceRef, applicationResourceRef, applicationGVR, matchLabels, false)
 	return converter.ToUnstructuredAsGVK(&sbr, v1alpha1.SchemeGroupVersion.WithKind(OperatorKind))
 }
 
+// DeploymentConfigListMock returns a list of DeploymentMock.
+func DeploymentConfigListMock(ns, name string, matchLabels map[string]string) ocav1.DeploymentConfigList {
+	return ocav1.DeploymentConfigList{
+		TypeMeta: metav1.TypeMeta{
+			Kind:       "DeploymentConfigList",
+			APIVersion: "apps/v1",
+		},
+		Items: []ocav1.DeploymentConfig{DeploymentConfigMock(ns, name, matchLabels)},
+	}
+}
+
+// UnstructuredDeploymentConfigMock converts the DeploymentMock to unstructured.
+func UnstructuredDeploymentConfigMock(
+	ns,
+	name string,
+	matchLabels map[string]string,
+) (*ustrv1.Unstructured, error) {
+	d := DeploymentConfigMock(ns, name, matchLabels)
+	data, err := runtime.DefaultUnstructuredConverter.ToUnstructured(&d)
+	return &ustrv1.Unstructured{Object: data}, err
+}
+
+// DeploymentConfigMock creates a mocked Deployment object of busybox.
+func DeploymentConfigMock(ns, name string, matchLabels map[string]string) ocav1.DeploymentConfig {
+	return ocav1.DeploymentConfig{
+		TypeMeta: metav1.TypeMeta{
+			Kind:       "DeploymentConfig",
+			APIVersion: "apps/v1",
+		},
+		ObjectMeta: metav1.ObjectMeta{
+			Namespace: ns,
+			Name:      name,
+			Labels:    matchLabels,
+		},
+		Spec: ocav1.DeploymentConfigSpec{
+			Selector: matchLabels,
+			Template: &corev1.PodTemplateSpec{
+				ObjectMeta: metav1.ObjectMeta{
+					Namespace: ns,
+					Name:      name,
+					Labels:    matchLabels,
+				},
+				Spec: corev1.PodSpec{
+					Containers: []corev1.Container{{
+						Name:    "busybox",
+						Image:   "busybox:latest",
+						Command: []string{"sleep", "3600"},
+					}},
+				},
+			},
+		},
+	}
+}
+
 // DeploymentListMock returns a list of DeploymentMock.
 func DeploymentListMock(ns, name string, matchLabels map[string]string) appsv1.DeploymentList {
 	return appsv1.DeploymentList{