Skip to content

Commit d067225

Browse files
authored
Extract core/v2 (collapse tier-0 utils into modules/core) (#1858)
* extract core/v2: collapse tier-0 utils into a modules/core submodule First tier of the v2 modularization. Moves logger, testing, retry, random, files, shell and the internal collections/formatting helpers into a new modules/core module (github.com/gruntwork-io/terratest/modules/core/v2), rewriting all imports to their /v2 paths. Adds a root go.work plus a replace so the umbrella module resolves core locally and under GOWORK=off. Core's go.mod is seeded to the root's dependency versions so nothing floats; the other domains, cmd/, and the CI tooling are untouched. * document the go.work and root replace resolution model
1 parent ba45e40 commit d067225

499 files changed

Lines changed: 576 additions & 447 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

cmd/terratest_log_parser/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ import (
4242
"github.com/gruntwork-io/go-commons/entrypoint"
4343
"github.com/gruntwork-io/go-commons/errors"
4444
"github.com/gruntwork-io/go-commons/logging"
45-
"github.com/gruntwork-io/terratest/modules/logger/parser"
45+
"github.com/gruntwork-io/terratest/modules/core/v2/logger/parser"
4646
"github.com/sirupsen/logrus"
4747
"github.com/urfave/cli"
4848
)

go.mod

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ require (
1616
github.com/hashicorp/hcl/v2 v2.22.0
1717
github.com/hashicorp/terraform-json v0.23.0
1818
github.com/jinzhu/copier v0.0.0-20190924061706-b57f9002281a
19-
github.com/jstemmer/go-junit-report v1.0.0
19+
github.com/jstemmer/go-junit-report v1.0.0 // indirect
2020
github.com/magiconair/properties v1.8.7
2121
github.com/mattn/go-zglob v0.0.2-0.20190814121620-e3c945676326
2222
github.com/miekg/dns v1.1.62
@@ -94,6 +94,7 @@ require (
9494
github.com/aws/aws-sdk-go-v2/service/sts v1.42.0
9595
github.com/aws/smithy-go v1.27.1
9696
github.com/gonvenience/ytbx v1.4.4
97+
github.com/gruntwork-io/terratest/modules/core/v2 v2.0.0-00010101000000-000000000000
9798
github.com/hashicorp/go-getter/v2 v2.2.3
9899
github.com/homeport/dyff v1.6.0
99100
github.com/jackc/pgx/v5 v5.9.0
@@ -243,3 +244,11 @@ require (
243244
sigs.k8s.io/structured-merge-diff/v6 v6.3.2 // indirect
244245
sigs.k8s.io/yaml v1.6.0 // indirect
245246
)
247+
248+
// The root module (examples/ and test/) imports core/v2, which is not published
249+
// yet. go.work resolves it for workspace builds, but `go mod tidy` (the CI tidy
250+
// check) and any GOWORK=off build ignore go.work, so this replace is what lets
251+
// them find core locally. Dev-only: the root module is not published in v2
252+
// (consumers import the submodules directly), and this replace is never part of
253+
// a release tag. As more tiers split out, the root gains one replace per submodule.
254+
replace github.com/gruntwork-io/terratest/modules/core/v2 => ./modules/core

go.work

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
go 1.26.0
2+
3+
// Development workspace. Resolves the local /v2 submodules for `go build` and
4+
// `go test` so they see each other's uncommitted code without publishing anything
5+
// or adding per-module `replace` directives, which keeps the submodule go.mod
6+
// files clean. As more tiers split out, each adds a `use ./modules/<name>` line.
7+
//
8+
// Not used at release: tags are cut with GOWORK=off and no replaces, and the
9+
// published modules resolve each other by version from the proxy. See
10+
// scripts/check-release-mode.sh, which validates that GOWORK=off build.
11+
use (
12+
.
13+
./modules/core
14+
)

go.work.sum

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
cloud.google.com/go/compute v1.54.0 h1:4CKmnpO+40z44bKG5bdcKxQ7ocNpRtOc9SCLLUzze1w=
2+
cloud.google.com/go/pubsub v1.50.1 h1:fzbXpPyJnSGvWXF1jabhQeXyxdbCIkXTpjXHy7xviBM=
3+
github.com/russross/blackfriday v1.6.0 h1:KqfZb0pUVN2lYqZUYRddxF4OR8ZMURnJIG5Y3VRLtww=

modules/aws/account.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
"github.com/aws/aws-sdk-go-v2/service/sts"
1010
"github.com/stretchr/testify/require"
1111

12-
"github.com/gruntwork-io/terratest/modules/testing"
12+
"github.com/gruntwork-io/terratest/modules/core/v2/testing"
1313
)
1414

1515
// minARNParts is the minimum number of colon-separated parts in a valid IAM ARN.

modules/aws/acm.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
"github.com/aws/aws-sdk-go-v2/service/acm"
77
"github.com/stretchr/testify/require"
88

9-
"github.com/gruntwork-io/terratest/modules/testing"
9+
"github.com/gruntwork-io/terratest/modules/core/v2/testing"
1010
)
1111

1212
// AcmAPI is the subset of *acm.Client operations used by the helpers in this file.

modules/aws/ami.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ import (
99
"github.com/aws/aws-sdk-go-v2/aws"
1010
"github.com/aws/aws-sdk-go-v2/service/ec2"
1111
"github.com/aws/aws-sdk-go-v2/service/ec2/types"
12-
"github.com/gruntwork-io/terratest/modules/logger"
13-
"github.com/gruntwork-io/terratest/modules/testing"
12+
"github.com/gruntwork-io/terratest/modules/core/v2/logger"
13+
"github.com/gruntwork-io/terratest/modules/core/v2/testing"
1414
"github.com/stretchr/testify/require"
1515
)
1616

modules/aws/asg.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ import (
99
"github.com/aws/aws-sdk-go-v2/service/autoscaling"
1010
"github.com/stretchr/testify/require"
1111

12-
"github.com/gruntwork-io/terratest/modules/logger"
13-
"github.com/gruntwork-io/terratest/modules/retry"
14-
"github.com/gruntwork-io/terratest/modules/testing"
12+
"github.com/gruntwork-io/terratest/modules/core/v2/logger"
13+
"github.com/gruntwork-io/terratest/modules/core/v2/retry"
14+
"github.com/gruntwork-io/terratest/modules/core/v2/testing"
1515
)
1616

1717
// AsgCapacityInfo holds capacity information about an Auto Scaling Group.

modules/aws/asg_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import (
1414
"github.com/stretchr/testify/require"
1515

1616
aws "github.com/gruntwork-io/terratest/modules/aws"
17-
"github.com/gruntwork-io/terratest/modules/random"
17+
"github.com/gruntwork-io/terratest/modules/core/v2/random"
1818
)
1919

2020
func TestGetCapacityInfoForAsg(t *testing.T) {

modules/aws/cloudwatch.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55

66
"github.com/aws/aws-sdk-go-v2/aws"
77
"github.com/aws/aws-sdk-go-v2/service/cloudwatchlogs"
8-
"github.com/gruntwork-io/terratest/modules/testing"
8+
"github.com/gruntwork-io/terratest/modules/core/v2/testing"
99
"github.com/stretchr/testify/require"
1010
)
1111

0 commit comments

Comments
 (0)