1
0
mirror of https://github.com/minio/minio synced 2024-07-08 11:45:53 +00:00

Fix regression in removing notification (#5673)

fixes a regression introduced in 0e4431725c
when removing a previously applied notification configuration.

event.ParseConfig() was stricter in terms of handling notification
configuration, we need to allow when notification configuration is
sent empty, this is the way to remove notification configuration.
This commit is contained in:
Harshavardhana 2018-03-20 12:02:56 -07:00 committed by kannappanr
parent b4ae2bd2f5
commit c726145baf
2 changed files with 12 additions and 12 deletions

View File

@ -219,14 +219,13 @@ func (conf *Config) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
return err
}
if len(parsedConfig.QueueList) == 0 {
return errors.New("missing queue configuration(s)")
}
for i, q1 := range parsedConfig.QueueList[:len(parsedConfig.QueueList)-1] {
for _, q2 := range parsedConfig.QueueList[i+1:] {
if reflect.DeepEqual(q1, q2) {
return &ErrDuplicateQueueConfiguration{q1}
// Empty queue list means user wants to delete the notification configuration.
if len(parsedConfig.QueueList) > 0 {
for i, q1 := range parsedConfig.QueueList[:len(parsedConfig.QueueList)-1] {
for _, q2 := range parsedConfig.QueueList[i+1:] {
if reflect.DeepEqual(q1, q2) {
return &ErrDuplicateQueueConfiguration{q1}
}
}
}
}
@ -278,10 +277,6 @@ func ParseConfig(reader io.Reader, region string, targetList *TargetList) (*Conf
return nil, err
}
if len(config.QueueList) == 0 {
return nil, errors.New("missing queue configuration(s)")
}
if err := config.Validate(region, targetList); err != nil {
return nil, err
}

View File

@ -494,6 +494,9 @@ func TestConfigUnmarshalXML(t *testing.T) {
</TopicConfiguration>
</NotificationConfiguration>
`)
dataCase5 := []byte(`<NotificationConfiguration></NotificationConfiguration>`)
testCases := []struct {
data []byte
expectErr bool
@ -502,6 +505,8 @@ func TestConfigUnmarshalXML(t *testing.T) {
{dataCase2, false},
{dataCase3, false},
{dataCase4, true},
// make sure we don't fail when queue is empty.
{dataCase5, false},
}
for i, testCase := range testCases {