Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Undefined behavior for of binding annotations with elementType=sliceOfStrings #131

Closed
pmacik opened this issue Oct 23, 2020 · 4 comments · Fixed by #137
Closed

Undefined behavior for of binding annotations with elementType=sliceOfStrings #131

pmacik opened this issue Oct 23, 2020 · 4 comments · Fixed by #137

Comments

@pmacik
Copy link
Contributor

pmacik commented Oct 23, 2020

The binding annotation spec contains option sliceOfStrings for elementType in annotation.

However the spec does not tell how it should behave in various situations.
The following scenarios suggest the behavior:

Scenario 1: sliceOfStrings from array

Given a CRD is annotated with service binding annotation using the sliceOfStrings element type like in the following snippet:

...
metadata:
   annotations:
      service.binding/tags: path={.spec.tags},elementType=sliceOfStrings

and the respective CR contains the following spec:

...
kind: Backend
...
spec:
   tags:
      - knowledge
      - is
      - power

when a service binding is created to bind the service CR to an application the application is enriched by the binding with the following env variables:

BACKEND_TAGS_0="knowledge"
BACKEND_TAGS_1="is"
BACKEND_TAGS_2="power"

Scenario 2: sliceOfStrings from slice of maps

Given a CRD is annotated with service binding annotation using the sliceOfStrings element type like in the following snippet:

...
metadata:
   annotations:
      service.binding/url: path={.spec.connections},elementType=sliceOfStrings,sourceValue=url

and the respective CR contains the following spec:

...
kind: Backend
...
spec:
    connections:
      - type: primary
        url: primary.example.com
      - type: secondary
        url: secondary.example.com
      - type: '404'
        url: black-hole.example.com

when a service binding is created to bind the service CR to an application the application is enriched with the following env variables by the binding:

BACKEND_URL_0="primary.example.com"
BACKEND_URL_1="secondary.example.com"
BACKEND_URL_2="black-hole.example.com"
@sbose78
Copy link
Contributor

sbose78 commented Oct 26, 2020

This looks right to me. In scenario one, we have list of strings, and in the latter, we have a list of 'structs'.

@navidsh @Avni-Sharma Scenario 2 was in use by the strimzi proposal. Am I right?

@Avni-Sharma
Copy link
Member

yes @sbose78 Scenario 2 is used in the case of strimzi. Referred redhat-developer/service-binding-operator#352 (comment) for cross-checking

@arthurdm
Copy link
Member

Discussed in the hangout. @pmacik - thanks for bringing this up. Would you be able to please propose a PR for this one?

@pmacik
Copy link
Contributor Author

pmacik commented Oct 29, 2020

Discussed in the hangout. @pmacik - thanks for bringing this up. Would you be able to please propose a PR for this one?

Sure, I'll send a PR for this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants