@@ -25,6 +25,7 @@ import (
25
25
. "github.com/onsi/ginkgo"
26
26
. "github.com/onsi/gomega"
27
27
kapi "k8s.io/api/core/v1"
28
+ "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
28
29
"k8s.io/apimachinery/pkg/types"
29
30
)
30
31
@@ -238,6 +239,27 @@ var _ = Describe("Zap logger setup", func() {
238
239
}))
239
240
})
240
241
242
+ It ("should log an unstructured Kubernetes object" , func () {
243
+ pod := & unstructured.Unstructured {
244
+ Object : map [string ]interface {}{
245
+ "metadata" : map [string ]interface {}{
246
+ "name" : "some-pod" ,
247
+ "namespace" : "some-ns" ,
248
+ },
249
+ },
250
+ }
251
+ logger .Info ("here's a kubernetes object" , "thing" , pod )
252
+
253
+ outRaw := logOut .Bytes ()
254
+ res := map [string ]interface {}{}
255
+ Expect (json .Unmarshal (outRaw , & res )).To (Succeed ())
256
+
257
+ Expect (res ).To (HaveKeyWithValue ("thing" , map [string ]interface {}{
258
+ "name" : "some-pod" ,
259
+ "namespace" : "some-ns" ,
260
+ }))
261
+ })
262
+
241
263
It ("should log a standard namespaced NamespacedName name and namespace" , func () {
242
264
name := types.NamespacedName {Name : "some-pod" , Namespace : "some-ns" }
243
265
logger .Info ("here's a kubernetes object" , "thing" , name )
0 commit comments