From 0471bc93239b196114530abd987a718bb8c90319 Mon Sep 17 00:00:00 2001 From: Alice-Lilith Date: Mon, 13 Jan 2025 12:21:02 -0800 Subject: [PATCH] update moduleset handling for edges Signed-off-by: Alice-Lilith --- pkg/managerdriver/edges.go | 17 +++++++++++++---- pkg/managerdriver/translator.go | 4 ++++ 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/pkg/managerdriver/edges.go b/pkg/managerdriver/edges.go index faaab346..82f532d5 100644 --- a/pkg/managerdriver/edges.go +++ b/pkg/managerdriver/edges.go @@ -2,6 +2,7 @@ package managerdriver import ( "context" + "encoding/json" "fmt" "reflect" "strings" @@ -206,10 +207,18 @@ func (d *Driver) calculateHTTPSEdgesFromIngress(edgeMap map[string]ingressv1alph continue } - policyJSON, err := d.getTrafficPolicyJSON(ingress, modSet) - if err != nil { - d.log.Error(err, "error marshalling JSON Policy for ingress", "ingress", ingress) - continue + var policyJSON json.RawMessage + if modSet != nil { + policyJSON, err = d.getTrafficPolicyJSON(ingress, modSet) + if err != nil { + d.log.Error(err, "error marshalling JSON Policy for ingress", "ingress", ingress) + continue + } + } + + // If there is no moduleset, initialize an empty one + if modSet == nil { + modSet = &ingressv1alpha1.NgrokModuleSet{} } for _, rule := range ingress.Spec.Rules { diff --git a/pkg/managerdriver/translator.go b/pkg/managerdriver/translator.go index d8d3ec6d..90b3c39e 100644 --- a/pkg/managerdriver/translator.go +++ b/pkg/managerdriver/translator.go @@ -58,6 +58,10 @@ func (t *translator) Translate() *TranslationResult { // TODO (Alice): implement Gateway API support for endpoints + t.log.Info("Alice, translation result", + "irVHosts", ingressVHosts, + ) + cloudEndpoints, agentEndpoints := t.IRToEndpoints(ingressVHosts) return &TranslationResult{