Skip to content

Commit

Permalink
add valid entities
Browse files Browse the repository at this point in the history
  • Loading branch information
AntoineJac committed Dec 2, 2024
1 parent 4d6e757 commit c1c1aef
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions cmd/gateway_validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit c1c1aef

Please sign in to comment.