From e6e49d5628a65ef3f803d3dded56cab97e2949cf Mon Sep 17 00:00:00 2001 From: Lachlan Donald Date: Tue, 27 Nov 2018 14:01:45 +1100 Subject: [PATCH] Add --inherit-env for copying all env --- README.md | 1 + main.go | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/README.md b/README.md index eec360d..ecb631b 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,7 @@ GLOBAL OPTIONS: --security-group value Security groups to launch task in (required for FARGATE). Can be specified multiple times --subnet value Subnet to launch task in (required for FARGATE). Can be specified multiple times --env KEY=value, -e KEY=value An environment variable to add in the form KEY=value or `KEY` (shorthand for `KEY=$KEY` to pass through an env var from the current host). Can be specified multiple times + --inherit-env, -E Inherit all of the environment variables from the calling shell --help, -h show help --version, -v print the version ``` diff --git a/main.go b/main.go index a438775..1ef513f 100644 --- a/main.go +++ b/main.go @@ -66,6 +66,10 @@ func main() { Name: "env, e", Usage: "An environment variable to add in the form `KEY=value` or `KEY` (shorthand for `KEY=$KEY` to pass through an env var from the current host). Can be specified multiple times", }, + cli.BoolFlag{ + Name: "inherit-env, E", + Usage: "Inherit all of the environment variables from the calling shell", + }, } app.Action = func(ctx *cli.Context) error { @@ -89,6 +93,12 @@ func main() { r.Subnets = ctx.StringSlice("subnet") r.Environment = ctx.StringSlice("env") + if ctx.Bool("inherit-env") { + for _, env := range os.Environ() { + r.Environment = append(r.Environment, env) + } + } + if args := ctx.Args(); len(args) > 0 { r.Overrides = append(r.Overrides, runner.Override{ Service: ctx.String("service"),