Skip to content

Commit

Permalink
Change getTfVarsDir() to convert result to unix format path (forward …
Browse files Browse the repository at this point in the history
…slash).

Fix test for config_helpers that were not processed correctly on Windows.
Fix Makefile (install hook was not working)
  • Loading branch information
jocgir committed Apr 24, 2017
1 parent 8672131 commit 29bf449
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ fmt:
gofmt -w $(GOFMT_FILES)

install-pre-commit-hook:
@if [ -f .git/hooks/pre-commit ]; then \
@if [ -f .git/hooks/pre-commit -o -L .git/hooks/pre-commit ]; then \
echo ""; \
echo "There is already a pre-commit hook installed. Remove it and run 'make"; \
echo "install-pre-commit-hook again, or manually alter it to add the contents"; \
echo "of 'scripts/pre-commit'."; \
echo ""; \
exit 1; \
fi
@ln -s ../../scripts/pre-commit .git/hooks/pre-commit
@ln -s scripts/pre-commit .git/hooks/pre-commit
@echo "pre-commit hook installed."

.PHONY: help fmtcheck fmt install-fmt-hook
2 changes: 1 addition & 1 deletion config/config_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func getTfVarsDir(terragruntOptions *options.TerragruntOptions) (string, error)
return "", errors.WithStackTrace(err)
}

return filepath.Dir(terragruntConfigFileAbsPath), nil
return filepath.ToSlash(filepath.Dir(terragruntConfigFileAbsPath)), nil
}

// Return the parent directory where the Terragrunt configuration file lives
Expand Down
7 changes: 5 additions & 2 deletions config/config_helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -507,13 +507,16 @@ TERRAGRUNT_HIT","")}/bar`,

func TestGetTfVarsDirAbsPath(t *testing.T) {
t.Parallel()
testGetTfVarsDir(t, "/foo/bar/terraform.tfvars", "/foo/bar")
workingDir, err := os.Getwd()
assert.Nil(t, err, "Could not get current working dir: %v", err)
testGetTfVarsDir(t, "/foo/bar/terraform.tfvars", fmt.Sprintf("%s/foo/bar", filepath.VolumeName(workingDir)))
}

func TestGetTfVarsDirRelPath(t *testing.T) {
t.Parallel()
workingDir, err := os.Getwd()
assert.Nil(t, err, "Could not get current working dir: %v", err)
workingDir = filepath.ToSlash(workingDir)

testGetTfVarsDir(t, "foo/bar/terraform.tfvars", fmt.Sprintf("%s/foo/bar", workingDir))
}
Expand Down Expand Up @@ -566,7 +569,7 @@ func TestGetParentTfVarsDir(t *testing.T) {
{
&IncludeConfig{Path: "../../other-child/" + DefaultTerragruntConfigPath},
options.TerragruntOptions{TerragruntConfigPath: helpers.RootFolder + "child/sub-child/" + DefaultTerragruntConfigPath, NonInteractive: true},
"/other-child",
fmt.Sprintf("%s/other-child", filepath.VolumeName(parentDir)),
},
{
&IncludeConfig{Path: "../../" + DefaultTerragruntConfigPath},
Expand Down

0 comments on commit 29bf449

Please sign in to comment.