From 46cb194e81c9d571e42733b315478a833d9efa5b Mon Sep 17 00:00:00 2001 From: Bill Monkman Date: Tue, 23 Jun 2020 12:25:08 -0700 Subject: [PATCH] Use only parent env vars when executing if no others provided --- go.sum | 2 ++ internal/apply/apply.go | 3 +++ internal/util/util.go | 2 ++ 3 files changed, 7 insertions(+) diff --git a/go.sum b/go.sum index 12988a9dc..6106a2703 100644 --- a/go.sum +++ b/go.sum @@ -42,6 +42,7 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no= +github.com/docker/docker v1.13.1 h1:IkZjBSIc8hBjLpqeAbeE5mca5mNgeatLHBy3GO78BWo= github.com/fatih/color v1.7.0 h1:DkWD4oS2D8LGGgTQ6IvwJJXSL5Vp2ffcQg58nFV38Ys= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= @@ -142,6 +143,7 @@ github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrk github.com/mitchellh/go-testing-interface v1.0.0 h1:fzU/JVNcaqHQEcVFAKeR41fkiLdIPrefOvVG1VZ96U0= github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI= github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= +github.com/moby/moby v1.13.1 h1:mC5WwQwCXt/dYxZ1cIrRsnJAWw7VdtcTZUIGr4tXzOM= github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= diff --git a/internal/apply/apply.go b/internal/apply/apply.go index 53f9d2832..af14fe64e 100644 --- a/internal/apply/apply.go +++ b/internal/apply/apply.go @@ -52,7 +52,9 @@ Only a single environment may be suitable for an initial test, but for a real sy func applyAll(dir string, projectConfig projectconfig.ZeroProjectConfig, applyEnvironments []string) { environmentArg := fmt.Sprintf("ENVIRONMENT=%s", strings.Join(applyEnvironments, ",")) + // Go through each of the modules and run `make` for _, mod := range projectConfig.Modules { + // Add env vars for the makefile envList := []string{ environmentArg, fmt.Sprintf("PROJECT_DIR=%s", path.Join(dir, mod.Files.Directory)), @@ -66,6 +68,7 @@ func applyAll(dir string, projectConfig projectconfig.ZeroProjectConfig, applyEn modulePath = filepath.Join(dir, modulePath) } + // Get project credentials for the makefile credentials := globalconfig.GetProjectCredentials(projectConfig.Name) envList = util.AppendProjectEnvToCmdEnv(mod.Parameters, envList) diff --git a/internal/util/util.go b/internal/util/util.go index b427c1858..f9c09c43f 100644 --- a/internal/util/util.go +++ b/internal/util/util.go @@ -59,6 +59,7 @@ func ExecuteCommand(cmd *exec.Cmd, pathPrefix string, envars []string) { var errStdout, errStderr error + cmd.Env = os.Environ() if envars != nil { cmd.Env = append(os.Environ(), envars...) } @@ -99,6 +100,7 @@ func ExecuteCommandOutput(cmd *exec.Cmd, pathPrefix string, envars []string) str cmd.Dir = path.Join(dir, pathPrefix) } + cmd.Env = os.Environ() if envars != nil { cmd.Env = append(os.Environ(), envars...) }