Skip to content

Commit

Permalink
Use only parent env vars when executing if no others provided
Browse files Browse the repository at this point in the history
  • Loading branch information
bmonkman committed Jun 23, 2020
1 parent 677667d commit 46cb194
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions go.sum
Expand Up @@ -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=
Expand Down Expand Up @@ -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=
Expand Down
3 changes: 3 additions & 0 deletions internal/apply/apply.go
Expand Up @@ -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)),
Expand All @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions internal/util/util.go
Expand Up @@ -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...)
}
Expand Down Expand Up @@ -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...)
}
Expand Down

0 comments on commit 46cb194

Please sign in to comment.