mirror of
https://github.com/kyverno/kyverno.git
synced 2025-03-15 12:17:56 +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:
parent
918cf193f6
commit
bcf9fa361b
1 changed files with 16 additions and 0 deletions
|
@ -1,6 +1,8 @@
|
||||||
package color
|
package color
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/fatih/color"
|
"github.com/fatih/color"
|
||||||
"github.com/kataras/tablewriter"
|
"github.com/kataras/tablewriter"
|
||||||
)
|
)
|
||||||
|
@ -32,6 +34,13 @@ func InitColors(noColor bool) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func Policy(namespace, name string) string {
|
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 == "" {
|
if namespace == "" {
|
||||||
return BoldFgCyan.Sprint(name)
|
return BoldFgCyan.Sprint(name)
|
||||||
}
|
}
|
||||||
|
@ -43,6 +52,13 @@ func Rule(name string) string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func Resource(kind, namespace, 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 == "" {
|
if namespace == "" {
|
||||||
return BoldFgCyan.Sprint(kind) + "/" + BoldFgCyan.Sprint(name)
|
return BoldFgCyan.Sprint(kind) + "/" + BoldFgCyan.Sprint(name)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue