Skip to content
go library and cli for executing apps with environments defined in a file
Go
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.chglog
cmd/withenv
.bonsai.yml
.gitignore
.goshipdone.yml
CHANGELOG.md
LICENSE.md
README.md
env.go
env_test.go
exec.go
go.mod
go.sum
magefile.go

README.md

withenv: runs commands with extra environment settings

It's just like envdir, but for go, and it reads files.

Goals

When I looked around, I couldn't find a tool for a small need: to run an application quickly with appropriate environment variables set, when no shell is available.

This particular use case helps running handlers in sensu-go, while secrets are not exposed to the API / web UI. Information about a file on a system is less threatening than seeing the actual secret set by an environment variable, which is not even redacted by the user interface.

Usage

usage: withenv PATH COMMAND [ARGS...]

Set environment variables defined in file PATH, and run COMMAND.

  -v       print program version
  -h       this help
Arguments:
  PATH     path to a file containing variable declarations in a KEY=VAL
           format. Spaces around KEY and VAL are NOT stripped. VAL has
                   variable expansion.
  COMMAND  next executable in line, which will be run with the newly set
           environment variables.
  ARGS...  any command line items are taken to COMMAND after variable
           expansion.

This tool can be used in sensu-go, chaining other commands for checks or handlers. Currently, both in asset and in Bonsai form, albeit this is still in the works.

Legal

This project is licensed under Blue Oak Model License v1.0.0. It is not registered either at OSI or GNU, therefore GitHub is widely looking at the other direction. However, this is the license I'm most happy with: you can read and understand it with no legal degree, and there are no hidden or cryptic meanings in it.

The project is also governed with Contributor Covenant's Code of Conduct in mind. I'm not copying it here, as a pledge for taking the verbatim version by the word, and we are not going to modify it in any way.

Any issues?

Open a ticket, perhaps a pull request. We support GitHub Flow. You might want to fork this project first.

You can’t perform that action at this time.