Skip to content

Commit

Permalink
Allow event notifications to work without region
Browse files Browse the repository at this point in the history
  • Loading branch information
harshavardhana committed Oct 27, 2017
1 parent 03df692 commit 93f21fc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
6 changes: 6 additions & 0 deletions cmd/bucket-notification-handlers.go
Expand Up @@ -150,6 +150,12 @@ func (api objectAPIHandlers) PutBucketNotificationHandler(w http.ResponseWriter,
return
}

// Convert the incoming ARNs properly to the GetRegion().
for i, queueConfig := range notificationCfg.QueueConfigs {
queueConfig.QueueARN = unmarshalSqsARN(queueConfig.QueueARN).String()
notificationCfg.QueueConfigs[i] = queueConfig
}

// Put bucket notification config.
err = PutBucketNotificationConfig(bucket, &notificationCfg, objectAPI)
if err != nil {
Expand Down
8 changes: 4 additions & 4 deletions cmd/bucket-notification-utils.go
Expand Up @@ -116,9 +116,9 @@ func checkARN(arn, arnType string) APIErrorCode {
if len(strs) != 6 {
return ErrARNNotification
}
if serverConfig.GetRegion() != "" {
if sregion := serverConfig.GetRegion(); sregion != "" {
region := strs[3]
if region != serverConfig.GetRegion() {
if region != sregion {
return ErrRegionNotification
}
}
Expand Down Expand Up @@ -273,9 +273,9 @@ func unmarshalSqsARN(queueARN string) (mSqs arnSQS) {
if len(strs) != 6 {
return
}
if serverConfig.GetRegion() != "" {
if sregion := serverConfig.GetRegion(); sregion != "" {
region := strs[3]
if region != serverConfig.GetRegion() {
if region != sregion {
return
}
}
Expand Down

0 comments on commit 93f21fc

Please sign in to comment.