fix(events): respect `--all-namespaces` flag

The `flux events` command always applied a namespace filter, even when `--all-namespaces` was set.
This produced incomplete results and confused users expecting cluster-wide events.

Changes made:
* Build `clientListOpts` dynamically.
* Omit `client.InNamespace(...)` when `eventArgs.allNamespaces` is true, ensuring no namespace constraint.

Impact:
`flux events --all-namespaces` now returns events from every namespace, restoring expected functionality without affecting other options.

Signed-off-by: S. M. Mohiuddin Khan Shiam <147746955+mohiuddin-khan-shiam@users.noreply.github.com>
pull/5414/head
S. M. Mohiuddin Khan Shiam 1 week ago committed by S. M. Mohiuddin Khan Shiam
parent 2b8564d79f
commit 9265d67fe6

@ -112,7 +112,12 @@ func eventsCmdRun(cmd *cobra.Command, args []string) error {
}
var diffRefNs bool
clientListOpts := []client.ListOption{client.InNamespace(*kubeconfigArgs.Namespace)}
// Build the base list options. When --all-namespaces is set we must NOT constrain the
// query to a single namespace, otherwise we silently return a partial result set.
clientListOpts := []client.ListOption{}
if !eventArgs.allNamespaces {
clientListOpts = append(clientListOpts, client.InNamespace(*kubeconfigArgs.Namespace))
}
var refListOpts [][]client.ListOption
if eventArgs.forSelector != "" {
kind, name := getKindNameFromSelector(eventArgs.forSelector)

Loading…
Cancel
Save