Skip to content

Commit

Permalink
variable name changes from callingObject to callingObjects
Browse files Browse the repository at this point in the history
  • Loading branch information
Devaansh-Kumar committed Nov 22, 2024
1 parent 715a879 commit 2cb7d04
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 17 deletions.
6 changes: 3 additions & 3 deletions PROVIDER.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,9 @@ package examplegateway

import "github.com/kubernetes-sigs/ingress2gateway/pkg/i2gw/notifications"

func notify(mType notifications.MessageType, message string) {
newNotification := notifications.Notification{Type: mType, Message: message}
notifications.CommonNotification.DispatchNotication(newNotification, string(ProviderName))
func notify(mType notifications.MessageType, message string, callingObjects ...client.Object){
newNotification := notifications.NewNotification(mType, message, callingObjects...)
notifications.NotificationAggr.DispatchNotification(newNotification, string(ProviderName))
}
```
7. Import the new package at `cmd/print`.
Expand Down
6 changes: 3 additions & 3 deletions pkg/i2gw/notifications/notifications.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ var NotificationAggr NotificationAggregator

// NotificationCallback is a callback function used to send notifications from within the common
// package without the common package having knowledge about which provider is making a call it
type NotificationCallback func(mType MessageType, message string, callingObject ...client.Object)
type NotificationCallback func(mType MessageType, message string, CallingObjects ...client.Object)

// DispatchNotification is used to send a notification to the NotificationAggregator
func (na *NotificationAggregator) DispatchNotification(notification Notification, ProviderName string) {
Expand Down Expand Up @@ -103,6 +103,6 @@ func convertObjectsToStr(ob []client.Object) string {
return sb.String()
}

func NewNotification(mType MessageType, message string, callingObject ...client.Object) Notification {
return Notification{Type: mType, Message: message, CallingObjects: callingObject}
func NewNotification(mType MessageType, message string, callingObjects ...client.Object) Notification {
return Notification{Type: mType, Message: message, CallingObjects: callingObjects}
}
4 changes: 2 additions & 2 deletions pkg/i2gw/providers/apisix/notification.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/client"
)

func notify(mType notifications.MessageType, message string, callingObject ...client.Object) {
newNotification := notifications.NewNotification(mType, message, callingObject...)
func notify(mType notifications.MessageType, message string, callingObjects ...client.Object) {
newNotification := notifications.NewNotification(mType, message, callingObjects...)
notifications.NotificationAggr.DispatchNotification(newNotification, string(Name))
}
3 changes: 2 additions & 1 deletion pkg/i2gw/providers/common/converter.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func ToIR(ingresses []networkingv1.Ingress, options i2gw.ProviderImplementationS
case 1:
notify = notifyOpts[0]
default:
return i2gw.GatewayResources{}, field.ErrorList{field.Invalid(field.NewPath(""), "", "number of notification callbacks exceeded. only 0 or 1 callbacks are currently supported")}
return intermediate.IR{}, field.ErrorList{field.Invalid(field.NewPath(""), "", "number of notification callbacks exceeded. only 0 or 1 callbacks are currently supported")}
}

var errs field.ErrorList
Expand Down Expand Up @@ -190,6 +190,7 @@ func (a *ingressAggregator) toHTTPRoutesAndGateways(options i2gw.ProviderImpleme
var httpRoutes []gatewayv1.HTTPRoute
var errors field.ErrorList
listenersByNamespacedGateway := map[string][]gatewayv1.Listener{}
ingressByNamespacedGateway := map[string][]client.Object{}

// Sort the rulegroups to iterate the map in a sorted order.
ruleGroupsKeys := make([]ruleGroupKey, 0, len(a.ruleGroups))
Expand Down
4 changes: 2 additions & 2 deletions pkg/i2gw/providers/gce/notification.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/client"
)

func notify(mType notifications.MessageType, message string, callingObject ...client.Object) {
newNotification := notifications.NewNotification(mType, message, callingObject...)
func notify(mType notifications.MessageType, message string, callingObjects ...client.Object) {
newNotification := notifications.NewNotification(mType, message, callingObjects...)
notifications.NotificationAggr.DispatchNotification(newNotification, string(ProviderName))
}
4 changes: 2 additions & 2 deletions pkg/i2gw/providers/ingressnginx/notification.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/client"
)

func notify(mType notifications.MessageType, message string, callingObject ...client.Object) {
newNotification := notifications.NewNotification(mType, message, callingObject...)
func notify(mType notifications.MessageType, message string, callingObjects ...client.Object) {
newNotification := notifications.NewNotification(mType, message, callingObjects...)
notifications.NotificationAggr.DispatchNotification(newNotification, string(Name))
}
4 changes: 2 additions & 2 deletions pkg/i2gw/providers/istio/notification.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/client"
)

func notify(mType notifications.MessageType, message string, callingObject ...client.Object) {
newNotification := notifications.NewNotification(mType, message, callingObject...)
func notify(mType notifications.MessageType, message string, callingObjects ...client.Object) {
newNotification := notifications.NewNotification(mType, message, callingObjects...)
notifications.NotificationAggr.DispatchNotification(newNotification, string(ProviderName))
}
4 changes: 2 additions & 2 deletions pkg/i2gw/providers/kong/notification.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ import (
"sigs.k8s.io/controller-runtime/pkg/client"
)

func notify(mType notifications.MessageType, message string, callingObject ...client.Object) {
newNotification := notifications.NewNotification(mType, message, callingObject...)
func notify(mType notifications.MessageType, message string, callingObjects ...client.Object) {
newNotification := notifications.NewNotification(mType, message, callingObjects...)
notifications.NotificationAggr.DispatchNotification(newNotification, string(Name))
}

Expand Down

0 comments on commit 2cb7d04

Please sign in to comment.