@@ -18,14 +18,89 @@ deprecated aliases inside v1; full removal is deferred to v2.
1818This page lists what changed at the v0.x to v1.0.0 boundary and points at
1919the per-service guides where the change set is large.
2020
21+ ## Function naming conventions
22+
23+ Most public Terratest helpers come in up to four variants. Knowing which
24+ to call is the most common source of confusion when reading v1 godoc:
25+
26+ | Suffix | Takes ` context.Context ` | On error |
27+ | --- | --- | --- |
28+ | ` Foo ` | no | calls ` t.Fatal ` (fails the test) |
29+ | ` FooE ` | no | returns ` error ` to the caller |
30+ | ` FooContext ` | yes | calls ` t.Fatal ` |
31+ | ` FooContextE ` | yes | returns ` error ` |
32+
33+ Two independent suffixes:
34+
35+ - ** ` E ` suffix.** Long-standing Terratest convention. Use the bare name
36+ (` Apply ` ) when you want any failure to fail the test, and the ` E `
37+ variant (` ApplyE ` ) when you want the error back to assert on it or
38+ retry. Both variants exist for almost every helper.
39+ - ** ` Context ` suffix.** Added in v1. Takes an explicit ` context.Context `
40+ as the second argument so callers can plumb timeouts, cancellation,
41+ and tracing through. The non-` Context ` variants are now deprecated and
42+ internally call the ` *Context* ` variant with ` context.Background() ` .
43+
44+ The preferred v1 call is ` FooContext ` (or ` FooContextE ` ). For example,
45+ prefer ` terraform.ApplyContext(t, ctx, opts) ` over ` terraform.Apply(t, opts) ` .
46+
47+ ## Migrating to the ` Context ` variants
48+
49+ The Context migration is the single largest source of deprecation
50+ warnings you will see when upgrading. Every helper that runs an external
51+ command, makes an SDK call, or sleeps got a ` *Context ` / ` *ContextE `
52+ companion. The non-` Context ` variants compile and behave identically;
53+ they just emit a ` // Deprecated: ` godoc warning and forward to the
54+ ` *Context* ` variant with ` context.Background() ` .
55+
56+ Affected packages (rough scope):
57+
58+ - ` modules/terraform ` , ` modules/helm ` , ` modules/dns-helper `
59+ - ` modules/k8s ` , ` modules/aws ` , ` modules/azure ` , ` modules/gcp `
60+
61+ Mechanical migration:
62+
63+ ``` go
64+ // Before
65+ out := terraform.Apply (t, options)
66+ out , err := terraform.ApplyE (t, options)
67+
68+ // After
69+ ctx := t.Context () // Go 1.24+; or context.Background() / context.WithTimeout(...)
70+ out := terraform.ApplyContext (t, ctx, options)
71+ out , err := terraform.ApplyContextE (t, ctx, options)
72+ ```
73+
74+ The order of arguments in ` *Context* ` variants is always
75+ ` (t, ctx, ...originalArgs) ` . If you do not need cancellation or
76+ timeouts yet, passing ` context.Background() ` is fine and gives you the
77+ same behavior as the deprecated wrapper while moving you off the
78+ deprecation warning.
79+
80+ You can do this incrementally. The deprecated wrappers will keep working
81+ for the entire v1 line; they only disappear in v2.
82+
2183## What changed by service
2284
2385### Azure
2486
25- The largest set of breaking changes. The whole ` modules/azure ` package was
26- moved from the archived ` services/... ` SDK to the actively maintained
27- ` sdk/resourcemanager/... ` SDK, with a few naming cleanups landed in the
28- same release. See [ Azure modules] ( ./azure/ ) for the full migration guide.
87+ The largest set of breaking changes. The whole ` modules/azure ` package
88+ was moved from the archived ` services/... ` SDK to the actively maintained
89+ ` sdk/resourcemanager/... ` SDK, plus a handful of naming cleanups landed
90+ in the same release. See [ Azure modules] ( ./azure/ ) for the full migration
91+ guide. Highlights:
92+
93+ - ` services/... ` imports become ` sdk/resourcemanager/.../arm<service> ` .
94+ - Resource fields move under ` .Properties ` .
95+ - Iterator-based list calls become pagers.
96+ - 8 ` Get*ClientE ` getters were removed; use the ` Create*ClientE `
97+ replacements that have been around for a while.
98+ - 4 ` CreateNew*ClientE ` factories were renamed to ` Create*ClientE ` (the
99+ old names remain as deprecated aliases).
100+ - ` NsgRuleSummary.SourceAdresssPrefixes ` (triple-s typo) renamed to
101+ ` SourceAddressPrefixes ` .
102+ - New ` *WithClient ` functions accept a pre-built SDK client for
103+ injection in unit tests.
29104
30105### AWS
31106
@@ -62,36 +137,46 @@ callers that drove the underlying client directly need to switch from
62137` TopicAdminClient ` / ` SubscriptionAdminClient ` calls that take fully
63138qualified resource names (` projects/<id>/topics/<name> ` ).
64139
140+ ` modules/gcp/compute.go ` also moved several free functions onto receiver
141+ methods of ` Instance ` , ` ZonalInstanceGroup ` , and ` RegionalInstanceGroup `
142+ (e.g. ` GetPublicIP(t, instance) ` becomes ` instance.GetPublicIP(t) ` ). The
143+ free-function forms are kept as deprecated wrappers; switch when
144+ convenient.
145+
65146### Kubernetes
66147
67148` GetKubernetesClientFromOptionsContextE ` no longer falls back silently to
68- ` rest.InClusterConfig() ` when an explicit kubeconfig path or context fails
69- to load. It now returns the underlying ` LoadAPIClientConfigE ` error.
149+ ` rest.InClusterConfig() ` when an explicit kubeconfig path or context
150+ fails to load. It now returns the underlying ` LoadAPIClientConfigE `
151+ error.
70152
71153This was a silent-failure footgun: a typo in ` KubectlOptions.ConfigPath `
72154would cause tests to run against the test runner's in-cluster identity
73155(potentially a different cluster) with no error. If you relied on that
74156fallback, set ` KubectlOptions.InClusterAuth = true ` to opt in
75157explicitly.
76158
77- ## Deprecations you can defer
159+ ## Other deprecations you can defer
78160
79- Throughout v1, replaced symbols carry a ` // Deprecated: ` godoc annotation
80- pointing at the new name. Examples:
161+ A handful of smaller renames also landed with ` // Deprecated: ` aliases:
81162
82- - Non-` Context ` variants in ` modules/terraform ` , ` modules/helm ` ,
83- ` modules/dns-helper ` , etc. (` Destroy ` , ` Show ` , ` RunTerraformCommand ` , ...)
84- are deprecated in favor of ` *Context ` / ` *ContextE ` variants that take
85- an explicit ` context.Context ` .
86- - ` CreateNew*Client* ` factories in ` modules/azure ` are deprecated in
87- favor of ` Create*Client* ` (the redundant ` New ` is dropped).
163+ - ` modules/azure ` : ` CreateNew*Client* ` factories deprecated in favor of
164+ ` Create*Client* ` (the redundant ` New ` is dropped).
165+ - ` modules/ssh ` : ` SshSession ` and ` SshConnectionOptions ` renamed to
166+ ` SSHSession ` and ` SSHConnectionOptions ` (Go-idiomatic acronym
167+ casing). The old names remain as deprecated type aliases.
168+ - ` modules/terraform ` : a few legacy spellings (e.g. ` CtyJsonOutput ` →
169+ ` CtyJSONOutput ` ).
170+ - ` modules/test-structure ` : SSH-key and artifact-ID save/load helpers
171+ picked up consistent names (` SaveSSHKeyPair ` , ` LoadSSHKeyPair ` ,
172+ ` SaveArtifactID ` , ` LoadArtifactID ` ).
88173
89- These keep working for the entire v1 line. Migrate at your convenience;
90- removal is a v2 concern .
174+ These are pure renames: the old names forward to the new ones and stay
175+ in the v1 line .
91176
92177## Need help
93178
94179Open an issue on the [ Terratest
95- repo] ( https://github.com/gruntwork-io/terratest/issues ) with a snippet of
96- the failing code and the relevant module label. If you spot a gap in
97- this guide, send a PR against ` docs/_docs/03_migrating-to-v1/ ` .
180+ repo] ( https://github.com/gruntwork-io/terratest/issues ) with a snippet
181+ of the failing code and the relevant module label. If you spot a gap
182+ in this guide, send a PR against ` docs/_docs/03_migrating-to-v1/ ` .
0 commit comments