Skip to content

Commit 333c486

Browse files
committed
chore: Expanding lll coverage to scaffold
1 parent f57ce70 commit 333c486

4 files changed

Lines changed: 22 additions & 10 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|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)/|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/cli/commands/scaffold/scaffold.go

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,8 @@ func downloadTemplate(
419419
}
420420

421421
l.Debugf("Downloading template from %s into %s", baseURL.String(), templateDir)
422-
// Downloading baseURL to support boilerplate dependencies and partials. Go-getter discards all but specified folder if one is provided.
422+
// Downloading baseURL to support boilerplate dependencies and partials.
423+
// Go-getter discards all but specified folder if one is provided.
423424
if _, err := getter.GetAny(ctx, templateDir, baseURL.String()); err != nil {
424425
return "", errors.New(err)
425426
}
@@ -558,7 +559,8 @@ func parseModuleURL(
558559
}
559560

560561
// rewriteModuleURL rewrites module url to git ssh if required
561-
// github.com/gruntwork-io/terragrunt.git//test/fixtures/inputs => git::https://github.com/gruntwork-io/terragrunt.git//test/fixtures/inputs
562+
// github.com/gruntwork-io/terragrunt.git//test/fixtures/inputs =>
563+
// git::https://github.com/gruntwork-io/terragrunt.git//test/fixtures/inputs
562564
func rewriteModuleURL(
563565
l log.Logger,
564566
opts *options.TerragruntOptions,
@@ -585,7 +587,8 @@ func rewriteModuleURL(
585587
return parsedModuleURL, nil
586588
}
587589
// try to rewrite module url if is https and is requested to be git
588-
// git::https://github.com/gruntwork-io/terragrunt.git//test/fixtures/inputs => git::ssh://git@github.com/gruntwork-io/terragrunt.git//test/fixtures/inputs
590+
// git::https://github.com/gruntwork-io/terragrunt.git//test/fixtures/inputs =>
591+
// git::ssh://git@github.com/gruntwork-io/terragrunt.git//test/fixtures/inputs
589592
if parsedValue.scheme == "https" && sourceURLType == sourceURLTypeGit {
590593
gitUser := sourceGitSSHUser
591594
if value, found := vars[sourceGitSSHUserVar]; found {
@@ -606,7 +609,8 @@ func rewriteModuleURL(
606609
}
607610

608611
// rewriteTemplateURL rewrites template url with reference to tag
609-
// github.com/denis256/terragrunt-tests.git//scaffold/base-template => github.com/denis256/terragrunt-tests.git//scaffold/base-template?ref=v0.53.8
612+
// github.com/denis256/terragrunt-tests.git//scaffold/base-template =>
613+
// github.com/denis256/terragrunt-tests.git//scaffold/base-template?ref=v0.53.8
610614
func rewriteTemplateURL(
611615
ctx context.Context,
612616
l log.Logger,
@@ -663,7 +667,8 @@ func addRefToModuleURL(
663667
ref := params.Get(refParam)
664668
if ref == "" {
665669
// if ref is not passed, find last release tag
666-
// git::https://github.com/gruntwork-io/terragrunt.git//test/fixtures/inputs => git::https://github.com/gruntwork-io/terragrunt.git//test/fixtures/inputs?ref=v0.53.8
670+
// git::https://github.com/gruntwork-io/terragrunt.git//test/fixtures/inputs =>
671+
// git::https://github.com/gruntwork-io/terragrunt.git//test/fixtures/inputs?ref=v0.53.8
667672
rootSourceURL, _, err := tf.SplitSourceURL(l, moduleURL)
668673
if err != nil {
669674
return nil, errors.New(err)

internal/cli/commands/scaffold/scaffold_test.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,11 @@ import (
2222
)
2323

2424
// newTestBoilerplateOptions creates a BoilerplateOptions for testing
25-
func newTestBoilerplateOptions(templateFolder, outputFolder string, vars map[string]any, noShell, noHooks bool) *boilerplateoptions.BoilerplateOptions {
25+
func newTestBoilerplateOptions(
26+
templateFolder, outputFolder string,
27+
vars map[string]any,
28+
noShell, noHooks bool,
29+
) *boilerplateoptions.BoilerplateOptions {
2630
return &boilerplateoptions.BoilerplateOptions{
2731
TemplateFolder: templateFolder,
2832
OutputFolder: outputFolder,
@@ -107,7 +111,9 @@ func TestDefaultTemplateVariables(t *testing.T) {
107111
assert.Len(t, cfg.Inputs, 1)
108112
_, found := cfg.Inputs["required_var_1"]
109113
require.True(t, found)
110-
require.Equal(t, "git::https://github.com/gruntwork-io/terragrunt.git//test/fixtures/inputs?ref=v0.53.8", *cfg.Terraform.Source)
114+
require.Equal(t,
115+
"git::https://github.com/gruntwork-io/terragrunt.git//test/fixtures/inputs?ref=v0.53.8",
116+
*cfg.Terraform.Source)
111117
}
112118

113119
func TestCatalogConfigApplication(t *testing.T) {

internal/cli/commands/scaffold/source_url_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@ func TestBuildSourceURL(t *testing.T) {
2020
{
2121
name: "catalog URL gets ref from resolved",
2222
originalURL: "github.com/gruntwork-io/terragrunt-scale-catalog//modules/azure/resource-group",
23-
resolvedURL: "git::https://github.com/gruntwork-io/terragrunt-scale-catalog.git//modules/azure/resource-group?ref=v1.10.2",
24-
expected: "github.com/gruntwork-io/terragrunt-scale-catalog//modules/azure/resource-group?ref=v1.10.2",
23+
resolvedURL: "git::https://github.com/gruntwork-io/terragrunt-scale-catalog.git//" +
24+
"modules/azure/resource-group?ref=v1.10.2",
25+
expected: "github.com/gruntwork-io/terragrunt-scale-catalog//modules/azure/resource-group?ref=v1.10.2",
2526
},
2627
{
2728
name: "original already has ref",

0 commit comments

Comments
 (0)