Giter Club home page Giter Club logo

yml2env's Introduction

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 ./...

yml2env's People

Contributors

saphmb avatar crsimmons avatar

Stargazers

Leo avatar  avatar Danilo avatar Norik Davtian avatar  avatar Levent Sagiroglu avatar Jonathan Matthews avatar  avatar Diogo Lemos avatar

Watchers

James Cloos avatar Daniel Jones avatar Conch Horse avatar  avatar  avatar

yml2env's Issues

yml2env shouldn't automatically uppercase envvars!

Heya - envvars aren't always upper case!

By doing https://github.com/EngineerBetter/yml2env/blob/master/yml2env.go#L35, (I /think/) case-sensitive envvar consumers can't use the tool.

One such consumer is bosh create-env --env-vars=PREFIX, which equates -v foo=bar with export MY_foo=bar ; bosh create-env --env-vars=MY.

Given that bosh manifests and ops files tend to use lower case vars, this is a whole use case being ruled out by (I /think/) just the above line #35.

Add option for prefix

As JSON is a subset of YAML, we can use yml2env to parse JSON files too - for instance the metadata output by a Concourse Terraform resource's get step. This will save some export CF_THING=$(cat metadata | jq blah) verbosity in our Sombrero project and elsewhere.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.