[Bug] [CLI] kyverno test output missing namespace in resource table
Description
When running kyverno test via the CLI, the result table fails to correctly parse and display the namespace of the tested resources.
The Resource column is intended to print the resource in distinct colors. However, currently, the namespace is swallowed into the "Kind" string and passed as an empty string to the output formatting function.
As seen in cmd/cli/kubectl-kyverno/commands/test/output.go:
Resource: color.Resource(strings.Join(resourceParts[:len(resourceParts)-1], "/"), "", resourceParts[len(resourceParts)-1]), // todo: handle namespaceBecause "" is explicitly passed as the namespace argument, the color.Resource utility doesn't format the Namespace distinctively from the Kind.
Steps to reproduce
- Run a CLI test where the tested resources contain namespaces, for example:
./cmd/cli/kubectl-kyverno/kubectl-kyverno test test/cli/test-mutate. - Observe the CLI output table under the
RESOURCEcolumn. The output merges the namespace into the Kind string (e.g.v1/Secret/staging/secret-1wherestagingis the namespace) instead of being colorized correctly.
Expected behavior
The CLI test output should correctly isolate the Kind, Namespace, and Name from the parsed resource string and pass them distinctively to the output formatter, honoring the todo: handle namespace comment.
Source: kyverno/kyverno