From 3f8703310cdd4375711e81c8f3fcefec913b2ecc Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Fri, 20 Aug 2021 11:54:00 +0200 Subject: [PATCH] Clarify what MustPackAny() does It always packs a slice, even if only one item given. --- pkg/icingadb/objectpacker/objectpacker.go | 6 +++--- pkg/icingadb/v1/customvar.go | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/icingadb/objectpacker/objectpacker.go b/pkg/icingadb/objectpacker/objectpacker.go index eb29ec1b..9ddfdc8b 100644 --- a/pkg/icingadb/objectpacker/objectpacker.go +++ b/pkg/icingadb/objectpacker/objectpacker.go @@ -11,11 +11,11 @@ import ( "sort" ) -// MustPackAny calls PackAny using in and panics if there was an error. -func MustPackAny(in ...interface{}) []byte { +// MustPackSlice calls PackAny using items and panics if there was an error. +func MustPackSlice(items ...interface{}) []byte { var buf bytes.Buffer - if err := PackAny(in, &buf); err != nil { + if err := PackAny(items, &buf); err != nil { panic(err) } diff --git a/pkg/icingadb/v1/customvar.go b/pkg/icingadb/v1/customvar.go index d648889d..9a66ce0b 100644 --- a/pkg/icingadb/v1/customvar.go +++ b/pkg/icingadb/v1/customvar.go @@ -72,7 +72,7 @@ func FlattenCustomvars(ctx context.Context, cvs <-chan contracts.Entity) (<-chan IdMeta: IdMeta{ // TODO(el): Schema comment is wrong. // Without customvar.Id we would produce duplicate keys here. - Id: utils.Checksum(objectpacker.MustPackAny(customvar.EnvironmentId, customvar.Id, flatname, flatvalue)), + Id: utils.Checksum(objectpacker.MustPackSlice(customvar.EnvironmentId, customvar.Id, flatname, flatvalue)), }, }, EnvironmentMeta: EnvironmentMeta{