Skip to content

Commit 8813653

Browse files
yhakbarRahul-Kumar-prog
authored andcommitted
chore: Expanding lll coverage to runcfg (gruntwork-io#5871)
1 parent ec7becb commit 8813653

2 files changed

Lines changed: 27 additions & 8 deletions

File tree

.golangci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ linters:
121121
# trying to get this merged in.
122122
- linters:
123123
- lll
124-
path-except: '^(internal/awshelper/|internal/cas/|internal/cli/commands/(backend/(delete|migrate)|catalog/tui/command|dag/graph|exec|find|help|list|scaffold|stack)/|internal/cloner/|internal/configbridge/|internal/engine/|internal/errorconfig/|internal/errors/|internal/experiment/|internal/gcphelper/|internal/git/|internal/os/exec/|internal/prepare/|internal/queue/|internal/runner/(common|graph|run/creds)/|internal/stacks/(generate|output)/|internal/tf/cache/(controllers|middleware)/|internal/tflint/|internal/tips/|internal/vfs/|internal/worktrees/|pkg/log/(format/(options|placeholders)|writer)/)'
124+
path-except: '^(internal/awshelper/|internal/cas/|internal/cli/commands/(backend/(delete|migrate)|catalog/tui/command|dag/graph|exec|find|help|list|scaffold|stack)/|internal/cloner/|internal/configbridge/|internal/engine/|internal/errorconfig/|internal/errors/|internal/experiment/|internal/gcphelper/|internal/git/|internal/os/exec/|internal/prepare/|internal/queue/|internal/runner/(common|graph|run/creds|runcfg)/|internal/stacks/(generate|output)/|internal/tf/cache/(controllers|middleware)/|internal/tflint/|internal/tips/|internal/vfs/|internal/worktrees/|pkg/log/(format/(options|placeholders)|writer)/)'
125125
paths:
126126
- docs
127127
- _ci

internal/runner/runcfg/util.go

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ const DefaultEngineType = "rpc"
2828
//
2929
// Terraform 0.14 now generates a lock file when you run `terraform init`.
3030
// If any such file exists, this function will copy the lock file to the destination folder.
31-
func CopyLockFile(l log.Logger, rootWorkingDir string, logShowAbsPaths bool, sourceFolder, destinationFolder string) error {
31+
func CopyLockFile(
32+
l log.Logger, rootWorkingDir string, logShowAbsPaths bool, sourceFolder, destinationFolder string,
33+
) error {
3234
sourceLockFilePath := filepath.Join(sourceFolder, tf.TerraformLockFile)
3335
destinationLockFilePath := filepath.Join(destinationFolder, tf.TerraformLockFile)
3436

@@ -59,7 +61,9 @@ func CopyLockFile(l log.Logger, rootWorkingDir string, logShowAbsPaths bool, sou
5961
// URL: via a command-line option or via an entry in the Terragrunt configuration. If the user used one of these, this
6062
// method returns the source URL. If neither is specified, returns "." to indicate the current directory should be
6163
// used as the source, ensuring a .terragrunt-cache directory is always created for consistency.
62-
func GetTerraformSourceURL(source string, sourceMap map[string]string, originalConfigPath string, cfg *RunConfig) (string, error) {
64+
func GetTerraformSourceURL(
65+
source string, sourceMap map[string]string, originalConfigPath string, cfg *RunConfig,
66+
) (string, error) {
6367
switch {
6468
case source != "":
6569
return source, nil
@@ -143,7 +147,11 @@ type InvalidSourceURLWithMapError struct {
143147
}
144148

145149
func (err InvalidSourceURLWithMapError) Error() string {
146-
return fmt.Sprintf("The --source-map parameter was passed in, but the source URL in the module at '%s' is invalid: '%s'. Note that the module URL must have a double-slash to separate the repo URL from the path within the repo!", err.ModulePath, err.ModuleSourceURL)
150+
return fmt.Sprintf(
151+
"The --source-map parameter was passed in, but the source URL in the module at '%s' is invalid: '%s'."+
152+
" Note that the module URL must have a double-slash to separate the repo URL from the path within the repo!",
153+
err.ModulePath, err.ModuleSourceURL,
154+
)
147155
}
148156

149157
// ParsingModulePathError is an error type for when module path cannot be parsed from source URL.
@@ -152,7 +160,11 @@ type ParsingModulePathError struct {
152160
}
153161

154162
func (err ParsingModulePathError) Error() string {
155-
return fmt.Sprintf("Unable to obtain the module path from the source URL '%s'. Ensure that the URL is in a supported format.", err.ModuleSourceURL)
163+
return fmt.Sprintf(
164+
"Unable to obtain the module path from the source URL '%s'."+
165+
" Ensure that the URL is in a supported format.",
166+
err.ModuleSourceURL,
167+
)
156168
}
157169

158170
// Regexp for module name extraction. It assumes that the query string has already been stripped off.
@@ -170,7 +182,8 @@ func GetModulePathFromSourceURL(sourceURL string) (string, error) {
170182

171183
matches := moduleNameRegexp.FindStringSubmatch(sourceURL)
172184

173-
// if regexp returns less/more than the full match + 1 capture group, then something went wrong with regex (invalid source string)
185+
// if regexp returns less/more than the full match + 1 capture group,
186+
// then something went wrong with regex (invalid source string)
174187
const matchedPats = 2
175188
if len(matches) != matchedPats {
176189
return "", errors.New(ParsingModulePathError{ModuleSourceURL: sourceURL})
@@ -237,11 +250,17 @@ func (cfg *RunConfig) ErrorsConfig() (*errorconfig.Config, error) {
237250

238251
// Validate retry settings
239252
if retryBlock.MaxAttempts < 1 {
240-
return nil, errors.Errorf("cannot have less than 1 max retry in errors.retry %q, but you specified %d", retryBlock.Label, retryBlock.MaxAttempts)
253+
return nil, errors.Errorf(
254+
"cannot have less than 1 max retry in errors.retry %q, but you specified %d",
255+
retryBlock.Label, retryBlock.MaxAttempts,
256+
)
241257
}
242258

243259
if retryBlock.SleepIntervalSec < 0 {
244-
return nil, errors.Errorf("cannot sleep for less than 0 seconds in errors.retry %q, but you specified %d", retryBlock.Label, retryBlock.SleepIntervalSec)
260+
return nil, errors.Errorf(
261+
"cannot sleep for less than 0 seconds in errors.retry %q, but you specified %d",
262+
retryBlock.Label, retryBlock.SleepIntervalSec,
263+
)
245264
}
246265

247266
compiledPatterns := make([]*errorconfig.Pattern, 0, len(retryBlock.RetryableErrors))

0 commit comments

Comments
 (0)