Skip to content

Commit 8996afb

Browse files
authored
Merge branch 'main' into james/oss-3397-ssh-file-handle-leaks
2 parents 337d691 + bcbe891 commit 8996afb

18 files changed

Lines changed: 183 additions & 11 deletions

README.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,23 @@ variety of helper functions and patterns for common infrastructure testing tasks
2222
- Running shell commands
2323
- And much more
2424

25-
Please see the following for more info:
25+
## Install
26+
27+
```bash
28+
go get github.com/gruntwork-io/terratest@latest
29+
```
30+
31+
Requires Go 1.26 or later.
32+
33+
## Stability and versioning
34+
35+
Starting with v1.0.0, Terratest follows [semantic versioning](https://semver.org/). Breaking changes to the public API
36+
only happen in major releases (e.g. v2.0.0).
37+
38+
Symbols renamed or replaced in v1 are kept with `// Deprecated:` annotations pointing at the new name; removals happen
39+
in v2. Migrating from v0.x: see [`MIGRATION.md`](./MIGRATION.md).
40+
41+
## More info
2642

2743
- [Terratest Website](https://terratest.gruntwork.io)
2844
- [Getting started with Terratest](https://terratest.gruntwork.io/docs/getting-started/quick-start/)

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ require (
9999
github.com/lib/pq v1.10.9
100100
github.com/microsoft/go-mssqldb v1.9.8
101101
github.com/slack-go/slack v0.15.0
102+
golang.org/x/sync v0.20.0
102103
google.golang.org/grpc v1.80.0
103104
gopkg.in/yaml.v3 v3.0.1
104105
gotest.tools/v3 v3.5.2
@@ -223,7 +224,6 @@ require (
223224
go.yaml.in/yaml/v2 v2.4.3 // indirect
224225
go.yaml.in/yaml/v3 v3.0.4 // indirect
225226
golang.org/x/mod v0.33.0 // indirect
226-
golang.org/x/sync v0.20.0 // indirect
227227
golang.org/x/sys v0.42.0 // indirect
228228
golang.org/x/term v0.41.0 // indirect
229229
golang.org/x/text v0.35.0 // indirect

modules/aws/account.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,17 @@ func GetAccountIDE(t testing.TestingT) (string, error) {
5959
return GetAccountIDContextE(t, context.Background())
6060
}
6161

62+
// GetAccountId gets the Account ID for the currently logged in IAM User.
63+
//
6264
// Deprecated: Use [GetAccountID] instead.
6365
//
6466
//nolint:staticcheck,revive // preserving deprecated function name
6567
func GetAccountId(t testing.TestingT) string {
6668
return GetAccountID(t)
6769
}
6870

71+
// GetAccountIdE gets the Account ID for the currently logged in IAM User.
72+
//
6973
// Deprecated: Use [GetAccountIDE] instead.
7074
//
7175
//nolint:staticcheck,revive // preserving deprecated function name

modules/aws/ami.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,13 +209,19 @@ func GetMostRecentAmiIDE(t testing.TestingT, region string, ownerID string, filt
209209
return GetMostRecentAmiIDContextE(t, context.Background(), region, ownerID, filters)
210210
}
211211

212+
// GetMostRecentAmiId gets the ID of the most recent AMI in the given region that has the given owner and matches
213+
// the given filters.
214+
//
212215
// Deprecated: Use [GetMostRecentAmiID] instead.
213216
//
214217
//nolint:staticcheck,revive // preserving deprecated function name
215218
func GetMostRecentAmiId(t testing.TestingT, region string, ownerId string, filters map[string][]string) string {
216219
return GetMostRecentAmiID(t, region, ownerId, filters)
217220
}
218221

222+
// GetMostRecentAmiIdE gets the ID of the most recent AMI in the given region that has the given owner and matches
223+
// the given filters.
224+
//
219225
// Deprecated: Use [GetMostRecentAmiIDE] instead.
220226
//
221227
//nolint:staticcheck,revive // preserving deprecated function name

modules/aws/auth.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ import (
1717
)
1818

1919
const (
20-
AuthAssumeRoleEnvVar = "TERRATEST_IAM_ROLE" // OS environment variable name through which Assume Role ARN may be passed for authentication
20+
// AuthAssumeRoleEnvVar is the OS environment variable name through which an
21+
// Assume Role ARN may be passed for authentication.
22+
AuthAssumeRoleEnvVar = "TERRATEST_IAM_ROLE"
2123
)
2224

2325
// NewAuthenticatedSessionContext creates an AWS Config following to standard AWS authentication workflow.

modules/aws/dynamodb.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ func GetDynamoDBTableTagsE(t testing.TestingT, region string, tableName string)
7474
return GetDynamoDBTableTagsContextE(t, context.Background(), region, tableName)
7575
}
7676

77+
// GetDynamoDbTableTags fetches resource tags of a specified dynamoDB table. This will fail the test if there are any errors.
78+
//
7779
// Deprecated: Use [GetDynamoDBTableTagsContext] instead.
7880
//
7981
//nolint:staticcheck,revive // preserving deprecated function name
@@ -82,6 +84,8 @@ func GetDynamoDbTableTags(t testing.TestingT, region string, tableName string) [
8284
return GetDynamoDBTableTagsContext(t, context.Background(), region, tableName)
8385
}
8486

87+
// GetDynamoDbTableTagsE fetches resource tags of a specified dynamoDB table.
88+
//
8589
// Deprecated: Use [GetDynamoDBTableTagsContextE] instead.
8690
//
8791
//nolint:staticcheck,revive // preserving deprecated function name

modules/aws/ec2-files.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,10 @@ func FetchFilesFromAsgsPE(t testing.TestingT, awsRegion string, spec *RemoteFile
394394
return FetchFilesFromAsgsPContextE(t, context.Background(), awsRegion, spec)
395395
}
396396

397+
// FetchFilesFromAsgs looks up the EC2 Instances in all the ASGs given in the
398+
// RemoteFileSpecification, downloads the matching files from each instance,
399+
// and stores them locally as described in [FetchFilesFromAsgsPContext].
400+
//
397401
// Deprecated: Use [FetchFilesFromAsgsPContext] instead.
398402
//
399403
//nolint:staticcheck,revive,gocritic // preserving deprecated function name
@@ -403,6 +407,8 @@ func FetchFilesFromAsgs(t testing.TestingT, awsRegion string, spec RemoteFileSpe
403407
FetchFilesFromAsgsPContext(t, context.Background(), awsRegion, &spec)
404408
}
405409

410+
// FetchFilesFromAsgsE is the error-returning equivalent of [FetchFilesFromAsgs].
411+
//
406412
// Deprecated: Use [FetchFilesFromAsgsPContextE] instead.
407413
//
408414
//nolint:staticcheck,revive,gocritic // preserving deprecated function name

modules/aws/errors.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import (
55
)
66

77
// IpForEc2InstanceNotFound is an error that occurs when the IP for an EC2 instance is not found.
8+
//
9+
// Deprecated: Use [IPForEc2InstanceNotFound] instead.
810
type IpForEc2InstanceNotFound struct { //nolint:staticcheck,revive // preserving deprecated type name
911
InstanceId string //nolint:staticcheck,revive // preserving existing field name
1012
AwsRegion string
@@ -40,6 +42,7 @@ func (err NotFoundError) Error() string {
4042
return fmt.Sprintf("Object of type %s with id %s not found in region %s", err.objectType, err.objectID, err.region)
4143
}
4244

45+
// NewNotFoundError returns a [NotFoundError] for the given object type, ID, and region.
4346
func NewNotFoundError(objectType string, objectID string, region string) NotFoundError {
4447
return NotFoundError{objectType, objectID, region}
4548
}
@@ -60,6 +63,8 @@ func (err AsgCapacityNotMetError) Error() string {
6063
)
6164
}
6265

66+
// NewAsgCapacityNotMetError returns an [AsgCapacityNotMetError] describing
67+
// the given ASG's desired and current capacities.
6368
func NewAsgCapacityNotMetError(asgName string, desiredCapacity int64, currentCapacity int64) AsgCapacityNotMetError {
6469
return AsgCapacityNotMetError{asgName, desiredCapacity, currentCapacity}
6570
}
@@ -80,6 +85,8 @@ func (err BucketVersioningNotEnabledError) Error() string {
8085
)
8186
}
8287

88+
// NewBucketVersioningNotEnabledError returns a [BucketVersioningNotEnabledError]
89+
// for the given S3 bucket, region, and observed versioning status.
8390
func NewBucketVersioningNotEnabledError(s3BucketName string, awsRegion string, versioningStatus string) BucketVersioningNotEnabledError {
8491
return BucketVersioningNotEnabledError{s3BucketName: s3BucketName, awsRegion: awsRegion, versioningStatus: versioningStatus}
8592
}
@@ -99,6 +106,8 @@ func (err NoBucketPolicyError) Error() string {
99106
)
100107
}
101108

109+
// NewNoBucketPolicyError returns a [NoBucketPolicyError] for the given S3
110+
// bucket, region, and bucket policy.
102111
func NewNoBucketPolicyError(s3BucketName string, awsRegion string, bucketPolicy string) NoBucketPolicyError {
103112
return NoBucketPolicyError{s3BucketName: s3BucketName, awsRegion: awsRegion, bucketPolicy: bucketPolicy}
104113
}

modules/aws/lambda.go

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,24 @@ import (
1212
"github.com/stretchr/testify/require"
1313
)
1414

15+
// InvocationTypeOption identifies the invocation mode passed to AWS Lambda
16+
// when calling [InvokeFunctionWithParamsContextE]. See the
17+
// InvocationType-prefixed constants for the supported values.
1518
type InvocationTypeOption string
1619

20+
// Supported [InvocationTypeOption] values for Lambda invocation modes.
1721
const (
22+
// InvocationTypeRequestResponse invokes the function synchronously, keeping
23+
// the connection open until the function returns a response or times out.
1824
InvocationTypeRequestResponse InvocationTypeOption = "RequestResponse"
19-
InvocationTypeDryRun InvocationTypeOption = "DryRun"
25+
// InvocationTypeDryRun validates parameter values and verifies that the user
26+
// or role has permission to invoke the function, without actually invoking it.
27+
InvocationTypeDryRun InvocationTypeOption = "DryRun"
2028
)
2129

30+
// Value returns the string form of the [InvocationTypeOption], defaulting to
31+
// [InvocationTypeRequestResponse] when itype is nil. It returns an error if
32+
// itype is set to a value that is not one of the supported invocation types.
2233
func (itype *InvocationTypeOption) Value() (string, error) {
2334
if itype != nil {
2435
switch *itype {
@@ -212,6 +223,9 @@ func InvokeFunctionWithParamsE(t testing.TestingT, region, functionName string,
212223
return InvokeFunctionWithParamsContextE(t, context.Background(), region, functionName, input)
213224
}
214225

226+
// FunctionError is returned when an AWS Lambda invocation reports a function
227+
// error in its response. It carries the error message, the HTTP status code,
228+
// and the raw payload returned by the function.
215229
type FunctionError struct {
216230
Message string
217231
Payload []byte

modules/aws/rds.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -698,6 +698,8 @@ func GetValidEngineVersionE(t testing.TestingT, region string, engine string, ma
698698

699699
// ParameterForDbInstanceNotFound is an error that occurs when the parameter group specified is not found for the DB instance.
700700
//
701+
// Deprecated: Use [ParameterForDBInstanceNotFound] instead.
702+
//
701703
//nolint:staticcheck,revive // preserving existing type name
702704
type ParameterForDbInstanceNotFound struct {
703705
ParameterName string
@@ -714,6 +716,8 @@ func (err ParameterForDbInstanceNotFound) Error() string {
714716

715717
// OptionGroupOptionSettingForDbInstanceNotFound is an error that occurs when the option setting specified is not found in the option group of the DB instance.
716718
//
719+
// Deprecated: Use [OptionGroupOptionSettingForDBInstanceNotFound] instead.
720+
//
717721
//nolint:staticcheck,revive // preserving existing type name
718722
type OptionGroupOptionSettingForDbInstanceNotFound struct {
719723
OptionName string

0 commit comments

Comments
 (0)