Skip to content

Commit a3147bb

Browse files
added notifications for plugins feature parsers in kong
1 parent f9ddda0 commit a3147bb

File tree

8 files changed

+17
-9
lines changed

8 files changed

+17
-9
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,6 @@ go.work
2626

2727
# GolangCI-Lint cache
2828
/cache
29+
30+
# VSCode files for debugging
31+
.vscode/

pkg/i2gw/notifications/notifications.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,6 @@ func convertObjectsToStr(ob []client.Object) string {
9898
return sb.String()
9999
}
100100

101-
func NotificationBuilder(mType MessageType, message string, callingObject ...client.Object) Notification {
101+
func NewNotification(mType MessageType, message string, callingObject ...client.Object) Notification {
102102
return Notification{Type: mType, Message: message, CallingObjects: callingObject}
103-
}
103+
}

pkg/i2gw/providers/istio/notification.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,6 @@ import (
2222
)
2323

2424
func notify(mType notifications.MessageType, message string, callingObject ...client.Object) {
25-
newNotification := notifications.NotificationBuilder(mType, message, callingObject...)
25+
newNotification := notifications.NewNotification(mType, message, callingObject...)
2626
notifications.NotificationAggr.DispatchNotification(newNotification, string(ProviderName))
2727
}

pkg/i2gw/providers/kong/crds/tcpingress.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,11 @@ func (a *tcpIngressAggregator) addIngress(tcpIngress kongv1beta1.TCPIngress, not
8181
var ingressClass string
8282
if ingressClassAnnotation, ok := tcpIngress.Annotations[networkingv1beta1.AnnotationIngressClass]; ok {
8383
ingressClass = tcpIngress.Annotations[networkingv1beta1.AnnotationIngressClass]
84-
n := notifications.NotificationBuilder(notifications.InfoNotification, fmt.Sprintf("ingress class \"%v\" taken from %v annotation", ingressClassAnnotation, networkingv1beta1.AnnotationIngressClass), &tcpIngress)
84+
n := notifications.NewNotification(notifications.InfoNotification, fmt.Sprintf("ingress class \"%v\" taken from %v annotation", ingressClassAnnotation, networkingv1beta1.AnnotationIngressClass), &tcpIngress)
8585
*notificationsAggregator = append(*notificationsAggregator, n)
8686
} else {
8787
ingressClass = tcpIngress.Name
88-
n := notifications.NotificationBuilder(notifications.InfoNotification, "ingress class taken from name of TCPIngress", &tcpIngress)
88+
n := notifications.NewNotification(notifications.InfoNotification, "ingress class taken from name of TCPIngress", &tcpIngress)
8989
*notificationsAggregator = append(*notificationsAggregator, n)
9090
}
9191
for _, rule := range tcpIngress.Spec.Rules {

pkg/i2gw/providers/kong/header_matching.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ func patchHTTPRouteHeaderMatching(httpRoute *gatewayv1.HTTPRoute, headerNames []
8383
}
8484
httpRoute.Spec.Rules[i].Matches = newMatches
8585
if len(newMatches) > 0 {
86-
notify(notifications.InfoNotification, fmt.Sprintf("parsed \"%v\" annotations of ingress and patched %v fields", kongAnnotation(headersKey), field.NewPath("httproute", "spec", "rules").Key("").Child("matches")), httpRoute)
86+
notify(notifications.InfoNotification, fmt.Sprintf("parsed \"%v\" annotation of ingress and patched %v fields", kongAnnotation(headersKey), field.NewPath("httproute", "spec", "rules").Key("").Child("matches")), httpRoute)
8787
}
8888
}
8989
}

pkg/i2gw/providers/kong/method_matching.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ func patchHTTPRouteMethodMatching(httpRoute *gatewayv1.HTTPRoute, methods []gate
6969
}
7070
if len(matches) > 0 {
7171
httpRoute.Spec.Rules[i].Matches = matches
72-
notify(notifications.InfoNotification, fmt.Sprintf("parsed \"%v\" annotations of ingress and patched %v fields", kongAnnotation(methodsKey), field.NewPath("httproute", "spec", "rules").Key("").Child("matches").Key("").Child("method")), httpRoute)
72+
notify(notifications.InfoNotification, fmt.Sprintf("parsed \"%v\" annotation of ingress and patched %v fields", kongAnnotation(methodsKey), field.NewPath("httproute", "spec", "rules").Key("").Child("matches").Key("").Child("method")), httpRoute)
7373
}
7474
}
7575
}

pkg/i2gw/providers/kong/notification.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ import (
2222
)
2323

2424
func notify(mType notifications.MessageType, message string, callingObject ...client.Object) {
25-
newNotification := notifications.NotificationBuilder(mType, message, callingObject...)
25+
newNotification := notifications.NewNotification(mType, message, callingObject...)
2626
notifications.NotificationAggr.DispatchNotification(newNotification, string(Name))
2727
}
2828

2929
func dispatchNotification(n []notifications.Notification) {
3030
for _, v := range n {
3131
notify(v.Type, v.Message, v.CallingObjects...)
3232
}
33-
}
33+
}

pkg/i2gw/providers/kong/plugins.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,11 @@ package kong
1818

1919
import (
2020
"errors"
21+
"fmt"
2122
"strings"
2223

2324
"github.com/kubernetes-sigs/ingress2gateway/pkg/i2gw"
25+
"github.com/kubernetes-sigs/ingress2gateway/pkg/i2gw/notifications"
2426
"github.com/kubernetes-sigs/ingress2gateway/pkg/i2gw/providers/common"
2527
networkingv1 "k8s.io/api/networking/v1"
2628
"k8s.io/apimachinery/pkg/types"
@@ -81,4 +83,7 @@ func patchHTTPRoutePlugins(httpRoute *gatewayv1.HTTPRoute, extensionRefs []gatew
8183
}
8284
httpRoute.Spec.Rules[i].Filters = append(httpRoute.Spec.Rules[i].Filters, extensionRefs...)
8385
}
86+
if len(extensionRefs) != 0 {
87+
notify(notifications.InfoNotification, fmt.Sprintf("parsed \"%v\" annotation of ingress and patched %v fields", kongAnnotation(pluginsKey), field.NewPath("httproute", "spec", "rules").Key("").Child("filters")), httpRoute)
88+
}
8489
}

0 commit comments

Comments
 (0)