From cc05fbf14df4b987745978f90933ba076b0c8cf9 Mon Sep 17 00:00:00 2001 From: Amine Hilaly Date: Mon, 17 May 2021 14:04:43 +0200 Subject: [PATCH] panic if matchFieldName configuration contains an element that is not part of Spec or Status fields --- pkg/generate/code/set_resource.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/pkg/generate/code/set_resource.go b/pkg/generate/code/set_resource.go index d45c5df5..78875cc3 100644 --- a/pkg/generate/code/set_resource.go +++ b/pkg/generate/code/set_resource.go @@ -416,6 +416,18 @@ func setResourceReadMany( // operation by checking for matching values in these fields. matchFieldNames := r.ListOpMatchFieldNames() + for _, matchFieldName := range matchFieldNames { + _, foundSpec := r.SpecFields[matchFieldName] + _, foundStatus := r.StatusFields[matchFieldName] + if !foundSpec && !foundStatus { + msg := fmt.Sprintf( + "Match field name %s is not in %s Spec or Status fields", + matchFieldName, r.Names.Camel, + ) + panic(msg) + } + } + // found := false out += fmt.Sprintf("%sfound := false\n", indent) // for _, elem := range resp.CacheClusters {