Skip to content

EngineerBetter/yml2env

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

40 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

yml2env

Build Status

Either executes a command with environment variables taken from a YAML file, or prints a load of exports 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)"

Why?

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.

Example

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

Installation

Go developers

go get github.com/EngineerBetter/yml2env

Everyone else

  1. Download a release
  2. Move to $PATH and rename to yml2env
  3. chmod +x yml2env

Testing

go test ./...