Skip to content

Commit 358334a

Browse files
authored
Extract helpers (ssh, httphelper, dnshelper) into /v2 modules (#1864)
* extract ssh/httphelper/dnshelper into their own /v2 modules Second tier (helpers) of the v2 modularization, on top of core. Each helper gets its own module (github.com/gruntwork-io/terratest/modules/<name>/v2) with go.mod seeded to root versions, imports rewritten to /v2, and a root replace + go.work use line. The helpers depend only on core/v2. Same pattern as the core extraction. * tidy helper go.mods to their real dependency sets The initial extraction seeded each helper with the root dependency graph, but go mod tidy could not prune it because the cross-module core/v2 pseudo-version is unresolvable outside the workspace. Regenerating each helper go.mod with a throwaway replace so tidy can resolve core, then dropping the replace, shrinks them to their actual deps (ssh 11, httphelper 6, dnshelper 13 requires) with a real go.sum, matching core's shape. Also reconcile the runbook: submodule go.mods do carry a sibling require at the local zero placeholder that go.work resolves; only the real-version pin waits for release-prep. * keep core untouched and drop the inert dnshelper root replace Review follow-ups: (1) go work sync had bumped modules/core's x/sys and left its go.sum incomplete, breaking core's standalone GOWORK=off build; revert core/go.mod+go.sum to main so the helpers PR does not modify the already-merged core module (ssh legitimately needs the newer x/sys; the workspace resolves the max). (2) Root replaced dnshelper/v2 without requiring it (dnshelper is test-only, not imported by root); drop the inert replace so root replaces match its requires.
1 parent 76bd330 commit 358334a

45 files changed

Lines changed: 187 additions & 42 deletions

Some content is hidden

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

docs/v2-release-runbook.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@ directives during normal development.
1616

1717
## Why pinning is a release-time step (do not commit it early)
1818

19-
The submodules' `go.mod` files are deliberately left without cross-module
20-
`require` lines on `main`. Pinning a sibling `require` to the to-be-published
19+
On `main`, a submodule's cross-module `require` sits at the local zero
20+
placeholder (e.g. `core/v2 v2.0.0-00010101000000-000000000000`) that `go.work`
21+
resolves; it is never pinned to a real, to-be-published version. Pinning a sibling `require` to the to-be-published
2122
version (e.g. `core/v2 v2.0.0-beta.1`) BREAKS the workspace build until that tag
2223
actually exists: `go.work` does not shadow an unpublished required version, so
2324
`go build` and `go work sync` try to fetch the missing revision and fail. The pin

go.mod

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ require (
1818
github.com/jinzhu/copier v0.0.0-20190924061706-b57f9002281a
1919
github.com/magiconair/properties v1.8.7
2020
github.com/mattn/go-zglob v0.0.2-0.20190814121620-e3c945676326
21-
github.com/miekg/dns v1.1.62
2221
github.com/mitchellh/go-homedir v1.1.0 // indirect
2322
github.com/pquerna/otp v1.4.0
2423
github.com/sirupsen/logrus v1.9.3 // indirect
@@ -94,6 +93,8 @@ require (
9493
github.com/aws/smithy-go v1.27.1
9594
github.com/gonvenience/ytbx v1.4.4
9695
github.com/gruntwork-io/terratest/modules/core/v2 v2.0.0-00010101000000-000000000000
96+
github.com/gruntwork-io/terratest/modules/httphelper/v2 v2.0.0-00010101000000-000000000000
97+
github.com/gruntwork-io/terratest/modules/ssh/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
@@ -157,7 +158,6 @@ require (
157158
github.com/go-openapi/jsonpointer v0.21.0 // indirect
158159
github.com/go-openapi/jsonreference v0.20.2 // indirect
159160
github.com/go-openapi/swag v0.23.0 // indirect
160-
github.com/go-test/deep v1.1.1 // indirect
161161
github.com/golang-jwt/jwt/v5 v5.3.1 // indirect
162162
github.com/golang-sql/civil v0.0.0-20220223132316-b832511892a9 // indirect
163163
github.com/golang-sql/sqlexp v0.1.0 // indirect
@@ -251,3 +251,7 @@ require (
251251
// (consumers import the submodules directly), and this replace is never part of
252252
// a release tag. As more tiers split out, the root gains one replace per submodule.
253253
replace github.com/gruntwork-io/terratest/modules/core/v2 => ./modules/core
254+
255+
replace github.com/gruntwork-io/terratest/modules/ssh/v2 => ./modules/ssh
256+
257+
replace github.com/gruntwork-io/terratest/modules/httphelper/v2 => ./modules/httphelper

go.sum

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -271,8 +271,8 @@ github.com/go-sql-driver/mysql v1.8.1 h1:LedoTUt/eveggdHS9qUFC1EFSa8bU2+1pZjSRpv
271271
github.com/go-sql-driver/mysql v1.8.1/go.mod h1:wEBSXgmK//2ZFJyE+qWnIsVGmvmEKlqwuVSjsCm7DZg=
272272
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI=
273273
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572/go.mod h1:9Pwr4B2jHnOSGXyyzV8ROjYa2ojvAY6HCGYYfMoC3Ls=
274-
github.com/go-test/deep v1.1.1 h1:0r/53hagsehfO4bzD2Pgr/+RgHqhmf+k1Bpse2cTu1U=
275-
github.com/go-test/deep v1.1.1/go.mod h1:5C2ZWiW0ErCdrYzpqxLbTX7MG14M9iiw8DgHncVwcsE=
274+
github.com/go-test/deep v1.0.7 h1:/VSMRlnY/JSyqxQUzQLKVMAskpY/NZKFA5j2P+0pP2M=
275+
github.com/go-test/deep v1.0.7/go.mod h1:QV8Hv/iy04NyLBxAdO9njL0iVPN1S4d/A3NVv1V36o8=
276276
github.com/golang-jwt/jwt/v5 v5.3.1 h1:kYf81DTWFe7t+1VvL7eS+jKFVWaUnK9cB1qbwn63YCY=
277277
github.com/golang-jwt/jwt/v5 v5.3.1/go.mod h1:fxCRLWMO43lRc8nhHWY6LGqRcf+1gQWArsqaEUEa5bE=
278278
github.com/golang-sql/civil v0.0.0-20220223132316-b832511892a9 h1:au07oEsX2xN0ktxqI+Sida1w446QrXBRJ0nee3SNZlA=
@@ -406,8 +406,6 @@ github.com/mattn/go-zglob v0.0.2-0.20190814121620-e3c945676326 h1:ofNAzWCcyTALn2
406406
github.com/mattn/go-zglob v0.0.2-0.20190814121620-e3c945676326/go.mod h1:9fxibJccNxU2cnpIKLRRFA7zX7qhkJIQWBb449FYHOo=
407407
github.com/microsoft/go-mssqldb v1.9.8 h1:d4IFMvF/o+HdpXUqbBfzHvn/NlFA75YGcfHUUvDFJEM=
408408
github.com/microsoft/go-mssqldb v1.9.8/go.mod h1:eGSRSGAW4hKMy5YcAenhCDjIRm2rhqIdmmwgciMzLus=
409-
github.com/miekg/dns v1.1.62 h1:cN8OuEF1/x5Rq6Np+h1epln8OiyPWV+lROx9LxcGgIQ=
410-
github.com/miekg/dns v1.1.62/go.mod h1:mvDlcItzm+br7MToIKqkglaGhlFMHJ9DTNNWONWXbNQ=
411409
github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=
412410
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
413411
github.com/mitchellh/go-ps v1.0.0 h1:i6ampVEEF4wQFF+bkYfwYgY+F/uYJDktmvLPf7qIgjc=

go.work

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,7 @@ go 1.26.0
1111
use (
1212
.
1313
./modules/core
14+
./modules/dnshelper
15+
./modules/httphelper
16+
./modules/ssh
1417
)

go.work.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
cloud.google.com/go/compute v1.54.0 h1:4CKmnpO+40z44bKG5bdcKxQ7ocNpRtOc9SCLLUzze1w=
22
cloud.google.com/go/pubsub v1.50.1 h1:fzbXpPyJnSGvWXF1jabhQeXyxdbCIkXTpjXHy7xviBM=
3+
github.com/miekg/dns v1.1.62 h1:cN8OuEF1/x5Rq6Np+h1epln8OiyPWV+lROx9LxcGgIQ=
4+
github.com/miekg/dns v1.1.62/go.mod h1:mvDlcItzm+br7MToIKqkglaGhlFMHJ9DTNNWONWXbNQ=
35
github.com/russross/blackfriday v1.6.0 h1:KqfZb0pUVN2lYqZUYRddxF4OR8ZMURnJIG5Y3VRLtww=

modules/aws/ec2-files.go

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

88
"github.com/gruntwork-io/terratest/modules/core/v2/files"
99
"github.com/gruntwork-io/terratest/modules/core/v2/testing"
10-
"github.com/gruntwork-io/terratest/modules/ssh"
10+
"github.com/gruntwork-io/terratest/modules/ssh/v2"
1111
"github.com/hashicorp/go-multierror"
1212
"github.com/stretchr/testify/require"
1313
)

modules/aws/keypair.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"github.com/aws/aws-sdk-go-v2/service/ec2"
88
"github.com/gruntwork-io/terratest/modules/core/v2/logger"
99
"github.com/gruntwork-io/terratest/modules/core/v2/testing"
10-
"github.com/gruntwork-io/terratest/modules/ssh"
10+
"github.com/gruntwork-io/terratest/modules/ssh/v2"
1111
"github.com/stretchr/testify/require"
1212
)
1313

modules/dnshelper/dns_local_server_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
"testing"
99
"time"
1010

11-
"github.com/gruntwork-io/terratest/modules/dnshelper"
11+
"github.com/gruntwork-io/terratest/modules/dnshelper/v2"
1212
"github.com/miekg/dns"
1313
)
1414

modules/dnshelper/dnshelper_test.go

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

77
"github.com/gruntwork-io/terratest/modules/core/v2/retry"
8-
"github.com/gruntwork-io/terratest/modules/dnshelper"
8+
"github.com/gruntwork-io/terratest/modules/dnshelper/v2"
99
"github.com/stretchr/testify/require"
1010
)
1111

modules/dnshelper/go.mod

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
module github.com/gruntwork-io/terratest/modules/dnshelper/v2
2+
3+
go 1.26.0
4+
5+
require (
6+
github.com/gruntwork-io/terratest/modules/core/v2 v2.0.0-00010101000000-000000000000
7+
github.com/miekg/dns v1.1.62
8+
github.com/stretchr/testify v1.11.1
9+
)
10+
11+
require (
12+
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
13+
github.com/google/go-cmp v0.7.0 // indirect
14+
github.com/kr/text v0.2.0 // indirect
15+
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
16+
golang.org/x/mod v0.35.0 // indirect
17+
golang.org/x/net v0.55.0 // indirect
18+
golang.org/x/sync v0.20.0 // indirect
19+
golang.org/x/sys v0.45.0 // indirect
20+
golang.org/x/tools v0.44.0 // indirect
21+
gopkg.in/yaml.v3 v3.0.1 // indirect
22+
)

0 commit comments

Comments
 (0)