From 188ce4cb4bb7f6dfba26cf1bdd773b19a161192d Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Mon, 19 Apr 2021 16:43:58 +0200 Subject: [PATCH] Flat CVs: represent null as "null", not "" --- pkg/icingadb/v1/customvar.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/pkg/icingadb/v1/customvar.go b/pkg/icingadb/v1/customvar.go index 52e19b07..7f4c808f 100644 --- a/pkg/icingadb/v1/customvar.go +++ b/pkg/icingadb/v1/customvar.go @@ -58,7 +58,13 @@ func FlattenCustomvars(ctx context.Context, cvs <-chan contracts.Entity) (<-chan flattened := flatten.Flatten(value, customvar.Name) for flatname, flatvalue := range flattened { - flatvalue := fmt.Sprintf("%v", flatvalue) + var fv string + if flatvalue == nil { + fv = "null" + } else { + fv = fmt.Sprintf("%v", flatvalue) + } + select { case cvFlats <- &CustomvarFlat{ CustomvarMeta: CustomvarMeta{ @@ -76,7 +82,7 @@ func FlattenCustomvars(ctx context.Context, cvs <-chan contracts.Entity) (<-chan }, Flatname: flatname, FlatnameChecksum: utils.Checksum(flatname), - Flatvalue: flatvalue, + Flatvalue: fv, }: case <-ctx.Done(): return ctx.Err()