Skip to content

Commit

Permalink
update subscriber for gapi objs
Browse files Browse the repository at this point in the history
Signed-off-by: Shubham Chauhan <shubham@tetrate.io>
  • Loading branch information
chauhanshubham committed Nov 20, 2022
1 parent f1e4aeb commit 63756e0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 21 deletions.
30 changes: 10 additions & 20 deletions internal/gatewayapi/runner/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,30 +45,20 @@ func (r *Runner) Start(ctx context.Context) error {
}

func (r *Runner) subscribeAndTranslate(ctx context.Context) {
// Subscribe to resources
resourcesCh := r.ProviderResources.GatewayAPIResources.Subscribe(ctx)
message.HandleSubscription(r.ProviderResources.GatewayAPIResources.Subscribe(ctx),
func(update message.Update[string, *gatewayapi.Resources]) {
val := update.Value

for ctx.Err() == nil {
var in *gatewayapi.Resources
// Receive subscribed resource notifications

<-resourcesCh
r.Logger.Info("received a notification")

// Load all resources required for translation
in = r.ProviderResources.GetResources()
if update.Delete || val == nil {
return
}

switch {
case in == nil:
// Envoy Gateway startup.
continue
default:
// Translate and publish IRs.
t := &gatewayapi.Translator{
GatewayClassName: v1beta1.ObjectName(r.ProviderResources.GetResourcesKey()),
GatewayClassName: v1beta1.ObjectName(update.Key),
}
// Translate to IR
result := t.Translate(in)
result := t.Translate(val)

yamlXdsIR, _ := yaml.Marshal(&result.XdsIR)
r.Logger.WithValues("output", "xds-ir").Info(string(yamlXdsIR))
Expand Down Expand Up @@ -121,8 +111,8 @@ func (r *Runner) subscribeAndTranslate(ctx context.Context) {
key := utils.NamespacedName(tlsRoute)
r.ProviderResources.TLSRouteStatuses.Store(key, tlsRoute)
}
}
}
},
)
r.Logger.Info("shutting down")
}

Expand Down
1 change: 0 additions & 1 deletion internal/provider/kubernetes/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@ func (r *gatewayAPIReconciler) Reconcile(ctx context.Context, request reconcile.
continue
}

r.log.Info("HEYO3 ADDING MATCH")
cc.addMatch(&gatewayClasses.Items[i])
}
}
Expand Down

0 comments on commit 63756e0

Please sign in to comment.