Repository: redhat-developer/service-binding-operator
Pull request #468 (2020-05-14 09:17:26)

Introduce id field in service selector to be used as shortcut in custom environment variables
### Motivation

With the configuration values collection and aggregation solved in #407, this change introduces the `id` field in backing service selectors to be used as alias while composing custom environment variables.

Solves #396 

### Changes

#407 has grouped service configuration values in the template context using the following the version, api group, kind and name (for example `{{ .v1alpha1.postgresql_baiju_dev.Database.db_testing.status.dbConnection }}`).

This change groups service configuration values in the template context using the optional `id` field declared by the user, allowing the user to write `{{ .db_testing.status.dbConnection }}` instead.

For further more details refer the CONTRIBUTING.md

openshift-ci-robot: Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with `/test all`
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 **isutton**
You can assign the PR to them by writing `/assign @isutton` 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":["isutton"]} -->
sbose78: I thought we were skipping this piece since we already had a way to refer to backing services as per #407 - however, it's your call team @redhat-developer/service-binding . I'm good with whatever users and the team feels about this! :)


> #407 has grouped service configuration values in the template context using the following the version, api group, kind and name (for example {{ .v1alpha1.postgresql_baiju_dev.Database.db_testing.status.dbConnection }}).
This change groups service configuration values in the template context using the optional id field declared by the user, allowing the user to write {{ .db_testing.status.dbConnection }} instead.

@isutton do you mean, we are supporting both what was introduced in #407 and what is currently being proposed ? I'm good if that's the case, wanted to check.
isutton: > I thought we were skipping this piece since we already had a way to refer to backing services as per #407 - however, it's your call team @redhat-developer/service-binding . I'm good with whatever users and the team feels about this! :)
> 
> > #407 has grouped service configuration values in the template context using the following the version, api group, kind and name (for example {{ .v1alpha1.postgresql_baiju_dev.Database.db_testing.status.dbConnection }}).
> > This change groups service configuration values in the template context using the optional id field declared by the user, allowing the user to write {{ .db_testing.status.dbConnection }} instead.
> 
> @isutton do you mean, we are supporting both what was introduced in #407 and what is currently being proposed ? I'm good if that's the case, wanted to check.

@sbose78 indeed, #407 populated the custom environment variable template context with:

- all collected service data in a hierarchy with transformed names, replacing `-` to `_` so the value can be used in templates like `{{ .v1alpha1.postgresql_baiju_dev.Database.db_testing.status.dbCredentials.username }}`;and
- all collected data in a hierarchy with the original names.

#468 allows the user to specify an alias (the `id` property) to be used in the template context, being used like `{{ .db_testing.status.dbCredentials.username }}`.

Is this clearer, @sbose78? 
sbose78: Sounds good, Igor.
ZhuangYuZY: What is target spec for "id" in SBR ? Thank you.
codecov[bot]: # [Codecov](https://codecov.io/gh/redhat-developer/service-binding-operator/pull/468?src=pr&el=h1) Report
> Merging [#468](https://codecov.io/gh/redhat-developer/service-binding-operator/pull/468?src=pr&el=desc) into [master](https://codecov.io/gh/redhat-developer/service-binding-operator/commit/861614de28833a2f046a31f6355ea40bd106abd8&el=desc) will **decrease** coverage by `2.74%`.
> The diff coverage is `70.21%`.

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

```diff
@@            Coverage Diff             @@
##           master     #468      +/-   ##
==========================================
- Coverage   66.26%   63.51%   -2.75%     
==========================================
  Files          21       27       +6     
  Lines        1479     1798     +319     
==========================================
+ Hits          980     1142     +162     
- Misses        377      489     +112     
- Partials      122      167      +45     
```


| [Impacted Files](https://codecov.io/gh/redhat-developer/service-binding-operator/pull/468?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [...r/servicebindingrequest/annotations/annotations.go](https://codecov.io/gh/redhat-developer/service-binding-operator/pull/468/diff?src=pr&el=tree#diff-cGtnL2NvbnRyb2xsZXIvc2VydmljZWJpbmRpbmdyZXF1ZXN0L2Fubm90YXRpb25zL2Fubm90YXRpb25zLmdv) | `0.00% <0.00%> (ø)` | |
| [...roller/servicebindingrequest/annotations/errors.go](https://codecov.io/gh/redhat-developer/service-binding-operator/pull/468/diff?src=pr&el=tree#diff-cGtnL2NvbnRyb2xsZXIvc2VydmljZWJpbmRpbmdyZXF1ZXN0L2Fubm90YXRpb25zL2Vycm9ycy5nbw==) | `0.00% <0.00%> (ø)` | |
| [pkg/controller/servicebindingrequest/binder.go](https://codecov.io/gh/redhat-developer/service-binding-operator/pull/468/diff?src=pr&el=tree#diff-cGtnL2NvbnRyb2xsZXIvc2VydmljZWJpbmRpbmdyZXF1ZXN0L2JpbmRlci5nbw==) | `64.61% <ø> (-0.02%)` | :arrow_down: |
| [pkg/controller/servicebindingrequest/controller.go](https://codecov.io/gh/redhat-developer/service-binding-operator/pull/468/diff?src=pr&el=tree#diff-cGtnL2NvbnRyb2xsZXIvc2VydmljZWJpbmRpbmdyZXF1ZXN0L2NvbnRyb2xsZXIuZ28=) | `0.00% <0.00%> (ø)` | |
| [pkg/controller/servicebindingrequest/reconciler.go](https://codecov.io/gh/redhat-developer/service-binding-operator/pull/468/diff?src=pr&el=tree#diff-cGtnL2NvbnRyb2xsZXIvc2VydmljZWJpbmRpbmdyZXF1ZXN0L3JlY29uY2lsZXIuZ28=) | `61.44% <56.09%> (+14.87%)` | :arrow_up: |
| [.../controller/servicebindingrequest/nested/nested.go](https://codecov.io/gh/redhat-developer/service-binding-operator/pull/468/diff?src=pr&el=tree#diff-cGtnL2NvbnRyb2xsZXIvc2VydmljZWJpbmRpbmdyZXF1ZXN0L25lc3RlZC9uZXN0ZWQuZ28=) | `59.03% <59.03%> (ø)` | |
| [...controller/servicebindingrequest/servicecontext.go](https://codecov.io/gh/redhat-developer/service-binding-operator/pull/468/diff?src=pr&el=tree#diff-cGtnL2NvbnRyb2xsZXIvc2VydmljZWJpbmRpbmdyZXF1ZXN0L3NlcnZpY2Vjb250ZXh0Lmdv) | `63.10% <63.10%> (ø)` | |
| [...ller/servicebindingrequest/annotations/resource.go](https://codecov.io/gh/redhat-developer/service-binding-operator/pull/468/diff?src=pr&el=tree#diff-cGtnL2NvbnRyb2xsZXIvc2VydmljZWJpbmRpbmdyZXF1ZXN0L2Fubm90YXRpb25zL3Jlc291cmNlLmdv) | `65.65% <65.65%> (ø)` | |
| [...roller/servicebindingrequest/annotations/secret.go](https://codecov.io/gh/redhat-developer/service-binding-operator/pull/468/diff?src=pr&el=tree#diff-cGtnL2NvbnRyb2xsZXIvc2VydmljZWJpbmRpbmdyZXF1ZXN0L2Fubm90YXRpb25zL3NlY3JldC5nbw==) | `69.23% <69.23%> (ø)` | |
| [.../controller/servicebindingrequest/servicebinder.go](https://codecov.io/gh/redhat-developer/service-binding-operator/pull/468/diff?src=pr&el=tree#diff-cGtnL2NvbnRyb2xsZXIvc2VydmljZWJpbmRpbmdyZXF1ZXN0L3NlcnZpY2ViaW5kZXIuZ28=) | `64.37% <75.00%> (ø)` | |
| ... and [26 more](https://codecov.io/gh/redhat-developer/service-binding-operator/pull/468/diff?src=pr&el=tree-more) | |

------

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

isutton: /retest
openshift-ci-robot: @isutton: The following test **failed**, say `/retest` to rerun all failed tests:

Test name | Commit | Details | Rerun command
--- | --- | --- | ---
ci/prow/4.5-e2e | 1b9e17b82bc02125c53dc31c48b77ef8ee1bf51b | [link](https://prow.svc.ci.openshift.org/view/gcs/origin-ci-test/pr-logs/pull/redhat-developer_service-binding-operator/468/pull-ci-redhat-developer-service-binding-operator-master-4.5-e2e/1272912748627365888) | `/test 4.5-e2e`

[Full PR test history](https://prow.svc.ci.openshift.org/pr-history?org=redhat-developer&repo=service-binding-operator&pr=468). [Your PR dashboard](https://prow.svc.ci.openshift.org/pr?query=is:pr+state:open+author:isutton). Please help us cut down on flakes by [linking to](https://github.com/kubernetes/community/blob/master/contributors/devel/flaky-tests.md#filing-issues-for-flaky-tests) an [open issue](https://github.com/redhat-developer/service-binding-operator/issues?q=is:issue+is:open) when you hit one in your PR.

<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. I understand the commands that are listed [here](https://go.k8s.io/bot-commands).
</details>
<!-- test report -->
openshift-ci-robot: @isutton: The following tests **failed**, say `/retest` to rerun all failed tests:

Test name | Commit | Details | Rerun command
--- | --- | --- | ---
ci/prow/4.5-e2e | 1b9e17b82bc02125c53dc31c48b77ef8ee1bf51b | [link](https://prow.svc.ci.openshift.org/view/gcs/origin-ci-test/pr-logs/pull/redhat-developer_service-binding-operator/468/pull-ci-redhat-developer-service-binding-operator-master-4.5-e2e/1272912748627365888) | `/test 4.5-e2e`
ci/prow/lint | 1b9e17b82bc02125c53dc31c48b77ef8ee1bf51b | [link](https://prow.svc.ci.openshift.org/view/gcs/origin-ci-test/pr-logs/pull/redhat-developer_service-binding-operator/468/pull-ci-redhat-developer-service-binding-operator-master-lint/1272912748887412736) | `/test lint`

[Full PR test history](https://prow.svc.ci.openshift.org/pr-history?org=redhat-developer&repo=service-binding-operator&pr=468). [Your PR dashboard](https://prow.svc.ci.openshift.org/pr?query=is:pr+state:open+author:isutton). Please help us cut down on flakes by [linking to](https://github.com/kubernetes/community/blob/master/contributors/devel/flaky-tests.md#filing-issues-for-flaky-tests) an [open issue](https://github.com/redhat-developer/service-binding-operator/issues?q=is:issue+is:open) when you hit one in your PR.

<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. I understand the commands that are listed [here](https://go.k8s.io/bot-commands).
</details>
<!-- test report -->
openshift-ci-robot: @isutton: The following tests **failed**, say `/retest` to rerun all failed tests:

Test name | Commit | Details | Rerun command
--- | --- | --- | ---
ci/prow/4.5-e2e | 1b9e17b82bc02125c53dc31c48b77ef8ee1bf51b | [link](https://prow.svc.ci.openshift.org/view/gcs/origin-ci-test/pr-logs/pull/redhat-developer_service-binding-operator/468/pull-ci-redhat-developer-service-binding-operator-master-4.5-e2e/1272912748627365888) | `/test 4.5-e2e`
ci/prow/lint | 1b9e17b82bc02125c53dc31c48b77ef8ee1bf51b | [link](https://prow.svc.ci.openshift.org/view/gcs/origin-ci-test/pr-logs/pull/redhat-developer_service-binding-operator/468/pull-ci-redhat-developer-service-binding-operator-master-lint/1272912748887412736) | `/test lint`
ci/prow/4.5-unit | 1b9e17b82bc02125c53dc31c48b77ef8ee1bf51b | [link](https://prow.svc.ci.openshift.org/view/gcs/origin-ci-test/pr-logs/pull/redhat-developer_service-binding-operator/468/pull-ci-redhat-developer-service-binding-operator-master-4.5-unit/1272912880202682368) | `/test 4.5-unit`

[Full PR test history](https://prow.svc.ci.openshift.org/pr-history?org=redhat-developer&repo=service-binding-operator&pr=468). [Your PR dashboard](https://prow.svc.ci.openshift.org/pr?query=is:pr+state:open+author:isutton). Please help us cut down on flakes by [linking to](https://github.com/kubernetes/community/blob/master/contributors/devel/flaky-tests.md#filing-issues-for-flaky-tests) an [open issue](https://github.com/redhat-developer/service-binding-operator/issues?q=is:issue+is:open) when you hit one in your PR.

<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. I understand the commands that are listed [here](https://go.k8s.io/bot-commands).
</details>
<!-- test report -->
openshift-ci-robot: @isutton: The following tests **failed**, say `/retest` to rerun all failed tests:

Test name | Commit | Details | Rerun command
--- | --- | --- | ---
ci/prow/4.5-e2e | 1b9e17b82bc02125c53dc31c48b77ef8ee1bf51b | [link](https://prow.svc.ci.openshift.org/view/gcs/origin-ci-test/pr-logs/pull/redhat-developer_service-binding-operator/468/pull-ci-redhat-developer-service-binding-operator-master-4.5-e2e/1272912748627365888) | `/test 4.5-e2e`
ci/prow/lint | 1b9e17b82bc02125c53dc31c48b77ef8ee1bf51b | [link](https://prow.svc.ci.openshift.org/view/gcs/origin-ci-test/pr-logs/pull/redhat-developer_service-binding-operator/468/pull-ci-redhat-developer-service-binding-operator-master-lint/1272912748887412736) | `/test lint`
ci/prow/4.5-unit | 1b9e17b82bc02125c53dc31c48b77ef8ee1bf51b | [link](https://prow.svc.ci.openshift.org/view/gcs/origin-ci-test/pr-logs/pull/redhat-developer_service-binding-operator/468/pull-ci-redhat-developer-service-binding-operator-master-4.5-unit/1272912880202682368) | `/test 4.5-unit`
ci/prow/4.5-lint | 1b9e17b82bc02125c53dc31c48b77ef8ee1bf51b | [link](https://prow.svc.ci.openshift.org/view/gcs/origin-ci-test/pr-logs/pull/redhat-developer_service-binding-operator/468/pull-ci-redhat-developer-service-binding-operator-master-4.5-lint/1272912877694488576) | `/test 4.5-lint`

[Full PR test history](https://prow.svc.ci.openshift.org/pr-history?org=redhat-developer&repo=service-binding-operator&pr=468). [Your PR dashboard](https://prow.svc.ci.openshift.org/pr?query=is:pr+state:open+author:isutton). Please help us cut down on flakes by [linking to](https://github.com/kubernetes/community/blob/master/contributors/devel/flaky-tests.md#filing-issues-for-flaky-tests) an [open issue](https://github.com/redhat-developer/service-binding-operator/issues?q=is:issue+is:open) when you hit one in your PR.

<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. I understand the commands that are listed [here](https://go.k8s.io/bot-commands).
</details>
<!-- test report -->
openshift-ci-robot: @isutton: The following tests **failed**, say `/retest` to rerun all failed tests:

Test name | Commit | Details | Rerun command
--- | --- | --- | ---
ci/prow/4.5-e2e | 1b9e17b82bc02125c53dc31c48b77ef8ee1bf51b | [link](https://prow.svc.ci.openshift.org/view/gcs/origin-ci-test/pr-logs/pull/redhat-developer_service-binding-operator/468/pull-ci-redhat-developer-service-binding-operator-master-4.5-e2e/1272912748627365888) | `/test 4.5-e2e`
ci/prow/lint | 1b9e17b82bc02125c53dc31c48b77ef8ee1bf51b | [link](https://prow.svc.ci.openshift.org/view/gcs/origin-ci-test/pr-logs/pull/redhat-developer_service-binding-operator/468/pull-ci-redhat-developer-service-binding-operator-master-lint/1272912748887412736) | `/test lint`
ci/prow/4.5-unit | 1b9e17b82bc02125c53dc31c48b77ef8ee1bf51b | [link](https://prow.svc.ci.openshift.org/view/gcs/origin-ci-test/pr-logs/pull/redhat-developer_service-binding-operator/468/pull-ci-redhat-developer-service-binding-operator-master-4.5-unit/1272912880202682368) | `/test 4.5-unit`
ci/prow/4.5-lint | 1b9e17b82bc02125c53dc31c48b77ef8ee1bf51b | [link](https://prow.svc.ci.openshift.org/view/gcs/origin-ci-test/pr-logs/pull/redhat-developer_service-binding-operator/468/pull-ci-redhat-developer-service-binding-operator-master-4.5-lint/1272912877694488576) | `/test 4.5-lint`
ci/prow/unit | 1b9e17b82bc02125c53dc31c48b77ef8ee1bf51b | [link](https://prow.svc.ci.openshift.org/view/gcs/origin-ci-test/pr-logs/pull/redhat-developer_service-binding-operator/468/pull-ci-redhat-developer-service-binding-operator-master-unit/1272912937140359168) | `/test unit`

[Full PR test history](https://prow.svc.ci.openshift.org/pr-history?org=redhat-developer&repo=service-binding-operator&pr=468). [Your PR dashboard](https://prow.svc.ci.openshift.org/pr?query=is:pr+state:open+author:isutton). Please help us cut down on flakes by [linking to](https://github.com/kubernetes/community/blob/master/contributors/devel/flaky-tests.md#filing-issues-for-flaky-tests) an [open issue](https://github.com/redhat-developer/service-binding-operator/issues?q=is:issue+is:open) when you hit one in your PR.

<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. I understand the commands that are listed [here](https://go.k8s.io/bot-commands).
</details>
<!-- test report -->
openshift-ci-robot: @isutton: The following tests **failed**, say `/retest` to rerun all failed tests:

Test name | Commit | Details | Rerun command
--- | --- | --- | ---
ci/prow/4.5-e2e | 1b9e17b82bc02125c53dc31c48b77ef8ee1bf51b | [link](https://prow.svc.ci.openshift.org/view/gcs/origin-ci-test/pr-logs/pull/redhat-developer_service-binding-operator/468/pull-ci-redhat-developer-service-binding-operator-master-4.5-e2e/1272912748627365888) | `/test 4.5-e2e`
ci/prow/lint | 1b9e17b82bc02125c53dc31c48b77ef8ee1bf51b | [link](https://prow.svc.ci.openshift.org/view/gcs/origin-ci-test/pr-logs/pull/redhat-developer_service-binding-operator/468/pull-ci-redhat-developer-service-binding-operator-master-lint/1272912748887412736) | `/test lint`
ci/prow/4.5-unit | 1b9e17b82bc02125c53dc31c48b77ef8ee1bf51b | [link](https://prow.svc.ci.openshift.org/view/gcs/origin-ci-test/pr-logs/pull/redhat-developer_service-binding-operator/468/pull-ci-redhat-developer-service-binding-operator-master-4.5-unit/1272912880202682368) | `/test 4.5-unit`
ci/prow/4.5-lint | 1b9e17b82bc02125c53dc31c48b77ef8ee1bf51b | [link](https://prow.svc.ci.openshift.org/view/gcs/origin-ci-test/pr-logs/pull/redhat-developer_service-binding-operator/468/pull-ci-redhat-developer-service-binding-operator-master-4.5-lint/1272912877694488576) | `/test 4.5-lint`
ci/prow/unit | 1b9e17b82bc02125c53dc31c48b77ef8ee1bf51b | [link](https://prow.svc.ci.openshift.org/view/gcs/origin-ci-test/pr-logs/pull/redhat-developer_service-binding-operator/468/pull-ci-redhat-developer-service-binding-operator-master-unit/1272912937140359168) | `/test unit`
ci/prow/e2e | 1b9e17b82bc02125c53dc31c48b77ef8ee1bf51b | [link](https://prow.svc.ci.openshift.org/view/gcs/origin-ci-test/pr-logs/pull/redhat-developer_service-binding-operator/468/pull-ci-redhat-developer-service-binding-operator-master-e2e/1272912844916002816) | `/test e2e`

[Full PR test history](https://prow.svc.ci.openshift.org/pr-history?org=redhat-developer&repo=service-binding-operator&pr=468). [Your PR dashboard](https://prow.svc.ci.openshift.org/pr?query=is:pr+state:open+author:isutton). Please help us cut down on flakes by [linking to](https://github.com/kubernetes/community/blob/master/contributors/devel/flaky-tests.md#filing-issues-for-flaky-tests) an [open issue](https://github.com/redhat-developer/service-binding-operator/issues?q=is:issue+is:open) when you hit one in your PR.

<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. I understand the commands that are listed [here](https://go.k8s.io/bot-commands).
</details>
<!-- test report -->
isutton: /retest
openshift-ci-robot: @isutton: The following tests **failed**, say `/retest` to rerun all failed tests:

Test name | Commit | Details | Rerun command
--- | --- | --- | ---
ci/prow/4.5-e2e | 1b9e17b82bc02125c53dc31c48b77ef8ee1bf51b | [link](https://prow.svc.ci.openshift.org/view/gcs/origin-ci-test/pr-logs/pull/redhat-developer_service-binding-operator/468/pull-ci-redhat-developer-service-binding-operator-master-4.5-e2e/1272912748627365888) | `/test 4.5-e2e`
ci/prow/lint | 1b9e17b82bc02125c53dc31c48b77ef8ee1bf51b | [link](https://prow.svc.ci.openshift.org/view/gcs/origin-ci-test/pr-logs/pull/redhat-developer_service-binding-operator/468/pull-ci-redhat-developer-service-binding-operator-master-lint/1272912748887412736) | `/test lint`
ci/prow/4.5-lint | 1b9e17b82bc02125c53dc31c48b77ef8ee1bf51b | [link](https://prow.svc.ci.openshift.org/view/gcs/origin-ci-test/pr-logs/pull/redhat-developer_service-binding-operator/468/pull-ci-redhat-developer-service-binding-operator-master-4.5-lint/1272912877694488576) | `/test 4.5-lint`
ci/prow/unit | 1b9e17b82bc02125c53dc31c48b77ef8ee1bf51b | [link](https://prow.svc.ci.openshift.org/view/gcs/origin-ci-test/pr-logs/pull/redhat-developer_service-binding-operator/468/pull-ci-redhat-developer-service-binding-operator-master-unit/1272912937140359168) | `/test unit`
ci/prow/e2e | 1b9e17b82bc02125c53dc31c48b77ef8ee1bf51b | [link](https://prow.svc.ci.openshift.org/view/gcs/origin-ci-test/pr-logs/pull/redhat-developer_service-binding-operator/468/pull-ci-redhat-developer-service-binding-operator-master-e2e/1272912844916002816) | `/test e2e`
ci/prow/4.5-unit | 1b9e17b82bc02125c53dc31c48b77ef8ee1bf51b | [link](https://prow.svc.ci.openshift.org/view/gcs/origin-ci-test/pr-logs/pull/redhat-developer_service-binding-operator/468/pull-ci-redhat-developer-service-binding-operator-master-4.5-unit/1273012877359321088) | `/test 4.5-unit`

[Full PR test history](https://prow.svc.ci.openshift.org/pr-history?org=redhat-developer&repo=service-binding-operator&pr=468). [Your PR dashboard](https://prow.svc.ci.openshift.org/pr?query=is:pr+state:open+author:isutton). Please help us cut down on flakes by [linking to](https://github.com/kubernetes/community/blob/master/contributors/devel/flaky-tests.md#filing-issues-for-flaky-tests) an [open issue](https://github.com/redhat-developer/service-binding-operator/issues?q=is:issue+is:open) when you hit one in your PR.

<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. I understand the commands that are listed [here](https://go.k8s.io/bot-commands).
</details>
<!-- test report -->
openshift-ci-robot: @isutton: The following tests **failed**, say `/retest` to rerun all failed tests:

Test name | Commit | Details | Rerun command
--- | --- | --- | ---
ci/prow/4.5-e2e | 1b9e17b82bc02125c53dc31c48b77ef8ee1bf51b | [link](https://prow.svc.ci.openshift.org/view/gcs/origin-ci-test/pr-logs/pull/redhat-developer_service-binding-operator/468/pull-ci-redhat-developer-service-binding-operator-master-4.5-e2e/1272912748627365888) | `/test 4.5-e2e`
ci/prow/lint | 1b9e17b82bc02125c53dc31c48b77ef8ee1bf51b | [link](https://prow.svc.ci.openshift.org/view/gcs/origin-ci-test/pr-logs/pull/redhat-developer_service-binding-operator/468/pull-ci-redhat-developer-service-binding-operator-master-lint/1272912748887412736) | `/test lint`
ci/prow/unit | 1b9e17b82bc02125c53dc31c48b77ef8ee1bf51b | [link](https://prow.svc.ci.openshift.org/view/gcs/origin-ci-test/pr-logs/pull/redhat-developer_service-binding-operator/468/pull-ci-redhat-developer-service-binding-operator-master-unit/1272912937140359168) | `/test unit`
ci/prow/e2e | 1b9e17b82bc02125c53dc31c48b77ef8ee1bf51b | [link](https://prow.svc.ci.openshift.org/view/gcs/origin-ci-test/pr-logs/pull/redhat-developer_service-binding-operator/468/pull-ci-redhat-developer-service-binding-operator-master-e2e/1272912844916002816) | `/test e2e`
ci/prow/4.5-unit | 1b9e17b82bc02125c53dc31c48b77ef8ee1bf51b | [link](https://prow.svc.ci.openshift.org/view/gcs/origin-ci-test/pr-logs/pull/redhat-developer_service-binding-operator/468/pull-ci-redhat-developer-service-binding-operator-master-4.5-unit/1273012877359321088) | `/test 4.5-unit`
ci/prow/4.5-lint | 1b9e17b82bc02125c53dc31c48b77ef8ee1bf51b | [link](https://prow.svc.ci.openshift.org/view/gcs/origin-ci-test/pr-logs/pull/redhat-developer_service-binding-operator/468/pull-ci-redhat-developer-service-binding-operator-master-4.5-lint/1273012877329960960) | `/test 4.5-lint`

[Full PR test history](https://prow.svc.ci.openshift.org/pr-history?org=redhat-developer&repo=service-binding-operator&pr=468). [Your PR dashboard](https://prow.svc.ci.openshift.org/pr?query=is:pr+state:open+author:isutton). Please help us cut down on flakes by [linking to](https://github.com/kubernetes/community/blob/master/contributors/devel/flaky-tests.md#filing-issues-for-flaky-tests) an [open issue](https://github.com/redhat-developer/service-binding-operator/issues?q=is:issue+is:open) when you hit one in your PR.

<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. I understand the commands that are listed [here](https://go.k8s.io/bot-commands).
</details>
<!-- test report -->
openshift-ci-robot: @isutton: The following tests **failed**, say `/retest` to rerun all failed tests:

Test name | Commit | Details | Rerun command
--- | --- | --- | ---
ci/prow/4.5-e2e | 1b9e17b82bc02125c53dc31c48b77ef8ee1bf51b | [link](https://prow.svc.ci.openshift.org/view/gcs/origin-ci-test/pr-logs/pull/redhat-developer_service-binding-operator/468/pull-ci-redhat-developer-service-binding-operator-master-4.5-e2e/1272912748627365888) | `/test 4.5-e2e`
ci/prow/lint | 1b9e17b82bc02125c53dc31c48b77ef8ee1bf51b | [link](https://prow.svc.ci.openshift.org/view/gcs/origin-ci-test/pr-logs/pull/redhat-developer_service-binding-operator/468/pull-ci-redhat-developer-service-binding-operator-master-lint/1272912748887412736) | `/test lint`
ci/prow/unit | 1b9e17b82bc02125c53dc31c48b77ef8ee1bf51b | [link](https://prow.svc.ci.openshift.org/view/gcs/origin-ci-test/pr-logs/pull/redhat-developer_service-binding-operator/468/pull-ci-redhat-developer-service-binding-operator-master-unit/1272912937140359168) | `/test unit`
ci/prow/4.5-unit | 1b9e17b82bc02125c53dc31c48b77ef8ee1bf51b | [link](https://prow.svc.ci.openshift.org/view/gcs/origin-ci-test/pr-logs/pull/redhat-developer_service-binding-operator/468/pull-ci-redhat-developer-service-binding-operator-master-4.5-unit/1273012877359321088) | `/test 4.5-unit`
ci/prow/4.5-lint | 1b9e17b82bc02125c53dc31c48b77ef8ee1bf51b | [link](https://prow.svc.ci.openshift.org/view/gcs/origin-ci-test/pr-logs/pull/redhat-developer_service-binding-operator/468/pull-ci-redhat-developer-service-binding-operator-master-4.5-lint/1273012877329960960) | `/test 4.5-lint`
ci/prow/e2e | 1b9e17b82bc02125c53dc31c48b77ef8ee1bf51b | [link](https://prow.svc.ci.openshift.org/view/gcs/origin-ci-test/pr-logs/pull/redhat-developer_service-binding-operator/468/pull-ci-redhat-developer-service-binding-operator-master-e2e/1273012877405458432) | `/test e2e`

[Full PR test history](https://prow.svc.ci.openshift.org/pr-history?org=redhat-developer&repo=service-binding-operator&pr=468). [Your PR dashboard](https://prow.svc.ci.openshift.org/pr?query=is:pr+state:open+author:isutton). Please help us cut down on flakes by [linking to](https://github.com/kubernetes/community/blob/master/contributors/devel/flaky-tests.md#filing-issues-for-flaky-tests) an [open issue](https://github.com/redhat-developer/service-binding-operator/issues?q=is:issue+is:open) when you hit one in your PR.

<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. I understand the commands that are listed [here](https://go.k8s.io/bot-commands).
</details>
<!-- test report -->
openshift-ci-robot: @isutton: The following tests **failed**, say `/retest` to rerun all failed tests:

Test name | Commit | Details | Rerun command
--- | --- | --- | ---
ci/prow/4.5-e2e | 1b9e17b82bc02125c53dc31c48b77ef8ee1bf51b | [link](https://prow.svc.ci.openshift.org/view/gcs/origin-ci-test/pr-logs/pull/redhat-developer_service-binding-operator/468/pull-ci-redhat-developer-service-binding-operator-master-4.5-e2e/1272912748627365888) | `/test 4.5-e2e`
ci/prow/unit | 1b9e17b82bc02125c53dc31c48b77ef8ee1bf51b | [link](https://prow.svc.ci.openshift.org/view/gcs/origin-ci-test/pr-logs/pull/redhat-developer_service-binding-operator/468/pull-ci-redhat-developer-service-binding-operator-master-unit/1272912937140359168) | `/test unit`
ci/prow/4.5-unit | 1b9e17b82bc02125c53dc31c48b77ef8ee1bf51b | [link](https://prow.svc.ci.openshift.org/view/gcs/origin-ci-test/pr-logs/pull/redhat-developer_service-binding-operator/468/pull-ci-redhat-developer-service-binding-operator-master-4.5-unit/1273012877359321088) | `/test 4.5-unit`
ci/prow/4.5-lint | 1b9e17b82bc02125c53dc31c48b77ef8ee1bf51b | [link](https://prow.svc.ci.openshift.org/view/gcs/origin-ci-test/pr-logs/pull/redhat-developer_service-binding-operator/468/pull-ci-redhat-developer-service-binding-operator-master-4.5-lint/1273012877329960960) | `/test 4.5-lint`
ci/prow/e2e | 1b9e17b82bc02125c53dc31c48b77ef8ee1bf51b | [link](https://prow.svc.ci.openshift.org/view/gcs/origin-ci-test/pr-logs/pull/redhat-developer_service-binding-operator/468/pull-ci-redhat-developer-service-binding-operator-master-e2e/1273012877405458432) | `/test e2e`
ci/prow/lint | 1b9e17b82bc02125c53dc31c48b77ef8ee1bf51b | [link](https://prow.svc.ci.openshift.org/view/gcs/origin-ci-test/pr-logs/pull/redhat-developer_service-binding-operator/468/pull-ci-redhat-developer-service-binding-operator-master-lint/1273012877451595776) | `/test lint`

[Full PR test history](https://prow.svc.ci.openshift.org/pr-history?org=redhat-developer&repo=service-binding-operator&pr=468). [Your PR dashboard](https://prow.svc.ci.openshift.org/pr?query=is:pr+state:open+author:isutton). Please help us cut down on flakes by [linking to](https://github.com/kubernetes/community/blob/master/contributors/devel/flaky-tests.md#filing-issues-for-flaky-tests) an [open issue](https://github.com/redhat-developer/service-binding-operator/issues?q=is:issue+is:open) when you hit one in your PR.

<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. I understand the commands that are listed [here](https://go.k8s.io/bot-commands).
</details>
<!-- test report -->
openshift-ci-robot: @isutton: The following tests **failed**, say `/retest` to rerun all failed tests:

Test name | Commit | Details | Rerun command
--- | --- | --- | ---
ci/prow/4.5-e2e | 1b9e17b82bc02125c53dc31c48b77ef8ee1bf51b | [link](https://prow.svc.ci.openshift.org/view/gcs/origin-ci-test/pr-logs/pull/redhat-developer_service-binding-operator/468/pull-ci-redhat-developer-service-binding-operator-master-4.5-e2e/1272912748627365888) | `/test 4.5-e2e`
ci/prow/4.5-unit | 1b9e17b82bc02125c53dc31c48b77ef8ee1bf51b | [link](https://prow.svc.ci.openshift.org/view/gcs/origin-ci-test/pr-logs/pull/redhat-developer_service-binding-operator/468/pull-ci-redhat-developer-service-binding-operator-master-4.5-unit/1273012877359321088) | `/test 4.5-unit`
ci/prow/4.5-lint | 1b9e17b82bc02125c53dc31c48b77ef8ee1bf51b | [link](https://prow.svc.ci.openshift.org/view/gcs/origin-ci-test/pr-logs/pull/redhat-developer_service-binding-operator/468/pull-ci-redhat-developer-service-binding-operator-master-4.5-lint/1273012877329960960) | `/test 4.5-lint`
ci/prow/e2e | 1b9e17b82bc02125c53dc31c48b77ef8ee1bf51b | [link](https://prow.svc.ci.openshift.org/view/gcs/origin-ci-test/pr-logs/pull/redhat-developer_service-binding-operator/468/pull-ci-redhat-developer-service-binding-operator-master-e2e/1273012877405458432) | `/test e2e`
ci/prow/lint | 1b9e17b82bc02125c53dc31c48b77ef8ee1bf51b | [link](https://prow.svc.ci.openshift.org/view/gcs/origin-ci-test/pr-logs/pull/redhat-developer_service-binding-operator/468/pull-ci-redhat-developer-service-binding-operator-master-lint/1273012877451595776) | `/test lint`
ci/prow/unit | 1b9e17b82bc02125c53dc31c48b77ef8ee1bf51b | [link](https://prow.svc.ci.openshift.org/view/gcs/origin-ci-test/pr-logs/pull/redhat-developer_service-binding-operator/468/pull-ci-redhat-developer-service-binding-operator-master-unit/1273012877489344512) | `/test unit`

[Full PR test history](https://prow.svc.ci.openshift.org/pr-history?org=redhat-developer&repo=service-binding-operator&pr=468). [Your PR dashboard](https://prow.svc.ci.openshift.org/pr?query=is:pr+state:open+author:isutton). Please help us cut down on flakes by [linking to](https://github.com/kubernetes/community/blob/master/contributors/devel/flaky-tests.md#filing-issues-for-flaky-tests) an [open issue](https://github.com/redhat-developer/service-binding-operator/issues?q=is:issue+is:open) when you hit one in your PR.

<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. I understand the commands that are listed [here](https://go.k8s.io/bot-commands).
</details>
<!-- test report -->
openshift-ci-robot: @isutton: The following tests **failed**, say `/retest` to rerun all failed tests:

Test name | Commit | Details | Rerun command
--- | --- | --- | ---
ci/prow/4.5-e2e | 1b9e17b82bc02125c53dc31c48b77ef8ee1bf51b | [link](https://prow.svc.ci.openshift.org/view/gcs/origin-ci-test/pr-logs/pull/redhat-developer_service-binding-operator/468/pull-ci-redhat-developer-service-binding-operator-master-4.5-e2e/1272912748627365888) | `/test 4.5-e2e`
ci/prow/e2e | 24e3e84ef02f76a9a2b3d18245fd3a7552f26a42 | [link](https://prow.svc.ci.openshift.org/view/gcs/origin-ci-test/pr-logs/pull/redhat-developer_service-binding-operator/468/pull-ci-redhat-developer-service-binding-operator-master-e2e/1273033182412804096) | `/test e2e`

[Full PR test history](https://prow.svc.ci.openshift.org/pr-history?org=redhat-developer&repo=service-binding-operator&pr=468). [Your PR dashboard](https://prow.svc.ci.openshift.org/pr?query=is:pr+state:open+author:isutton). Please help us cut down on flakes by [linking to](https://github.com/kubernetes/community/blob/master/contributors/devel/flaky-tests.md#filing-issues-for-flaky-tests) an [open issue](https://github.com/redhat-developer/service-binding-operator/issues?q=is:issue+is:open) when you hit one in your PR.

<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. I understand the commands that are listed [here](https://go.k8s.io/bot-commands).
</details>
<!-- test report -->
pedjak: @isutton were you able to understand why e2e job is failing on this branch? I see it failing regularly. 
pedjak: /retest
openshift-ci-robot: @isutton: The following test **failed**, say `/retest` to rerun all failed tests:

Test name | Commit | Details | Rerun command
--- | --- | --- | ---
ci/prow/e2e | 24e3e84ef02f76a9a2b3d18245fd3a7552f26a42 | [link](https://prow.svc.ci.openshift.org/view/gcs/origin-ci-test/pr-logs/pull/redhat-developer_service-binding-operator/468/pull-ci-redhat-developer-service-binding-operator-master-e2e/1273330374704893952) | `/test e2e`

[Full PR test history](https://prow.svc.ci.openshift.org/pr-history?org=redhat-developer&repo=service-binding-operator&pr=468). [Your PR dashboard](https://prow.svc.ci.openshift.org/pr?query=is:pr+state:open+author:isutton). Please help us cut down on flakes by [linking to](https://github.com/kubernetes/community/blob/master/contributors/devel/flaky-tests.md#filing-issues-for-flaky-tests) an [open issue](https://github.com/redhat-developer/service-binding-operator/issues?q=is:issue+is:open) when you hit one in your PR.

<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. I understand the commands that are listed [here](https://go.k8s.io/bot-commands).
</details>
<!-- test report -->
baijum: /test e2e
openshift-ci-robot: New changes are detected. LGTM label has been removed.
isutton: > please squash commits and we are good to go

@pedjak force pushed the squashed commits, needs another LGTM.
pedjak: /lgtm
pedjak: /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/468#issuecomment-646743098" title="Approved">pedjak</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)~~ [pedjak]

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/deploy/crds/apps.openshift.io_servicebindingrequests_crd.yaml b/deploy/crds/apps.openshift.io_servicebindingrequests_crd.yaml
index e1d738ee..818d87ae 100644
--- a/deploy/crds/apps.openshift.io_servicebindingrequests_crd.yaml
+++ b/deploy/crds/apps.openshift.io_servicebindingrequests_crd.yaml
@@ -116,6 +116,8 @@ spec:
                   type: string
                 envVarPrefix:
                   type: string
+                id:
+                  type: string
               required:
               - group
               - kind
@@ -142,6 +144,8 @@ spec:
                     type: string
                   envVarPrefix:
                     type: string
+                  id:
+                    type: string
                 required:
                 - group
                 - kind
diff --git a/pkg/apis/apps/v1alpha1/servicebindingrequest_types.go b/pkg/apis/apps/v1alpha1/servicebindingrequest_types.go
index f6887015..321ae486 100644
--- a/pkg/apis/apps/v1alpha1/servicebindingrequest_types.go
+++ b/pkg/apis/apps/v1alpha1/servicebindingrequest_types.go
@@ -65,6 +65,7 @@ type BackingServiceSelector struct {
 	// +optional
 	Namespace    *string `json:"namespace,omitempty"`
 	EnvVarPrefix *string `json:"envVarPrefix,omitempty"`
+	Id           *string `json:"id,omitempty"`
 }
 
 // BoundApplication defines the application workloads to which the binding secret has
diff --git a/pkg/apis/apps/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/apps/v1alpha1/zz_generated.deepcopy.go
index e00095f5..2ddc6224 100644
--- a/pkg/apis/apps/v1alpha1/zz_generated.deepcopy.go
+++ b/pkg/apis/apps/v1alpha1/zz_generated.deepcopy.go
@@ -58,6 +58,16 @@ func (in *BackingServiceSelector) DeepCopyInto(out *BackingServiceSelector) {
 		*out = new(string)
 		**out = **in
 	}
+	if in.EnvVarPrefix != nil {
+		in, out := &in.EnvVarPrefix, &out.EnvVarPrefix
+		*out = new(string)
+		**out = **in
+	}
+	if in.Id != nil {
+		in, out := &in.Id, &out.Id
+		*out = new(string)
+		**out = **in
+	}
 	return
 }
 
diff --git a/pkg/controller/servicebindingrequest/retriever.go b/pkg/controller/servicebindingrequest/retriever.go
index bfbc78e2..dda808e4 100644
--- a/pkg/controller/servicebindingrequest/retriever.go
+++ b/pkg/controller/servicebindingrequest/retriever.go
@@ -85,6 +85,20 @@ func (r *retriever) processServiceContext(
 		return nil, nil, err
 	}
 
+	// add an entry in the custom environment variable context with the informed 'id'.
+	//
+	// `{{ .db_testing.status.connectionUrl }}`
+	if svcCtx.id != nil {
+		err = unstructured.SetNestedField(
+			customEnvVarCtx,
+			svcCtx.service.Object,
+			*svcCtx.id,
+		)
+		if err != nil {
+			return nil, nil, err
+		}
+	}
+
 	envVars := make(map[string][]byte, len(svcEnvVars))
 	for k, v := range svcEnvVars {
 		envVars[k] = []byte(v)
diff --git a/pkg/controller/servicebindingrequest/service.go b/pkg/controller/servicebindingrequest/service.go
index ec2685b5..34190665 100644
--- a/pkg/controller/servicebindingrequest/service.go
+++ b/pkg/controller/servicebindingrequest/service.go
@@ -192,7 +192,7 @@ func buildOwnedResourceContext(
 ) (*serviceContext, error) {
 	svcCtx, err := buildServiceContext(
 		client, obj.GetNamespace(), obj.GetObjectKind().GroupVersionKind(), obj.GetName(),
-		ownerEnvVarPrefix, restMapper)
+		ownerEnvVarPrefix, restMapper, nil)
 	if err != nil {
 		return nil, err
 	}
diff --git a/pkg/controller/servicebindingrequest/servicecontext.go b/pkg/controller/servicebindingrequest/servicecontext.go
index 4a426004..5696a17f 100644
--- a/pkg/controller/servicebindingrequest/servicecontext.go
+++ b/pkg/controller/servicebindingrequest/servicecontext.go
@@ -23,6 +23,8 @@ type serviceContext struct {
 	volumeKeys []string
 	// envVarPrefix indicates the prefix to use in environment variables.
 	envVarPrefix *string
+	// Id indicates a name the service can be referred in custom environment variables.
+	id *string
 }
 
 // serviceContextList is a list of ServiceContext values.
@@ -58,7 +60,7 @@ func buildServiceContexts(
 		ns := stringValueOrDefault(s.Namespace, defaultNs)
 		gvk := schema.GroupVersionKind{Kind: s.Kind, Version: s.Version, Group: s.Group}
 		svcCtx, err := buildServiceContext(
-			client, ns, gvk, s.ResourceRef, s.EnvVarPrefix, restMapper)
+			client, ns, gvk, s.ResourceRef, s.EnvVarPrefix, restMapper, s.Id)
 		if err != nil {
 			return nil, err
 		}
@@ -127,6 +129,7 @@ func buildServiceContext(
 	resourceRef string,
 	envVarPrefix *string,
 	restMapper meta.RESTMapper,
+	id *string,
 ) (*serviceContext, error) {
 	obj, err := findService(client, ns, gvk, resourceRef)
 	if err != nil {
@@ -202,6 +205,7 @@ func buildServiceContext(
 		envVars:      envVars,
 		volumeKeys:   volumeKeys,
 		envVarPrefix: envVarPrefix,
+		id:           id,
 	}
 
 	return serviceCtx, nil


Test patch:
diff --git a/pkg/controller/servicebindingrequest/retriever_test.go b/pkg/controller/servicebindingrequest/retriever_test.go
index 1efd9d9d..38ecb146 100644
--- a/pkg/controller/servicebindingrequest/retriever_test.go
+++ b/pkg/controller/servicebindingrequest/retriever_test.go
@@ -2,22 +2,38 @@ package servicebindingrequest
 
 import (
 	"fmt"
+	"strings"
 	"testing"
 
 	"github.com/stretchr/testify/require"
-	v1 "k8s.io/api/core/v1"
+	corev1 "k8s.io/api/core/v1"
 	"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
 	logf "sigs.k8s.io/controller-runtime/pkg/runtime/log"
 
 	"github.com/redhat-developer/service-binding-operator/test/mocks"
 )
 
-func TestRetriever(t *testing.T) {
+func toIndexTemplate(obj *unstructured.Unstructured, fieldPath string) string {
+	gvk := obj.GetObjectKind().GroupVersionKind()
+	name := obj.GetName()
+	parts := strings.Split(fieldPath, ".")
+	var newParts []string
+	for _, part := range parts {
+		newParts = append(newParts, fmt.Sprintf(`%q`, part))
+	}
+	indexArg := strings.Join(newParts, " ")
+	return fmt.Sprintf(
+		`{{ index . %q %q %q %q %s }}`, gvk.Version, gvk.Group, gvk.Kind, name, indexArg)
+}
+
+func TestRetrieverProcessServiceContexts(t *testing.T) {
+
 	logf.SetLogger(logf.ZapLogger(true))
 
 	ns := "testing"
-	backingServiceNs := "backing-servicec-ns"
+	backingServiceNs := "backing-service-ns"
 	crName := "db-testing"
+	crId := "db_testing"
 
 	f := mocks.NewFake(t, ns)
 	f.AddMockedUnstructuredCSV("csv")
@@ -26,41 +42,93 @@ func TestRetriever(t *testing.T) {
 	cr, err := mocks.UnstructuredDatabaseCRMock(backingServiceNs, crName)
 	require.NoError(t, err)
 
-	crInSameNamespace, err := mocks.UnstructuredDatabaseCRMock(ns, crName)
-	require.NoError(t, err)
+	fakeDynClient := f.FakeDynClient()
 
-	serviceCtxs := serviceContextList{
+	type testCase struct {
+		dataMapping  []corev1.EnvVar
+		envVarPrefix string
+		expected     map[string][]byte
+		name         string
+		svcCtxs      serviceContextList
+	}
+
+	testCases := []testCase{
 		{
-			service: cr,
+			name:         "access with index should return correct value",
+			envVarPrefix: "SERVICE_BINDING",
+			svcCtxs: serviceContextList{
+				{service: cr},
+			},
+			dataMapping: []corev1.EnvVar{
+				{Name: "SAME_NAMESPACE", Value: toIndexTemplate(cr, "metadata.name")},
+			},
+			expected: map[string][]byte{
+				"SERVICE_BINDING_SAME_NAMESPACE": []byte(cr.GetName()),
+			},
 		},
 		{
-			service: crInSameNamespace,
+			name:         "direct access with apiVersion and kind should return correct value",
+			envVarPrefix: "SERVICE_BINDING",
+			svcCtxs: serviceContextList{
+				{service: cr},
+			},
+			dataMapping: []corev1.EnvVar{
+				{
+					Name:  "DIRECT_ACCESS",
+					Value: `{{ .v1alpha1.postgresql_baiju_dev.Database.db_testing.metadata.name }}`,
+				},
+			},
+			expected: map[string][]byte{
+				"SERVICE_BINDING_DIRECT_ACCESS": []byte(cr.GetName()),
+			},
+		},
+		{
+			name:         "direct access with declared id should return correct value",
+			envVarPrefix: "SERVICE_BINDING",
+			svcCtxs: serviceContextList{
+				{
+					service: cr,
+					id:      &crId,
+				},
+			},
+			dataMapping: []corev1.EnvVar{
+				{
+					Name:  "ID_ACCESS",
+					Value: `{{ .db_testing.metadata.name }}`,
+				},
+			},
+			expected: map[string][]byte{
+				"SERVICE_BINDING_ID_ACCESS": []byte(cr.GetName()),
+			},
+		},
+		{
+			name:         "direct access without declared id should return <no value>",
+			envVarPrefix: "SERVICE_BINDING",
+			svcCtxs: serviceContextList{
+				{
+					service: cr,
+				},
+			},
+			dataMapping: []corev1.EnvVar{
+				{
+					Name:  "ID_ACCESS",
+					Value: `{{ .db_testing.metadata.name }}`,
+				},
+			},
+			expected: map[string][]byte{
+				"SERVICE_BINDING_ID_ACCESS": []byte("<no value>"),
+			},
 		},
 	}
 
-	fakeDynClient := f.FakeDynClient()
-
-	toTmpl := func(obj *unstructured.Unstructured) string {
-		gvk := obj.GetObjectKind().GroupVersionKind()
-		name := obj.GetName()
-		return fmt.Sprintf(`{{ index . %q %q %q %q "metadata" "name" }}`, gvk.Version, gvk.Group, gvk.Kind, name)
+	for _, tc := range testCases {
+		t.Run(tc.name, func(t *testing.T) {
+			got, _, err := NewRetriever(fakeDynClient).ProcessServiceContexts(
+				tc.envVarPrefix, tc.svcCtxs, tc.dataMapping)
+			require.NoError(t, err)
+			require.Equal(t, tc.expected, got)
+		})
 	}
-
-	actual, _, err := NewRetriever(fakeDynClient).ProcessServiceContexts(
-		"SERVICE_BINDING",
-		serviceCtxs,
-		[]v1.EnvVar{
-			{Name: "SAME_NAMESPACE", Value: toTmpl(crInSameNamespace)},
-			{Name: "OTHER_NAMESPACE", Value: toTmpl(cr)},
-			{Name: "DIRECT_ACCESS", Value: `{{ .v1alpha1.postgresql_baiju_dev.Database.db_testing.metadata.name }}`},
-		},
-	)
-	require.NoError(t, err)
-	require.Equal(t, map[string][]byte{
-		"SERVICE_BINDING_SAME_NAMESPACE":  []byte(crInSameNamespace.GetName()),
-		"SERVICE_BINDING_OTHER_NAMESPACE": []byte(cr.GetName()),
-		"SERVICE_BINDING_DIRECT_ACCESS":   []byte(cr.GetName()),
-	}, actual)
 }
 
 func TestBuildServiceEnvVars(t *testing.T) {