From 7f18ce70318860a1a4677f738a25a62b43895148 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Pinson?= Date: Wed, 9 Dec 2020 23:32:14 +0100 Subject: [PATCH] Support services in app xray --- internal/xray/application.go | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/internal/xray/application.go b/internal/xray/application.go index c94fac7b..187106ba 100644 --- a/internal/xray/application.go +++ b/internal/xray/application.go @@ -41,14 +41,15 @@ func (a *Application) Render(ctx context.Context, ns string, o interface{}) erro var ar ApplicationResource var dp Deployment + var svc Service + f, ok := ctx.Value(internal.KeyFactory).(dao.Factory) + if !ok { + return fmt.Errorf("Expecting a factory but got %T", ctx.Value(internal.KeyFactory)) + } for _, res := range app.Status.Resources { gvr := gvkToGvr(res.GroupVersionKind()) switch gvr.String() { case "apps/v1/deployments": - f, ok := ctx.Value(internal.KeyFactory).(dao.Factory) - if !ok { - return fmt.Errorf("Expecting a factory but got %T", ctx.Value(internal.KeyFactory)) - } d, err := f.Get("apps/v1/deployments", fmt.Sprintf("%s/%s", res.Namespace, res.Name), false, labels.Everything()) if err != nil { return err @@ -58,6 +59,16 @@ func (a *Application) Render(ctx context.Context, ns string, o interface{}) erro return err } + case "v1/services": + d, err := f.Get("v1/services", fmt.Sprintf("%s/%s", res.Namespace, res.Name), false, labels.Everything()) + if err != nil { + return err + } + + if err := svc.Render(ctx, app.Namespace, d); err != nil { + return err + } + default: if err := ar.Render(ctx, app.Namespace, res); err != nil { return err