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
Feat: Environment variables in templating #849
Comments
It would be great, even then the values could be updated at runtime without restarting the service. export MOCKOON_FOO_VAR=hello-world fooVar = process.env.MOCKOON_FOO_VAR;
console.log('Show ENVVAR: ', fooVar); // Print "Show ENVVAR: hello-world" Even better, dotenv can be used to isolate and bundle envvar's into a single MOCKOON_PRIVATE_KEY=-----BEGIN RSA PRIVATE KEY-----\nKh9NV...\n-----END RSA PRIVATE KEY-----\n
MOCKOON_PRIVATE_KEY_MULTILINE="-----BEGIN RSA PRIVATE KEY-----
...
Kh9NV...
...
-----END RSA PRIVATE KEY-----"
MOCKOON_ENV=development
MOCKOON_URL_HEALTHCHECK=http://localhost/api/v1/healthcheck
MOCKOON_HELLO=hello-world import * as dotenv from 'dotenv';
dotenv.config();
process.env.MOCKOON_PRIVATE_KEY;
process.env.MOCKOON_PRIVATE_KEY_MULTILINE;
process.env.MOCKOON_ENV;
process.env.MOCKOON_URL_HEALTHCHECK;
process.env.MOCKOON_HELLO; Reference: |
@supr3m Thank you for the feedback. There is currently no plan to support dotenv files as it requires way more work to make it work in the desktop/CLI/serverless apps. |
Add tests in commons-server and CLI Add serverless option Add desktop setting Closes #849
Add tests in commons-server and CLI Add serverless option Add desktop setting Closes #849
Add tests in commons-server and CLI Add serverless option Add desktop setting Closes #849
Add tests in commons-server and CLI Add serverless option Add desktop setting Closes #849
Add tests in commons-server and CLI Add serverless option Add desktop setting Closes #849
See mockoon/mockoon#849 Add new docs variables pages Update docs images
See mockoon/mockoon#849 Add new docs variables pages Update docs images
See mockoon/mockoon#849 Add new docs variables pages Update docs images
See mockoon/mockoon#849 Add new docs variables pages Update docs images
Add environment variables documentation see mockoon/mockoon#849 Add new docs variables pages Update docs images
Add environment variables documentation see mockoon/mockoon#849 Add new docs variables pages Update docs images
Add environment variables documentation see mockoon/mockoon#849 Add new docs variables pages Update docs images
📦 This is now released in v7.0.0. |
I find Mockoon CLI useful for testing purposes in CI/CD environments. In my use case, I am spinning up multiple Mockoon instances running in a Docker container. Even tho I want them to source from the same config file, I would prefer having the option to identify instances.
As a solution to this, I would like to add a new set of helpers that would allow you to read environment variables. Implementation might look something like this:
To keep the solution secure, this would only allow reading variables that are prefixed with
MOCKOON_
. There should be an option (CLI parameter?) to change this prefix. Setting prefix to empty string and allowing reading any variable should NOT be allowed.TODO:
System Helpers
If possible, I would like to contribute to this issue.
The text was updated successfully, but these errors were encountered: