-
Story
-
Resolution: Done
-
Major
-
None
-
None
-
13
-
False
-
False
-
Undefined
-
-
AppSvc Sprint 194, AppSvc Sprint 195, AppSvc Sprint 196
At the moment, binding names declared through annotations or CSV descriptors are processed before injected into the application according to the following strategy:
- names are upper-cased
- service resource kind is upper-cased and prepended to the name
For example, if the service is of kind Database and the binding name is host, then environment variable injected into the application is DATABASE_HOST.
The current approach is not flexible and make impossible for many applications to bind without changing them. We should openup a possibility to apply some otherr naming strategy, or none if needed, for example:
- none
- upercasing ( service kind + binding name)
- naming template (fully customizable approach)
"none" should be default if bindAsFile: true, otherwise "uppercassing"
Scenario: By default bindings are injected into app as env variables with upper-cased names Given OLM Operator "backend" is running * Generic test application "myapp1" is running * The Custom Resource is present """ apiVersion: "stable.example.com/v1" kind: Backend metadata: name: backend1 annotations: service.binding/host: path={.spec.host} service.binding/username: path={.spec.username} spec: host: example.common username: foo """ When Service Binding is applied """ apiVersion: operators.coreos.com/v1alpha1 kind: ServiceBinding metadata: name: bind1 spec: services: - group: stable.example.com version: v1 kind: Backend name: backend1 """ Then Service Binding "bind1" is ready And The application env var "HOST" has value "example.common" And The application env var "USERNAME" has value "foo" Scenario: Bindings are injected into app as env variables with original names Given OLM Operator "backend" is running * Generic test application "myapp1" is running * The Custom Resource is present """ apiVersion: "stable.example.com/v1" kind: Backend metadata: name: backend1 annotations: service.binding/host: path={.spec.host} service.binding/username: path={.spec.username} spec: host: example.common username: foo """ When Service Binding is applied """ apiVersion: operators.coreos.com/v1alpha1 kind: ServiceBinding metadata: name: bind1 spec: namingStrategy: none services: - group: stable.example.com version: v1 kind: Backend name: backend1 """ Then Service Binding "bind1" is ready And The application env var "host" has value "example.common" And The application env var "username" has value "foo" Scenario: Bindings names passed as if when injected as files into app Given OLM Operator "backend" is running * Generic test application "myapp2" is running * The Custom Resource is present """ apiVersion: "stable.example.com/v1" kind: Backend metadata: name: backend1 annotations: service.binding/host: path={.spec.host} service.binding/username: path={.spec.username} spec: host: example.common username: foo """ When Service Binding is applied """ apiVersion: operators.coreos.com/v1alpha1 kind: ServiceBinding metadata: name: bind2 spec: bindAsFiles: true services: - group: stable.example.com version: v1 kind: Backend name: backend1 """ Then Service Binding "bind1" is ready And Content of file "/bindings/bind2/host" in application pod is """ example.common """ And Content of file "/bindings/bind2/username" in application pod is """ foo """ Scenario: Bindings names are transformed using template before injecting into app Given OLM Operator "backend" is running * Generic test application "myapp2" is running * The Custom Resource is present """ apiVersion: "stable.example.com/v1" kind: Backend metadata: name: backend1 annotations: service.binding/host: path={.spec.host} service.binding/username: path={.spec.username} spec: host: example.common username: foo """ When Service Binding is applied """ apiVersion: operators.coreos.com/v1alpha1 kind: ServiceBinding metadata: name: bind2 spec: namingStrategy: '{{.service | kind | upper}}_{{ .name | upper }}' services: - group: stable.example.com version: v1 kind: Backend name: backend1 """ Then Service Binding "bind1" is ready And The application env var "BACKEND_HOST has value "example.common" And The application env var "BACKEND_USERNAME" has value "foo"
- incorporates
-
APPSVC-456 [SBO] Change default service environment variable prefix format
- Closed
- relates to
-
APPSVC-456 [SBO] Change default service environment variable prefix format
- Closed