Skip to content

Commit 46cb194

Browse files
committed
Use only parent env vars when executing if no others provided
1 parent 677667d commit 46cb194

3 files changed

Lines changed: 7 additions & 0 deletions

File tree

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
4242
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
4343
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
4444
github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no=
45+
github.com/docker/docker v1.13.1 h1:IkZjBSIc8hBjLpqeAbeE5mca5mNgeatLHBy3GO78BWo=
4546
github.com/fatih/color v1.7.0 h1:DkWD4oS2D8LGGgTQ6IvwJJXSL5Vp2ffcQg58nFV38Ys=
4647
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
4748
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
142143
github.com/mitchellh/go-testing-interface v1.0.0 h1:fzU/JVNcaqHQEcVFAKeR41fkiLdIPrefOvVG1VZ96U0=
143144
github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI=
144145
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
146+
github.com/moby/moby v1.13.1 h1:mC5WwQwCXt/dYxZ1cIrRsnJAWw7VdtcTZUIGr4tXzOM=
145147
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
146148
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs=
147149
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=

internal/apply/apply.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,9 @@ Only a single environment may be suitable for an initial test, but for a real sy
5252
func applyAll(dir string, projectConfig projectconfig.ZeroProjectConfig, applyEnvironments []string) {
5353
environmentArg := fmt.Sprintf("ENVIRONMENT=%s", strings.Join(applyEnvironments, ","))
5454

55+
// Go through each of the modules and run `make`
5556
for _, mod := range projectConfig.Modules {
57+
// Add env vars for the makefile
5658
envList := []string{
5759
environmentArg,
5860
fmt.Sprintf("PROJECT_DIR=%s", path.Join(dir, mod.Files.Directory)),
@@ -66,6 +68,7 @@ func applyAll(dir string, projectConfig projectconfig.ZeroProjectConfig, applyEn
6668
modulePath = filepath.Join(dir, modulePath)
6769
}
6870

71+
// Get project credentials for the makefile
6972
credentials := globalconfig.GetProjectCredentials(projectConfig.Name)
7073

7174
envList = util.AppendProjectEnvToCmdEnv(mod.Parameters, envList)

internal/util/util.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ func ExecuteCommand(cmd *exec.Cmd, pathPrefix string, envars []string) {
5959

6060
var errStdout, errStderr error
6161

62+
cmd.Env = os.Environ()
6263
if envars != nil {
6364
cmd.Env = append(os.Environ(), envars...)
6465
}
@@ -99,6 +100,7 @@ func ExecuteCommandOutput(cmd *exec.Cmd, pathPrefix string, envars []string) str
99100
cmd.Dir = path.Join(dir, pathPrefix)
100101
}
101102

103+
cmd.Env = os.Environ()
102104
if envars != nil {
103105
cmd.Env = append(os.Environ(), envars...)
104106
}

0 commit comments

Comments
 (0)