-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for setting terragrunt-source-map using env vars (#1676)
- Loading branch information
1 parent
daabff2
commit a716f68
Showing
6 changed files
with
108 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -207,3 +207,24 @@ func TestTerragruntValidateInputsWithUnusedEnvVar(t *testing.T) { | |
moduleDir := filepath.Join("fixture-validate-inputs", "success-inputs-only") | ||
runTerragruntValidateInputs(t, moduleDir, nil, false) | ||
} | ||
|
||
func TestTerragruntSourceMapEnvArg(t *testing.T) { | ||
fixtureSourceMapPath := "fixture-source-map" | ||
cleanupTerraformFolder(t, fixtureSourceMapPath) | ||
tmpEnvPath := copyEnvironment(t, fixtureSourceMapPath) | ||
rootPath := filepath.Join(tmpEnvPath, fixtureSourceMapPath) | ||
|
||
os.Setenv( | ||
"TERRAGRUNT_SOURCE_MAP", | ||
strings.Join( | ||
[]string{ | ||
fmt.Sprintf("git::ssh://[email protected]/gruntwork-io/i-dont-exist.git=%s", tmpEnvPath), | ||
fmt.Sprintf("git::ssh://[email protected]/gruntwork-io/another-dont-exist.git=%s", tmpEnvPath), | ||
}, | ||
",", | ||
), | ||
) | ||
tgPath := filepath.Join(rootPath, "multiple-match") | ||
tgArgs := fmt.Sprintf("terragrunt run-all apply -auto-approve --terragrunt-log-level debug --terragrunt-non-interactive --terragrunt-working-dir %s", tgPath) | ||
runTerragrunt(t, tgArgs) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -235,3 +235,44 @@ func TestStringListInsert(t *testing.T) { | |
t.Logf("%v passed", testCase.list) | ||
} | ||
} | ||
|
||
func TestKeyValuePairStringListToMap(t *testing.T) { | ||
t.Parallel() | ||
|
||
testCases := []struct { | ||
name string | ||
input []string | ||
output map[string]string | ||
}{ | ||
{ | ||
"base", | ||
[]string{"foo=bar", "baz=carol"}, | ||
map[string]string{ | ||
"foo": "bar", | ||
"baz": "carol", | ||
}, | ||
}, | ||
{ | ||
"special_chars", | ||
[]string{"ssh://[email protected]=/path/to/local"}, | ||
map[string]string{"ssh://[email protected]": "/path/to/local"}, | ||
}, | ||
{ | ||
"empty", | ||
[]string{}, | ||
map[string]string{}, | ||
}, | ||
} | ||
|
||
for _, testCase := range testCases { | ||
t.Run(testCase.name, func(t *testing.T) { | ||
actualOutput, err := KeyValuePairStringListToMap(testCase.input) | ||
assert.NoError(t, err) | ||
assert.Equal( | ||
t, | ||
testCase.output, | ||
actualOutput, | ||
) | ||
}) | ||
} | ||
} |