Skip to content

Commit d67c2ef

Browse files
committed
review: helper for path prefix
Signed-off-by: Kimonas Sotirchos <kimwnasptd@gmail.com>
1 parent 177bb8b commit d67c2ef

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

components/notebook-controller/controllers/notebook_controller.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,12 @@ func generateService(instance *v1beta1.Notebook) *corev1.Service {
473473
return svc
474474
}
475475

476+
func ingressPath(instance *v1beta1.Notebook) string {
477+
name := instance.Name
478+
namespace := instance.Namespace
479+
return fmt.Sprintf("/notebook/%s/%s/", namespace, name)
480+
}
481+
476482
func virtualServiceName(kfName string, namespace string) string {
477483
return fmt.Sprintf("notebook-%s-%s", namespace, kfName)
478484
}
@@ -481,7 +487,7 @@ func generateVirtualService(instance *v1beta1.Notebook) (*unstructured.Unstructu
481487
name := instance.Name
482488
namespace := instance.Namespace
483489
clusterDomain := "cluster.local"
484-
prefix := fmt.Sprintf("/notebook/%s/%s/", namespace, name)
490+
prefix := ingressPath(instance)
485491

486492
// unpack annotations from Notebook resource
487493
annotations := make(map[string]string)
@@ -580,7 +586,7 @@ func generateVirtualService(instance *v1beta1.Notebook) (*unstructured.Unstructu
580586
func generateHTTPRoute(instance *v1beta1.Notebook) (*gwapiv1beta1.HTTPRoute, error) {
581587
name := instance.Name
582588
namespace := instance.Namespace
583-
pathPrefix := fmt.Sprintf("/notebook/%s/%s", namespace, name)
589+
pathPrefix := ingressPath(instance)
584590

585591
// unpack annotations from Notebook resource
586592
annotations := make(map[string]string)

0 commit comments

Comments
 (0)