Either executes a command with environment variables taken from a YAML file, or prints a load of export
s you can eval
yml2env <path-to-yaml-file> [<command> | --eval]
# Run command with env vars from YAML file
$ yml2env vars.yml tests.sh
# Set env vars in current shell
$ eval "$(yml2env var.yml --eval)"
It's quite handy for using Concourse --load-vars-from
files when running local tasks, like tests. The --eval
feature is useful when you need to get lots of stuff from the output of a Concourse Terraform resource as env vars.
Given a YAML file stored in ci/vars/local.yml
:
---
cf_username: admin
cf_password: whevsmate
...running yml2env ci/vars/local.yml fly execute ci/tasks/system-tests.yml
is equivalent to running
CF_USERNAME=admin CF_PASSWORD=whevsmate fly execute ci/tasks/system-tests.yml
go get github.com/EngineerBetter/yml2env
- Download a release
- Move to
$PATH
and rename toyml2env
chmod +x yml2env
go test ./...