Skip to content

Commit

Permalink
Expand $PATH
Browse files Browse the repository at this point in the history
  • Loading branch information
maximede committed Jun 13, 2019
1 parent bb20ef0 commit 5c99d1c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
3 changes: 2 additions & 1 deletion server/events/runtime/run_step_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func (r *RunStepRunner) Run(ctx models.ProjectCommandContext, command string, pa
"HEAD_BRANCH_NAME": ctx.Pull.HeadBranch,
"HEAD_REPO_NAME": ctx.HeadRepo.Name,
"HEAD_REPO_OWNER": ctx.HeadRepo.Owner,
"PATH": fmt.Sprintf("$PATH:%s", r.TerraformBinDir),
"PATH": fmt.Sprintf(os.ExpandEnv("$PATH:%s"), r.TerraformBinDir),
"PLANFILE": filepath.Join(path, GetPlanFilename(ctx.Workspace, ctx.ProjectName)),
"PROJECT_NAME": ctx.ProjectName,
"PULL_AUTHOR": ctx.Pull.Author,
Expand All @@ -46,6 +46,7 @@ func (r *RunStepRunner) Run(ctx models.ProjectCommandContext, command string, pa
for key, val := range customEnvVars {
finalEnvVars = append(finalEnvVars, fmt.Sprintf("%s=%s", key, val))
}

cmd.Env = finalEnvVars
out, err := cmd.CombinedOutput()

Expand Down
10 changes: 6 additions & 4 deletions server/events/runtime/run_step_runner_test.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package runtime_test

import (
"fmt"
"os"
"strings"
"testing"

version "github.com/hashicorp/go-version"
"github.com/hashicorp/go-version"
"github.com/runatlantis/atlantis/server/events/models"
"github.com/runatlantis/atlantis/server/events/runtime"
"github.com/runatlantis/atlantis/server/logging"
Expand Down Expand Up @@ -62,9 +64,9 @@ func TestRunStepRunner_Run(t *testing.T) {
{
Command: "echo user_name=$USER_NAME",
ExpOut: "user_name=acme-user\n",
},{
}, {
Command: "echo $PATH",
ExpOut: "$PATH:/bin/dir\n",
ExpOut: fmt.Sprintf(os.ExpandEnv("$PATH%s"), ":/bin/dir\n"),
},
}

Expand All @@ -73,7 +75,7 @@ func TestRunStepRunner_Run(t *testing.T) {
defaultVersion, _ := version.NewVersion("0.8")
r := runtime.RunStepRunner{
DefaultTFVersion: defaultVersion,
TerraformBinDir: "/bin/dir",
TerraformBinDir: "/bin/dir",
}
for _, c := range cases {
t.Run(c.Command, func(t *testing.T) {
Expand Down

0 comments on commit 5c99d1c

Please sign in to comment.