mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-19 09:52:49 +00:00
Merge pull request #106379 from shivanshu1333/feature/master/105782
Implemented MarshalLog in namespacedname.go
This commit is contained in:
commit
14549722e4
@ -37,3 +37,13 @@ const (
|
||||
func (n NamespacedName) String() string {
|
||||
return n.Namespace + string(Separator) + n.Name
|
||||
}
|
||||
|
||||
// MarshalLog emits a struct containing required key/value pair
|
||||
func (n NamespacedName) MarshalLog() interface{} {
|
||||
return struct {
|
||||
Name, Namespace string
|
||||
}{
|
||||
Name: n.Name,
|
||||
Namespace: n.Namespace,
|
||||
}
|
||||
}
|
||||
|
@ -27,6 +27,7 @@ import (
|
||||
"go.uber.org/zap"
|
||||
"go.uber.org/zap/zapcore"
|
||||
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
logsapi "k8s.io/component-base/logs/api/v1"
|
||||
)
|
||||
|
||||
@ -71,6 +72,11 @@ func TestZapLoggerInfo(t *testing.T) {
|
||||
format: "{\"ts\":%f,\"caller\":\"json/json_test.go:%d\",\"msg\":\"test for duplicate keys\",\"v\":0,\"akey\":\"avalue\",\"akey\":\"anothervalue\"}\n",
|
||||
keysValues: []interface{}{"akey", "avalue", "akey", "anothervalue"},
|
||||
},
|
||||
{
|
||||
msg: "test for NamespacedName argument",
|
||||
format: "{\"ts\":%f,\"caller\":\"json/json_test.go:%d\",\"msg\":\"test for NamespacedName argument\",\"v\":0,\"obj\":{\"Name\":\"kube-proxy\",\"Namespace\":\"kube-system\"}}\n",
|
||||
keysValues: []interface{}{"obj", types.NamespacedName{Name: "kube-proxy", Namespace: "kube-system"}},
|
||||
},
|
||||
}
|
||||
|
||||
for _, data := range testDataInfo {
|
||||
|
Loading…
Reference in New Issue
Block a user