Skip to content

Commit

Permalink
Merge pull request #291 from runatlantis/bitbucket-spaceseparated
Browse files Browse the repository at this point in the history
Quote the -out variable in terraform plan.
  • Loading branch information
lkysow committed Sep 27, 2018
2 parents a0de1c8 + c56aa9e commit 7e2d2d1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
3 changes: 2 additions & 1 deletion server/events/models/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,11 @@ import (
// Repo is a VCS repository.
type Repo struct {
// FullName is the owner and repo name separated
// by a "/", ex. "runatlantis/atlantis" or "gitlab/subgroup/atlantis"
// by a "/", ex. "runatlantis/atlantis", "gitlab/subgroup/atlantis", "Bitbucket Server/atlantis".
FullName string
// Owner is just the repo owner, ex. "runatlantis" or "gitlab/subgroup".
// This may contain /'s in the case of GitLab subgroups.
// This may contain spaces in the case of Bitbucket Server.
Owner string
// Name is just the repo name, ex. "atlantis". This will never have
// /'s in it.
Expand Down
4 changes: 3 additions & 1 deletion server/events/runtime/plan_step_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,9 @@ func (p *PlanStepRunner) buildPlanCmd(ctx models.ProjectCommandContext, extraArg
}

argList := [][]string{
{"plan", "-input=false", "-refresh", "-no-color", "-out", planFile},
// NOTE: we need to quote the plan filename because Bitbucket Server can
// have spaces in its repo owner names.
{"plan", "-input=false", "-refresh", "-no-color", "-out", fmt.Sprintf("%q", planFile)},
tfVars,
extraArgs,
ctx.CommentArgs,
Expand Down
13 changes: 7 additions & 6 deletions server/events/runtime/plan_step_runner_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package runtime_test

import (
"fmt"
"io/ioutil"
"os"
"path/filepath"
Expand Down Expand Up @@ -58,7 +59,7 @@ func TestRun_NoWorkspaceIn08(t *testing.T) {
"-refresh",
"-no-color",
"-out",
"/path/default.tfplan",
"\"/path/default.tfplan\"",
"-var",
"atlantis_user=username",
"-var",
Expand Down Expand Up @@ -187,7 +188,7 @@ func TestRun_SwitchesWorkspace(t *testing.T) {
"-refresh",
"-no-color",
"-out",
"/path/workspace.tfplan",
"\"/path/workspace.tfplan\"",
"-var",
"atlantis_user=username",
"-var",
Expand Down Expand Up @@ -252,7 +253,7 @@ func TestRun_CreatesWorkspace(t *testing.T) {
"-refresh",
"-no-color",
"-out",
"/path/workspace.tfplan",
"\"/path/workspace.tfplan\"",
"-var",
"atlantis_user=username",
"-var",
Expand Down Expand Up @@ -306,7 +307,7 @@ func TestRun_NoWorkspaceSwitchIfNotNecessary(t *testing.T) {
"-refresh",
"-no-color",
"-out",
"/path/workspace.tfplan",
"\"/path/workspace.tfplan\"",
"-var",
"atlantis_user=username",
"-var",
Expand Down Expand Up @@ -368,7 +369,7 @@ func TestRun_AddsEnvVarFile(t *testing.T) {
"-refresh",
"-no-color",
"-out",
filepath.Join(tmpDir, "workspace.tfplan"),
fmt.Sprintf("%q", filepath.Join(tmpDir, "workspace.tfplan")),
"-var",
"atlantis_user=username",
"-var",
Expand Down Expand Up @@ -423,7 +424,7 @@ func TestRun_UsesDiffPathForProject(t *testing.T) {
"-refresh",
"-no-color",
"-out",
"/path/projectname-default.tfplan",
"\"/path/projectname-default.tfplan\"",
"-var",
"atlantis_user=username",
"-var",
Expand Down

0 comments on commit 7e2d2d1

Please sign in to comment.