From 567de2e11518b152957f2fb2c446996617d73388 Mon Sep 17 00:00:00 2001 From: James Shubin Date: Sat, 2 Sep 2023 01:32:59 -0400 Subject: [PATCH] engine: Use a struct instead of a compound string for resUID This struct combination of resource kind+name is suitable for use as a unique map key. --- engine/resources.go | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/engine/resources.go b/engine/resources.go index de818969..3b4bcc30 100644 --- a/engine/resources.go +++ b/engine/resources.go @@ -221,13 +221,19 @@ func Stringer(res Res) string { } // ResPtrUID is a unique identifier that is consistent for the kind and name of -// the resource only. -type ResPtrUID string +// the resource only. This was formerly a string, but a struct is more precise. +// The result is suitable as a unique map key. +type ResPtrUID struct { + kind string + name string +} -// PtrUID generates a ResPtrUID from a resource. +// PtrUID generates a ResPtrUID from a resource. The result is suitable as a +// unique map key. func PtrUID(res Res) ResPtrUID { // the use of "repr" is kind of arbitrary as long as it's unique - return ResPtrUID(Repr(res.Kind(), res.Name())) + //return ResPtrUID(Repr(res.Kind(), res.Name())) + return ResPtrUID{kind: res.Kind(), name: res.Name()} } // Validate validates a resource by checking multiple aspects. This is the main