|
|
@ -268,18 +268,17 @@ func validateTopicConfigs(topicConfigs []topicConfig) APIErrorCode { |
|
|
|
|
|
|
|
|
|
|
|
// Check all the queue configs for any duplicates.
|
|
|
|
// Check all the queue configs for any duplicates.
|
|
|
|
func checkDuplicateQueueConfigs(configs []queueConfig) APIErrorCode { |
|
|
|
func checkDuplicateQueueConfigs(configs []queueConfig) APIErrorCode { |
|
|
|
configMaps := make(map[string]int) |
|
|
|
var queueConfigARNS []string |
|
|
|
|
|
|
|
|
|
|
|
// Navigate through each configs and count the entries.
|
|
|
|
// Navigate through each configs and count the entries.
|
|
|
|
for _, config := range configs { |
|
|
|
for _, config := range configs { |
|
|
|
configMaps[config.QueueARN]++ |
|
|
|
queueConfigARNS = append(queueConfigARNS, config.QueueARN) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Validate if there are any duplicate counts.
|
|
|
|
// Check if there are any duplicate counts.
|
|
|
|
for _, count := range configMaps { |
|
|
|
if err := checkDuplicates(queueConfigARNS); err != nil { |
|
|
|
if count != 1 { |
|
|
|
errorIf(err, "Invalid queue configs found.") |
|
|
|
return ErrOverlappingConfigs |
|
|
|
return ErrOverlappingConfigs |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Success.
|
|
|
|
// Success.
|
|
|
@ -288,18 +287,17 @@ func checkDuplicateQueueConfigs(configs []queueConfig) APIErrorCode { |
|
|
|
|
|
|
|
|
|
|
|
// Check all the topic configs for any duplicates.
|
|
|
|
// Check all the topic configs for any duplicates.
|
|
|
|
func checkDuplicateTopicConfigs(configs []topicConfig) APIErrorCode { |
|
|
|
func checkDuplicateTopicConfigs(configs []topicConfig) APIErrorCode { |
|
|
|
configMaps := make(map[string]int) |
|
|
|
var topicConfigARNS []string |
|
|
|
|
|
|
|
|
|
|
|
// Navigate through each configs and count the entries.
|
|
|
|
// Navigate through each configs and count the entries.
|
|
|
|
for _, config := range configs { |
|
|
|
for _, config := range configs { |
|
|
|
configMaps[config.TopicARN]++ |
|
|
|
topicConfigARNS = append(topicConfigARNS, config.TopicARN) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Validate if there are any duplicate counts.
|
|
|
|
// Check if there are any duplicate counts.
|
|
|
|
for _, count := range configMaps { |
|
|
|
if err := checkDuplicates(topicConfigARNS); err != nil { |
|
|
|
if count != 1 { |
|
|
|
errorIf(err, "Invalid topic configs found.") |
|
|
|
return ErrOverlappingConfigs |
|
|
|
return ErrOverlappingConfigs |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Success.
|
|
|
|
// Success.
|
|
|
@ -320,12 +318,17 @@ func validateNotificationConfig(nConfig notificationConfig) APIErrorCode { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Check for duplicate queue configs.
|
|
|
|
// Check for duplicate queue configs.
|
|
|
|
if s3Error := checkDuplicateQueueConfigs(nConfig.QueueConfigs); s3Error != ErrNone { |
|
|
|
if len(nConfig.QueueConfigs) > 1 { |
|
|
|
return s3Error |
|
|
|
if s3Error := checkDuplicateQueueConfigs(nConfig.QueueConfigs); s3Error != ErrNone { |
|
|
|
|
|
|
|
return s3Error |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Check for duplicate topic configs.
|
|
|
|
// Check for duplicate topic configs.
|
|
|
|
if s3Error := checkDuplicateTopicConfigs(nConfig.TopicConfigs); s3Error != ErrNone { |
|
|
|
if len(nConfig.TopicConfigs) > 1 { |
|
|
|
return s3Error |
|
|
|
if s3Error := checkDuplicateTopicConfigs(nConfig.TopicConfigs); s3Error != ErrNone { |
|
|
|
|
|
|
|
return s3Error |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Add validation for other configurations.
|
|
|
|
// Add validation for other configurations.
|
|
|
|