diff --git a/internal/plog/klog.go b/internal/plog/klog.go index 52759814..9544d886 100644 --- a/internal/plog/klog.go +++ b/internal/plog/klog.go @@ -4,6 +4,7 @@ package plog import ( + "fmt" "sync" "github.com/spf13/pflag" @@ -32,6 +33,17 @@ func RemoveKlogGlobalFlags() { } } +// KRef is (mostly) copied from klog - it is a standard way to represent a a metav1.Object in logs +// when you only have access to the namespace and name of the object. +func KRef(namespace, name string) string { + return fmt.Sprintf("%s/%s", namespace, name) +} + +// KObj is (mostly) copied from klog - it is a standard way to represent a metav1.Object in logs. +func KObj(obj klog.KMetadata) string { + return fmt.Sprintf("%s/%s", obj.GetNamespace(), obj.GetName()) +} + func klogLevelForPlogLevel(plogLevel LogLevel) (klogLevel klog.Level) { switch plogLevel { case LevelWarning: