-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add functions CheckQueueExists CheckBucketExists #183
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some changes.
Please add tests to s3_integration_test.go
and sqs_integration_test.go
, where it's ensured that it gives an error before the asset is created, and then nil error afterwards.
Will need an equivalent set for SNS too.
If the caller doesn't have permission, that will return an error too? Not sure if our testing infrastructure can test for lack of permissions, so maybe add that behaviour to each function documentation.
aws/s3/s3.go
Outdated
@@ -271,6 +271,16 @@ func (s *S3) PutWithMetadata(bucket, key string, object []byte, metadata Meta) e | |||
return err | |||
} | |||
|
|||
// checks if the given S3 bucket exists. | |||
func (s *S3) CheckBucketExists(bucketName string) error { | |||
// Check if the bucket exists. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment not needed
aws/s3/s3.go
Outdated
@@ -271,6 +271,16 @@ func (s *S3) PutWithMetadata(bucket, key string, object []byte, metadata Meta) e | |||
return err | |||
} | |||
|
|||
// checks if the given S3 bucket exists. | |||
func (s *S3) CheckBucketExists(bucketName string) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bucket
to be consistent with the others.
aws/sqs/sqs.go
Outdated
// checks if the given SQS queue exists. | ||
func (s *SQS) CheckQueueExists(queueName string) error { | ||
// Check if the queue exists. | ||
_, err := s.client.GetQueueUrl(context.TODO(), &sqs.GetQueueUrlInput{ | ||
QueueName: aws.String(queueName), | ||
}) | ||
|
||
return err | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we usually have the queue URL as an environment variable - is it possible to check from the URL?
0d06f95
to
5ae4175
Compare
aws/sqs/sqs_integration_test.go
Outdated
client, err := New() | ||
|
||
// ASSERT | ||
assert.Nil(t, err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the test isn't focused on whether client creation works, and subsequent client methods will fail if the client creation failed, this is more appropriate:
client, err := New()
require.Nil(t, err, fmt.Sprintf("error creating sqs client: %v", err))
aws/sns/sns_integration_test.go
Outdated
client, err := New() | ||
ready := client.Ready() | ||
// ASSERT | ||
assert.Nil(t, err) | ||
assert.True(t, ready) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
client, err := New()
require.Nil(t, err, fmt.Sprintf("error creating sns client: %v", err))
ready := client.Ready()
require.True(t, ready, fmt.Sprint("sns client not ready"))
aws/sqs/sqs.go
Outdated
@@ -320,6 +320,18 @@ func (s *SQS) CreateQueue(queueName string, isFifoQueue bool) (string, error) { | |||
return aws.ToString(queue.QueueUrl), err | |||
} | |||
|
|||
// checks if the given SQS queue exists. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// checks if the given SQS queue exists. | |
// CheckQueueExists returns an error if the given queue doesn't exist or cannot be accessed. |
aws/s3/s3.go
Outdated
@@ -271,6 +271,15 @@ func (s *S3) PutWithMetadata(bucket, key string, object []byte, metadata Meta) e | |||
return err | |||
} | |||
|
|||
// checks if the given S3 bucket exists. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// checks if the given S3 bucket exists. | |
// CheckBucketExists returns an error if the given bucket doesn't exist or cannot be accessed. |
aws/sns/sns.go
Outdated
@@ -116,6 +116,14 @@ func (s *SNS) DeleteTopic(topicArn string) error { | |||
return err | |||
} | |||
|
|||
// checks if an SNS topic exists given its ARN. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// checks if an SNS topic exists given its ARN. | |
// CheckTopicExists returns an error if the given topic doesn't exist or cannot be accessed. |
On second thought, I think dropping |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just some suggestions to bring inline with Go Docs conventions.
aws/s3/s3.go
Outdated
@@ -271,6 +271,15 @@ func (s *S3) PutWithMetadata(bucket, key string, object []byte, metadata Meta) e | |||
return err | |||
} | |||
|
|||
// checks if the given S3 bucket exists and is accessible. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// checks if the given S3 bucket exists and is accessible. | |
// CheckBucket checks if the given S3 bucket exists and is accessible. |
aws/sns/sns.go
Outdated
@@ -116,6 +116,14 @@ func (s *SNS) DeleteTopic(topicArn string) error { | |||
return err | |||
} | |||
|
|||
// checks if an SNS topic exists and is accessible given its ARN. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// checks if an SNS topic exists and is accessible given its ARN. | |
// CheckTopic checks if an SNS topic exists and is accessible given its ARN. |
aws/sqs/sqs.go
Outdated
@@ -320,6 +320,18 @@ func (s *SQS) CreateQueue(queueName string, isFifoQueue bool) (string, error) { | |||
return aws.ToString(queue.QueueUrl), err | |||
} | |||
|
|||
// checks if the given SQS queue exists and is accessible. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// checks if the given SQS queue exists and is accessible. | |
// CheckQueue checks if the given SQS queue exists and is accessible. |
Proposed Changes
Ticket https://github.com/GeoNet/tickets/issues/13878
Changes proposed in this pull request:
Production Changes
The following production changes are required to deploy these changes:
Review
Check the box that applies to this code review. If necessary please seek help with adding a checklist guide for the reviewer.
When assigning the code review please consider the expertise needed to review the changes.
Code Review Guide
Insert check list here if needed.