mirror of
https://github.com/minio/minio.git
synced 2025-01-25 13:43:17 -05:00
Fix regression in removing notification (#5673)
fixes a regression introduced in 0e4431725cd85236d3d18643f8fc2506c7d88c66 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:
parent
b4ae2bd2f5
commit
c726145baf
@ -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
|
||||
}
|
||||
|
@ -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 {
|
||||
|
Loading…
x
Reference in New Issue
Block a user