Skip to content

Commit 8c24dda

Browse files
authored
Merge branch 'main' into james/oss-3364-bump-gcp-sdk
2 parents db444ef + 2bb4a8b commit 8c24dda

16 files changed

Lines changed: 460 additions & 2 deletions

File tree

modules/aws/account.go

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

62+
// Deprecated: Use [GetAccountID] instead.
63+
//
64+
//nolint:staticcheck,revive // preserving deprecated function name
65+
func GetAccountId(t testing.TestingT) string {
66+
return GetAccountID(t)
67+
}
68+
69+
// Deprecated: Use [GetAccountIDE] instead.
70+
//
71+
//nolint:staticcheck,revive // preserving deprecated function name
72+
func GetAccountIdE(t testing.TestingT) (string, error) {
73+
return GetAccountIDE(t)
74+
}
75+
6276
// ExtractAccountIDFromARN extracts the AWS account ID from an IAM ARN.
6377
// An IAM ARN is of the format arn:aws:iam::123456789012:user/test. The account ID is the number after arn:aws:iam::,
6478
// so we split on a colon and return the 5th item.

modules/aws/ami.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@ const (
2222
CentOsAccountID = "679593333241"
2323
// AmazonAccountID is the AWS account ID (or alias) for Amazon.
2424
AmazonAccountID = "amazon"
25+
26+
// Deprecated: Use [CanonicalAccountID] instead.
27+
CanonicalAccountId = CanonicalAccountID //nolint:staticcheck,revive // preserving deprecated constant name
28+
// Deprecated: Use [CentOsAccountID] instead.
29+
CentOsAccountId = CentOsAccountID //nolint:staticcheck,revive // preserving deprecated constant name
30+
// Deprecated: Use [AmazonAccountID] instead.
31+
AmazonAccountId = AmazonAccountID //nolint:staticcheck,revive // preserving deprecated constant name
2532
)
2633

2734
// DeleteAmiAndAllSnapshotsContextE will delete the given AMI along with all EBS snapshots that backed that AMI.
@@ -202,6 +209,20 @@ func GetMostRecentAmiIDE(t testing.TestingT, region string, ownerID string, filt
202209
return GetMostRecentAmiIDContextE(t, context.Background(), region, ownerID, filters)
203210
}
204211

212+
// Deprecated: Use [GetMostRecentAmiID] instead.
213+
//
214+
//nolint:staticcheck,revive // preserving deprecated function name
215+
func GetMostRecentAmiId(t testing.TestingT, region string, ownerId string, filters map[string][]string) string {
216+
return GetMostRecentAmiID(t, region, ownerId, filters)
217+
}
218+
219+
// Deprecated: Use [GetMostRecentAmiIDE] instead.
220+
//
221+
//nolint:staticcheck,revive // preserving deprecated function name
222+
func GetMostRecentAmiIdE(t testing.TestingT, region string, ownerId string, filters map[string][]string) (string, error) {
223+
return GetMostRecentAmiIDE(t, region, ownerId, filters)
224+
}
225+
205226
// Image sorting code borrowed from: https://github.com/hashicorp/packer/blob/7f4112ba229309cfc0ebaa10ded2abdfaf1b22c8/builder/amazon/common/step_source_ami_info.go
206227
type imageSort []types.Image
207228

modules/aws/ec2.go

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,24 @@ func GetPrivateIPOfEc2InstanceE(t testing.TestingT, instanceID string, awsRegion
5656
return GetPrivateIPOfEc2InstanceContextE(t, context.Background(), instanceID, awsRegion)
5757
}
5858

59+
// GetPrivateIpOfEc2Instance gets the private IP address of the given EC2 Instance in the given region.
60+
//
61+
// Deprecated: Use [GetPrivateIPOfEc2Instance] instead.
62+
//
63+
//nolint:staticcheck,revive // preserving deprecated function name
64+
func GetPrivateIpOfEc2Instance(t testing.TestingT, instanceID string, awsRegion string) string {
65+
return GetPrivateIPOfEc2Instance(t, instanceID, awsRegion)
66+
}
67+
68+
// GetPrivateIpOfEc2InstanceE gets the private IP address of the given EC2 Instance in the given region.
69+
//
70+
// Deprecated: Use [GetPrivateIPOfEc2InstanceE] instead.
71+
//
72+
//nolint:staticcheck,revive // preserving deprecated function name
73+
func GetPrivateIpOfEc2InstanceE(t testing.TestingT, instanceID string, awsRegion string) (string, error) {
74+
return GetPrivateIPOfEc2InstanceE(t, instanceID, awsRegion)
75+
}
76+
5977
// GetPrivateIpsOfEc2InstancesContextE gets the private IP address of the given EC2 Instance in the given region. Returns a map of instance ID to IP address.
6078
// The ctx parameter supports cancellation and timeouts.
6179
func GetPrivateIpsOfEc2InstancesContextE(t testing.TestingT, ctx context.Context, instanceIDs []string, awsRegion string) (map[string]string, error) {
@@ -212,6 +230,24 @@ func GetPublicIPOfEc2InstanceE(t testing.TestingT, instanceID string, awsRegion
212230
return GetPublicIPOfEc2InstanceContextE(t, context.Background(), instanceID, awsRegion)
213231
}
214232

233+
// GetPublicIpOfEc2Instance gets the public IP address of the given EC2 Instance in the given region.
234+
//
235+
// Deprecated: Use [GetPublicIPOfEc2Instance] instead.
236+
//
237+
//nolint:staticcheck,revive // preserving deprecated function name
238+
func GetPublicIpOfEc2Instance(t testing.TestingT, instanceID string, awsRegion string) string {
239+
return GetPublicIPOfEc2Instance(t, instanceID, awsRegion)
240+
}
241+
242+
// GetPublicIpOfEc2InstanceE gets the public IP address of the given EC2 Instance in the given region.
243+
//
244+
// Deprecated: Use [GetPublicIPOfEc2InstanceE] instead.
245+
//
246+
//nolint:staticcheck,revive // preserving deprecated function name
247+
func GetPublicIpOfEc2InstanceE(t testing.TestingT, instanceID string, awsRegion string) (string, error) {
248+
return GetPublicIPOfEc2InstanceE(t, instanceID, awsRegion)
249+
}
250+
215251
// GetPublicIpsOfEc2InstancesContextE gets the public IP address of the given EC2 Instance in the given region. Returns a map of instance ID to IP address.
216252
// The ctx parameter supports cancellation and timeouts.
217253
func GetPublicIpsOfEc2InstancesContextE(t testing.TestingT, ctx context.Context, instanceIDs []string, awsRegion string) (map[string]string, error) {

modules/aws/vpc.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,20 @@ func GetVpcByIDE(t testing.TestingT, vpcID string, region string) (*Vpc, error)
128128
return GetVpcByIDContextE(t, context.Background(), vpcID, region)
129129
}
130130

131+
// GetVpcById fetches information about a VPC with given ID in the given region.
132+
//
133+
// Deprecated: Use [GetVpcByID] instead.
134+
func GetVpcById(t testing.TestingT, vpcID string, region string) *Vpc { //nolint:staticcheck,revive // preserving deprecated function name
135+
return GetVpcByID(t, vpcID, region)
136+
}
137+
138+
// GetVpcByIdE fetches information about a VPC with given ID in the given region.
139+
//
140+
// Deprecated: Use [GetVpcByIDE] instead.
141+
func GetVpcByIdE(t testing.TestingT, vpcID string, region string) (*Vpc, error) { //nolint:staticcheck,revive // preserving deprecated function name
142+
return GetVpcByIDE(t, vpcID, region)
143+
}
144+
131145
// GetVpcsContextE fetches information about VPCs from given regions limited by filters
132146
// The ctx parameter supports cancellation and timeouts.
133147
func GetVpcsContextE(t testing.TestingT, ctx context.Context, filters []types.Filter, region string) ([]*Vpc, error) {

modules/gcp/compute.go

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,12 @@ type InstanceGroup interface {
5656
// GetInstanceIDsContextE gets the IDs of Instances in the given Instance Group.
5757
// The ctx parameter supports cancellation and timeouts.
5858
GetInstanceIDsContextE(t testing.TestingT, ctx context.Context) ([]string, error)
59+
60+
// Deprecated: Use [InstanceGroup.GetInstanceIDs] instead.
61+
GetInstanceIds(t testing.TestingT) []string //nolint:staticcheck,revive // preserving deprecated method name
62+
63+
// Deprecated: Use [InstanceGroup.GetInstanceIDsE] instead.
64+
GetInstanceIdsE(t testing.TestingT) ([]string, error) //nolint:staticcheck,revive // preserving deprecated method name
5965
}
6066

6167
// FetchInstance queries GCP to return an instance of the Compute Instance type.
@@ -297,6 +303,21 @@ func (i *Instance) GetPublicIPE(t testing.TestingT) (string, error) {
297303
return i.GetPublicIPContextE(t, context.Background())
298304
}
299305

306+
// GetPublicIp gets the public IP address of the given Compute Instance.
307+
// This will fail the test if there is an error.
308+
//
309+
// Deprecated: Use [Instance.GetPublicIP] instead.
310+
func (i *Instance) GetPublicIp(t testing.TestingT) string { //nolint:staticcheck,revive // preserving deprecated method name
311+
return i.GetPublicIP(t)
312+
}
313+
314+
// GetPublicIpE gets the public IP address of the given Compute Instance.
315+
//
316+
// Deprecated: Use [Instance.GetPublicIPE] instead.
317+
func (i *Instance) GetPublicIpE(t testing.TestingT) (string, error) { //nolint:staticcheck,revive // preserving deprecated method name
318+
return i.GetPublicIPE(t)
319+
}
320+
300321
// GetPublicIPContextE gets the public IP address of the given Compute Instance.
301322
// The ctx parameter supports cancellation and timeouts.
302323
// Returns an error (rather than panicking) when the instance has no network interfaces
@@ -555,6 +576,21 @@ func (i *Instance) AddSSHKeyE(t testing.TestingT, username string, publicKey str
555576
return i.AddSSHKeyContextE(t, context.Background(), username, publicKey)
556577
}
557578

579+
// AddSshKey adds the given public SSH key to the Compute Instance. Users can SSH in with the given username.
580+
// This will fail the test if there is an error.
581+
//
582+
// Deprecated: Use [Instance.AddSSHKey] instead.
583+
func (i *Instance) AddSshKey(t testing.TestingT, username string, publicKey string) { //nolint:staticcheck,revive // preserving deprecated method name
584+
i.AddSSHKey(t, username, publicKey)
585+
}
586+
587+
// AddSshKeyE adds the given public SSH key to the Compute Instance. Users can SSH in with the given username.
588+
//
589+
// Deprecated: Use [Instance.AddSSHKeyE] instead.
590+
func (i *Instance) AddSshKeyE(t testing.TestingT, username string, publicKey string) error { //nolint:staticcheck,revive // preserving deprecated method name
591+
return i.AddSSHKeyE(t, username, publicKey)
592+
}
593+
558594
// AddSSHKeyContextE adds the given public SSH key to the Compute Instance. Users can SSH in with the given username.
559595
// The ctx parameter supports cancellation and timeouts.
560596
func (i *Instance) AddSSHKeyContextE(t testing.TestingT, ctx context.Context, username string, publicKey string) error {
@@ -661,6 +697,21 @@ func (ig *ZonalInstanceGroup) GetInstanceIDsE(t testing.TestingT) ([]string, err
661697
return ig.GetInstanceIDsContextE(t, context.Background())
662698
}
663699

700+
// GetInstanceIds gets the IDs of Instances in the given Zonal Instance Group.
701+
// This will fail the test if there is an error.
702+
//
703+
// Deprecated: Use [ZonalInstanceGroup.GetInstanceIDs] instead.
704+
func (ig *ZonalInstanceGroup) GetInstanceIds(t testing.TestingT) []string { //nolint:staticcheck,revive // preserving deprecated method name
705+
return ig.GetInstanceIDs(t)
706+
}
707+
708+
// GetInstanceIdsE gets the IDs of Instances in the given Zonal Instance Group.
709+
//
710+
// Deprecated: Use [ZonalInstanceGroup.GetInstanceIDsE] instead.
711+
func (ig *ZonalInstanceGroup) GetInstanceIdsE(t testing.TestingT) ([]string, error) { //nolint:staticcheck,revive // preserving deprecated method name
712+
return ig.GetInstanceIDsE(t)
713+
}
714+
664715
// GetInstanceIDsContextE gets the IDs of Instances in the given Zonal Instance Group.
665716
// The ctx parameter supports cancellation and timeouts.
666717
func (ig *ZonalInstanceGroup) GetInstanceIDsContextE(t testing.TestingT, ctx context.Context) ([]string, error) {
@@ -730,6 +781,21 @@ func (ig *RegionalInstanceGroup) GetInstanceIDsE(t testing.TestingT) ([]string,
730781
return ig.GetInstanceIDsContextE(t, context.Background())
731782
}
732783

784+
// GetInstanceIds gets the IDs of Instances in the given Regional Instance Group.
785+
// This will fail the test if there is an error.
786+
//
787+
// Deprecated: Use [RegionalInstanceGroup.GetInstanceIDs] instead.
788+
func (ig *RegionalInstanceGroup) GetInstanceIds(t testing.TestingT) []string { //nolint:staticcheck,revive // preserving deprecated method name
789+
return ig.GetInstanceIDs(t)
790+
}
791+
792+
// GetInstanceIdsE gets the IDs of Instances in the given Regional Instance Group.
793+
//
794+
// Deprecated: Use [RegionalInstanceGroup.GetInstanceIDsE] instead.
795+
func (ig *RegionalInstanceGroup) GetInstanceIdsE(t testing.TestingT) ([]string, error) { //nolint:staticcheck,revive // preserving deprecated method name
796+
return ig.GetInstanceIDsE(t)
797+
}
798+
733799
// GetInstanceIDsContextE gets the IDs of Instances in the given Regional Instance Group.
734800
// The ctx parameter supports cancellation and timeouts.
735801
func (ig *RegionalInstanceGroup) GetInstanceIDsContextE(t testing.TestingT, ctx context.Context) ([]string, error) {
@@ -882,6 +948,21 @@ func (ig *ZonalInstanceGroup) GetPublicIPsE(t testing.TestingT, projectID string
882948
return ig.GetPublicIPsContextE(t, context.Background(), projectID)
883949
}
884950

951+
// GetPublicIps returns a slice of the public IPs from the given Zonal Instance Group.
952+
// This will fail the test if there is an error.
953+
//
954+
// Deprecated: Use [ZonalInstanceGroup.GetPublicIPs] instead.
955+
func (ig *ZonalInstanceGroup) GetPublicIps(t testing.TestingT, projectID string) []string { //nolint:staticcheck,revive // preserving deprecated method name
956+
return ig.GetPublicIPs(t, projectID)
957+
}
958+
959+
// GetPublicIpsE returns a slice of the public IPs from the given Zonal Instance Group.
960+
//
961+
// Deprecated: Use [ZonalInstanceGroup.GetPublicIPsE] instead.
962+
func (ig *ZonalInstanceGroup) GetPublicIpsE(t testing.TestingT, projectID string) ([]string, error) { //nolint:staticcheck,revive // preserving deprecated method name
963+
return ig.GetPublicIPsE(t, projectID)
964+
}
965+
885966
// GetPublicIPsContextE returns a slice of the public IPs from the given Zonal Instance Group.
886967
// The ctx parameter supports cancellation and timeouts.
887968
func (ig *ZonalInstanceGroup) GetPublicIPsContextE(t testing.TestingT, ctx context.Context, projectID string) ([]string, error) {
@@ -913,6 +994,21 @@ func (ig *RegionalInstanceGroup) GetPublicIPsE(t testing.TestingT, projectID str
913994
return ig.GetPublicIPsContextE(t, context.Background(), projectID)
914995
}
915996

997+
// GetPublicIps returns a slice of the public IPs from the given Regional Instance Group.
998+
// This will fail the test if there is an error.
999+
//
1000+
// Deprecated: Use [RegionalInstanceGroup.GetPublicIPs] instead.
1001+
func (ig *RegionalInstanceGroup) GetPublicIps(t testing.TestingT, projectID string) []string { //nolint:staticcheck,revive // preserving deprecated method name
1002+
return ig.GetPublicIPs(t, projectID)
1003+
}
1004+
1005+
// GetPublicIpsE returns a slice of the public IPs from the given Regional Instance Group.
1006+
//
1007+
// Deprecated: Use [RegionalInstanceGroup.GetPublicIPsE] instead.
1008+
func (ig *RegionalInstanceGroup) GetPublicIpsE(t testing.TestingT, projectID string) ([]string, error) { //nolint:staticcheck,revive // preserving deprecated method name
1009+
return ig.GetPublicIPsE(t, projectID)
1010+
}
1011+
9161012
// GetPublicIPsContextE returns a slice of the public IPs from the given Regional Instance Group.
9171013
// The ctx parameter supports cancellation and timeouts.
9181014
func (ig *RegionalInstanceGroup) GetPublicIPsContextE(t testing.TestingT, ctx context.Context, projectID string) ([]string, error) {
@@ -1131,3 +1227,10 @@ func RandomValidGCPName() string {
11311227

11321228
return "terratest-" + id
11331229
}
1230+
1231+
// RandomValidGcpName returns a random, valid name for GCP resources. Many resources in GCP require lowercase letters only.
1232+
//
1233+
// Deprecated: Use [RandomValidGCPName] instead.
1234+
func RandomValidGcpName() string { //nolint:staticcheck,revive // preserving deprecated function name
1235+
return RandomValidGCPName()
1236+
}

modules/gcp/region.go

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,38 @@ func GetAllGCPRegionsE(t testing.TestingT, projectID string) ([]string, error) {
233233
return GetAllGCPRegionsContextE(t, context.Background(), projectID)
234234
}
235235

236+
// GetAllGcpRegions gets the list of GCP regions available in this account.
237+
// This will fail the test if there is an error.
238+
//
239+
// Deprecated: Use [GetAllGCPRegionsContext] instead.
240+
func GetAllGcpRegions(t testing.TestingT, projectID string) []string { //nolint:staticcheck,revive // preserving deprecated function name
241+
return GetAllGCPRegionsContext(t, context.Background(), projectID)
242+
}
243+
244+
// GetAllGcpRegionsContext gets the list of GCP regions available in this account.
245+
// This will fail the test if there is an error.
246+
// The ctx parameter supports cancellation and timeouts.
247+
//
248+
// Deprecated: Use [GetAllGCPRegionsContext] instead.
249+
func GetAllGcpRegionsContext(t testing.TestingT, ctx context.Context, projectID string) []string { //nolint:staticcheck,revive // preserving deprecated function name
250+
return GetAllGCPRegionsContext(t, ctx, projectID)
251+
}
252+
253+
// GetAllGcpRegionsE gets the list of GCP regions available in this account.
254+
//
255+
// Deprecated: Use [GetAllGCPRegionsContextE] instead.
256+
func GetAllGcpRegionsE(t testing.TestingT, projectID string) ([]string, error) { //nolint:staticcheck,revive // preserving deprecated function name
257+
return GetAllGCPRegionsContextE(t, context.Background(), projectID)
258+
}
259+
260+
// GetAllGcpRegionsContextE gets the list of GCP regions available in this account.
261+
// The ctx parameter supports cancellation and timeouts.
262+
//
263+
// Deprecated: Use [GetAllGCPRegionsContextE] instead.
264+
func GetAllGcpRegionsContextE(t testing.TestingT, ctx context.Context, projectID string) ([]string, error) { //nolint:staticcheck,revive // preserving deprecated function name
265+
return GetAllGCPRegionsContextE(t, ctx, projectID)
266+
}
267+
236268
// GetAllGCPRegionsContextE gets the list of GCP regions available in this account.
237269
// The ctx parameter supports cancellation and timeouts.
238270
func GetAllGCPRegionsContextE(t testing.TestingT, ctx context.Context, projectID string) ([]string, error) {
@@ -293,6 +325,38 @@ func GetAllGCPZonesE(t testing.TestingT, projectID string) ([]string, error) {
293325
return GetAllGCPZonesContextE(t, context.Background(), projectID)
294326
}
295327

328+
// GetAllGcpZones gets the list of GCP Zones available in this account.
329+
// This will fail the test if there is an error.
330+
//
331+
// Deprecated: Use [GetAllGCPZonesContext] instead.
332+
func GetAllGcpZones(t testing.TestingT, projectID string) []string { //nolint:staticcheck,revive // preserving deprecated function name
333+
return GetAllGCPZonesContext(t, context.Background(), projectID)
334+
}
335+
336+
// GetAllGcpZonesContext gets the list of GCP Zones available in this account.
337+
// This will fail the test if there is an error.
338+
// The ctx parameter supports cancellation and timeouts.
339+
//
340+
// Deprecated: Use [GetAllGCPZonesContext] instead.
341+
func GetAllGcpZonesContext(t testing.TestingT, ctx context.Context, projectID string) []string { //nolint:staticcheck,revive // preserving deprecated function name
342+
return GetAllGCPZonesContext(t, ctx, projectID)
343+
}
344+
345+
// GetAllGcpZonesE gets the list of GCP Zones available in this account.
346+
//
347+
// Deprecated: Use [GetAllGCPZonesContextE] instead.
348+
func GetAllGcpZonesE(t testing.TestingT, projectID string) ([]string, error) { //nolint:staticcheck,revive // preserving deprecated function name
349+
return GetAllGCPZonesContextE(t, context.Background(), projectID)
350+
}
351+
352+
// GetAllGcpZonesContextE gets the list of GCP Zones available in this account.
353+
// The ctx parameter supports cancellation and timeouts.
354+
//
355+
// Deprecated: Use [GetAllGCPZonesContextE] instead.
356+
func GetAllGcpZonesContextE(t testing.TestingT, ctx context.Context, projectID string) ([]string, error) { //nolint:staticcheck,revive // preserving deprecated function name
357+
return GetAllGCPZonesContextE(t, ctx, projectID)
358+
}
359+
296360
// GetAllGCPZonesContextE gets the list of GCP Zones available in this account.
297361
// The ctx parameter supports cancellation and timeouts.
298362
func GetAllGCPZonesContextE(t testing.TestingT, ctx context.Context, projectID string) ([]string, error) {
@@ -334,6 +398,13 @@ func ZoneURLToZone(zoneURL string) string {
334398
return tokens[len(tokens)-1]
335399
}
336400

401+
// ZoneUrlToZone extracts the zone name from a GCP Zone URL.
402+
//
403+
// Deprecated: Use [ZoneURLToZone] instead.
404+
func ZoneUrlToZone(zoneURL string) string { //nolint:staticcheck,revive // preserving deprecated function name
405+
return ZoneURLToZone(zoneURL)
406+
}
407+
337408
// RegionURLToRegion extracts the region name from a GCP Region URL formatted like
338409
// https://www.googleapis.com/compute/v1/projects/project-123456/regions/southamerica-east1 and returns
339410
// "southamerica-east1".
@@ -343,6 +414,13 @@ func RegionURLToRegion(regionURL string) string {
343414
return tokens[len(tokens)-1]
344415
}
345416

417+
// RegionUrlToRegion extracts the region name from a GCP Region URL.
418+
//
419+
// Deprecated: Use [RegionURLToRegion] instead.
420+
func RegionUrlToRegion(regionURL string) string { //nolint:staticcheck,revive // preserving deprecated function name
421+
return RegionURLToRegion(regionURL)
422+
}
423+
346424
// isInRegions returns true if the given zone is in any of the given regions.
347425
func isInRegions(zone string, regions []string) bool {
348426
for _, region := range regions {

0 commit comments

Comments
 (0)