Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Jakub Warczarek <[email protected]>
  • Loading branch information
mlavacca and programmer04 committed Oct 24, 2023
1 parent 5851d22 commit ddb9a65
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions internal/dataplane/parser/translators/httproute.go
Original file line number Diff line number Diff line change
Expand Up @@ -362,20 +362,18 @@ func SetRoutePlugins(route *kongstate.Route, filters []gatewayapi.HTTPRouteFilte
return err
}
if len(plugins) > 0 {
if route.Plugins == nil {
route.Plugins = make([]kong.Plugin, 0)
}
route.Plugins = append(route.Plugins, plugins...)
}
if len(pluginAnnotation) > 0 {
if route.Ingress.Annotations == nil {
route.Ingress.Annotations = make(map[string]string)
}
if _, ok := route.Ingress.Annotations[annotations.AnnotationPrefix+annotations.PluginsKey]; !ok {
route.Ingress.Annotations[annotations.AnnotationPrefix+annotations.PluginsKey] = pluginAnnotation
const pluginAnnotationKey = annotations.AnnotationPrefix + annotations.PluginsKey
if _, ok := route.Ingress.Annotations[pluginAnnotationKey]; !ok {
route.Ingress.Annotations[pluginAnnotationKey] = pluginAnnotation
} else {
route.Ingress.Annotations[annotations.AnnotationPrefix+annotations.PluginsKey] = fmt.Sprintf("%s,%s",
route.Ingress.Annotations[annotations.AnnotationPrefix+annotations.PluginsKey],
route.Ingress.Annotations[pluginAnnotationKey] = fmt.Sprintf("%s,%s",
route.Ingress.Annotations[pluginAnnotationKey],
pluginAnnotation)
}
}
Expand Down

0 comments on commit ddb9a65

Please sign in to comment.