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:
parent
918cf193f6
commit
bcf9fa361b
1 changed files with 16 additions and 0 deletions
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue