A CLI that does only one thing: outputs the contents of a YAML file (.yml or .yaml) as a string (so as to help you load each key/value pair as environment variables).
npm install -g yaml-env-cliFor example, you have a file staging.yaml1:
ENVIRONMENT: "staging"
API_URL: "https://lol.hi"
API_KEY: "69sike420"Running yec staging.yaml will output the string:
API_KEY=69sike420 API_URL=https://lol.hi ENVIRONMENT=stagingThis is useful because you can instead run2:
export `yec staging.yaml`Now all the secrets in staging.yaml will be available in your terminal as environment variables.
So if you have a main.go script that requires certain variables, you can run:
export `yec staging.yaml` && go run main.goTo see what environment variables are set, run printenv (this is just a regular shell command).
Running npm start reads the sample.yaml, exports each key/value pair as environment variables, and runs test.js which will print the three3 set variables.
Note: npm start will not update the environment variables except for the execution of test.js
Adjust the script to your liking by editing index.js and then install your custom version of yec command with npm run global
Launching Cloud Functions to GCP is easy with --env-vars-file=production.yml but when you try to use the Functions Framework you now have to figure out a way to get those environment variables loaded. Perhaps you use a shell script which duplicates the contents of the .yml file, but it's annoying.