1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2024-12-14 11:57:48 +00:00

fix: names not formatted correctly in cli output (#8411)

Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>
This commit is contained in:
Charles-Edouard Brétéché 2023-09-14 23:02:44 +02:00 committed by GitHub
parent 918cf193f6
commit bcf9fa361b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,6 +1,8 @@
package color
import (
"strings"
"github.com/fatih/color"
"github.com/kataras/tablewriter"
)
@ -32,6 +34,13 @@ func InitColors(noColor bool) {
}
func Policy(namespace, name string) string {
if strings.Contains(name, "/") {
parts := strings.Split(name, "/")
if len(parts) >= 2 {
namespace = parts[0]
name = parts[1]
}
}
if namespace == "" {
return BoldFgCyan.Sprint(name)
}
@ -43,6 +52,13 @@ func Rule(name string) string {
}
func Resource(kind, namespace, name string) string {
if strings.Contains(name, "/") {
parts := strings.Split(name, "/")
if len(parts) >= 2 {
namespace = parts[0]
name = parts[1]
}
}
if namespace == "" {
return BoldFgCyan.Sprint(kind) + "/" + BoldFgCyan.Sprint(name)
}