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

Support for environment variables #935

Open
tobiasqueck opened this issue Mar 19, 2024 · 8 comments · May be fixed by SAP/ui5-project#764
Open

Support for environment variables #935

tobiasqueck opened this issue Mar 19, 2024 · 8 comments · May be fixed by SAP/ui5-project#764
Labels
enhancement New feature or request

Comments

@tobiasqueck
Copy link

tobiasqueck commented Mar 19, 2024

Is your feature request related to a problem? Please describe.

I would like to have an out of the box supported standard approach to use environment variables to configure my middlewares and tasks.

Why? As one of the maintainers of the middleware in the open-ux-tools, I have noticed a repetitive pattern: usage of environment variables. In nearly all our middlewares/tasks we support some kind of usage of environment variables as input. A quick search through other middlewares also shows that we are not the only ones but many others also have their way of allowing to provide parts of the configuration as env variables.
The problem is that everybody does their own thing leading to inconsistencies of how to use env variables.

Describe the solution you'd like

I'd prefer a very simple solution allowing me to define environment variable placeholders in my yaml e.g.

server:
  customMiddleware:
  - name: preview-middleware
    afterMiddleware: compression
    configuration:
      debug: ${DEBUG}

The UI5 CLI should resolve the environment variable before calling my middleware so that the middleware implementation does not have to bother.
Please also support dotenv out of the box as part of the same feature.

Describe alternatives you've considered

No.

Additional context

No.

@tobiasqueck tobiasqueck added the enhancement New feature or request label Mar 19, 2024
@d3xter666
Copy link
Contributor

Hi @tobiasqueck ,

Thank you for your proposal!

@fkolar
Copy link
Member

fkolar commented Sep 16, 2024

I understand that every environment needs to deal with its own specifics. So for the LOCAL dev you might have to set different URLs or any kinds of constants that are different to TEST or PROD. There needs to be a way to support this.

  • Some teams might use custom middleware, but that might be just to deal with rerouting one URLs to the another
  • Having placeholders and storing actual values in the .env specific files

I believe this is something that should be supported by default.

For the placeholders I found this ui5-string-replacer or this one with this custom middleware , the same goes for this community string replacer.

What to use?

@RandomByte
Copy link
Member

@tobiasqueck, @menof36go and others:

The example above shows a custom middleware configuration. Do you have specific use cases for using environment variable substitutions in other places of the ui5.yaml? We have some concerns that lead us wondering whether this feature should be restricted to custom middleware configuration for the time being.

@marianfoo
Copy link

marianfoo commented Sep 30, 2024

I want to build my app for different customers. So I test this with middleware and then build and deploy with different parameters.
So Middleware and build is used for one app. Build and deploy for example to different packages and/or transports and other variables.
If you use this only for Middleware I still have one yaml for each customer.
It only reduces my mock yaml to one file.

@RandomByte
Copy link
Member

Thanks @marianfoo. So besides custom middleware, you also need to change the configuration of custom tasks (but no standard tasks)?

I guess inheritance between ui5.yaml files would still be the better solution for your use case?

@marianfoo
Copy link

Correct, currently only parameters with custom task.
Inheritance or cli Parameter would also work.

@tobiasqueck
Copy link
Author

When requesting the feature I was only thinking about customTasks and customMiddlewares. Now, I'd add customConfiguration. I don't have use cases for other parts of the config.

@flovogt
Copy link
Member

flovogt commented Oct 2, 2024

We track this enhancement request SAP internally in backlog item CPOUI5FOUNDATION-919.

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

Successfully merging a pull request may close this issue.

6 participants