ui5-tooling
ui5-tooling copied to clipboard
Allow to share configuration between middlewares
Hi!
Currently writing multiple middleware ( cannot be wrapped into one as used in different moments ) I found out that it's not possible to share configuration between them.
Yes, we have resources - but then we need to detect which is active config and then read and parse yaml manually.
So one of solutions is to use a separate file or environment variables, but more elegant solution to my opinion might be give an option to read the whole configuration file from middleware util.
One of the use cases is to write extensions for existing middlewares ( like fiori-tools-proxy ) when we don't copy configuration but just reading it from the global config.
As a simple workaround - it might be easier to provide also custom customConfiguration as a parameter or util method.
Thank you!
I have solved my task currently by using yaml merge:
specVersion: "2.2"
#type: application|library|theme-library|module
type: library
metadata:
name: test
customConfiguration: &global
fiori-tools-proxy: &fiori-tools-proxy
ui5:
path:
- /resources
- /test-resources
url: https://sapui5.hana.ondemand.com
version: 1.78.0
myTool:
key: value
myOtherTool:
otherKey: otherValue
server:
customMiddleware:
- name: fiori-tools-proxy
afterMiddleware: compression
configuration:
<<: *fiori-tools-proxy
- name: fiori-tools-home-page
beforeMiddleware: serveIndex
configuration:
<<: *global
- name: fiori-tools-proxy-cdn
beforeMiddleware: fiori-tools-proxy
configuration:
<<: *global
It works but then it requires ui5.yaml configuration which impacts middleware's usability
It works but then it requires ui5.yaml configuration which impacts middleware's usability
Could you elaborate a bit more on that? I guess some configuration needs to be in the ui5.yaml in any case, right? In your example, would that be the "customConfiguration"?
Which parts of your example would be unnecessary in that case?
I meant if the application already exists and ui5.yaml let's say already has this section:
server:
customMiddleware:
- name: fiori-tools-proxy
afterMiddleware: compression
configuration:
ui5:
path:
- /resources
- /test-resources
url: https://sapui5.hana.ondemand.com
version: 1.78.0
and if I want to develop another middleware which is reusing fiori-tools-proxy configuration - i need to copy this configuration in ui5.yaml file. If I want to develop easy-to-use middleware I would like to avoid this situation when consumer needs to modify also descriptor instead of just adding couple new lines.
Just about this =). But yaml merge also works quite good. I found this way already after creating a ticket