diff --git a/docs/content/about/configuration.md b/docs/content/about/configuration.md index 943b55b3d..fc0402ac0 100644 --- a/docs/content/about/configuration.md +++ b/docs/content/about/configuration.md @@ -1048,6 +1048,15 @@ accept event notifications. | `mediatypes`|no| A list of target media types to ignore. Events with these target media types are not published to the endpoint. | | `actions` |no| A list of actions to ignore. Events with these actions are not published to the endpoint. | +The `mediatypes` and `actions` filters work independently. You can specify: + +- Only `mediatypes` to filter by media type. +- Only `actions` to filter by action (e.g., `pull`, `push`, `delete`, `mount`) +- Both to filter events matching either condition (OR logic) +- Neither to receive all events + +Common use case: Set `mediatypes: []` with `actions: [pull, delete, mount]` to receive only push events regardless of media type. + ### `events` The `events` structure configures the information provided in event notifications. diff --git a/notifications/sinks.go b/notifications/sinks.go index 9334a0875..7caf9be01 100644 --- a/notifications/sinks.go +++ b/notifications/sinks.go @@ -128,7 +128,7 @@ type ignoredSink struct { } func newIgnoredSink(sink events.Sink, ignored []string, ignoreActions []string) events.Sink { - if len(ignored) == 0 { + if len(ignored) == 0 && len(ignoreActions) == 0 { return sink } diff --git a/notifications/sinks_test.go b/notifications/sinks_test.go index 15be67c1a..116fdc91c 100644 --- a/notifications/sinks_test.go +++ b/notifications/sinks_test.go @@ -79,6 +79,9 @@ func TestIgnoredSink(t *testing.T) { {ignoreMediaTypes: []string{"blob", "manifest"}, ignoreActions: []string{"other"}}, {ignoreMediaTypes: []string{"other"}, ignoreActions: []string{"pull"}, expected: blob}, {ignoreMediaTypes: []string{"other"}, ignoreActions: []string{"pull", "push"}}, + {ignoreMediaTypes: []string{}, ignoreActions: []string{"pull"}, expected: blob}, + {ignoreMediaTypes: []string{}, ignoreActions: []string{"push"}}, + {ignoreMediaTypes: []string{}, ignoreActions: []string{"mount", "delete"}, expected: blob}, } for _, tc := range tests { @@ -103,6 +106,9 @@ func TestIgnoredSink(t *testing.T) { {ignoreMediaTypes: []string{"blob", "manifest"}, ignoreActions: []string{"other"}}, {ignoreMediaTypes: []string{"other"}, ignoreActions: []string{"push"}, expected: manifest}, {ignoreMediaTypes: []string{"other"}, ignoreActions: []string{"pull", "push"}}, + {ignoreMediaTypes: []string{}, ignoreActions: []string{"push"}, expected: manifest}, + {ignoreMediaTypes: []string{}, ignoreActions: []string{"pull"}}, + {ignoreMediaTypes: []string{}, ignoreActions: []string{"mount", "delete"}, expected: manifest}, } for _, tc := range tests {