From c1c1aef23ed36dfcbdef4e4459708666aab387f5 Mon Sep 17 00:00:00 2001 From: Antoine Jacquemin Date: Mon, 2 Dec 2024 14:27:36 +0100 Subject: [PATCH] add valid entities --- cmd/gateway_validate.go | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/cmd/gateway_validate.go b/cmd/gateway_validate.go index d3f394bcb..c3a5750db 100644 --- a/cmd/gateway_validate.go +++ b/cmd/gateway_validate.go @@ -214,19 +214,19 @@ this command unless --online flag is used. // Iterate over the input values and validate them against the keys in entityMap for _, value := range validateCmdOnlineEntitiesFilter { - // Check if the value is valid by comparing it with keys in entityMap - isValid := false - for key := range validate.EntityMap { - if value == key { - isValid = true - break + // Check if the value is valid by comparing it with keys in EntityMap + if _, exists := validate.EntityMap[value]; !exists { + // Generate an error message with the list of valid keys + listOfKeys := make([]string, 0, len(validate.EntityMap)) + for key := range validate.EntityMap { + listOfKeys = append(listOfKeys, key) } - } - if !isValid { - // Generate an error message stating that the value should be part of Kong entities - return fmt.Errorf("invalid value '%s' for --check-online-plugins-only; it should be a valid Kong entity", - value) + return fmt.Errorf( + "invalid value '%s' for --check-online-plugins-only; it should be a valid Kong entity. "+ + "Valid entities: %v", + value, listOfKeys, + ) } } return preRunSilenceEventsFlag()