Skip to content
This repository was archived by the owner on Oct 14, 2020. It is now read-only.

Commit 2f8d38d

Browse files
committed
Use generatedName from ingress to decrease length of name
TODO: Look for existing Host before creating. Currently every change to an ingress will create a new Host
1 parent 0dc0700 commit 2f8d38d

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

cloud-integrations/kubernetes/controllers/ingress_scan_controller.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package controllers
1818

1919
import (
2020
"context"
21+
"fmt"
2122

2223
"github.com/go-logr/logr"
2324
targetsv1 "github.com/secureCodeBox/secureCodeBox-v2-alpha/operator/apis/targets/v1"
@@ -77,7 +78,7 @@ func (r *IngressScanReconciler) CreateOrUpdateTlsForHosts(ingress networking.Ing
7778
host := targetsv1.Host{}
7879
err := r.Get(context.Background(), types.NamespacedName{Name: hostname, Namespace: ingress.Namespace}, &host)
7980
if apierrors.IsNotFound(err) {
80-
host.Name = hostname
81+
host.GenerateName = fmt.Sprintf("%s-", ingress.Name)
8182
host.Namespace = ingress.Namespace
8283
host.Spec.Hostname = hostname
8384
host.Spec.Ports = make([]targetsv1.HostPort, 0)
@@ -126,16 +127,16 @@ func (r *IngressScanReconciler) SetupWithManager(mgr ctrl.Manager) error {
126127

127128
isInDemoNamespaceFilter := predicate.Funcs{
128129
CreateFunc: func(event event.CreateEvent) bool {
129-
return event.Meta.GetNamespace() == "demo"
130+
return event.Meta.GetNamespace() == "juice-shop" || event.Meta.GetNamespace() == "bodgeit"
130131
},
131132
DeleteFunc: func(event event.DeleteEvent) bool {
132-
return event.Meta.GetNamespace() == "demo"
133+
return event.Meta.GetNamespace() == "juice-shop" || event.Meta.GetNamespace() == "bodgeit"
133134
},
134135
UpdateFunc: func(event event.UpdateEvent) bool {
135-
return event.MetaNew.GetNamespace() == "demo"
136+
return event.MetaNew.GetNamespace() == "juice-shop" || event.MetaNew.GetNamespace() == "bodgeit"
136137
},
137138
GenericFunc: func(event event.GenericEvent) bool {
138-
return event.Meta.GetNamespace() == "demo"
139+
return event.Meta.GetNamespace() == "juice-shop" || event.Meta.GetNamespace() == "bodgeit"
139140
},
140141
}
141142

0 commit comments

Comments
 (0)