Skip to content

Commit cc852ec

Browse files
pohlyk8s-publishing-bot
authored andcommitted
api: encode NamespacedName with lower case in JSON
That is how a workaround in controller-runtime has encoded NamespacedName (https://github.com/kubernetes-sigs/controller-runtime/blob/a33d038b84d0e7f615b8d803bdc47f0d1f8484b7/pkg/log/zap/kube_helpers.go#L49-L57) and it is also more consistent with Kubernetes API standards. The namespace can be left out. Returning an anonymous struct in MarshalLog makes it impossible for controller-runtime to adapt the type and thus blocks updating controller-runtime to Kubernetes 1.27 because log content would change. Kubernetes-commit: f564f7a3559a2710b879122dd81b536fc930c410
1 parent b1123d2 commit cc852ec

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

pkg/types/namespacedname.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ func (n NamespacedName) String() string {
4141
// MarshalLog emits a struct containing required key/value pair
4242
func (n NamespacedName) MarshalLog() interface{} {
4343
return struct {
44-
Name, Namespace string
44+
Name string `json:"name"`
45+
Namespace string `json:"namespace,omitempty"`
4546
}{
4647
Name: n.Name,
4748
Namespace: n.Namespace,

0 commit comments

Comments
 (0)