Skip to content

Commit 04042a3

Browse files
added notifications for apisix provider
1 parent 58fc830 commit 04042a3

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed

pkg/i2gw/providers/apisix/http_to_https.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@ limitations under the License.
1717
package apisix
1818

1919
import (
20+
"fmt"
21+
2022
"github.com/kubernetes-sigs/ingress2gateway/pkg/i2gw"
23+
"github.com/kubernetes-sigs/ingress2gateway/pkg/i2gw/notifications"
2124
"github.com/kubernetes-sigs/ingress2gateway/pkg/i2gw/providers/common"
2225
networkingv1 "k8s.io/api/networking/v1"
2326
"k8s.io/apimachinery/pkg/types"
@@ -32,7 +35,7 @@ func httpToHTTPSFeature(ingresses []networkingv1.Ingress, gatewayResources *i2gw
3235
ruleGroups := common.GetRuleGroups(ingresses)
3336
for _, rg := range ruleGroups {
3437
for _, rule := range rg.Rules {
35-
if val := rule.Ingress.Annotations[httpToHTTPSAnnotation]; val == "true" {
38+
if val, annotationFound := rule.Ingress.Annotations[httpToHTTPSAnnotation]; val == "true" {
3639
if rule.Ingress.Spec.Rules == nil {
3740
continue
3841
}
@@ -52,6 +55,9 @@ func httpToHTTPSFeature(ingresses []networkingv1.Ingress, gatewayResources *i2gw
5255
})
5356
httpRoute.Spec.Rules[i] = rule
5457
}
58+
if annotationFound && ok {
59+
notify(notifications.InfoNotification, fmt.Sprintf("parsed \"%v\" annotation of ingress and patched %v fields", httpToHTTPSAnnotation, field.NewPath("httproute", "spec", "rules").Key("").Child("filters")), &httpRoute)
60+
}
5561
}
5662
}
5763
}
Lines changed: 27 additions & 0 deletions
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 apisix
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) {
25+
newNotification := notifications.NewNotification(mType, message, callingObject...)
26+
notifications.NotificationAggr.DispatchNotification(newNotification, string(Name))
27+
}

0 commit comments

Comments
 (0)