Skip to content

Commit

Permalink
Rename SourceUpdate to UpdateSource. Clarify docs.
Browse files Browse the repository at this point in the history
  • Loading branch information
brikis98 committed Feb 2, 2017
1 parent 02c116f commit 1bf8ed3
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions cli/args.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func parseTerragruntOptionsFromArgs(args []string) (*options.TerragruntOptions,
return nil, err
}

updateSource := parseBooleanArg(args, OPT_TERRAGRUNT_SOURCE_UPDATE, false)
sourceUpdate := parseBooleanArg(args, OPT_TERRAGRUNT_SOURCE_UPDATE, false)

return &options.TerragruntOptions{
TerragruntConfigPath: filepath.ToSlash(terragruntConfigPath),
Expand All @@ -71,7 +71,7 @@ func parseTerragruntOptionsFromArgs(args []string) (*options.TerragruntOptions,
Logger: util.CreateLogger(""),
RunTerragrunt: runTerragrunt,
Source: terraformSource,
UpdateSource: updateSource,
SourceUpdate: sourceUpdate,
Env: parseEnvironmentVariables(os.Environ()),
}, nil
}
Expand Down
2 changes: 1 addition & 1 deletion cli/cli_app.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ GLOBAL OPTIONS:
terragrunt-non-interactive Assume "yes" for all prompts.
terragrunt-working-dir The path to the Terraform templates. Default is current directory.
terragrunt-source Download Terraform configurations from the specified source into a temporary folder, and run Terraform in that temporary folder
terragrunt-source-update Delete the contents of the temporary folder before downloading source code into it
terragrunt-source-update Delete the contents of the temporary folder to clear out any old, cached source code before downloading new source code into it
VERSION:
{{.Version}}{{if len .Authors}}
Expand Down
2 changes: 1 addition & 1 deletion cli/download_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func downloadTerraformSource(source string, terragruntOptions *options.Terragrun

// Download the specified TerraformSource if the latest code hasn't already been downloaded.
func downloadTerraformSourceIfNecessary(terraformSource *TerraformSource, terragruntOptions *options.TerragruntOptions) error {
if terragruntOptions.UpdateSource {
if terragruntOptions.SourceUpdate {
terragruntOptions.Logger.Printf("The --%s flag is set, so deleting the temporary folder %s before downloading source.", OPT_TERRAGRUNT_SOURCE_UPDATE, terraformSource.DownloadDir)
if err := os.RemoveAll(terraformSource.DownloadDir); err != nil {
return errors.WithStackTrace(err)
Expand Down
4 changes: 2 additions & 2 deletions cli/download_source_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,15 +146,15 @@ func TestDownloadTerraformSourceIfNecessaryRemoteUrlOverrideSource(t *testing.T)
testDownloadTerraformSourceIfNecessary(t, canonicalUrl, downloadDir, true, "# Hello, World")
}

func testDownloadTerraformSourceIfNecessary(t *testing.T, canonicalUrl string, downloadDir string, updateSource bool, expectedFileContents string) {
func testDownloadTerraformSourceIfNecessary(t *testing.T, canonicalUrl string, downloadDir string, sourceUpdate bool, expectedFileContents string) {
terraformSource := &TerraformSource{
CanonicalSourceURL: parseUrl(t, canonicalUrl),
DownloadDir: downloadDir,
VersionFile: filepath.Join(downloadDir, "version-file.txt"),
}

terragruntOptions := options.NewTerragruntOptionsForTest("./should-not-be-used")
terragruntOptions.UpdateSource = updateSource
terragruntOptions.SourceUpdate = sourceUpdate

err := downloadTerraformSourceIfNecessary(terraformSource, terragruntOptions)
assert.Nil(t, err, "For terraform source %v: %v", terraformSource, err)
Expand Down
6 changes: 3 additions & 3 deletions options/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ type TerragruntOptions struct {
Source string

// If set to true, delete the contents of the temporary folder before downloading Terraform source code into it
UpdateSource bool
SourceUpdate bool

// A command that can be used to run Terragrunt with the given options. This is useful for running Terragrunt
// multiple times (e.g. when spinning up a stack of Terraform modules). The actual command is normally defined
Expand All @@ -59,7 +59,7 @@ func NewTerragruntOptions(terragruntConfigPath string) *TerragruntOptions {
Logger: util.CreateLogger(""),
Env: map[string]string{},
Source: "",
UpdateSource: false,
SourceUpdate: false,
RunTerragrunt: func(terragruntOptions *TerragruntOptions) error {
return errors.WithStackTrace(RunTerragruntCommandNotSet)
},
Expand Down Expand Up @@ -89,7 +89,7 @@ func (terragruntOptions *TerragruntOptions) Clone(terragruntConfigPath string) *
Logger: util.CreateLogger(workingDir),
Env: terragruntOptions.Env,
Source: terragruntOptions.Source,
UpdateSource: terragruntOptions.UpdateSource,
SourceUpdate: terragruntOptions.SourceUpdate,
RunTerragrunt: terragruntOptions.RunTerragrunt,
}
}
Expand Down

0 comments on commit 1bf8ed3

Please sign in to comment.