Skip to content

Commit

Permalink
feat(flag): Add --ingress-annotation-prefix flag
Browse files Browse the repository at this point in the history
  • Loading branch information
gabe565 committed Apr 17, 2024
1 parent dbb58d3 commit ad4ca5b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
3 changes: 3 additions & 0 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ func main() {
flag.StringVar(&clusterResourceNamespace, "cluster-resource-namespace", controller.ClusterResourceNamespace,
"Namespace to store resources owned by cluster scoped resources",
)
flag.StringVar(&controller.IngressAnnotationPrefix, "ingress-annotation-prefix", controller.IngressAnnotationPrefix,
"Ingress annotation prefix",
)
opts := zap.Options{
Development: true,
}
Expand Down
8 changes: 4 additions & 4 deletions internal/controller/ingress_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/predicate"
)

const AnnotationPrefix = "uptime-robot.clevyr.com/"
var IngressAnnotationPrefix = "uptime-robot.clevyr.com/"

// IngressReconciler reconciles a Ingress object
type IngressReconciler struct {
Expand Down Expand Up @@ -170,7 +170,7 @@ func (r *IngressReconciler) findMonitors(ctx context.Context, ingress *networkin
func (r *IngressReconciler) countMatchingAnnotations(ingress *networkingv1.Ingress) uint {
var count uint
for k := range ingress.Annotations {
if strings.HasPrefix(k, AnnotationPrefix) {
if strings.HasPrefix(k, IngressAnnotationPrefix) {
count++
}
}
Expand All @@ -180,8 +180,8 @@ func (r *IngressReconciler) countMatchingAnnotations(ingress *networkingv1.Ingre
func (r *IngressReconciler) getMatchingAnnotations(ingress *networkingv1.Ingress) map[string]string {
annotations := make(map[string]string, r.countMatchingAnnotations(ingress))
for k, v := range ingress.Annotations {
if strings.HasPrefix(k, AnnotationPrefix) {
annotations[strings.TrimPrefix(k, AnnotationPrefix)] = v
if strings.HasPrefix(k, IngressAnnotationPrefix) {
annotations[strings.TrimPrefix(k, IngressAnnotationPrefix)] = v
}
}
return annotations
Expand Down

0 comments on commit ad4ca5b

Please sign in to comment.