Repository: redhat-developer/service-binding-operator
Pull request #105 (2019-08-09 05:45:46)

Adds ApplicationObjects in status
This status field has all the objects that were found for that label.

Partially fixes ODC-1327.

Note:
Changes in README will be in a followup PR.

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 **dhritishikhar**
You can assign the PR to them by writing `/assign @dhritishikhar` 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":["dhritishikhar"]} -->
openshift-ci-robot: @DhritiShikhar: PR needs rebase.

<details>

Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md).  If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes/test-infra](https://github.com/kubernetes/test-infra/issues/new?title=Prow%20issue:) repository.
</details>
DhritiShikhar: /assign @baijum 
codecov[bot]: # [Codecov](https://codecov.io/gh/redhat-developer/service-binding-operator/pull/105?src=pr&el=h1) Report
> :exclamation: No coverage uploaded for pull request base (`master@b938fd9`). [Click here to learn what that means](https://docs.codecov.io/docs/error-reference#section-missing-base-commit).
> The diff coverage is `40%`.

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

```diff
@@            Coverage Diff            @@
##             master     #105   +/-   ##
=========================================
  Coverage          ?   58.63%           
=========================================
  Files             ?        6           
  Lines             ?      411           
  Branches          ?        0           
=========================================
  Hits              ?      241           
  Misses            ?      142           
  Partials          ?       28
```


| [Impacted Files](https://codecov.io/gh/redhat-developer/service-binding-operator/pull/105?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pkg/controller/servicebindingrequest/status.go](https://codecov.io/gh/redhat-developer/service-binding-operator/pull/105/diff?src=pr&el=tree#diff-cGtnL2NvbnRyb2xsZXIvc2VydmljZWJpbmRpbmdyZXF1ZXN0L3N0YXR1cy5nbw==) | `60% <100%> (ø)` | |
| [pkg/controller/servicebindingrequest/reconciler.go](https://codecov.io/gh/redhat-developer/service-binding-operator/pull/105/diff?src=pr&el=tree#diff-cGtnL2NvbnRyb2xsZXIvc2VydmljZWJpbmRpbmdyZXF1ZXN0L3JlY29uY2lsZXIuZ28=) | `43.88% <25%> (ø)` | |

------

[Continue to review full report at Codecov](https://codecov.io/gh/redhat-developer/service-binding-operator/pull/105?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/105?src=pr&el=footer). Last update [b938fd9...a86de53](https://codecov.io/gh/redhat-developer/service-binding-operator/pull/105?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

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"]} -->
baijum: /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/105#issuecomment-519812482" title="Approved">baijum</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)~~ [baijum]

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":[]} -->

Patch:
diff --git a/pkg/apis/apps/v1alpha1/servicebindingrequest_types.go b/pkg/apis/apps/v1alpha1/servicebindingrequest_types.go
index 278bed84..966ac66b 100644
--- a/pkg/apis/apps/v1alpha1/servicebindingrequest_types.go
+++ b/pkg/apis/apps/v1alpha1/servicebindingrequest_types.go
@@ -86,6 +86,8 @@ type ServiceBindingRequestStatus struct {
 	BindingStatus BindingStatus `json:"BindingStatus"`
 	// Secret is the name of the intermediate secret
 	Secret string `json:"Secret"`
+	// ApplicationObjects contains all the application objects filtered by label
+	ApplicationObjects []string `json:"ApplicationObjects"`
 }
 
 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
diff --git a/pkg/controller/servicebindingrequest/reconciler.go b/pkg/controller/servicebindingrequest/reconciler.go
index dc787da9..6f818d93 100644
--- a/pkg/controller/servicebindingrequest/reconciler.go
+++ b/pkg/controller/servicebindingrequest/reconciler.go
@@ -192,6 +192,13 @@ func (r *Reconciler) Reconcile(request reconcile.Request) (reconcile.Result, err
 			logger.WithValues("DeploymentConfig.Name", deploymentConfigObj.GetName()).
 				Info("Inspecting DeploymentConfig object...")
 
+			// Update ApplicationObjects Status
+			r.setApplicationObjectsStatus(instance, deploymentConfigObj.GetName())
+			err = r.client.Status().Update(context.TODO(), instance)
+			if err != nil {
+				return reconcile.Result{}, err
+			}
+
 			for i, c := range deploymentConfigObj.Spec.Template.Spec.Containers {
 				if len(retriever.data) > 0 {
 					logger.Info("Adding EnvFrom to container")
@@ -254,6 +261,13 @@ func (r *Reconciler) Reconcile(request reconcile.Request) (reconcile.Result, err
 			logger = logger.WithValues("Deployment.Name", deploymentObj.GetName())
 			logger.Info("Inspecting Deploymen object...")
 
+			// Update ApplicationObjects Status
+			r.setApplicationObjectsStatus(instance, deploymentObj.GetName())
+			err = r.client.Status().Update(context.TODO(), instance)
+			if err != nil {
+				return reconcile.Result{}, err
+			}
+
 			for i, c := range deploymentObj.Spec.Template.Spec.Containers {
 				if len(retriever.data) > 0 {
 					logger.Info("Adding EnvFrom to container")
diff --git a/pkg/controller/servicebindingrequest/status.go b/pkg/controller/servicebindingrequest/status.go
index aca06b3b..7f177979 100644
--- a/pkg/controller/servicebindingrequest/status.go
+++ b/pkg/controller/servicebindingrequest/status.go
@@ -19,3 +19,7 @@ func (r *Reconciler) setBindingFailStatus(sbr *v1alpha1.ServiceBindingRequest) {
 func (r *Reconciler) setSecretStatus(sbr *v1alpha1.ServiceBindingRequest) {
 	sbr.Status.Secret = sbr.GetName()
 }
+
+func (r *Reconciler) setApplicationObjectsStatus(sbr *v1alpha1.ServiceBindingRequest, object string) {
+	sbr.Status.ApplicationObjects = append(sbr.Status.ApplicationObjects, object)
+}


Test patch:
diff --git a/pkg/controller/servicebindingrequest/reconciler_test.go b/pkg/controller/servicebindingrequest/reconciler_test.go
index 212e80eb..b7b89aa7 100644
--- a/pkg/controller/servicebindingrequest/reconciler_test.go
+++ b/pkg/controller/servicebindingrequest/reconciler_test.go
@@ -88,6 +88,7 @@ func TestReconcilerNew(t *testing.T) {
 		require.Nil(t, reconcilerFakeClient.Get(context.TODO(), namespacedName, &sbrOutput))
 		require.Equal(t, v1alpha1.BindingSuccess, sbrOutput.Status.BindingStatus)
 		require.Equal(t, reconcilerName, sbrOutput.Status.Secret)
+		require.Equal(t, reconcilerName, sbrOutput.Status.ApplicationObjects[0])
 	})
 
 }