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

Allow environment variable substitution in config yaml #22

Closed
eacmen opened this issue Jan 25, 2018 · 5 comments · Fixed by #36
Closed

Allow environment variable substitution in config yaml #22

eacmen opened this issue Jan 25, 2018 · 5 comments · Fixed by #36

Comments

@eacmen
Copy link

eacmen commented Jan 25, 2018

Allow variables such as sensitive API keys or other auth tokens to be set as environment variables and substituted in config.yaml when parsed at runtime (i.e. with a $ENV{ENVNAME} type syntax). This is standard practice for cloud-based CI solutions such a Travis, Circle CI, etc.

@benhowes
Copy link
Member

benhowes commented Jan 30, 2018

In #6 we're looking at adding a means to pass in variables on the command line. I expect that will be the preferred way to pass env variables to tests in tavern.

leaving this open for now, until we move forward with #6 and decide if this is needed as well as that.

@michaelboulton
Copy link
Member

I realised this was only a couple of lines of code to do so I have implemented it in this branch https://github.com/taverntesting/tavern/tree/feature/env-var-formatting - not sure what the 'magic' variable name should be for environment variables though? I suppose that it just means people can't save a variable called ENV_VARS

@eacmen
Copy link
Author

eacmen commented Feb 6, 2018

👍 we'll test it out and let you know of any issues.

@AmiSMB
Copy link

AmiSMB commented Feb 21, 2018

I have tested this branch out and it works very well for me as I am using tox with tox-docker which launches my docker container and leaves an environment variable in the form of for any port listed with EXPOSE in the Dockerfile.

So now when tox-docker starts the container, pytest runs with the Tavern plugin I can use the ENV_VARS in the yaml file to get the correct port for the url to test my microservice. Good work 👍

@michaelboulton
Copy link
Member

With #36 there is going to be a value called tavern.env_vars that you can format environment keys from

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

Successfully merging a pull request may close this issue.

4 participants