Skip to content

Commit 7518994

Browse files
committed
docs(v1): tighten migration overview after accuracy audit
Independent review of the overview surfaced several inaccuracies and altitude problems. Rewrite to: - Fix wrong AWS function names. The doc named NewS3UploaderWithSession and NewS3UploaderWithSessionE, neither of which exist. The actual four functions are NewS3Uploader, NewS3UploaderE, NewS3UploaderContext, and NewS3UploaderContextE. - Drop the GCP compute receiver-method paragraph. That conversion happened in 2018, not for v1; there are no surviving deprecated free functions to migrate from. - Replace the t.Context() example. Helpers take testing.TestingT, an interface that does not expose Context(); the example was misleading for callers passing the abstracted type. Default to context.Background() and mention t.Context() only as an option for *testing.T. - Expand the affected-packages list to include http-helper, packer, docker, ssh, and oci. - Soften the "wrappers forward to *Context* with context.Background()" blanket claim, which has at least one false case. Cut altitude per a "don't stay too low level" instruction: - Trim Azure highlights bullet list; the per-rename detail belongs in the Azure sub-guide which the overview already links to. - Trim AWS section: drop the SDK service enumeration in favor of "every direct github.com/aws/aws-* dep was bumped". - Replace the named per-rename "Other deprecations" list with a principled paragraph plus a pointer to running staticcheck/go vet, which surfaces the deprecation warnings with replacement guidance. Add a Prerequisites section calling out Go 1.26+ and the cross-cloud go mod tidy step. Add a one-line callout for the new GCP *WithClient injection helpers (parallels the Azure note).
1 parent 5591f5e commit 7518994

1 file changed

Lines changed: 82 additions & 96 deletions

File tree

docs/_docs/03_migrating-to-v1/overview.md

Lines changed: 82 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,15 @@ changes to the public API only happen in major releases (e.g. v2.0.0), per
1515
[semver](https://semver.org/). Renamed or replaced symbols stay around as
1616
deprecated aliases inside v1; full removal is deferred to v2.
1717

18-
This page lists what changed at the v0.x to v1.0.0 boundary and points at
19-
the per-service guides where the change set is large.
18+
This page is the orientation map for v0.x to v1.0.0. It tells you what
19+
shape the changes take and where to look; the per-service guides hold the
20+
mechanical details.
21+
22+
## Prerequisites
23+
24+
- **Go 1.26 or newer.** v1.0.0 raised the minimum.
25+
- After upgrading, run `go mod tidy` from the directory that holds your
26+
test module's `go.mod`. The AWS, Azure, and GCP SDK pins all moved.
2027

2128
## Function naming conventions
2229

@@ -35,28 +42,29 @@ Two independent suffixes:
3542
- **`E` suffix.** Long-standing Terratest convention. Use the bare name
3643
(`Apply`) when you want any failure to fail the test, and the `E`
3744
variant (`ApplyE`) when you want the error back to assert on it or
38-
retry. Both variants exist for almost every helper.
45+
retry.
3946
- **`Context` suffix.** Added in v1. Takes an explicit `context.Context`
4047
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()`.
48+
and tracing through. The non-`Context` variants are now deprecated
49+
in favor of their `*Context*` counterparts.
4350

4451
The preferred v1 call is `FooContext` (or `FooContextE`). For example,
45-
prefer `terraform.ApplyContext(t, ctx, opts)` over `terraform.Apply(t, opts)`.
52+
prefer `terraform.ApplyContext(t, ctx, opts)` over
53+
`terraform.Apply(t, opts)`.
54+
55+
A small number of helpers do not yet expose all four variants (some
56+
packages added `Context` and dropped the bare `Foo` form, others have
57+
not grown a `Context` variant at all). Trust godoc and the deprecation
58+
warnings over the table when they disagree.
4659

4760
## Migrating to the `Context` variants
4861

4962
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`
63+
warnings you will see when upgrading. It touches nearly every helper
64+
package: `terraform`, `helm`, `dns-helper`, `http-helper`, `packer`,
65+
`docker`, `ssh`, `oci`, `k8s`, `aws`, `azure`, `gcp`. The non-`Context`
66+
variants compile and behave the same as before; they just emit a
67+
`// Deprecated:` godoc warning.
6068

6169
Mechanical migration:
6270

@@ -66,113 +74,91 @@ out := terraform.Apply(t, options)
6674
out, err := terraform.ApplyE(t, options)
6775

6876
// After
69-
ctx := t.Context() // Go 1.24+; or context.Background() / context.WithTimeout(...)
77+
ctx := context.Background() // or context.WithTimeout(...) for cancellation
7078
out := terraform.ApplyContext(t, ctx, options)
7179
out, err := terraform.ApplyContextE(t, ctx, options)
7280
```
7381

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.
82+
The `*Context*` variants always take `(t, ctx, ...originalArgs)`. If
83+
you do not need cancellation or timeouts, `context.Background()` gives
84+
you the same behavior as the deprecated wrapper. When `t` is
85+
`*testing.T` (Go 1.24+), `t.Context()` is an even better default
86+
because it ties the context lifetime to the test.
7987

80-
You can do this incrementally. The deprecated wrappers will keep working
81-
for the entire v1 line; they only disappear in v2.
88+
You can do this incrementally. The deprecated wrappers will keep
89+
working for the entire v1 line; they only disappear in v2.
8290

8391
## What changed by service
8492

8593
### Azure
8694

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.
95+
The largest set of breaking changes by far. The whole `modules/azure`
96+
package was moved from the archived `services/...` SDK to the actively
97+
maintained `sdk/resourcemanager/...` SDK, plus a handful of naming
98+
cleanups. Updating imports and the resulting compile errors is the bulk
99+
of the work; per-service tables and a search-and-replace cheatsheet are
100+
in [Azure modules](./azure/).
104101

105102
### AWS
106103

107-
`modules/aws/s3.go` migrated off the deprecated `s3/manager` package onto
108-
`s3/transfermanager`. Four exported functions changed return type:
109-
110-
- `NewS3Uploader`
111-
- `NewS3UploaderE`
112-
- `NewS3UploaderWithSession`
113-
- `NewS3UploaderWithSessionE`
114-
115-
These now return `*transfermanager.Client` instead of
116-
`*manager.Uploader`. The call shape moves from
104+
`modules/aws/s3.go` migrated off the deprecated
105+
`s3/manager` package onto `s3/transfermanager`. Four exported functions
106+
that returned `*manager.Uploader` now return `*transfermanager.Client`:
107+
`NewS3Uploader`, `NewS3UploaderE`, `NewS3UploaderContext`, and
108+
`NewS3UploaderContextE`. The call shape moves from
117109
`uploader.Upload(ctx, &s3.PutObjectInput{...})` to
118-
`client.UploadObject(ctx, &transfermanager.UploadObjectInput{...})`. The
119-
input and output types live in
110+
`client.UploadObject(ctx, &transfermanager.UploadObjectInput{...})`,
111+
with the input/output types under
120112
`github.com/aws/aws-sdk-go-v2/feature/s3/transfermanager`.
121113

122-
All other AWS SDK v2 service deps (acm, autoscaling, cloudwatchlogs,
123-
dynamodb, ec2, ecr, ecs, iam, kms, lambda, rds, route53, s3,
124-
secretsmanager, sns, sqs, ssm, sts, config, credentials) were bumped to
125-
the versions current at v1.0.0 cut. If your tests import those SDKs
126-
directly, run `go mod tidy` after upgrading Terratest.
114+
Every direct `github.com/aws/aws-*` dependency was bumped to the
115+
versions current at the v1.0.0 cut. If your tests import the AWS SDKs
116+
directly, expect to run `go mod tidy` and resolve a small number of
117+
type renames at the SDK level.
127118

128119
### GCP
129120

130121
`modules/gcp/pubsub.go` moved from `cloud.google.com/go/pubsub` (v1) to
131-
`cloud.google.com/go/pubsub/v2`. The v1 client is deprecated upstream and
132-
trips `staticcheck` SA1019.
133-
134-
The shape of the wrapper functions in `modules/gcp` is unchanged, but
135-
callers that drove the underlying client directly need to switch from
136-
`client.Topic("name")` / `client.Subscription("name")` handles to
137-
`TopicAdminClient` / `SubscriptionAdminClient` calls that take fully
138-
qualified resource names (`projects/<id>/topics/<name>`).
139-
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.
122+
`cloud.google.com/go/pubsub/v2`. The wrapper functions in `modules/gcp`
123+
are unchanged in shape, but callers that drove the underlying client
124+
directly need to switch from `client.Topic("name")` /
125+
`client.Subscription("name")` handles to `TopicAdminClient` /
126+
`SubscriptionAdminClient` calls that take fully qualified resource
127+
names (`projects/<id>/topics/<name>`).
128+
129+
A new family of `*WithClient` helpers was added across `modules/gcp`
130+
(compute, oslogin, region, pubsub, storage, cloudbuild, gcr) so tests
131+
can inject a pre-built SDK client. This parallels the Azure
132+
`*WithClient` change and is purely additive.
145133

146134
### Kubernetes
147135

148-
`GetKubernetesClientFromOptionsContextE` no longer falls back silently to
149-
`rest.InClusterConfig()` when an explicit kubeconfig path or context
150-
fails to load. It now returns the underlying `LoadAPIClientConfigE`
151-
error.
136+
`GetKubernetesClientFromOptionsContextE` no longer falls back silently
137+
to `rest.InClusterConfig()` when an explicit kubeconfig path or
138+
context fails to load. It now returns the load error.
152139

153-
This was a silent-failure footgun: a typo in `KubectlOptions.ConfigPath`
154-
would cause tests to run against the test runner's in-cluster identity
155-
(potentially a different cluster) with no error. If you relied on that
156-
fallback, set `KubectlOptions.InClusterAuth = true` to opt in
157-
explicitly.
140+
This was a silent-failure footgun: a typo in
141+
`KubectlOptions.ConfigPath` would cause tests to run against the test
142+
runner's in-cluster identity (potentially a different cluster) with no
143+
error returned. If you relied on the fallback, set
144+
`KubectlOptions.InClusterAuth = true` to opt in explicitly.
158145

159146
## Other deprecations you can defer
160147

161-
A handful of smaller renames also landed with `// Deprecated:` aliases:
162-
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`).
173-
174-
These are pure renames: the old names forward to the new ones and stay
175-
in the v1 line.
148+
A large set of legacy spellings picked up Go-idiomatic replacements in
149+
v1, all preserved as deprecated aliases. Most follow common acronym
150+
casing (`Id``ID`, `Ip``IP`, `Json``JSON`, `Url``URL`,
151+
`Ssh``SSH`, `Gcp``GCP`); a few drop redundant prefixes (Azure's
152+
`CreateNew*Client*` becomes `Create*Client*`); and a few rename for
153+
clarity (e.g. `SaveAmiId` / `LoadAmiId` became
154+
`SaveArtifactID` / `LoadArtifactID` to reflect that the helpers are
155+
not AMI-specific).
156+
157+
You do not need to track these one by one. Run `go vet` or
158+
`staticcheck` against your test module after upgrading; the deprecated
159+
aliases all carry `// Deprecated:` annotations and the linter will
160+
list them with the replacement to use. Aliases stay for the v1 line
161+
and are removed in v2.
176162

177163
## Need help
178164

0 commit comments

Comments
 (0)