Skip to content

Commit e9621a1

Browse files
added notifications for openapi3 provider (#178)
* added notifications for openapi3 provider * added nolint:unparam to bypass golint
1 parent 1a6031b commit e9621a1

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

pkg/i2gw/providers/openapi3/converter.go

+5
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import (
3636

3737
"github.com/kubernetes-sigs/ingress2gateway/pkg/i2gw"
3838
"github.com/kubernetes-sigs/ingress2gateway/pkg/i2gw/intermediate"
39+
"github.com/kubernetes-sigs/ingress2gateway/pkg/i2gw/notifications"
3940
"github.com/kubernetes-sigs/ingress2gateway/pkg/i2gw/providers/common"
4041
)
4142

@@ -121,17 +122,21 @@ func (c *resourcesToIRConverter) Convert(storage Storage) (intermediate.IR, fiel
121122
httpRoutes, gateways := c.toHTTPRoutesAndGateways(spec, resourcesNamePrefix, errors)
122123
for _, httpRoute := range httpRoutes {
123124
ir.HTTPRoutes[types.NamespacedName{Name: httpRoute.GetName(), Namespace: httpRoute.GetNamespace()}] = intermediate.HTTPRouteContext{HTTPRoute: httpRoute}
125+
notify(notifications.InfoNotification, fmt.Sprintf("successfully created HTTPRoute \"%v/%v\" from OpenAPI spec \"%v\"", httpRoute.Namespace, httpRoute.Name, spec.Info.Title))
124126
}
125127

126128
// build reference grants for the resources
127129
if referenceGrant := c.buildHTTPRouteBackendReferenceGrant(); referenceGrant != nil {
128130
ir.ReferenceGrants[types.NamespacedName{Name: referenceGrant.GetName(), Namespace: referenceGrant.GetNamespace()}] = *referenceGrant
131+
notify(notifications.InfoNotification, fmt.Sprintf("successfully created ReferenceGrant \"%v/%v\" from OpenAPI spec \"%v\"", referenceGrant.Namespace, referenceGrant.Name, spec.Info.Title))
129132
}
130133
for _, gateway := range gateways {
131134
ir.Gateways[types.NamespacedName{Name: gateway.GetName(), Namespace: gateway.GetNamespace()}] = intermediate.GatewayContext{Gateway: gateway}
132135
if referenceGrant := c.buildGatewayTLSSecretReferenceGrant(gateway); referenceGrant != nil {
133136
ir.ReferenceGrants[types.NamespacedName{Name: referenceGrant.GetName(), Namespace: referenceGrant.GetNamespace()}] = *referenceGrant
137+
notify(notifications.InfoNotification, fmt.Sprintf("successfully created ReferenceGrant \"%v/%v\" from OpenAPI spec \"%v\"", referenceGrant.Namespace, referenceGrant.Name, spec.Info.Title))
134138
}
139+
notify(notifications.InfoNotification, fmt.Sprintf("successfully created Gateway \"%v/%v\" from OpenAPI spec \"%v\"", gateway.Namespace, gateway.Name, spec.Info.Title))
135140
}
136141
}
137142

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
Copyright 2024 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package openapi3
18+
19+
import (
20+
"github.com/kubernetes-sigs/ingress2gateway/pkg/i2gw/notifications"
21+
"sigs.k8s.io/controller-runtime/pkg/client"
22+
)
23+
24+
func notify(mType notifications.MessageType, message string, callingObject ...client.Object) { //nolint:unparam
25+
newNotification := notifications.NewNotification(mType, message, callingObject...)
26+
notifications.NotificationAggr.DispatchNotification(newNotification, string(ProviderName))
27+
}

0 commit comments

Comments
 (0)