Skip to content

Commit 6fd2ca3

Browse files
Merge pull request #1449 from seblaz/master
fix: replace the deprecated logger.Logf and logger.Log for the new Logger
2 parents cf38360 + bce67fe commit 6fd2ca3

Some content is hidden

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

48 files changed

+154
-167
lines changed

modules/aws/ami.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ func GetEbsSnapshotsForAmi(t testing.TestingT, region string, ami string) []stri
5959

6060
// GetEbsSnapshotsForAmi retrieves the EBS snapshots which back the given AMI
6161
func GetEbsSnapshotsForAmiE(t testing.TestingT, region string, ami string) ([]string, error) {
62-
logger.Logf(t, "Retrieving EBS snapshots backing AMI %s", ami)
62+
logger.Default.Logf(t, "Retrieving EBS snapshots backing AMI %s", ami)
6363
ec2Client, err := NewEc2ClientE(t, region)
6464
if err != nil {
6565
return nil, err

modules/aws/asg.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ func WaitForCapacityE(
120120
return fmt.Sprintf("ASG %s is now at desired capacity %d", asgName, capacityInfo.DesiredCapacity), nil
121121
},
122122
)
123-
logger.Log(t, msg)
123+
logger.Default.Logf(t, "%s", msg)
124124
return err
125125
}
126126

modules/aws/ebs.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ func DeleteEbsSnapshot(t testing.TestingT, region string, snapshot string) {
1717

1818
// DeleteEbsSnapshot deletes the given EBS snapshot
1919
func DeleteEbsSnapshotE(t testing.TestingT, region string, snapshot string) error {
20-
logger.Logf(t, "Deleting EBS snapshot %s", snapshot)
20+
logger.Default.Logf(t, "Deleting EBS snapshot %s", snapshot)
2121
ec2Client, err := NewEc2ClientE(t, region)
2222
if err != nil {
2323
return err

modules/aws/ec2-syslog.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ func GetSyslogForInstanceE(t testing.TestingT, instanceID string, region string)
3333
maxRetries := 120
3434
timeBetweenRetries := 5 * time.Second
3535

36-
logger.Log(t, description)
36+
logger.Default.Logf(t, "%s", description)
3737

3838
client, err := NewEc2ClientE(t, region)
3939
if err != nil {
@@ -89,7 +89,7 @@ func GetSyslogForInstancesInAsg(t testing.TestingT, asgName string, awsRegion st
8989
// minute after the Instance boots and are very useful for debugging boot-time issues, such as an error in User Data.
9090
// Returns a map of Instance Id -> Syslog for that Instance.
9191
func GetSyslogForInstancesInAsgE(t testing.TestingT, asgName string, awsRegion string) (map[string]string, error) {
92-
logger.Logf(t, "Fetching syslog for each Instance in ASG %s in %s", asgName, awsRegion)
92+
logger.Default.Logf(t, "Fetching syslog for each Instance in ASG %s in %s", asgName, awsRegion)
9393

9494
instanceIDs, err := GetEc2InstanceIdsByTagE(t, awsRegion, "aws:autoscaling:groupName", asgName)
9595
if err != nil {

modules/aws/ec2.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ func DeleteAmi(t testing.TestingT, region string, imageID string) {
268268

269269
// DeleteAmiE deletes the given AMI in the given region.
270270
func DeleteAmiE(t testing.TestingT, region string, imageID string) error {
271-
logger.Logf(t, "Deregistering AMI %s", imageID)
271+
logger.Default.Logf(t, "Deregistering AMI %s", imageID)
272272

273273
client, err := NewEc2ClientE(t, region)
274274
if err != nil {
@@ -314,7 +314,7 @@ func TerminateInstance(t testing.TestingT, region string, instanceID string) {
314314

315315
// TerminateInstanceE terminates the EC2 instance with the given ID in the given region.
316316
func TerminateInstanceE(t testing.TestingT, region string, instanceID string) error {
317-
logger.Logf(t, "Terminating Instance %s", instanceID)
317+
logger.Default.Logf(t, "Terminating Instance %s", instanceID)
318318

319319
client, err := NewEc2ClientE(t, region)
320320
if err != nil {

modules/aws/ecr.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ func PutECRRepoLifecyclePolicy(t testing.TestingT, region string, repo *ecr.Repo
126126

127127
// PutEcrRepoLifecyclePolicy puts the given policy for the given ECR repository.
128128
func PutECRRepoLifecyclePolicyE(t testing.TestingT, region string, repo *ecr.Repository, policy string) error {
129-
logger.Logf(t, "Applying policy for repository %s in %s", *repo.RepositoryName, region)
129+
logger.Default.Logf(t, "Applying policy for repository %s in %s", *repo.RepositoryName, region)
130130

131131
client, err := NewECRClientE(t, region)
132132
if err != nil {

modules/aws/iam.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ func CreateMfaDevice(t testing.TestingT, iamClient *iam.IAM, deviceName string)
6868

6969
// CreateMfaDeviceE creates an MFA device using the given IAM client.
7070
func CreateMfaDeviceE(t testing.TestingT, iamClient *iam.IAM, deviceName string) (*iam.VirtualMFADevice, error) {
71-
logger.Logf(t, "Creating an MFA device called %s", deviceName)
71+
logger.Default.Logf(t, "Creating an MFA device called %s", deviceName)
7272

7373
output, err := iamClient.CreateVirtualMFADevice(&iam.CreateVirtualMFADeviceInput{
7474
VirtualMFADeviceName: aws.String(deviceName),
@@ -96,7 +96,7 @@ func EnableMfaDevice(t testing.TestingT, iamClient *iam.IAM, mfaDevice *iam.Virt
9696
// EnableMfaDeviceE enables a newly created MFA Device by supplying the first two one-time passwords, so that it can be used for future
9797
// logins by the given IAM User.
9898
func EnableMfaDeviceE(t testing.TestingT, iamClient *iam.IAM, mfaDevice *iam.VirtualMFADevice) error {
99-
logger.Logf(t, "Enabling MFA device %s", aws.StringValue(mfaDevice.SerialNumber))
99+
logger.Default.Logf(t, "Enabling MFA device %s", aws.StringValue(mfaDevice.SerialNumber))
100100

101101
iamUserName, err := GetIamCurrentUserArnE(t)
102102
if err != nil {
@@ -108,7 +108,7 @@ func EnableMfaDeviceE(t testing.TestingT, iamClient *iam.IAM, mfaDevice *iam.Vir
108108
return err
109109
}
110110

111-
logger.Logf(t, "Waiting 30 seconds for a new MFA Token to be generated...")
111+
logger.Default.Logf(t, "Waiting 30 seconds for a new MFA Token to be generated...")
112112
time.Sleep(30 * time.Second)
113113

114114
authCode2, err := GetTimeBasedOneTimePassword(mfaDevice)
@@ -127,7 +127,7 @@ func EnableMfaDeviceE(t testing.TestingT, iamClient *iam.IAM, mfaDevice *iam.Vir
127127
return err
128128
}
129129

130-
logger.Log(t, "Waiting for MFA Device enablement to propagate.")
130+
logger.Default.Logf(t, "Waiting for MFA Device enablement to propagate.")
131131
time.Sleep(10 * time.Second)
132132

133133
return nil

modules/aws/keypair.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ func ImportEC2KeyPair(t testing.TestingT, region string, name string, keyPair *s
4545

4646
// ImportEC2KeyPairE creates a Key Pair in EC2 by importing an existing public key.
4747
func ImportEC2KeyPairE(t testing.TestingT, region string, name string, keyPair *ssh.KeyPair) (*Ec2Keypair, error) {
48-
logger.Logf(t, "Creating new Key Pair in EC2 region %s named %s", region, name)
48+
logger.Default.Logf(t, "Creating new Key Pair in EC2 region %s named %s", region, name)
4949

5050
client, err := NewEc2ClientE(t, region)
5151
if err != nil {
@@ -75,7 +75,7 @@ func DeleteEC2KeyPair(t testing.TestingT, keyPair *Ec2Keypair) {
7575

7676
// DeleteEC2KeyPairE deletes an EC2 key pair.
7777
func DeleteEC2KeyPairE(t testing.TestingT, keyPair *Ec2Keypair) error {
78-
logger.Logf(t, "Deleting Key Pair in EC2 region %s named %s", keyPair.Region, keyPair.Name)
78+
logger.Default.Logf(t, "Deleting Key Pair in EC2 region %s named %s", keyPair.Region, keyPair.Name)
7979

8080
client, err := NewEc2ClientE(t, keyPair.Region)
8181
if err != nil {

modules/aws/region.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ func GetRandomRegion(t testing.TestingT, approvedRegions []string, forbiddenRegi
7474
func GetRandomRegionE(t testing.TestingT, approvedRegions []string, forbiddenRegions []string) (string, error) {
7575
regionFromEnvVar := os.Getenv(regionOverrideEnvVarName)
7676
if regionFromEnvVar != "" {
77-
logger.Logf(t, "Using AWS region %s from environment variable %s", regionFromEnvVar, regionOverrideEnvVarName)
77+
logger.Default.Logf(t, "Using AWS region %s from environment variable %s", regionFromEnvVar, regionOverrideEnvVarName)
7878
return regionFromEnvVar, nil
7979
}
8080

@@ -91,7 +91,7 @@ func GetRandomRegionE(t testing.TestingT, approvedRegions []string, forbiddenReg
9191
regionsToPickFrom = collections.ListSubtract(regionsToPickFrom, forbiddenRegions)
9292
region := random.RandomString(regionsToPickFrom)
9393

94-
logger.Logf(t, "Using region %s", region)
94+
logger.Default.Logf(t, "Using region %s", region)
9595
return region, nil
9696
}
9797

@@ -106,7 +106,7 @@ func GetAllAwsRegions(t testing.TestingT) []string {
106106

107107
// GetAllAwsRegionsE gets the list of AWS regions available in this account.
108108
func GetAllAwsRegionsE(t testing.TestingT) ([]string, error) {
109-
logger.Log(t, "Looking up all AWS regions available in this account")
109+
logger.Default.Logf(t, "Looking up all AWS regions available in this account")
110110

111111
ec2Client, err := NewEc2ClientE(t, defaultRegion)
112112
if err != nil {
@@ -139,7 +139,7 @@ func GetAvailabilityZones(t testing.TestingT, region string) []string {
139139
// GetAvailabilityZonesE gets the Availability Zones for a given AWS region. Note that for certain regions (e.g. us-east-1), different AWS
140140
// accounts have access to different availability zones.
141141
func GetAvailabilityZonesE(t testing.TestingT, region string) ([]string, error) {
142-
logger.Logf(t, "Looking up all availability zones available in this account for region %s", region)
142+
logger.Default.Logf(t, "Looking up all availability zones available in this account for region %s", region)
143143

144144
ec2Client, err := NewEc2ClientE(t, region)
145145
if err != nil {

modules/aws/s3.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ func FindS3BucketWithTagE(t testing.TestingT, awsRegion string, key string, valu
5353

5454
for _, tag := range tagResponse.TagSet {
5555
if *tag.Key == key && *tag.Value == value {
56-
logger.Logf(t, "Found S3 bucket %s with tag %s=%s", *bucket.Name, key, value)
56+
logger.Default.Logf(t, "Found S3 bucket %s with tag %s=%s", *bucket.Name, key, value)
5757
return *bucket.Name, nil
5858
}
5959
}
@@ -123,7 +123,7 @@ func GetS3ObjectContentsE(t testing.TestingT, awsRegion string, bucket string, k
123123
}
124124

125125
contents := buf.String()
126-
logger.Logf(t, "Read contents from s3://%s/%s", bucket, key)
126+
logger.Default.Logf(t, "Read contents from s3://%s/%s", bucket, key)
127127

128128
return contents, nil
129129
}
@@ -136,7 +136,7 @@ func CreateS3Bucket(t testing.TestingT, region string, name string) {
136136

137137
// CreateS3BucketE creates an S3 bucket in the given region with the given name. Note that S3 bucket names must be globally unique.
138138
func CreateS3BucketE(t testing.TestingT, region string, name string) error {
139-
logger.Logf(t, "Creating bucket %s in %s", name, region)
139+
logger.Default.Logf(t, "Creating bucket %s in %s", name, region)
140140

141141
s3Client, err := NewS3ClientE(t, region)
142142
if err != nil {
@@ -160,7 +160,7 @@ func PutS3BucketPolicy(t testing.TestingT, region string, bucketName string, pol
160160

161161
// PutS3BucketPolicyE applies an IAM resource policy to a given S3 bucket to create it's bucket policy
162162
func PutS3BucketPolicyE(t testing.TestingT, region string, bucketName string, policyJSONString string) error {
163-
logger.Logf(t, "Applying bucket policy for bucket %s in %s", bucketName, region)
163+
logger.Default.Logf(t, "Applying bucket policy for bucket %s in %s", bucketName, region)
164164

165165
s3Client, err := NewS3ClientE(t, region)
166166
if err != nil {
@@ -184,7 +184,7 @@ func PutS3BucketVersioning(t testing.TestingT, region string, bucketName string)
184184

185185
// PutS3BucketVersioningE creates an S3 bucket versioning configuration in the given region against the given bucket name, WITHOUT requiring MFA to remove versioning.
186186
func PutS3BucketVersioningE(t testing.TestingT, region string, bucketName string) error {
187-
logger.Logf(t, "Creating bucket versioning configuration for bucket %s in %s", bucketName, region)
187+
logger.Default.Logf(t, "Creating bucket versioning configuration for bucket %s in %s", bucketName, region)
188188

189189
s3Client, err := NewS3ClientE(t, region)
190190
if err != nil {
@@ -211,7 +211,7 @@ func DeleteS3Bucket(t testing.TestingT, region string, name string) {
211211

212212
// DeleteS3BucketE destroys the S3 bucket in the given region with the given name.
213213
func DeleteS3BucketE(t testing.TestingT, region string, name string) error {
214-
logger.Logf(t, "Deleting bucket %s in %s", region, name)
214+
logger.Default.Logf(t, "Deleting bucket %s in %s", region, name)
215215

216216
s3Client, err := NewS3ClientE(t, region)
217217
if err != nil {
@@ -233,7 +233,7 @@ func EmptyS3Bucket(t testing.TestingT, region string, name string) {
233233

234234
// EmptyS3BucketE removes the contents of an S3 bucket in the given region with the given name.
235235
func EmptyS3BucketE(t testing.TestingT, region string, name string) error {
236-
logger.Logf(t, "Emptying bucket %s in %s", name, region)
236+
logger.Default.Logf(t, "Emptying bucket %s in %s", name, region)
237237

238238
s3Client, err := NewS3ClientE(t, region)
239239
if err != nil {
@@ -253,7 +253,7 @@ func EmptyS3BucketE(t testing.TestingT, region string, name string) error {
253253

254254
//Checks if the bucket is already empty
255255
if len((*bucketObjects).Versions) == 0 {
256-
logger.Logf(t, "Bucket %s is already empty", name)
256+
logger.Default.Logf(t, "Bucket %s is already empty", name)
257257
return nil
258258
}
259259

@@ -291,12 +291,12 @@ func EmptyS3BucketE(t testing.TestingT, region string, name string) error {
291291
if *(*bucketObjects).IsTruncated { //if there are more objects in the bucket, IsTruncated = true
292292
// params.Marker = (*deleteParams).Delete.Objects[len((*deleteParams).Delete.Objects)-1].Key
293293
params.KeyMarker = bucketObjects.NextKeyMarker
294-
logger.Logf(t, "Requesting next batch | %s", *(params.KeyMarker))
294+
logger.Default.Logf(t, "Requesting next batch | %s", *(params.KeyMarker))
295295
} else { //if all objects in the bucket have been cleaned up.
296296
break
297297
}
298298
}
299-
logger.Logf(t, "Bucket %s is now empty", name)
299+
logger.Default.Logf(t, "Bucket %s is now empty", name)
300300
return err
301301
}
302302

0 commit comments

Comments
 (0)