Skip to content

Commit

Permalink
run gofmt
Browse files Browse the repository at this point in the history
  • Loading branch information
jonapich committed Apr 9, 2024
1 parent afdb9df commit d4ac17c
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 23 deletions.
30 changes: 15 additions & 15 deletions cli/download_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,25 +141,25 @@ func writeVersionFile(terraformSource *TerraformSource) error {
// To maximize reuse, given a working directory w and a source URL s, we download code from S into the folder /T/W/H
// where:
//
// 1. S is the part of s before the double-slash (//). This typically represents the root of the repo (e.g.
// github.com/foo/infrastructure-modules). We download the entire repo so that relative paths to other files in that
// repo resolve correctly. If no double-slash is specified, all of s is used.
// 1. T is the OS temp dir (e.g. /tmp).
// 2. W is the base 64 encoded sha1 hash of w. This ensures that if you are running Terragrunt concurrently in
// multiple folders (e.g. during automated tests), then even if those folders are using the same source URL s, they
// do not overwrite each other.
// 3. H is the base 64 encoded sha1 of S without its query string. For remote source URLs (e.g. Git
// URLs), this is based on the assumption that the scheme/host/path of the URL (e.g. git::github.com/foo/bar)
// identifies the repo, and we always want to download the same repo into the same folder (see the encodeSourceName
// method). We also assume the version of the module is stored in the query string (e.g. ref=v0.0.3), so we store
// the base 64 encoded sha1 of the query string in a file called .terragrunt-source-version within /T/W/H.
// 1. S is the part of s before the double-slash (//). This typically represents the root of the repo (e.g.
// github.com/foo/infrastructure-modules). We download the entire repo so that relative paths to other files in that
// repo resolve correctly. If no double-slash is specified, all of s is used.
// 1. T is the OS temp dir (e.g. /tmp).
// 2. W is the base 64 encoded sha1 hash of w. This ensures that if you are running Terragrunt concurrently in
// multiple folders (e.g. during automated tests), then even if those folders are using the same source URL s, they
// do not overwrite each other.
// 3. H is the base 64 encoded sha1 of S without its query string. For remote source URLs (e.g. Git
// URLs), this is based on the assumption that the scheme/host/path of the URL (e.g. git::github.com/foo/bar)
// identifies the repo, and we always want to download the same repo into the same folder (see the encodeSourceName
// method). We also assume the version of the module is stored in the query string (e.g. ref=v0.0.3), so we store
// the base 64 encoded sha1 of the query string in a file called .terragrunt-source-version within /T/W/H.
//
// The downloadTerraformSourceIfNecessary decides when we should download the Terraform code and when not to. It uses
// the following rules:
//
// 1. Always download source URLs pointing to local file paths.
// 2. Only download source URLs pointing to remote paths if /T/W/H doesn't already exist or, if it does exist, if the
// version number in /T/W/H/.terragrunt-source-version doesn't match the current version.
// 1. Always download source URLs pointing to local file paths.
// 2. Only download source URLs pointing to remote paths if /T/W/H doesn't already exist or, if it does exist, if the
// version number in /T/W/H/.terragrunt-source-version doesn't match the current version.
func processTerraformSource(source string, terragruntOptions *options.TerragruntOptions) (*TerraformSource, error) {
canonicalWorkingDir, err := util.CanonicalPath(terragruntOptions.WorkingDir, "")
if err != nil {
Expand Down
3 changes: 2 additions & 1 deletion config/config_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,8 @@ func (ctx *resolveContext) getParentDir() (string, error) {
}

// Returns the named environment variable or default value if it does not exist
// get_env(variable_name, default_value)
//
// get_env(variable_name, default_value)
func (ctx *resolveContext) getEnvironmentVariable(env, defValue string) string {
if value, exists := ctx.options.Env[env]; exists {
return value
Expand Down
6 changes: 3 additions & 3 deletions configstack/running_module.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,9 @@ func toRunningModules(modules []*TerraformModule, dependencyOrder dependencyOrde

// Loop through the map of runningModules and for each module M:
//
// * If dependencyOrder is NormalOrder, plug in all the modules M depends on into the Dependencies field and all the
// modules that depend on M into the NotifyWhenDone field.
// * If dependencyOrder is ReverseOrder, do the reverse.
// - If dependencyOrder is NormalOrder, plug in all the modules M depends on into the Dependencies field and all the
// modules that depend on M into the NotifyWhenDone field.
// - If dependencyOrder is ReverseOrder, do the reverse.
func crossLinkDependencies(modules map[string]*runningModule, dependencyOrder dependencyOrder) (map[string]*runningModule, error) {
for _, module := range modules {
for _, dependency := range module.Module.Dependencies {
Expand Down
7 changes: 4 additions & 3 deletions util/collections.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,10 @@ func RemoveDuplicatesFromListKeepLast(list []string) []string {

// RemoveDuplicatesFromList returns a copy of the given list with all duplicates removed (keeping the last encountereds)
// Params:
// list: The list to filter
// keepLast: Indicates whether the last or first encountered duplicate element should be kept
// getKey: Function used to extract the actual key from the string
//
// list: The list to filter
// keepLast: Indicates whether the last or first encountered duplicate element should be kept
// getKey: Function used to extract the actual key from the string
func RemoveDuplicatesFromList(list []string, keepLast bool, getKey func(key string) string) []string {
out := make([]string, 0, len(list))
present := make(map[string]bool)
Expand Down
4 changes: 3 additions & 1 deletion util/random.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ import (
)

// GetRandomTime returns random time duration between the lower bound and upper bound. This is useful because some of our
// automated tests wound up flooding the AWS API all at once, leading to a "Subscriber limit exceeded" error.
//
// automated tests wound up flooding the AWS API all at once, leading to a "Subscriber limit exceeded" error.
//
// TODO: Some of the more exotic test cases fail, but it's not worth catching them given the intended use of this function.
func GetRandomTime(lowerBound, upperBound time.Duration) time.Duration {
if lowerBound < 0 {
Expand Down

0 comments on commit d4ac17c

Please sign in to comment.